0

Im trying to create a line chart with multiple datasets but with only one data value inside, its posible? Because i tried a lot of modes but always i get undefined in the options, or all the data always in one column.

My code example is the following

const data = {
  labels: ['January', 'February', 'March'],
  datasets: [
    {
      label: 'My First dataset',
      backgroundColor: 'rgba(255,99,132,0.2)',
      borderColor: 'rgba(255,99,132,1)',
      borderWidth: 1,
      hoverBackgroundColor: 'rgba(255,99,132,0.4)',
      hoverBorderColor: 'rgba(255,99,132,1)',
      data: [65]
    },
    {
      label: 'My Second dataset',
      backgroundColor: 'rgba(255,99,132,0.2)',
      borderColor: 'rgba(255,99,132,1)',
      borderWidth: 1,
      hoverBackgroundColor: 'rgba(255,99,132,0.4)',
      hoverBorderColor: 'rgba(255,99,132,1)',
      data: [86]
    },
    {
      label: 'My Third dataset',
      backgroundColor: 'rgba(255,99,132,0.2)',
      borderColor: 'rgba(255,99,132,1)',
      borderWidth: 1,
      hoverBackgroundColor: 'rgba(255,99,132,0.4)',
      hoverBorderColor: 'rgba(255,99,132,1)',
      data: [95]
    }
  ]
};

and i get this

Problem in the chart

But i want to order the first data of the dataset in the first label

Ex: Junuary : 65 February : 86 March : 95

Here is an image that what im looking for

Any one have any idea? Thx

Alejandro
  • 1
  • 2

1 Answers1

0

I don't think you can connect points from different datasets into a single line. The only way I can think to do it is to simply include each of the data values into a single data set shown below

const data = {
  labels: ['January', 'February', 'March'],
  datasets: [
    {
      label: 'My First dataset',
      backgroundColor: 'rgba(255,99,132,0.2)',
      borderColor: 'rgba(255,99,132,1)',
      borderWidth: 1,
      hoverBackgroundColor: 'rgba(255,99,132,0.4)',
      hoverBorderColor: 'rgba(255,99,132,1)',
      data: [65, 86, 95]
    }
  }

If you wouldn't mind explaining why you need these in separate datasets, I might be able to help further

Xyloking17
  • 83
  • 1
  • 5