Skip to content

Instantly share code, notes, and snippets.

@vuongngo
Created August 24, 2017 11:19
Show Gist options
  • Save vuongngo/35114e3a08c7d7dcf1fde6a0f7107d25 to your computer and use it in GitHub Desktop.
Save vuongngo/35114e3a08c7d7dcf1fde6a0f7107d25 to your computer and use it in GitHub Desktop.
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