I´m trying to add a different color in each column, i have the following code to draw the chart:
var formDataKinder = {type:"Kinder"};
var jsonDataKinder = $.ajax({
type: "POST",
data : formDataKinder,
url: "./content/chartsData.php",
dataType:"json",
async: false
}).responseText;
var dataKinder = new google.visualization.DataTable(jsonDataKinder);
var optionsKinder = {
legend: 'none',
chartArea: {'width': '80%', 'height': '80%'}
};
var chartKinder = new google.visualization.ColumnChart(document.getElementById('Kinderchart'));
chartKinder.draw(dataKinder, optionsKinder);
I add the style in the array but the column do not change:
{"cols": [
{"id":"","label":"Grado","pattern":"","type":"string"},
{"id":"","label":"Estudiantes","pattern":"","type":"number"},
{"id":"","role":"style","type":"string"}
],
"rows": [
{"c":[{"v":"1ro.","f":null},{"v":8,"f":null},{"p":"color: #A22979","f":null}]},
{"c":[{"v":"2do.","f":null},{"v":23,"f":null},{"p":"color: #1D63BB","f":null}]},
{"c":[{"v":"3ro.","f":null},{"v":32,"f":null},{"p":"color: #D72D16","f":null}]}
]}
Any idea?
Hope this helps.
{"cols": [
{"id":"","label":"Grado","pattern":"","type":"string"},
{"id":"","label":"Estudiantes","pattern":"","type":"number"},
{"id":"","role":"style","type":"string"}
],
"rows": [
{"c":[{"v":"1ro.","f":null},{"v":8,"f":null},{"v":"#A22979","f":null}]},
{"c":[{"v":"2do.","f":null},{"v":23,"f":null},{"v":"#1D63BB","f":null}]},
{"c":[{"v":"3ro.","f":null},{"v":32,"f":null},{"v":"#D72D16","f":null}]}
]}
You can know the JSON structure of the DataTable by using DataTable.toJSON()
after execute google.visualization.arrayToDataTable()
.
https://developers.google.com/chart/interactive/docs/gallery/columnchart
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다