54
rated 0 times
[
58]
[
4]
/ answers: 1 / hits: 32682
/ 11 Years ago, sun, april 7, 2013, 12:00:00
I'm trying to use Google's chart api: https://google-developers.appspot.com/chart/interactive/docs/gallery/columnchart
I have two arrays that I'd like to use to generate and label the visualization. However, I can't find a way to combine and convert these arrays into the proper object structure.
My arrays are the following and their contents are next to them:
years; // 2014,2015,2020,2021
sales; // 100,100,200,100
I need to dynamically use these arrays to form this object, which is in the format that Google's API uses:
var data = google.visualization.arrayToDataTable([
['Year', 'Sales'],
['2014', 100],
['2015', 100],
['2020', 200],
['2021', 100]
]);
Thank you for any help.
More From » arrays