Created
August 24, 2017 11:19
-
-
Save vuongngo/35114e3a08c7d7dcf1fde6a0f7107d25 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import HighCharts from 'highcharts'; | |
export default class Chart extends Component { | |
componentDidMount() { | |
if (this.props.modules) { | |
this.props.modules.forEach(module => { | |
module(HighCharts); | |
}); | |
} | |
HighCharts.setOptions({ | |
global: { | |
useUTC: false, | |
} | |
}); | |
this.chart = new HighCharts[this.props.type || "Chart"]( | |
this.props.container, | |
this.props.options, | |
); | |
} | |
shouldComponentUpdate(nextProps) { | |
this.chart.update(nextProps.options); | |
return false; | |
} | |
componentWillUnmount() { | |
this.chart.destroy(); | |
} | |
render() { | |
return ( | |
<div id={this.props.container} /> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment