Skip to content

Commit

Permalink
feat: heatmap chart setData
Browse files Browse the repository at this point in the history
  • Loading branch information
jung-han committed Dec 2, 2020
1 parent 7f25849 commit 2563944
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
9 changes: 9 additions & 0 deletions src/charts/heatmapChart.ts
Expand Up @@ -97,4 +97,13 @@ export default class HeatmapChart extends Chart<HeatmapChartOptions> {
public addSeries = (data: HeatmapSeriesDataType, dataInfo: AddSeriesDataInfo) => {
this.store.dispatch('addHeatmapSeries', { data, ...dataInfo });
};

public setData(data: HeatmapSeriesData) {
const { categories, series } = data;

this.store.dispatch('setData', {
series: { heatmap: getSeriesWithYCategory(series, categories) },
categories,
});
}
}
12 changes: 4 additions & 8 deletions src/store/heatmapSeriesData.ts
@@ -1,5 +1,4 @@
import { HeatmapSeriesData, Series, StoreModule } from '@t/store/store';
import { extend } from '@src/store/store';
import { HeatmapCategoriesType, RangeDataType } from '@t/options';
import { getDataInRange } from '@src/helpers/range';

Expand Down Expand Up @@ -33,13 +32,10 @@ const heatmapSeriesData: StoreModule = {
}),
action: {
setHeatmapSeriesData({ state, computed }) {
extend(
state.heatmapSeries,
makeHeatmapSeries(
state.series,
state.categories as HeatmapCategoriesType,
computed.viewRange
)
state.heatmapSeries = makeHeatmapSeries(
state.series,
state.categories as HeatmapCategoriesType,
computed.viewRange
);
},
},
Expand Down
3 changes: 2 additions & 1 deletion types/options.d.ts
Expand Up @@ -641,4 +641,5 @@ export type DataInput =
| BoxPlotSeriesData
| ScatterSeriesData
| BubbleSeriesData
| BulletSeriesData;
| BulletSeriesData
| HeatmapSeriesData;

0 comments on commit 2563944

Please sign in to comment.