1
The idea is to make the text of the line type Annotation stand over the column.
I tried to create another Annotation for the same column, but did not succeed.
JS:
google.charts.load("current", {
packages: ['corechart']
});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'x');
data.addColumn({type: 'string', role: 'annotation'});
data.addColumn('number', 'Faixas');
data.addColumn({type: 'string', role: 'annotation'});
data.addRow(["até 4", null, 0, '0']);
data.addRow(["4.5", null, 0, '0']);
data.addRow(["5", null, 0, '0']);
data.addRow(["5.5", null, 0, '0']);
data.addRow(["6", null, 0, '0']);
data.addRow(["6.5", null, 0, '0']);
data.addRow(["7", null, 1, '1']);
data.addRow(["7.5", null, 2, '2']);
data.addRow(["8", 'Você', 5, '5']);
data.addRow(["8.5", null, 6, '6']);
data.addRow(["9", null, 2, '2']);
data.addRow(["9.5", null, 0, '0']);
data.addRow(["10", null, 3, '3']);
var view = new google.visualization.DataView(data);
var chart = new google.visualization.ColumnChart(document.getElementById("grafico"));
chart.draw(view, {
legend: {position: 'bottom'},
curveType: 'function',
vAxis: {
maxValue: 10,
format: 0
},
annotation: {
1: {
style: 'line'
}
}
});
$(document).ready(function () {
$(window).resize(function () {
drawChart();
});
});
}
HTML:
<div id="grafico"></div>
EXPECTED RESULT:
Maybe my explanation got confused. My idea is that, in the column in which the text "you" will appear, also appear Annotation with quantity. That is, two annotations for the same column, a string and a row - and I don’t know if that’s possible -.
– Cobra
@Thiagobarros, I don’t know if this is possible only with google functions Charts. Maybe if you overwrite SVG it will work. You can try to replace the Annotations, see: https://jsfiddle.net/7m7gbbsb/1/ Only one detail when you use
style: 'line'
in Annotations is to leave it upright.– Taisbevalle