dojox chart update/destroy does not work after dojo.byId

隐身守侯 提交于 2019-12-12 01:39:25

问题


I created a dojo chart using;

var pieChart = new dojox.charting.Chart2D("pieChart");

Afterwards I want to update/destroy this chart. SO I do;

var pieChart = dojo.byId("pieChart");
pieChart.destroy();

This seems to be not functional. Am I doing something wrong here?

best


回答1:


As you're using dojox so dojo.byId will not return javascript object try using dijit.byId I think it'll work as suggested below:

var pieChart = dijit.byId("pieChart"); pieChart.destroy();

the same problem I was facing with dojox.form.BusyButton after a great effort I found this...




回答2:


I ran into this same problem, where I created the chart in one place and then wanted to destroy it in another, but I didn't have a reference to the chart object. The only solution I found is to empty the DOM node you used to make the chart:

dojo.empty("pieChart");



回答3:


The second variable will reference DOM object, not the javascript object that store chart object.

var pieChart = new dojox.charting.Chart2D("pieChart");
pieChartDom = dojo.byId("pieChart"); //you cannot destroy, 
pieChart.destroy();  //you can destroy, this is original variable

I hope it helps.



来源:https://stackoverflow.com/questions/4610920/dojox-chart-update-destroy-does-not-work-after-dojo-byid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!