JSFiddle - React, Tailwind, and code Playground
by Rikin Patel
HTML
<script src="http://www.google.com/jsapi?.js"></script>
<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="chart_div"></div>
<div id="chart_div1"></div>
JavaScript
google.charts.load('current', {
callback: function () {
// create empty data table
var emptyData = new google.visualization.DataTable({
cols: [
{label: 'Element', type: 'string'},
{label: 'Density', type: 'number'},
{role: 'style', type: 'string'},
{role: 'annotation', type: 'string'}
]
});
var withData = emptyData.clone();
var options = {
// set annotation for -- No Data Copy
annotations: {
// remove annotation stem and push to middle of chart
stem: {
color: 'transparent',
length: 120
},
textStyle: {
color: '#9E9E9E',
fontSize: 18
}
},
bar: {groupWidth: '95%'},
height: 400,
legend: {position: 'none'},
vAxis: {
viewWindow: {
min: 0,
max: 30
}
},
width: 600
};
// if no data add row for annotation -- No Data Copy
if (emptyData.getNumberOfRows() === 0) {
emptyData.addRows([
['', 0, null, 'No Data Copy']
]);
}
var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
chart.draw(emptyData, options);
},
packages: ['corechart']
});