hAxis maxValue

4,904 views
Skip to first unread message

Vincent Bruneau

unread,
May 15, 2012, 12:00:12 PM5/15/12
to Google Visualization API
Hello,

In this code I try to modify the maxValue of hAxis :

function drawVisualization() {
// Create and populate the data table.
var data = google.visualization.arrayToDataTable([
['x', 'Cats', 'Blanket 1', 'Blanket 2'],
[0, 1, 1, 0.5],
[1, 2, 0.5, 1],
[2, 4, 1, 0.5],
[3, 8, 0.5, 1],
[4, 7, 1, 0.5],
[4, 7, 0.5, 1],
[5, 8, 1, 0.5],
[3, 4, 0.5, 1]
]);

// Create and draw the visualization.
new
google.visualization.LineChart(document.getElementById('visualization')).
draw(data, {curveType: "function",
width: 500, height: 400, hAxis:{title:'plop',
maxValue:50},
vAxis: {maxValue: 10}}
);
}


but in the graphic the hAxis stay from 0 to 5 .

Where I'm wrong ?

Thank

asgallant

unread,
May 15, 2012, 1:11:21 PM5/15/12
to google-visua...@googlegroups.com
Set the hAxis.viewWindowMode option to 'explicit' and the hAxis.viewWindow.max/min options to force the chart to draw a given range, even if the data would normally make it otherwise:

hAxis{
    viewWindowMode'explicit',
    viewWindow{
        max50

Vincent Bruneau

unread,
May 16, 2012, 3:14:40 AM5/16/12
to Google Visualization API
Thank you it's work.

So minValue and maxValue are useless ?

asgallant

unread,
May 16, 2012, 9:29:40 AM5/16/12
to google-visua...@googlegroups.com
No, they aren't useless.  min/maxValue options specify the outer boundaries of the charts axis, but can be overridden if the chart's values lie outside the boundaries.  The viewWindow options force the chart to display a certain area regardless of the data (so, in your case, if you had a data point at x=55, it would not show up on the chart).  The implementation of domain axis min/maxValue options seems to be broken ATM, which is probably why you had to ask the question.

chris....@gmail.com

unread,
Jan 1, 2013, 6:30:13 AM1/1/13
to google-visua...@googlegroups.com
hAxis.minValue and hAxis.maxValue are broken at the moment, so yes, they are useless. vAxis.minValue and vAxis.maxValue work as documented.

hAxis.viewWindow.min and hAxis.viewWindow.max are not quite the same because they are not overridden by the data if it falls outside the specified range.

I'm able to work around this using hAxis.viewWindow.min and hAxis.viewWindow.max, but it means I have to analyse the data myself to find the minimum and maximum values, then use hAxis.viewWindow.min and hAxis.viewWindow.max to specify either the preferred ranges or the actual data ranges. It's just a bit more work.

I'd prefer to use hAxis.minValue and hAxis.maxValue. Will they be fixed some day?
Reply all
Reply to author
Forward
0 new messages