Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. export default class CandlestickChart extends React.Component {
  2. constructor (props) {
  3. super(props);
  4. this.state = {
  5. apiParam1: this.props.propData.param1,
  6. apiParam2: this.props.propData.param2,
  7. chartConfig: this.getChartConfig(this.props.apiParam1),
  8. };
  9. }
  10.  
  11. componentDidMount() {
  12. this.renderChart();
  13. }
  14.  
  15. render() {
  16. return (
  17. <div className='col-lg-6'>
  18. <div className='well'>
  19. <ReactHighStock config={this.state.chartConfig} />
  20. </div>
  21. </div>
  22. );
  23. }
  24.  
  25. renderChart() {
  26. var that = this;
  27. NanoAjax.ajax({
  28. url: 'myApi.com?param1=' + this.state.apiParam1 + '&param2=' + this.state.apiParam2;
  29. }, function (statusCode, responseText) {
  30. //transform the data a bit
  31.  
  32. var chartConfig = that.getChartConfig(that.state.apiParam1);
  33. chartConfig.series[0].data = chartData;
  34.  
  35. that.setState({
  36. chartConfig: chartConfig
  37. })
  38. });
  39. }
  40.  
  41. getChartConfig(param1) {
  42. // returns HighCharts chartConfig object based on apiParam1
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement