@sdetweil I finally update my chart with this.myChart.update()!!! it is all for your help now I can get sleep…
Read the statement by Michael Teeuw here.
Latest posts made by doridol
-
RE: How can I update my chart?
-
RE: How can I update my chart?
@sdetweil okay thanks for you a lot of help:beaming_face_with_smiling_eyes:
-
RE: How can I update my chart?
@sdetweil I have really really last question I changed my socketNotificationReceived like this
socketNotificationReceived: function(notification, payload) { if (notification === "TEXT_RESULT") { this.textDataRecived = payload; this.loaded = true; } if(count < 2) { this.updateDom(); count = count + 1; } else { this.myChart.data.datasets.data = this.textDataRecived console.log(this.myChart.data.datasets.data) this.myChart.update(); } },
and console.log(this.myChart.data.datasets.data) successfully print this.textDataRecived but my chart is not updated in the screen why???
-
RE: How can I update my chart?
@sdetweil oh… it is very difficult to update chart… really thanks for your help I seem I have to study more…
-
RE: How can I update my chart?
@sdetweil I define myChart in getDom like this
getDom: function () { const wrapper = document.createElement("div"); this.ctx = document.createElement("canvas"); this.ctx.style.width = "700px"; this.ctx.style.height = '700px'; wrapper.appendChild(this.ctx) labels = [2,4,6,8] this.myChart = new Chart(this.ctx, { type: 'line', data: { labels: labels, datasets: [{ data: [1,2,3,4], backgroundColor: 'rgba(255,255,255,0.3)', borderColor: 'white', borderWidth: 2, fill: true, }] }, options: { title: { display: true, text: 'Air-Quality', }, scales: { xAxes: [{ gridLines: { color: 'rgba(255,255,255,0.2)', }, }], }, } }); return wrapper; } });
and I’ll only update myChart in socketNotificationReceived
-
RE: How can I update my chart?
@sdetweil I tried it but nothing is printed in develop console window :anxious_face_with_sweat:
-
RE: How can I update my chart?
@sdetweil aaaaah!! I understood! I’ll try it
-
RE: How can I update my chart?
@sdetweil I changed my socketNotificationReceived like this
socketNotificationReceived: (notification, payload) => { if (notification === "TEXT_RESULT") { this.textDataRecived = payload; this.loaded = true; } console.log(this.myChart) // this.myChart.data.datasets.data = this.textDataRecived // this.updateDom(60000); },
I add console.log(this.myChart) to check it point this.myChart in getDom but it print undefined… what did I do wrong??
Really thanks for your so many helps -
RE: How can I update my chart?
@sdetweil I’m so sorry that I asked same question twice although you answered my questions.
I found that this.myChart in socketNotificationReceived doens’t pointing the this.myChart in getDom how can I point this.myChart in socketNotificationReceived exactly to this.myChart in getDom?? -
RE: How can I update my chart?
@sdetweil
I changed socketNotificationReceived like thissocketNotificationReceived: function (notification, payload) { if (notification === "TEXT_RESULT") { this.textDataRecived = payload; this.loaded = true; } this.myChart.data.datasets.data.push(this.textDataRecived) this.myChart.update(); // this.updateDom(60000); },
And I got error like these