Google data visualization with CSV data

I have a url that returns CSV data. I would like to use Google Vizualization to create an interactive data chart. I looked at a few examples on the Google Chart and Vizualization webpage, but it bothers me a bit as I am not familiar with JavaScript or web programming in general.

Question: Should I use JavaScript to analyze the CSV string myself and manually build the DataTable using addColumn () and addRows ()? Or is there a way to simply pass the CSV URL to the charting function? I hope to do something like this:

var csv_data = get_data_from_url('http://...') var data = new google.visualization.DataTable(csv_data); var chart = new google.visualization.PieChart(document.getElementById('chart_div')); chart.draw(data, ...); 

Can anyone help me out?

Thanks.

+4
source share
1 answer

Yes, they seem to be using JSON or some close variant of JSON for the data. You can try the CSV to JSON converter. Converting CSV to JSON seems to be a pretty trivial operation requiring only a few lines of code:

Convert CSV / XLS to JSON?

+2
source

Source: https://habr.com/ru/post/1304950/


All Articles