I try to create bar chart using google chart example
var data = new google.visualization.DataTable();
data.addColumn('string', 'Topping');
data.addColumn('number', 'Slices');
data.addRows([
['Mushrooms', 5],
['Onions', 4],
['Olives', 3]
['Zucchini', 2],
['Pepperoni', 1]
]);
Chart is created successfully but on X-Axis it shows value from 0 to 6. When i pass all values as 0 it shows X-Axis from -1 to +1.
Is it possible to set X-Axis to always start from 0% to 100%.
To change the axis type to a text or date axis, expand Axis Options, and then under Axis Type, select Text axis or Date axis. Text and data points are evenly spaced on a text axis.
You can force the x-axis of a BarChart to always show a certain range by setting the hAxis.viewWindow.min
and hAxis.viewWindow.max
options:
hAxis: {
viewWindow: {
min: 0,
max: 100
},
ticks: [0, 25, 50, 75, 100] // display labels every 25
}
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