javascript - Google chart error when hideColumns[1] -
i'm under creating google linechart jquery hide/show column of data. i'm stuck in problem when click on first data checkbox using hidecolumns1 error if hidecolumns[2] , hidecolumns[3] not error.
$(document).ready(function () { // stuff on "ready" event $(".checkbox").change(function() { view = new google.visualization.dataview(data); view.setcolumns([0, 1, { calc: "stringify", sourcecolumn: 1, type: "string", role: "annotation" },2, { calc: "stringify", sourcecolumn: 2, type: "string", role: "annotation" },3, { calc: "stringify", sourcecolumn: 3, type: "string", role: "annotation" }]); if(!$("#kolom1").is(':checked')) view.hidecolumns([1]); if(!$("#kolom2").is(':checked')) view.hidecolumns([2]); if(!$("#kolom3").is(':checked')) view.hidecolumns([3]); chart.draw(view, options); }); }); the error in chrome said:
"failed execute 'replacechild' on 'node'"
but if other checkbox(hidecolumns[2] , hidecolumns[3]) no problem, how fix it? can try @ jsfiddle below:
after trial , error solved own question code below
$(document).ready(function () { // stuff on "ready" event $(".checkbox").change(function() { view = new google.visualization.dataview(data); var tes =[0]; if($("#kolom1").is(':checked')) { tes.push(1, { calc: "stringify", sourcecolumn: 1, type: "string", role: "annotation" }); } if($("#kolom2").is(':checked')) { tes.push(2, { calc: "stringify", sourcecolumn: 2, type: "string", role: "annotation" }); } if($("#kolom3").is(':checked')) { tes.push(3, { calc: "stringify", sourcecolumn: 3, type: "string", role: "annotation" }); } view.setcolumns(tes); chart.draw(view, options); }); }); hope useful view on jsfiddle
Comments
Post a Comment