javascript - Google Charts throws "cannot read property '1' of undefined" when creating a view -
i working google charts , create line chart not colums underlying data visible. found here - https://developers.google.com/chart/interactive/docs/reference#dataview dataviewclass should solution , tried implement below. unfortunately when try generate chart getting "cannot read property '1' of undefined" error no errors in console.
has came across this? ideas solution?
best,
adam
function testersbreakdown (testtype, app){ // data graph - need replaced correct query backend // do: format data , generate graphs var data; data = new google.visualization.datatable(); data.addcolumn('number', 'test cycle'); data.addcolumn('number', 'total'); data.addcolumn('number', 'f2f'); data.addcolumn('number', 'scalable in office'); data.addcolumn('number', 'remote testing'); data.addrows([ [1, 10, 3, 4, 3], [2, 11, 4, 4, 3], [3, 15, 3, 9, 3], [4, 20, 3, 9, 8], [5, 45, 30, 14, 1] ]); var options = { width: '100%', height: 600, haxis: { title: 'test cycle' }, vaxis: { title: 'responses' }, colors: ['#a52714', '#097138', 'black', 'blue'], animation: { duration: 300, startup: true, }, }; // intermediate object control views based on dropdown // do: determine show based on testtype dropdown selected var view = new google.visualization.dataview(data); view.setcolumns(['test cycle','total' ]); //here set columns want display //visualization go draw! var chart = new google.visualization.linechart(document.getelementbyid('testtypechart')); chart.draw(view, options); };
this due bug when using animations dataview (see this issue more info regarding bug).
solve try loading release candidate google instead of stablegoogle.load("visualization", "1", {packages:["corechart"]}); google.load("visualization", "1.1", {packages:["corechart"]});.
check here more info using release candidates. i've got little repuptation post more 2 links, if go google developers page (that linked to) , navigate "google chart news" , scroll bottom-ish can find more info this.
i tried in fiddle , works charm.
hope helped!
henrik
Comments
Post a Comment