This repository has been archived by the owner on Dec 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 272
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
3,387 additions
and
9 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
packages/superset-ui-demo/storybook/stories/plugins/plugin-chart-echarts/Stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
}} | ||
/> | ||
); | ||
}; |
Oops, something went wrong.