Chartjs-Chart.js / Google Charts and JSON

1๐Ÿ‘

What would be the most efficient approach with the least amount of
code? Should I convert the string to an array of objects, then work
with that?

Converting the string to a format required by Chart.js would be a necessary step. Chart.js does not accept csv as an input. The appropriate format varies by chart type (line, pieโ€ฆ)

For Google charts โ€“ see How to use Google Chart with data from a csv


Also, how do I create charts in google charts and chart.js with json
data?

For Chart.js, the documentation (http://www.chartjs.org/docs/#line-chart-introduction) has examples for each chart type to get you started.

The same for Google charts โ€“ https://developers.google.com/chart/interactive/docs/quick_start

Leave a comment