Fix a dumb bug
This commit is contained in:
parent
b9376a725e
commit
6f69ecd087
|
@ -31,7 +31,7 @@ export const BinaryContractChart = (props: {
|
||||||
const isMobile = useIsMobile(800)
|
const isMobile = useIsMobile(800)
|
||||||
const containerRef = useRef<HTMLDivElement>(null)
|
const containerRef = useRef<HTMLDivElement>(null)
|
||||||
const width = useElementWidth(containerRef) ?? 0
|
const width = useElementWidth(containerRef) ?? 0
|
||||||
const height = props.height ?? isMobile ? 150 : 250
|
const height = props.height ?? (isMobile ? 150 : 250)
|
||||||
const xScale = scaleTime(getDateRange(contract), [0, width - MARGIN_X])
|
const xScale = scaleTime(getDateRange(contract), [0, width - MARGIN_X])
|
||||||
const yScale = scaleLinear([0, 1], [height - MARGIN_Y, 0])
|
const yScale = scaleLinear([0, 1], [height - MARGIN_Y, 0])
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -12,7 +12,8 @@ import { useElementWidth } from 'web/hooks/use-element-width'
|
||||||
|
|
||||||
const getMultiChartData = (
|
const getMultiChartData = (
|
||||||
contract: FreeResponseContract | MultipleChoiceContract,
|
contract: FreeResponseContract | MultipleChoiceContract,
|
||||||
bets: Bet[]
|
bets: Bet[],
|
||||||
|
topN: number
|
||||||
) => {
|
) => {
|
||||||
const { answers, totalBets, outcomeType } = contract
|
const { answers, totalBets, outcomeType } = contract
|
||||||
|
|
||||||
|
@ -32,7 +33,7 @@ const getMultiChartData = (
|
||||||
const trackedAnswers = sortBy(
|
const trackedAnswers = sortBy(
|
||||||
validAnswers,
|
validAnswers,
|
||||||
(answer) => -1 * getOutcomeProbability(contract, answer.id)
|
(answer) => -1 * getOutcomeProbability(contract, answer.id)
|
||||||
).slice(0, 10)
|
).slice(0, topN)
|
||||||
|
|
||||||
const points: MultiPoint[] = []
|
const points: MultiPoint[] = []
|
||||||
|
|
||||||
|
@ -78,13 +79,13 @@ export const ChoiceContractChart = (props: {
|
||||||
}) => {
|
}) => {
|
||||||
const { contract, bets } = props
|
const { contract, bets } = props
|
||||||
const data = useMemo(
|
const data = useMemo(
|
||||||
() => getMultiChartData(contract, bets),
|
() => getMultiChartData(contract, bets, 6),
|
||||||
[contract, bets]
|
[contract, bets]
|
||||||
)
|
)
|
||||||
const isMobile = useIsMobile(800)
|
const isMobile = useIsMobile(800)
|
||||||
const containerRef = useRef<HTMLDivElement>(null)
|
const containerRef = useRef<HTMLDivElement>(null)
|
||||||
const width = useElementWidth(containerRef) ?? 0
|
const width = useElementWidth(containerRef) ?? 0
|
||||||
const height = props.height ?? isMobile ? 150 : 250
|
const height = props.height ?? (isMobile ? 150 : 250)
|
||||||
const xScale = scaleTime(getDateRange(contract), [0, width - MARGIN_X])
|
const xScale = scaleTime(getDateRange(contract), [0, width - MARGIN_X])
|
||||||
const yScale = scaleLinear([0, 1], [height - MARGIN_Y, 0])
|
const yScale = scaleLinear([0, 1], [height - MARGIN_Y, 0])
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -28,7 +28,7 @@ export const NumericContractChart = (props: {
|
||||||
const isMobile = useIsMobile(800)
|
const isMobile = useIsMobile(800)
|
||||||
const containerRef = useRef<HTMLDivElement>(null)
|
const containerRef = useRef<HTMLDivElement>(null)
|
||||||
const width = useElementWidth(containerRef) ?? 0
|
const width = useElementWidth(containerRef) ?? 0
|
||||||
const height = props.height ?? isMobile ? 150 : 250
|
const height = props.height ?? (isMobile ? 150 : 250)
|
||||||
const maxY = max(data.map((d) => d[1])) as number
|
const maxY = max(data.map((d) => d[1])) as number
|
||||||
const xScale = scaleLinear(
|
const xScale = scaleLinear(
|
||||||
[contract.min, contract.max],
|
[contract.min, contract.max],
|
||||||
|
|
|
@ -36,7 +36,7 @@ export const PseudoNumericContractChart = (props: {
|
||||||
const isMobile = useIsMobile(800)
|
const isMobile = useIsMobile(800)
|
||||||
const containerRef = useRef<HTMLDivElement>(null)
|
const containerRef = useRef<HTMLDivElement>(null)
|
||||||
const width = useElementWidth(containerRef) ?? 0
|
const width = useElementWidth(containerRef) ?? 0
|
||||||
const height = props.height ?? isMobile ? 150 : 250
|
const height = props.height ?? (isMobile ? 150 : 250)
|
||||||
const scaleType = contract.isLogScale ? scaleLog : scaleLinear
|
const scaleType = contract.isLogScale ? scaleLog : scaleLinear
|
||||||
const xScale = scaleTime(getDateRange(contract), [0, width - MARGIN_X])
|
const xScale = scaleTime(getDateRange(contract), [0, width - MARGIN_X])
|
||||||
const yScale = scaleType([contract.min, contract.max], [height - MARGIN_Y, 0])
|
const yScale = scaleType([contract.min, contract.max], [height - MARGIN_Y, 0])
|
||||||
|
|
Loading…
Reference in New Issue
Block a user