Skip to content
This repository was archived by the owner on Dec 10, 2021. It is now read-only.

Commit b90aa82

Browse files
committed
add storybook
1 parent 0389110 commit b90aa82

File tree

4 files changed

+3389
-11
lines changed

4 files changed

+3389
-11
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import React from 'react';
2+
import { SuperChart, getChartTransformPropsRegistry } from '@superset-ui/chart';
3+
import { number, radios, select, withKnobs } from '@storybook/addon-knobs';
4+
import { EchartsTimeseriesChartPlugin } from '@superset-ui/plugin-chart-echarts';
5+
import transformProps from '@superset-ui/plugin-chart-echarts/lib/Timeseries/transformProps';
6+
import { withResizableChartDemo } from '../../../shared/components/ResizableChartDemo';
7+
import data from './data';
8+
9+
new EchartsTimeseriesChartPlugin().configure({ key: 'echarts-timeseries' }).register();
10+
11+
getChartTransformPropsRegistry().registerValue('echarts-timeseries', transformProps);
12+
13+
export default {
14+
title: 'Chart Plugins|plugin-chart-echarts',
15+
decorators: [withKnobs, withResizableChartDemo],
16+
};
17+
18+
export const Timeseries = ({ width, height }) => {
19+
const enableForecast = radios('Enable forecast', { Yes: 'yes', No: 'no' }, 'yes');
20+
const forecastEnabled = enableForecast === 'yes';
21+
const queryData = data
22+
.map(row =>
23+
forecastEnabled
24+
? row
25+
: {
26+
__timestamp: row.__timestamp,
27+
Boston: row.Boston,
28+
California: row.California,
29+
WestTexNewMexico: row.WestTexNewMexico,
30+
},
31+
)
32+
.filter(row => forecastEnabled || !!row.Boston);
33+
return (
34+
<SuperChart
35+
chartType="echarts-timeseries"
36+
width={width}
37+
height={height}
38+
queryData={{ data: queryData }}
39+
formData={{
40+
contributionMode: undefined,
41+
forecastEnabled,
42+
colorScheme: 'supersetColors',
43+
seriesType: select(
44+
'Line type',
45+
['line', 'scatter', 'smooth', 'bar', 'start', 'middle', 'end'],
46+
'line',
47+
),
48+
logAxis: radios('Log axis', { Yes: 'yes', No: 'no' }, 'no') === 'yes',
49+
yAxisFormat: 'SMART_NUMBER',
50+
stack: radios('Stack', { Yes: 'yes', No: 'no' }, 'no') === 'yes',
51+
area: radios('Area chart', { Yes: 'yes', No: 'no' }, 'no') === 'yes',
52+
markerEnabled: radios('Enable markers', { Yes: 'yes', No: 'no' }, 'no') === 'yes',
53+
markerSize: number('Marker Size', 6),
54+
minorSplitLine: radios('Minor splitline', { Yes: 'yes', No: 'no' }, 'no') === 'yes',
55+
opacity: number('Opacity', 0.2),
56+
zoomable: radios('Zoomable', { Yes: 'yes', No: 'no' }, 'no') === 'yes',
57+
}}
58+
/>
59+
);
60+
};

0 commit comments

Comments
 (0)