How do I add blank space or whitespcaes in the chart title. I tried   and   but it is not working. Please suggest.
Asked
Active
Viewed 584 times
1 Answers
2
labels in google charts (title, legend, axis) will not accept html,
but you can use Unicode characters...
in this case, use the non-breaking space --> \u00A0
title: 'Begin>\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0<End'
see following working snippet...
google.charts.load('current', {
packages:['corechart']
}).then(function () {
var data = google.visualization.arrayToDataTable([
['x', 'y0'],
[0, 0],
[1, 2],
[2, 4],
[3, 6]
]);
var options = {
title: 'Begin>\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0<End'
};
var container = document.getElementById('chart_div');
var chart = new google.visualization.ColumnChart(container);
chart.draw(data, options);
});
<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="chart_div"></div>

WhiteHat
- 59,912
- 7
- 51
- 133
-
Thank you. This works. Is this '\u00A0' non-breaking space different for different browsers? – Feb 22 '19 at 19:01