PLT-3257 Fix Team Statistics (#3290)

This commit is contained in:
enahum
2016-06-09 12:08:20 -03:00
committed by Joram Wilander
parent 6a3e742e9b
commit 1b2fd5af5e
2 changed files with 12 additions and 12 deletions

View File

@@ -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() {

View File

@@ -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() {