I am running into a case where all the data is by default coming as zero. Something like this:
function drawVisualization() {
// Create and populate the data table.
var data = google.visualization.arrayToDataTable([
['Year', 'Austria', 'Belgium', 'Czech Republic', 'Finland', 'France', 'Germany'],
['2003', 0, 0, 0, 0, 0, 0],
['2004', 0, 0, 0, 0, 0, 0],
['2005', 0, 0, 0, 0, 0, 0],
['2006', 0, 0, 0, 0, 0, 0],
['2007', 0, 0, 0, 0, 0, 0],
['2008', 0, 0, 0, 0, 0, 0]
]);
// Create and draw the visualization.
new google.visualization.ColumnChart(document.getElementById('visualization')).
draw(data,
{title:"Yearly Coffee Consumption by Country",
width:600, height:400,
hAxis: {title: "Year"},vAxis:{minValue:0,format:"#"}}
);
}
If you copy above code and play around on google playground you will find that the graph is hard limiting the minimum value to -1.0. What I wanted is to start the vAxis from zero and pick only integral values. But it is not happening. I have also tried viewWindowMode but, it also couldn't solve the problem. Screenshot below of how it got rendered.
Use noData() method to enable "No data" label: chart. noData().
To change the colors assigned to data series in a specific chart: Select that chart, then on the right, open the STYLE tab. In the Color by section, select Series order, Bar order, or Slice order, depending on the type of chart. Click a color box to set the color for each series.
You nee to add max value in viewWindow
and remove baseline by color it.
vAxis: {
viewWindowMode: "explicit",
viewWindow: {min: 0,max:1},
baseline:{
color: '#F6F6F6'
}
}
You can fix it using viewWindow.min
option (The minimum horizontal data value to render.), like:
vAxis: {
minValue:0,
viewWindow: {
min: 0
}
}
This can be achieved by setting the viewwindow values.
vAxis: { viewWindow: { min: 0 }, viewWindowMode: "explicit" }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With