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

Commit

Permalink
add storybook
Browse files Browse the repository at this point in the history
  • Loading branch information
villebro committed Aug 31, 2020
1 parent 0389110 commit 4a57e21
Show file tree
Hide file tree
Showing 3 changed files with 3,387 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import React from 'react';
import { SuperChart, getChartTransformPropsRegistry } from '@superset-ui/chart';
import { number, radios, select, withKnobs } from '@storybook/addon-knobs';
import { EchartsTimeseriesChartPlugin } from '@superset-ui/plugin-chart-echarts';
import transformProps from '@superset-ui/plugin-chart-echarts/lib/Timeseries/transformProps';
import { withResizableChartDemo } from '../../../shared/components/ResizableChartDemo';
import data from './data';

new EchartsTimeseriesChartPlugin().configure({ key: 'echarts-timeseries' }).register();

getChartTransformPropsRegistry().registerValue('echarts-timeseries', transformProps);

export default {
title: 'Chart Plugins|plugin-chart-echarts-timeseries',
decorators: [withKnobs, withResizableChartDemo],
};

export const prophetTimeseries = ({ width, height }) => {
const enableForecast = radios('Enable forecast', { Yes: 'yes', No: 'no' }, 'yes');
const forecastEnabled = enableForecast === 'yes';
const queryData = data
.map(row =>
forecastEnabled
? row
: {
__timestamp: row.__timestamp,
Boston: row.Boston,
California: row.California,
WestTexNewMexico: row.WestTexNewMexico,
},
)
.filter(row => forecastEnabled || !!row.Boston);
return (
<SuperChart
chartType="echarts-timeseries"
width={width}
height={height}
queryData={{ data: queryData }}
formData={{
contributionMode: undefined,
forecastEnabled,
colorScheme: 'supersetColors',
seriesType: select(
'Line type',
['line', 'scatter', 'smooth', 'bar', 'start', 'middle', 'end'],
'line',
),
logAxis: radios('Log axis', { Yes: 'yes', No: 'no' }, 'no') === 'yes',
yAxisFormat: 'SMART_NUMBER',
stack: radios('Stack', { Yes: 'yes', No: 'no' }, 'no') === 'yes',
area: radios('Area chart', { Yes: 'yes', No: 'no' }, 'no') === 'yes',
markerEnabled: radios('Enable markers', { Yes: 'yes', No: 'no' }, 'no') === 'yes',
markerSize: number('Marker Size', 6),
minorSplitLine: radios('Minor splitline', { Yes: 'yes', No: 'no' }, 'no') === 'yes',
opacity: number('Opacity', 0.2),
zoomable: radios('Zoomable', { Yes: 'yes', No: 'no' }, 'no') === 'yes',
}}
/>
);
};
Loading

0 comments on commit 4a57e21

Please sign in to comment.