I'm making a reporting tool that uses Google Charts graphics. I want to create Combo Charts but the number of datas is dynamic so i have to pass a variable "nbEGP" in options.series:
/* Création de graphique Google Chart */
function drawChart(array, title, div, type, nbEGP) {
var data = new google.visualization.arrayToDataTable(array);
// Set chart options
var options = {
'title' : title,
'width' : '80%',
'height' : '600',
seriesType : "bars",
series : {
nbEGP : {
type : "line"
}
}
};
...
chart.draw(data, options);
}
but it doesn't work. If i try to display options.series I can see it did not put the value of my variable but the name "nbEGP".
I finally managed doing like this:
// Set chart options
var options = {
'title' : title,
'width' : '80%',
'height' : '600',
seriesType : "bars",
series : ""
};
myObj = {};
myObj[nbEGP] = {type : "line"};
options.series = myObj;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With