javascript - google visualization line chart animation blank -


i have created line chart 'select' event listener. when item in chart legend clicked alter view of chart.

i can data change can't chart animate.

the lines on chart disappear animation 'duration' period , new lines drawn. when remove animation portion options map in chartwrapper action of clearing chart no longer takes place seem registering animation request.

i wondering if give me advice on how trouble shoot these types of animation problems because have no idea going on.

i guess i'm kind of looking p.m.d.a.s.(mathematical order of operations) of google charts animation..

code:

<html> <script type="text/javascript" src="https://www.google.com/jsapi"></script> <script type="text/javascript"> google.load('visualization', '1', {packages: ['corechart', 'controls']}); function drawvisualization() {      var chartdata = new google.visualization.datatable({         'cols': [             {'id': 'a', 'label': 'a','type': 'number', 'p': {'role': 'domain'}},             {'id': 'a', 'label': 'a','type': 'number', 'p': {'role': 'data'}},             {'id': 'a_', 'label': null, 'type': 'boolean', 'p': {'role':'certainty'}},             {'id': 'b', 'label': 'b','type': 'number', 'p': {'role': 'data'}},             {'id': 'b_', 'label': null, 'type': 'boolean', 'p': {'role':'certainty'}},             {'id': 'c', 'label': 'c','type': 'number', 'p': {'role': 'data'}},             {'id': 'c_', 'label': null, 'type': 'boolean', 'p': {'role':'certainty'}}         ],         'rows':[                 {'c': [{'v': 0, 'f': 'date string'}, {'v': 1, 'f': null}, {'v': true, 'f': null}, {'v': 1, 'f': null}, {'v': true, 'f': null}, {'v': 1, 'f': null}, {'v': true, 'f': null}]},                 {'c': [{'v': 1, 'f': 'date string'}, {'v': 2, 'f': null}, {'v': false, 'f': null}, {'v': 3, 'f': null}, {'v': true, 'f': null}, {'v': 4, 'f': null}, {'v': false, 'f': null}]},                 {'c': [{'v': 2, 'f': 'date string'}, {'v': 3, 'f': null}, {'v': true, 'f': null}, {'v': 2, 'f': null}, {'v': true, 'f': null}, {'v': 1, 'f': null}, {'v': true, 'f': null}]}         ]     });      var score_chart = new google.visualization.chartwrapper({         'charttype': 'linechart',         'containerid': 'score_chart',         'datatable': chartdata,         'options': {             animation:{                 duration: 1000,                 easing: 'out'                 },             curvetype: "function"         },         view: {columns: [0,1,2]}     });      var score_check = google.visualization.events.addlistener(score_chart, 'ready', function(){         google.visualization.events.removelistener(score_check);         var score_select = google.visualization.events.addlistener(score_chart, 'select', function(){         var selection = score_chart.getchart().getselection();         if (selection.length) {             score_chart.setview({'columns': [0,3,4,5,6]});             score_chart.draw();         };     });      });     score_chart.draw(); }; google.setonloadcallback(drawvisualization); 

the problem stems id's. seems charts have undocumented behavior tracks data series column id (if specified). since id's columns 1 , 3 different, chart removes series id "a" , adds 2 new series id's "b" , "c". new series not animated, why animations appear broken. if remove id's on columns 1, 3, , 5 (or give columns 1 , 3 same id) chart animate way expect to:

var chartdata = new google.visualization.datatable({     'cols': [         {'id': 'a', 'label': 'a','type': 'number', 'p': {'role': 'domain'}},         {'label': 'a','type': 'number', 'p': {'role': 'data'}},         {'id': 'a_', 'label': null, 'type': 'boolean', 'p': {'role':'certainty'}},         {'label': 'b','type': 'number', 'p': {'role': 'data'}},         {'id': 'b_', 'label': null, 'type': 'boolean', 'p': {'role':'certainty'}},         {'label': 'c','type': 'number', 'p': {'role': 'data'}},         {'id': 'c_', 'label': null, 'type': 'boolean', 'p': {'role':'certainty'}}     ],     'rows':[         {'c': [{'v': 0, 'f': 'date string'}, {'v': 1, 'f': null}, {'v': true, 'f': null}, {'v': 1, 'f': null}, {'v': true, 'f': null}, {'v': 1, 'f': null}, {'v': true, 'f': null}]},         {'c': [{'v': 1, 'f': 'date string'}, {'v': 2, 'f': null}, {'v': false, 'f': null}, {'v': 3, 'f': null}, {'v': true, 'f': null}, {'v': 4, 'f': null}, {'v': false, 'f': null}]},         {'c': [{'v': 2, 'f': 'date string'}, {'v': 3, 'f': null}, {'v': true, 'f': null}, {'v': 2, 'f': null}, {'v': true, 'f': null}, {'v': 1, 'f': null}, {'v': true, 'f': null}]}     ] }); 

see working example: http://jsfiddle.net/asgallant/b7w68/


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -