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

Commit 63caa62

Browse files
villebrorusackas
andauthored
feat: Add ECharts Timeseries plugin (#737)
* make it work * Add color scheme and timeseries limits * latest improvements * bump * moving dependencies to plugin * Shuffling logic to transformProps, making Typescript happy. * zoom controls! * declaration for the dang PNG files * Revert "declaration for the dang PNG files" This reverts commit b37f010. * PIE! (super basic) * lowercase import name, moving types. * capitalization fix * nixing console log * removing echarts peer dependency (missed it earlier) * basic pie controls/types * typescript fixes and whatnot * yarn alphabetizing peerDependencies * fixing Pie chart typing * less enthusiasm * fixing resize and data redraw quirks * fixing zoom display quirks * add predictive analytics * fix controls * improve typing and tests * add rebasing to forecasts * improve stacking etc * Minor improvements * add tooltip * Charts draw and resize correctly * clean up code * lint * yet more lint * fix unit tests * fix unit tests * fix tests * add useEchartsComponent and address comments * address comments * address more comments * Add Echart component * bump echarts to 4.9.0 * clean up Echart component * add storybook * replace radios with boolean * address review comments Co-authored-by: Evan Rusackas <[email protected]>
1 parent 2115ecd commit 63caa62

31 files changed

+5979
-13
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import React from 'react';
2+
import { SuperChart, getChartTransformPropsRegistry } from '@superset-ui/chart';
3+
import { boolean, number, 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 forecastEnabled = boolean('Enable forecast', true);
20+
const queryData = data
21+
.map(row =>
22+
forecastEnabled
23+
? row
24+
: {
25+
__timestamp: row.__timestamp,
26+
Boston: row.Boston,
27+
California: row.California,
28+
WestTexNewMexico: row.WestTexNewMexico,
29+
},
30+
)
31+
.filter(row => forecastEnabled || !!row.Boston);
32+
return (
33+
<SuperChart
34+
chartType="echarts-timeseries"
35+
width={width}
36+
height={height}
37+
queryData={{ data: queryData }}
38+
formData={{
39+
contributionMode: undefined,
40+
forecastEnabled,
41+
colorScheme: 'supersetColors',
42+
seriesType: select(
43+
'Line type',
44+
['line', 'scatter', 'smooth', 'bar', 'start', 'middle', 'end'],
45+
'line',
46+
),
47+
logAxis: boolean('Log axis', false),
48+
yAxisFormat: 'SMART_NUMBER',
49+
stack: boolean('Stack', false),
50+
area: boolean('Area chart', false),
51+
markerEnabled: boolean('Enable markers', false),
52+
markerSize: number('Marker Size', 6),
53+
minorSplitLine: boolean('Minor splitline', false),
54+
opacity: number('Opacity', 0.2),
55+
zoomable: boolean('Zoomable', false),
56+
}}
57+
/>
58+
);
59+
};

0 commit comments

Comments
 (0)