wonsuc
wonsuc

Reputation: 3625

Can "Bar" be placed center of vertical grid line in Chart.js?

My current project needs to show this kind of graphics chart.

Most of the time a Bar element is at the middle of 2 vertical grid lines, but in my case, it should be at the center of 1 vertical grid line.

I searched sample codes and API documents, but I couldn't find a solution for my case.

Is it possible to draw this kind of chart with Chart.js? enter image description here

Upvotes: 0

Views: 1223

Answers (1)

Aaron Tee
Aaron Tee

Reputation: 91

Did you tried to set gridLines.offsetGridLines to false? It should be working fine. Check out the documentation here: https://www.chartjs.org/docs/latest/charts/bar.html#scale-configuration

options: {
  scales: {
    xAxes: [{
      gridLines: {
        offsetGridLines: false
      }
    }
  }
}

Upvotes: 1

Related Questions