Skip to content

Commit

Permalink
feat: add Dataset component
Browse files Browse the repository at this point in the history
  • Loading branch information
SevenOutman committed Jun 16, 2022
1 parent dd2cf04 commit 968973e
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
19 changes: 19 additions & 0 deletions src/components/Dataset.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import * as echarts from 'echarts/core';
import { DatasetComponent, type DatasetComponentOption } from 'echarts/components';
import { symbols } from '../constants';

echarts.use([DatasetComponent]);

export type DatasetProps = DatasetComponentOption;

function Dataset(_: DatasetProps) {
return null;
}

Dataset[symbols.typeKey] = symbols.dataset;

if (process.env.NODE_ENV !== 'production') {
Dataset.displayName = 'Dataset';
}

export default Dataset;
1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const EChartsContext = React.createContext<EChartsContext>({});
export const symbols = {
typeKey: Symbol.for('$$typeKey'),
// components
dataset: Symbol.for('$$dataset'),
dataZoom: Symbol.for('$$dataZoom'),
legend: Symbol.for('$$legend'),
radar: Symbol.for('$$radar'),
Expand Down
5 changes: 3 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import ECharts from './ECharts';

// Components
import Dataset from './components/Dataset';
import DataZoom from './components/DataZoom';
import Legend from './components/Legend';
import Radar from './components/Radar';
Expand Down Expand Up @@ -35,7 +36,7 @@ import TreemapChart from './charts/TreemapChart';

export default ECharts;

export { DataZoom, Legend, Radar, Tooltip, VisualMap, XAxis, YAxis };
export { Dataset, DataZoom, Legend, Radar, Tooltip, VisualMap, XAxis, YAxis };

export { Bars, Funnel, Line, Map, Pie, RadarLine, Sankey, Scatter, Tree, Treemap };

Expand All @@ -49,5 +50,5 @@ export {
SankeyChart,
ScatterChart,
TreeChart,
TreemapChart,
TreemapChart
};
4 changes: 4 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { TitleComponent } from 'echarts/components';
import { symbols } from './constants';
import { ChartComponentProps } from './ECharts';
import type { YAxisProps } from './components/YAxis';
import type { DatasetProps } from './components/Dataset';

echarts.use([TitleComponent]);

Expand Down Expand Up @@ -65,6 +66,9 @@ const stackKey = randstr();

const createOptions = {
// components
[symbols.dataset](option: any, props: DatasetProps, _:any) {
option.dataset = _merge({}, props);
},
[symbols.dataZoom](option: any, props: any, _: any) {
function getOption() {
return _merge(
Expand Down

0 comments on commit 968973e

Please sign in to comment.