diff --git a/packages/visx-demo/src/sandboxes/visx-xychart/Example.tsx b/packages/visx-demo/src/sandboxes/visx-xychart/Example.tsx index d42b5debf..c22cd3739 100644 --- a/packages/visx-demo/src/sandboxes/visx-xychart/Example.tsx +++ b/packages/visx-demo/src/sandboxes/visx-xychart/Example.tsx @@ -1,6 +1,13 @@ import React from 'react'; import cityTemperature, { CityTemperature } from '@visx/mock-data/lib/mocks/cityTemperature'; -import { AnimatedAxis, AnimatedGrid, DataProvider, LineSeries, XYChart } from '@visx/xychart'; +import { + AnimatedAxis, + AnimatedGrid, + DataProvider, + BarSeries, + LineSeries, + XYChart, +} from '@visx/xychart'; import ExampleControls from './ExampleControls'; import CustomChartBackground from './CustomChartBackground'; @@ -9,53 +16,72 @@ type Props = { height: number; }; -const xScaleConfig = { type: 'time' } as const; +const xScaleConfig = { type: 'band', paddingInner: 0.3 } as const; const yScaleConfig = { type: 'linear' } as const; const numTicks = 4; -const data = cityTemperature.slice(0, 100); -const getDate = (d: CityTemperature) => new Date(d.date); +const data = cityTemperature.slice(150, 225); +const getDate = (d: CityTemperature) => d.date; // new Date(d.date); const getSfTemperature = (d: CityTemperature) => Number(d['San Francisco']); +const getNyTemperature = (d: CityTemperature) => Number(d['New York']); export default function Example({ height }: Props) { return ( {({ + animationTrajectory, + renderBarSeries, + renderHorizontally, + renderLineSeries, + showGridColumns, + showGridRows, theme, xAxisOrientation, yAxisOrientation, - showGridRows, - showGridColumns, - animationTrajectory, }) => ( - + + + {renderBarSeries && ( + + )} + {renderLineSeries && ( + + )} - - )} diff --git a/packages/visx-demo/src/sandboxes/visx-xychart/ExampleControls.tsx b/packages/visx-demo/src/sandboxes/visx-xychart/ExampleControls.tsx index 010db735b..cb57f221d 100644 --- a/packages/visx-demo/src/sandboxes/visx-xychart/ExampleControls.tsx +++ b/packages/visx-demo/src/sandboxes/visx-xychart/ExampleControls.tsx @@ -6,6 +6,9 @@ import customTheme from './customTheme'; type ProvidedProps = { animationTrajectory: AnimationTrajectory; + renderHorizontally: boolean; + renderBarSeries: boolean; + renderLineSeries: boolean; showGridColumns: boolean; showGridRows: boolean; theme: XYChartTheme; @@ -24,11 +27,17 @@ export default function ExampleControls({ children }: ControlsProps) { const [showGridRows, showGridColumns] = gridProps; const [xAxisOrientation, setXAxisOrientation] = useState<'top' | 'bottom'>('bottom'); const [yAxisOrientation, setYAxisOrientation] = useState<'left' | 'right'>('right'); + const [renderHorizontally, setRenderHorizontally] = useState(false); + const [renderBarSeries, setRenderBarSeries] = useState(true); + const [renderLineSeries, setRenderLineSeries] = useState(true); return ( <> {children({ animationTrajectory, + renderBarSeries, + renderHorizontally, + renderLineSeries, showGridColumns, showGridRows, theme, @@ -65,6 +74,27 @@ export default function ExampleControls({ children }: ControlsProps) { + {/** series orientation */} +
+ series orientation + + +
+ {/** axes */}
axes @@ -175,6 +205,26 @@ export default function ExampleControls({ children }: ControlsProps) { from max
+ {/** series */} +
+ series + + +