I've set up a material bar chart going off the documentation and have run in to an issue; the axis titles that are displayed aren't what I'm setting them to.
function drawGoogleBarChart(parentID, width, height, json) {
var bcd = JSON.parse(json);
var bars = bcd.Bars;
var colors = [];
var data = new google.visualization.DataTable();
data.addColumn('string', 'Name');
for (var i = 0; i < bars[0].Segments.length; ++i) {
data.addColumn('number', bars[0].Segments[i].Name);
data.addColumn({ type: 'string', role: 'style' });
colors.push(rgbToHex(bars[0].Segments[i].Color.R, bars[0].Segments[i].Color.G, bars[0].Segments[i].Color.B));
}
for (var i = 0; i < bars.length; ++i) {
var row = [];
row.push(bars[i].Label);
for (var j = 0; j < bars[i].Segments.length; ++j) {
row.push(bars[i].Segments[j].Count);
row.push(rgbToHex(bars[i].Segments[j].Color.R, bars[i].Segments[j].Color.G, bars[i].Segments[j].Color.B));
}
data.addRow(row);
}
var xTitle = bcd.XAxis != null ? bcd.XAxis.Title : ""; // set to "Task Count"
var yTitle = bcd.YAxis != null ? bcd.YAxis.Title : ""; // set to ""
var options = {
isStacked: true,
animation: {
startUp: true,
duration: 500,
easing: 'out'
},
hAxis: {
title: xTitle,
minValue: 0,
},
vAxis: {
title: yTitle
},
colors: colors,
bars: 'horizontal',
width: width,
height: height
};
var material = new google.charts.Bar(document.getElementById(parentID));
material.draw(data, options);
}
And here's what my bar chart looks like. The vAxis, which should have no title, is set to "Name", and the hAxis, which should say "Task Count" is empty.