nsunkad
nsunkad

Reputation: 3

Is there a way to make a scatter line in ChartJS using LineChart?

Scatter Line in ChartJS

I would like to make a scatter line plot in ChartJS. This is what I currently have: enter image description here

I want to modify this graph so that there are no connections between the points. Is there any property of the ChartJS Line Chart that I can modify to hide the connections between the points on my line? Or would I need to use the Scatter Chart?

Upvotes: 0

Views: 136

Answers (1)

Amirhossein Sefati
Amirhossein Sefati

Reputation: 709

Here is what you can do for it:

var chart = new Chart(ctx, {
   type: 'line',
   data: {
      labels: ['A', 'B', 'C'],
      datasets: [{
         label: 'Test',
         data: [1, 6, 3],
         pointBackgroundColor: 'black',
         pointRadius: 5,
         fill: false,
         showLine: false //<- This is what you need actually
      }]
   }
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.6.0/Chart.min.js"></script>
<canvas id="ctx"></canvas>

Hope it helps.

Upvotes: 1

Related Questions