From 155436c9e8c9638c742f60fd43d069ac0bbea091 Mon Sep 17 00:00:00 2001 From: Eliad Moosavi Date: Thu, 2 May 2019 21:51:53 -0400 Subject: [PATCH] Show warning when multiple datasets are used in Pie & Donut --- packages/core/src/pie-chart.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/core/src/pie-chart.ts b/packages/core/src/pie-chart.ts index a9cfa88269..d60f261efa 100644 --- a/packages/core/src/pie-chart.ts +++ b/packages/core/src/pie-chart.ts @@ -1,5 +1,5 @@ // D3 Imports -import { select, selectAll, mouse } from "d3-selection"; +import { select } from "d3-selection"; import { scaleOrdinal } from "d3-scale"; import { pie, arc, Pie, Arc } from "d3-shape"; import { interpolate } from "d3-interpolate"; @@ -44,6 +44,10 @@ export class PieChart extends BaseChart { // Cap number of slices at a specific number, and group the remaining items into the label "Other" dataProcessor(dataObject: ChartData): PieData { // TODO - Support multiple datasets + if (dataObject.datasets.length > 1) { + console.warn("Currently the Pie & Donut charts support a single dataset, you appear to have more than that. Will only use your first provided dataset."); + } + // Check for duplicate keys in the data const duplicates = Tools.getDuplicateValues(dataObject.labels); if (duplicates.length > 0) { @@ -313,6 +317,7 @@ export class PieChart extends BaseChart { const oldData = Tools.clone(this.displayData); const activeLegendItems = this.getActiveLegendItems(); + // TODO - Support multiple datasets const newDisplayData = Object.assign({}, oldData); newDisplayData.datasets[0].data = oldData.datasets[0].data.filter(dataPoint => activeLegendItems.indexOf(dataPoint.label) !== -1);