Reactjs – How to create a HighCharts chart in react

highchartsreactjs

How can I create a component with a HighCharts chart, that create the chart ones on the first render and only update the series data when new data comes in using chart.series[0].setData(data,true);

Best Answer

I have made a library called React JSX Highcharts, which might be what you're looking for. GitHub / NPM

It allows you to create Highcharts charts with React components. So to update the series data, would just need to pass an updated data prop.

Behind the scenes, React JSX Highcharts would call setData for you.

Example

<HighchartsChart plotOptions={plotOptions}>
  <Chart />

  <Title>My Highcharts Chart</Title>

  <Legend layout="vertical" align="right" verticalAlign="middle" />

  <XAxis>
    <XAxis.Title>Time</XAxis.Title>
  </XAxis>

  <YAxis id="number">
    <YAxis.Title>My Axis Title</YAxis.Title>
    <LineSeries id="series1" data={data1} />
    <LineSeries id="series2" data={data2} />
  </YAxis>
</HighchartsChart>