[Chartjs]-Empty circle – only point strok in line chart for ChartJS

7πŸ‘

βœ…

Here is an example to get the point style you are after:

documentation for point options for line chart can be found here

A codePen of the below code here

HTML:

<html>
  <body>
    <div class="myChartDiv">
      <canvas id="myChart" width="600" height="400"></canvas>
    </div>
  </body>
</html>

JS:

new Chart(document.getElementById("myChart"), {
  type: "line",
  data: {
    labels: ["January", "February", "March", "April", "May", "June"],
    datasets: [
      {
        label: "My First Dataset",
        data: [20, 25, 22, 19, 31, 40],
        fill: true,
        borderColor: "rgb(75, 192, 192)",
        backgroundColor: "rgba(0,0,0,0.1)",
        borderWidth: 2,
        lineTension: 0,
        /* point options */
        pointBorderColor: "blue", // blue point border
        pointBackgroundColor: "white", // wite point fill
        pointBorderWidth: 1, // point border width
      }
    ]
  },
  options: {
    legend: {
      labels: {
        usePointStyle: true, // show legend as point instead of box
        fontSize: 10 // legend point size is based on fontsize
      }
    }
  }
});

Leave a comment