Categories
JavaScript Answers

How to hide points in Chart.js line graph with JavaScript?

Spread the love

Sometimes, we want to hide points in Chart.js line graph with JavaScript.

In this article, we’ll look at how to hide points in Chart.js line graph with JavaScript.

How to hide points in Chart.js line graph with JavaScript?

To hide points in Chart.js line graph with JavaScript,. we can set the pointRadius option to 0.

For instance, we write

const myChart = new Chart(ctx, {
  type: "line",
  data: {
    labels: [
      //...
    ],
    datasets: [
      {
        data: [
          //...
        ],
        pointRadius: 0,
      },
    ],
  },
  options: {},
});

to create a new chart with the Chart constructor.

We call it with an object that has the pointRadius property set to 0 in the object in the datasets array.

As a result, the points on the line graph will be hidden.

Conclusion

To hide points in Chart.js line graph with JavaScript,. we can set the pointRadius option to 0.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *