views:

405

answers:

1

Is there any way to force the Annotated Time Line graph to automatically change scale on the Y-axis when the user zooms in on a range of dates?

Check example below, and note that the value ("price") for 2009-10-09 is about two magnitudes larger than the other values. When the user zooms in on e.g. 2009-10-01 -- 2009-10-08, the Y-axis is unchanged (making the graph pretty useless). Is there a way to automatically rescale the Y-axis so that in this is example it would range from 0 to 25 or something more reasonable (and then of course back to the default when the user zooms out)?

Example: http://jsbin.com/ifogo

Sample code (same as in link above):

<script src="http://www.google.com/jsapi"&gt;&lt;/script&gt;
<div id="visualization" style="width: 800px; height: 400px;"></div>
<script>
google.load('visualization', '1', {packages: ['annotatedtimeline' ]});
function drawVisualization() {
  var data = new google.visualization.DataTable({
  cols: [{label: 'Date', type: 'date'}, {label: 'Price', type: 'number'}],
  rows: [
    { c:[{v: new Date(2009, 10, 1) }, {v: 11 }]},
    { c:[{v: new Date(2009, 10, 2) }, {v: 12 }]},
    { c:[{v: new Date(2009, 10, 3) }, {v: 13 }]},
    { c:[{v: new Date(2009, 10, 4) }, {v: 11 }]},
    { c:[{v: new Date(2009, 10, 5) }, {v: 10 }]},
    { c:[{v: new Date(2009, 10, 6) }, {v: 16 }]},
    { c:[{v: new Date(2009, 10, 7) }, {v: 22 }]},
    { c:[{v: new Date(2009, 10, 8) }, {v: 12 }]},
    { c:[{v: new Date(2009, 10, 9) }, {v: 999 }]},
]},0.6);
var annotatedtimeline = new google.visualization.AnnotatedTimeLine(document.getElementById('visualization'));
annotatedtimeline.draw(data);
}
google.setOnLoadCallback(drawVisualization);
</script>
A: 

Try using

annotatedtimeline.draw(data, {scaleType: 'maximized'});

Google's page on that visualization shows the various options you can use.

jnj
Thanks! I must have missed that in the documentation.
error