Chartjs-Chart.js time interval as bars

-1👍

You can use horizontalBar for your bar type. Example:

{
  type: 'horizontalBar',
  data: {
  labels: ["a","b","c","d","e","f","g"],
  datasets: [{
    axis: 'y',
    label: 'My First Dataset',
    data: [[5,65], [30,90], [20,80], [15,71], [20,56], [24,55], [15,70]],
    fill: false,
    backgroundColor: [
      'rgba(255, 99, 132, 0.2)',
      'rgba(255, 159, 64, 0.2)',
      'rgba(255, 205, 86, 0.2)',
      'rgba(75, 192, 192, 0.2)',
      'rgba(54, 162, 235, 0.2)',
      'rgba(153, 102, 255, 0.2)',
      'rgba(201, 203, 207, 0.2)'
    ],
    borderColor: [
      'rgb(255, 99, 132)',
      'rgb(255, 159, 64)',
      'rgb(255, 205, 86)',
      'rgb(75, 192, 192)',
      'rgb(54, 162, 235)',
      'rgb(153, 102, 255)',
      'rgb(201, 203, 207)'
    ],
    borderWidth: 1
  }]
},
  options: {
    indexAxis: 'y',
     scales: {
            x: {
                stacked: true
            },
            y: {
                stacked: true
            }
        }
  }
}

here the result

I hope can help you.

Leave a comment