-
-
Save c0debreaker/390245014dabf4e965d7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function plotStackedColumnChartTemplateForGoogleCharts(jsonData) { | |
var parentArray = {}, | |
loopCtr = 0, | |
allFieldsFromArguments = [].slice.call(arguments, 1), | |
chartTitle = allFieldsFromArguments.shift(), // Grabing first argument which is title | |
dataFields = allFieldsFromArguments, | |
tmpForCObjectArray = [], | |
rows = [], | |
cols = []; | |
jsonData.forEach(function(a) { | |
dataFields.forEach(function(f) { | |
if (loopCtr == 0) { | |
tmpForCObjectArray.push({v: a[f]}); | |
} else { | |
tmpForCObjectArray.push({ | |
v: parseInt(a[f]), | |
f: a[f] + " byte(s)" | |
}); | |
} | |
loopCtr++; | |
}) | |
rows.push({c : tmpForCObjectArray}); | |
tmpForCObjectArray = [] | |
loopCtr = 0; | |
}) | |
for (var i=0; i < dataFields.length; i++) { | |
if (i == 0) { | |
cols.push({ | |
id: dataFields[i]+"-id", | |
label: dataFields[i], | |
type: "string" | |
} | |
); | |
} else { | |
cols.push({ | |
id: dataFields[i]+"-id", | |
label: dataFields[i], | |
type: "number" | |
} | |
); | |
} | |
} | |
parentArray = { | |
"cols": cols, | |
"rows": rows | |
} | |
var chart1 = {}; | |
chart1.type = "ColumnChart"; | |
chart1.displayed = true; | |
chart1.data = parentArray; | |
chart1.options = { | |
title: chartTitle, | |
displayExactValues: true, | |
fill: 20, | |
seriesType: "bars", | |
series: {2: { type: "area", curveType: 'function' }}, | |
// width: 130, | |
height: 400, | |
// is3D: true, | |
isStacked: true, | |
// pieHole: 0.4,// for donut pie | |
colors: ["#98abc5", "#8a89a6", "#7b6888", "#6b486b", "#a05d56", "#d0743c", "#ff8c00"], | |
// chartArea: {left:10,top:3, bottom:0,width:"90%",height:"90%"}, | |
vAxis: { | |
viewWindow : { min : 0 , max : 6000000 }, | |
"title": "Traffic Usage (bytes)", | |
"gridlines": { | |
"count": -1 | |
} | |
}, | |
legend: { position: 'right'} | |
}; | |
chart1.formatters = {}; | |
// { | |
// number : [{ | |
// columnNum: 1, | |
// pattern: "#,##0" | |
// }] | |
// }; | |
return chart1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment