PLT-3257 Fix Team Statistics (#3290)
Этот коммит содержится в:
коммит произвёл
Joram Wilander
родитель
6a3e742e9b
Коммит
1b2fd5af5e
@@ -23,26 +23,26 @@ export default class DoughnutChart extends React.Component {
|
|||||||
|
|
||||||
componentDidUpdate(prevProps) {
|
componentDidUpdate(prevProps) {
|
||||||
if (!Utils.areObjectsEqual(prevProps.data, this.props.data) || !Utils.areObjectsEqual(prevProps.options, this.props.options)) {
|
if (!Utils.areObjectsEqual(prevProps.data, this.props.data) || !Utils.areObjectsEqual(prevProps.options, this.props.options)) {
|
||||||
if (this.chart) {
|
this.initChart(true);
|
||||||
this.chart.destroy();
|
|
||||||
}
|
|
||||||
this.initChart();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
if (this.chart) {
|
if (this.chart && this.refs.canvas) {
|
||||||
this.chart.destroy();
|
this.chart.destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
initChart() {
|
initChart(update) {
|
||||||
if (!this.refs.canvas) {
|
if (!this.refs.canvas) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var el = ReactDOM.findDOMNode(this.refs.canvas);
|
var el = ReactDOM.findDOMNode(this.refs.canvas);
|
||||||
var ctx = el.getContext('2d');
|
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
|
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() {
|
render() {
|
||||||
|
|||||||
@@ -23,26 +23,26 @@ export default class LineChart extends React.Component {
|
|||||||
|
|
||||||
componentDidUpdate(prevProps) {
|
componentDidUpdate(prevProps) {
|
||||||
if (!Utils.areObjectsEqual(prevProps.data, this.props.data) || !Utils.areObjectsEqual(prevProps.options, this.props.options)) {
|
if (!Utils.areObjectsEqual(prevProps.data, this.props.data) || !Utils.areObjectsEqual(prevProps.options, this.props.options)) {
|
||||||
if (this.chart) {
|
this.initChart(true);
|
||||||
this.chart.destroy();
|
|
||||||
}
|
|
||||||
this.initChart();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
if (this.chart) {
|
if (this.chart && this.refs.canvas) {
|
||||||
this.chart.destroy();
|
this.chart.destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
initChart() {
|
initChart(update) {
|
||||||
if (!this.refs.canvas) {
|
if (!this.refs.canvas) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var el = ReactDOM.findDOMNode(this.refs.canvas);
|
var el = ReactDOM.findDOMNode(this.refs.canvas);
|
||||||
var ctx = el.getContext('2d');
|
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
|
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() {
|
render() {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user