hi,
i m using dhtmlx bar chart with dynamic json data. My problem is i can not clear data before drawing the chart. if i draw 2 charts consecutively they overlap and view is ruined. I used clearAll() function as below but didnt work:
hi Darya,
can you give me a simple example of repainting chart after clicking a button. I can not clean old chart before painting new one. I have button and i draw chart by clicking this button but it draws new chart on old one and they overlap. There are method like clearAll() and refresh(), can i use them to solve this problem? if so can you tell me where shall i call these methods in my code. (before parsing, after parsing etc.) I m using json data and my code is below:
function onJsonDataRetrieved(response) {
var jsonObject=JSON.parse(response);
var resultArray=jsonObject.resultArray;
var length=jsonObject.length;
var barChart=new dhtmlXChart({
view:"stackedBar",
container:"chart_container",
value:"#sales#",
label:"#sales#",
width:100,
xAxis:{
title:"Sales",
template:"#year#"
},
yAxis:{
title:"sales per year"
},
gradient:"3d",
color: "#00FF22"
});
for(var k=0;k<length;k++){
barChart.addSeries({
value:"#sales"+k+"#",
color:get_random_color(),
label:"#sales"+k+"#",
});
}
barChart.parse(resultArray,"json");
}
Here is online sample with the same chert type as you have: dhtmlx.com/docs/products/dht … chart.html
Just call barChart1.clearAll() - and it will clear your chart data.
Get a guaranteed answer from DHTMLX technical support team
under the most suitable support plan