reactjs / react-chartjs

common react charting components using chart.js
MIT License
2.93k stars 301 forks source link

new feature support: stream chart #162

Open yuqkevin opened 7 years ago

yuqkevin commented 7 years ago

Hi there,

I'm working on a dashboard project and find that react-chartjs does not support stream chart which chart.js does by addData() and removeData(). So I just added couple lines into react-chartjs core.js to support this feature. I've tested changes on dev environment and it just works.

The component jsx looks like this: <LineChart data={this.state.chartData} options={this.state.chartOptions} width={500} height={200} stream />

The nextPoints is a json object under chartData with values and label like this (2-lines in example): chartData: { labels: [...], datasets: [{ ... }, { ... }], nextPoints: { values: [<val1>, <val2>], label: <newLabel> } }

I really appreciate it if you can take a quick review.

Thanks, Kevin