How do I put this on Real-Time? I already put (async: True) but it doesnt work

Instead of polling, you can use server-sent-events, which does not put as much strain on the server as data is only sent if a new event has happened (like a new row). More can be found out about them here: https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events Here is an example, as the one in the link is not that good. … Read more

Chart.js Line, different fill color for negative point

You can extend the line chart to do this. Preview Script Chart.defaults.NegativeTransparentLine = Chart.helpers.clone(Chart.defaults.line); Chart.controllers.NegativeTransparentLine = Chart.controllers.line.extend({ update: function () { // get the min and max values var min = Math.min.apply(null, this.chart.data.datasets[0].data); var max = Math.max.apply(null, this.chart.data.datasets[0].data); var yScale = this.getScaleForId(this.getDataset().yAxisID); // figure out the pixels for these and the value 0 var top … Read more

Chart JS custom tooltip option?

Try this: You can make changes globally using this code: Chart.defaults.global = { // Boolean – Determines whether to draw tooltips on the canvas or not showTooltips: true, // Array – Array of string names to attach tooltip events tooltipEvents: [“mousemove”, “touchstart”, “touchmove”], // String – Tooltip background colour tooltipFillColor: “rgba(0,0,0,0.8)”, // String – Tooltip … Read more

ng2-charts update labels and data

Apparently, if you do not modify the original reference to the labels array, it seems to work, at least for me. I mean, if you want a completely different set of labels, you should do something like this: In the template: <canvas baseChart [datasets]=”lineChartData” [labels]=”lineChartLabels” [options]=”lineChartOptions” [chartType]=”‘line'”></canvas> In the ts component: this.lineChartLabels.length = 0; for … Read more

chart.js – link to other page when click on specific section in chart

You can use getElementAtEvent() method to detect which section/slice of your pie chart was clicked on, and based on that open a link/page accordingly. Here is a quick example : var canvasP = document.getElementById(“pieChart”); var ctxP = canvasP.getContext(‘2d’); var myPieChart = new Chart(ctxP, { type: ‘pie’, data: { labels: [“Värde 1”, “Värde 2”, “Värde 3”, … Read more

How to save Chart JS charts as image without black background using blobs and filesaver?

If you want a customized background color then, you’d have to draw a background with your preferred color, and you can do so, like this … var backgroundColor=”white”; Chart.plugins.register({ beforeDraw: function(c) { var ctx = c.chart.ctx; ctx.fillStyle = backgroundColor; ctx.fillRect(0, 0, c.chart.width, c.chart.height); } }); DEMO // draw background var backgroundColor=”white”; Chart.plugins.register({ beforeDraw: function(c) { … Read more