Example of JavaScript Dynamic Chart that constantly updates with live data. Column Chart, like any other chart in CanvasJS, supports updating of data in real-time. Dynamic Charts are also popularly called as Live or Real-Time Charts. Given example shows Real-Time temperature of different boilers using Column Chart. It also contains HTML / JavaScript source code that you can edit in-browser or save to run locally.
window.onload = function () { var chart = new CanvasJS.Chart("chartContainer", { title: { text: "Temperature of Each Boiler" }, axisY: { title: "Temperature (°C)", includeZero: true, suffix: " °C" }, data: [{ type: "column", yValueFormatString: "#,### °C", indexLabel: "{y}", dataPoints: [ { label: "boiler1", y: 206 }, { label: "boiler2", y: 163 }, { label: "boiler3", y: 154 }, { label: "boiler4", y: 176 }, { label: "boiler5", y: 184 }, { label: "boiler6", y: 122 } ] }] }); function updateChart() { var boilerColor, deltaY, yVal; var dps = chart.options.data[0].dataPoints; for (var i = 0; i < dps.length; i++) { deltaY = Math.round(2 + Math.random() *(-2-2)); yVal = deltaY + dps[i].y > 0 ? dps[i].y + deltaY : 0; boilerColor = yVal > 200 ? "#FF2500" : yVal >= 170 ? "#FF6000" : yVal < 170 ? "#6B8E23 " : null; dps[i] = {label: "Boiler "+(i+1) , y: yVal, color: boilerColor}; } chart.options.data[0].dataPoints = dps; chart.render(); }; updateChart(); setInterval(function() {updateChart()}, 500); }
The color of the columns can be changed using color property. Other commonly used customization options are fillOpacity, indexLabel, etc.