Skip to content

drawing line plot using [{x,y}] format #9685

Answered by LeeLenaleee
sandeep-gh asked this question in Q&A
Discussion options

You must be logged in to vote

This is because by default the x axis is a category axis, this expects predefined labels. The reason a scatter plot works is because the type of the x axis gets changed to linear by default. If you do that it works fine:

 var config = {
   type: 'line',
   data: {
     datasets: [{
       data: [{
         x: 10,
         y: 20
       }, {
         x: 15,
         y: 7
       }, {
         x: 20,
         y: 10
       }]

     }]
   },
   options: {
     scales: {
       x: {
         type: 'linear'
       }
     },
     parsing: false
   }
 };

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by sandeep-gh
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants