|
1 | 1 | import React, { Fragment } from 'react'; |
2 | | -import { |
3 | | - Axis, |
4 | | - Chart, |
5 | | - getAxisId, |
6 | | - getSpecId, |
7 | | - Position, |
8 | | - ScaleType, |
9 | | - Settings, |
10 | | - BarSeries, |
11 | | - LineSeries, |
12 | | - AreaSeries, |
13 | | -} from '../src'; |
| 2 | +import { Axis, Chart, getAxisId, getSpecId, Position, ScaleType, Settings, AreaSeries } from '../src'; |
14 | 3 |
|
15 | 4 | export class Playground extends React.Component { |
16 | 5 | render() { |
17 | 6 | return ( |
18 | 7 | <Fragment> |
19 | 8 | <div className="chart"> |
20 | | - <Chart className="story-chart"> |
21 | | - <Settings |
22 | | - theme={{ |
23 | | - areaSeriesStyle: { |
24 | | - point: { |
25 | | - visible: true, |
26 | | - }, |
27 | | - }, |
28 | | - }} |
29 | | - xDomain={{ |
30 | | - max: 3.8, |
31 | | - }} |
32 | | - /> |
| 9 | + <Chart> |
| 10 | + <Settings showLegend theme={{ areaSeriesStyle: { point: { visible: true } } }} /> |
33 | 11 | <Axis |
34 | 12 | id={getAxisId('bottom')} |
35 | 13 | position={Position.Bottom} |
36 | 14 | title={'Bottom axis'} |
37 | 15 | showOverlappingTicks={true} |
38 | 16 | /> |
39 | 17 | <Axis |
40 | | - id={getAxisId('left')} |
| 18 | + id={getAxisId('left2')} |
41 | 19 | title={'Left axis'} |
42 | 20 | position={Position.Left} |
43 | | - domain={{ |
44 | | - max: 5, |
45 | | - }} |
46 | | - /> |
47 | | - |
48 | | - <BarSeries |
49 | | - id={getSpecId('bar')} |
50 | | - xScaleType={ScaleType.Linear} |
51 | | - yScaleType={ScaleType.Linear} |
52 | | - xAccessor={0} |
53 | | - yAccessors={[1]} |
54 | | - data={[[0, 1], [1, 2], [2, 10], [3, 4], [4, 5]]} |
| 21 | + tickFormat={(d: any) => Number(d).toFixed(2)} |
55 | 22 | /> |
56 | | - |
57 | | - <LineSeries |
58 | | - id={getSpecId('line')} |
| 23 | + <AreaSeries |
| 24 | + id={getSpecId('bars1')} |
59 | 25 | xScaleType={ScaleType.Linear} |
60 | 26 | yScaleType={ScaleType.Linear} |
61 | | - xAccessor={0} |
62 | | - yAccessors={[1]} |
63 | | - data={[[0, 1], [1, 2], [2, 10], [3, 4], [4, 5]]} |
| 27 | + xAccessor="x" |
| 28 | + yAccessors={['y']} |
| 29 | + stackAccessors={['x']} |
| 30 | + splitSeriesAccessors={['g']} |
| 31 | + // curve={CurveType.CURVE_MONOTONE_X} |
| 32 | + data={[ |
| 33 | + { x: 0, y: 2, g: 'a' }, |
| 34 | + { x: 1, y: 7, g: 'a' }, |
| 35 | + { x: 2, y: 3, g: 'a' }, |
| 36 | + { x: 3, y: 6, g: 'a' }, |
| 37 | + { x: 0, y: 4, g: 'b' }, |
| 38 | + { x: 1, y: 5, g: 'b' }, |
| 39 | + { x: 2, y: 8, g: 'b' }, |
| 40 | + { x: 3, y: 2, g: 'b' }, |
| 41 | + { x: 4, y: 6, g: 'b' }, |
| 42 | + { x: 5, y: 7, g: 'a' }, |
| 43 | + { x: 5, y: 7, g: 'b' }, |
| 44 | + { x: 6, y: 7, g: 'a' }, |
| 45 | + { x: 6, y: 7, g: 'b' }, |
| 46 | + ]} |
64 | 47 | /> |
65 | | - |
66 | 48 | <AreaSeries |
67 | | - id={getSpecId('area')} |
| 49 | + id={getSpecId('area2')} |
68 | 50 | xScaleType={ScaleType.Linear} |
69 | 51 | yScaleType={ScaleType.Linear} |
70 | | - xAccessor={0} |
71 | | - yAccessors={[1]} |
72 | | - data={[[0, 1], [1, 2], [2, 10], [3, 4], [4, 5]]} |
| 52 | + xAccessor="x" |
| 53 | + yAccessors={['y']} |
| 54 | + stackAccessors={['x']} |
| 55 | + splitSeriesAccessors={['g']} |
| 56 | + // curve={CurveType.CURVE_MONOTONE_X} |
| 57 | + data={[ |
| 58 | + { x: 1, y: 7, g: 'a' }, |
| 59 | + { x: 2, y: 3, g: 'a' }, |
| 60 | + { x: 3, y: 6, g: 'a' }, |
| 61 | + { x: 0, y: 4, g: 'b' }, |
| 62 | + { x: 1, y: 5, g: 'b' }, |
| 63 | + { x: 2, y: 8, g: 'b' }, |
| 64 | + { x: 3, y: 2, g: 'b' }, |
| 65 | + { x: 4, y: 6, g: 'b' }, |
| 66 | + ]} |
73 | 67 | /> |
74 | 68 | </Chart> |
75 | 69 | </div> |
|
0 commit comments