diff --git a/web/components/charts/contract/binary.tsx b/web/components/charts/contract/binary.tsx index a6ba9bee..264e1e3b 100644 --- a/web/components/charts/contract/binary.tsx +++ b/web/components/charts/contract/binary.tsx @@ -34,10 +34,10 @@ const BinaryChartTooltip = (props: TooltipProps>) => { const { x, y, datum } = p const [start, end] = xScale.domain() return ( - + {datum && } - {formatPct(y)} - {formatDateInRange(x, start, end)} + {formatDateInRange(x, start, end)} + {formatPct(y)} ) } diff --git a/web/components/charts/contract/choice.tsx b/web/components/charts/contract/choice.tsx index 127e7d9c..1908f98f 100644 --- a/web/components/charts/contract/choice.tsx +++ b/web/components/charts/contract/choice.tsx @@ -9,7 +9,6 @@ import { getOutcomeProbability } from 'common/calculate' import { useIsMobile } from 'web/hooks/use-is-mobile' import { DAY_MS } from 'common/util/time' import { - Legend, TooltipProps, MARGIN_X, MARGIN_Y, @@ -121,6 +120,29 @@ const getBetPoints = (answers: Answer[], bets: Bet[]) => { return points } +type LegendItem = { color: string; label: string; value?: string } +const Legend = (props: { className?: string; items: LegendItem[] }) => { + const { items, className } = props + return ( +
    + {items.map((item) => ( +
  1. + + + + {item.label} + + + {item.value} +
  2. + ))} +
+ ) +} + export const ChoiceContractChart = (props: { contract: FreeResponseContract | MultipleChoiceContract bets: Bet[] @@ -173,13 +195,15 @@ export const ChoiceContractChart = (props: { (item) => -item.p ).slice(0, 10) return ( -
+ <> {datum && } - {formatDateInRange(x, start, end)} + + {formatDateInRange(x, start, end)} + - -
+ + ) }, [answers] diff --git a/web/components/charts/contract/numeric.tsx b/web/components/charts/contract/numeric.tsx index dd031ab8..ac300361 100644 --- a/web/components/charts/contract/numeric.tsx +++ b/web/components/charts/contract/numeric.tsx @@ -24,9 +24,10 @@ const getNumericChartData = (contract: NumericContract) => { const NumericChartTooltip = (props: TooltipProps) => { const { x, y } = props.p return ( - - {formatPct(y, 2)} {formatLargeNumber(x)} - + <> + {formatLargeNumber(x)} + {formatPct(y, 2)} + ) } diff --git a/web/components/charts/contract/pseudo-numeric.tsx b/web/components/charts/contract/pseudo-numeric.tsx index 1232a96c..adf2e493 100644 --- a/web/components/charts/contract/pseudo-numeric.tsx +++ b/web/components/charts/contract/pseudo-numeric.tsx @@ -46,10 +46,10 @@ const PseudoNumericChartTooltip = (props: TooltipProps>) => { const { x, y, datum } = p const [start, end] = xScale.domain() return ( - + {datum && } - {formatLargeNumber(y)} - {formatDateInRange(x, start, end)} + {formatDateInRange(x, start, end)} + {formatLargeNumber(y)} ) } diff --git a/web/components/charts/helpers.tsx b/web/components/charts/helpers.tsx index b7948298..acd88a4f 100644 --- a/web/components/charts/helpers.tsx +++ b/web/components/charts/helpers.tsx @@ -16,7 +16,6 @@ import dayjs from 'dayjs' import clsx from 'clsx' import { Contract } from 'common/contract' -import { Row } from 'web/components/layout/row' export type Point = { x: X; y: Y; datum?: T } export type XScale

= P extends Point ? AxisScale : never @@ -256,7 +255,7 @@ export const TooltipContainer = (props: {

@@ -265,27 +264,6 @@ export const TooltipContainer = (props: { ) } -export type LegendItem = { color: string; label: string; value?: string } -export const Legend = (props: { className?: string; items: LegendItem[] }) => { - const { items, className } = props - return ( -
    - {items.map((item) => ( -
  1. - - - {item.label} - - {item.value} -
  2. - ))} -
- ) -} - export const getDateRange = (contract: Contract) => { const { createdTime, closeTime, resolutionTime } = contract const isClosed = !!closeTime && Date.now() > closeTime