From b2f9fbe08570ffe6bfc35df3fae111150f8154f0 Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Sun, 16 Dec 2018 00:08:21 -0500 Subject: [PATCH] Fix doughnut charts acting weird when resized The charts would start displaying data from other charts, and would have graphical glitches. The glitches are fixed by giving the chart its own copy of the dataset. Signed-off-by: Mcat12 --- src/components/dashboard/GenericDoughnutChart.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/dashboard/GenericDoughnutChart.js b/src/components/dashboard/GenericDoughnutChart.js index d82c176..4bb949f 100644 --- a/src/components/dashboard/GenericDoughnutChart.js +++ b/src/components/dashboard/GenericDoughnutChart.js @@ -79,7 +79,12 @@ export class GenericDoughnutChart extends Component { data={{ datasets: [ { - data: this.props.data, + // Make a copy of the data here. ChartJS does weird things + // to the data, which React doesn't catch. This can cause + // oddities such as one chart showing the other chart's + // data. This behavior is fixed by sending ChartJS its own + // copy of the data. + data: [...this.props.data], backgroundColor: this.props.colors } ],