5👍
Late Answer. But it’ll be helpful for the people who is searching for this.
Code to set different point size in line chart in Chart.js.
var speedCanvas = document.getElementById("speedChart");
var pointRadius=[];
var dataFirst = {
label: "Car A - Speed (mph)",
data: [10, 59, 75, 25, 20, 65, 40],
lineTension: 0.3,
fill: false,
borderColor: 'red',
backgroundColor: 'transparent',
pointBackgroundColor: 'green',
pointBorderColor:'green',
pointRadius: pointRadius
};
var speedData = {
labels: ["0s", "10s", "20s", "30s", "40s", "50s", "60s"],
datasets: [dataFirst]
};
var chartOptions = {
legend: {
display: true,
position: 'top',
labels: {
boxWidth: 80,
fontColor: 'black'
}
}
};
var lineChart = new Chart(speedCanvas, {
type: 'line',
data: speedData,
options: chartOptions
});
for(var i=0;i<this.lineChart.data.datasets[0].data.length;i++){
pointRadius.push(i);
}
lineChart.update();
The below code is to set the point size.
for(var i=0;i<this.lineChart.data.datasets[0].data.length;i++){
pointRadius.push(i);
}
lineChart.update();
This method is working in latest versions of ChartJS
Running CodePen Example : CodePen Example
0👍
You can Simply increase the size of dot in line chart follow the Documentation of Chart.js. There is customizing method is available.
You can try this:
var myLineChart = Chart.Line(ctx, {
pointDot: false,
pointLabelFontSize: 20
});
lineChartData = {
datasets: [{
data: dataArray,
pointStrokeColor: "#fff",
fillColor: "rgba(220,220,220,0.5)",
pointColor: "rgba(220,220,220,1)",
strokeColor: "rgba(220,220,220,1)"
}],
labels: labelsArray
};
// Changing color of point #5
myLineChart.datasets[0].points[4].fillColor = "#FF0000";
pointLabelFontSize: 20 // Font Size in pixel
Source:stackexchange.com