Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export default class CandlestickChart extends React.Component {
- constructor (props) {
- super(props);
- this.state = {
- apiParam1: this.props.propData.param1,
- apiParam2: this.props.propData.param2,
- chartConfig: this.getChartConfig(this.props.apiParam1),
- };
- }
- componentDidMount() {
- this.renderChart();
- }
- render() {
- return (
- <div className='col-lg-6'>
- <div className='well'>
- <ReactHighStock config={this.state.chartConfig} />
- </div>
- </div>
- );
- }
- renderChart() {
- var that = this;
- NanoAjax.ajax({
- url: 'myApi.com?param1=' + this.state.apiParam1 + '¶m2=' + this.state.apiParam2;
- }, function (statusCode, responseText) {
- //transform the data a bit
- var chartConfig = that.getChartConfig(that.state.apiParam1);
- chartConfig.series[0].data = chartData;
- that.setState({
- chartConfig: chartConfig
- })
- });
- }
- getChartConfig(param1) {
- // returns HighCharts chartConfig object based on apiParam1
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement