14.02.2022, 11:32
(05.01.2022, 09:30)admin Wrote: You should only create a chart instance once then update it with new data. Keep in mind that this library does not work correctly if visualization scaling is enabled.
Code:$(function(){
var chart;
grp.listen('20/3/200', function(obj) {
var classImage = 'pie1';
var idChart = 'chart1';
const variableCourbes = ["20/3/0", "20/3/1", "20/3/2", "20/3/3", "20/3/4"];
var labelTab = [];
var serieTab = [];
var separateurNom = ' ';
for (let i = 0; i < variableCourbes.length; i++) {
var id = Scada.encodeGroupAddress(variableCourbes[i]);
var obj = objectStore.getObject(id);
var nom = obj.name.split(separateurNom)[0];
labelTab.push(nom);
serieTab.push(obj.value);
}
var data = {
labels: labelTab,
series: serieTab
};
var options = {
width: 300+20,
height: 300+20,
donut: true,
donutWidth: 50,
donutSolid: true,
startAngle: 270,
showLabel: true
};
if (chart) {
chart.update(data);
}
else {
var plans = $('.' + classImage)[0]
plans.innerHTML = '<div class="" id="'+ idChart + '"></div>';
chart = new Chartist.Pie('#'+idChart, data, options);
}
}, true);
});
Hi @admin, why it doesn't work if visualitzation sacling is enabled? Is there any way to solve it?
Thanks!