0👍
✅
It looks like you are looking to format labels
before passing them to the chart.js
You can do it like below:
//Below are the original Labels
var labels = ['Red', 'Blue', 'Yellow', 'Green', 'Purple', 'Orange'];
//Run a while loop and format them as you want.
index = 0;
while (index < labels.length) {
labels[index] += index;
index++;
}
var myChartObject = document.getElementById('myChartHistory');
var chart = new Chart(myChartObject,{
type: 'line',
data: {
labels: labels, //pass the formatted labels
datasets: [{
label: "GATEWAY1",
fill: true,
backgroundColor: 'rgba(255, 99, 132, 0.2)',
borderColor: 'rgba(255, 99, 132, 1)',
data: [//WANT TO CODE HERE],
You can check the Demo at JSFiddle
Source:stackexchange.com