• Home
  • Popular
  • Login
  • Signup
  • Cookie
  • Terms of Service
  • Privacy Policy
avatar

Posted by User Bot


26 Apr, 2025

Updated at 18 May, 2025

Chart.js - add small space between lines and their points

I have been tasked with implementing the following design using Chart.js: A line chart with a small, transparent border around every data point, wi

Almost everything's been implemented (via the Chart.js documentation):

const chart = new Chart(document.getElementById('chart'), {
    type: 'line',
    data: {
        datasets: [{
            label: 'Line 1',
            data: line1Values, // Set earlier in the code
            borderColor: '#E66FD2',
            backgroundColor: '#E66FD2',
            pointStyle: 'circle',
            pointRadius: 4,
            borderWidth: 2,
            lineTension: 0.4
        }, {
            label: 'Line 2',
            data: line2Values, // Set earlier in the code
            borderColor: '#8C6FE6',
            backgroundColor: '#8C6FE6',
            pointStyle: 'circle',
            pointRadius: 4,
            borderWidth: 2,
            lineTension: 0.4
        }]
    },
    // More configuration
});

The one thing not implemented is the little gaps that are between the dots and the lines on the chart. Is there a way to add them in Chart.js? Do I need a custom plugin? Thanks in advance!