I need to develop a stacked chart in Google Charts and I'm new to it.
Here is the sample code for generating the chart.

function drawChart()
    {
       var data = google.visualization.arrayToDataTable(["Label", "I", { role: 
"style" }, "J", { role: "style" }, "K", { role: "style" }, "M", { role: "style" 
}],["MJ1", 0.05, "#808080", 0.0775, "#C71585", 0.069, "#FFC0CB", 0.05, 
"Blue"],["MJ2", 0.05, "Yellow", 0.0775, "Pink", 0.069, "#808080", 0.05, 
"black"]);
       var options = {
            width: 1000,
            height: 550,
            legend: { position: 'none', maxLines: 6, textStyle: {color: 
'black', fontSize: 10 } },
            isStacked: true,                
        };
        var chart = new 
google.visualization.ColumnChart(document.getElementById('chart_div'));
        chart.draw(data, options);
    }

The above mentioned code is working fine. But when I change the data to a 
variable and use that variable as mentioned below, the graph is not 
generated.

var temp = '["Machine", "I", { role: "style" }, "J", { role: "style" }, "K", { 
role: "style" }, "M", { role: "style" }],["MJ1", 0.05, "#808080", 0.0775, 
"#C71585", 0.069, "#FFC0CB", 0.05, "Blue"],["MJ2", 0.05, "Yellow", 0.0775, 
"Pink", 0.069, "#808080", 0.05, "black"]';
var data = google.visualization.arrayToDataTable([temp]);  


I even tried 


function drawChart()
    {
        var myArray = [];

            myArray.push('"Machine", "I", { role: "style" }, "J", { role: 
"style" }, "K", { role: "style" }, "M", { role: "style" }');

            myArray.push('"MJ1", 0.05, "#808080", 0.0775, "#C71585", 0.069, 
"#FFC0CB", 0.05, "Blue"');

            myArray.push('"MJ2", 0.05, "Yellow", 0.0775, "Pink", 0.069, 
"#808080", 0.05, "black"');



            var data = google.visualization.arrayToDataTable(myArray);

       var options = {
            width: 1000,
            height: 550,
            legend: { position: 'none', maxLines: 6, textStyle: {color: 
'black', fontSize: 10 } },
            isStacked: true,                
        };
        var chart = new 
google.visualization.ColumnChart(document.getElementById('chart_div'));
        chart.draw(data, options);
    }


Can anyone tell me what am I doing wrong.

Your quick response is highly appreciated!!           


Thanks in advance!
JSFiddle for the same - http://jsfiddle.net/crazyCoder1989/79ffvayr/653/




-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-visualization-api+unsubscr...@googlegroups.com.
To post to this group, send email to google-visualization-api@googlegroups.com.
Visit this group at https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-visualization-api/0af05cb2-0b6b-43b9-8682-8e1777215aaa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to