summaryrefslogtreecommitdiffstats
path: root/webapp/components
diff options
context:
space:
mode:
Diffstat (limited to 'webapp/components')
-rw-r--r--webapp/components/analytics/doughnut_chart.jsx12
-rw-r--r--webapp/components/analytics/line_chart.jsx12
2 files changed, 12 insertions, 12 deletions
diff --git a/webapp/components/analytics/doughnut_chart.jsx b/webapp/components/analytics/doughnut_chart.jsx
index b946ad8bb..5834e290a 100644
--- a/webapp/components/analytics/doughnut_chart.jsx
+++ b/webapp/components/analytics/doughnut_chart.jsx
@@ -23,26 +23,26 @@ export default class DoughnutChart extends React.Component {
componentDidUpdate(prevProps) {
if (!Utils.areObjectsEqual(prevProps.data, this.props.data) || !Utils.areObjectsEqual(prevProps.options, this.props.options)) {
- if (this.chart) {
- this.chart.destroy();
- }
- this.initChart();
+ this.initChart(true);
}
}
componentWillUnmount() {
- if (this.chart) {
+ if (this.chart && this.refs.canvas) {
this.chart.destroy();
}
}
- initChart() {
+ initChart(update) {
if (!this.refs.canvas) {
return;
}
var el = ReactDOM.findDOMNode(this.refs.canvas);
var ctx = el.getContext('2d');
this.chart = new Chart(ctx, {type: 'doughnut', data: this.props.data, options: this.props.options || {}}); //eslint-disable-line new-cap
+ if (update) {
+ this.chart.update();
+ }
}
render() {
diff --git a/webapp/components/analytics/line_chart.jsx b/webapp/components/analytics/line_chart.jsx
index bebeb0223..aa603d819 100644
--- a/webapp/components/analytics/line_chart.jsx
+++ b/webapp/components/analytics/line_chart.jsx
@@ -23,26 +23,26 @@ export default class LineChart extends React.Component {
componentDidUpdate(prevProps) {
if (!Utils.areObjectsEqual(prevProps.data, this.props.data) || !Utils.areObjectsEqual(prevProps.options, this.props.options)) {
- if (this.chart) {
- this.chart.destroy();
- }
- this.initChart();
+ this.initChart(true);
}
}
componentWillUnmount() {
- if (this.chart) {
+ if (this.chart && this.refs.canvas) {
this.chart.destroy();
}
}
- initChart() {
+ initChart(update) {
if (!this.refs.canvas) {
return;
}
var el = ReactDOM.findDOMNode(this.refs.canvas);
var ctx = el.getContext('2d');
this.chart = new Chart(ctx, {type: 'line', data: this.props.data, options: this.props.options || {}}); //eslint-disable-line new-cap
+ if (update) {
+ this.chart.update();
+ }
}
render() {