reactjs / react-chartjs

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

Allow complex data values #223

Open francisco4challenge opened 5 years ago

francisco4challenge commented 5 years ago

Hi, is it possible to allow the data property to have an array of objects with a specific structure, like: { value: 32, [anything else] } and use the value prop to make the chart? Or define a "render" prop to be a allow a function that determines how to get the value. ( (point) => point.value )

I'm asking this because i need to have a something in the chartElement object that i can link to a structure outside the chart. Example: having an id value for each point so that i can use to query a DB.

Is this possible or i would have to fork the lib and costumize it?

agent3bood commented 5 years ago

This functionality is part of the chart.js library, react-chartjs is just a wrapper. According to the docs https://github.com/chartjs/Chart.js/blob/v1.1.1/docs/01-Line-Chart.md you have to pass an array of points, if you are getting complex data from your api you have to arrange it in the way that the library will accept.