3
  • I'm trying to set max/min for y-axis in my horizontal bar graph.
  • The result (image/pen below) shows that setting min/max for y-axis works but the ticks of min/max are not placed at the start/end of y-axis.
  • As you can see, my min/max are 1450/1810 and they are not shown at the bottom/top grid lines of y-axis.
  • I guess bars have width and ticks are placed at the middle of the bars. I my code, line and scatter graphs are fine but bar graphs.
  • This is my codepen link: https://codepen.io/hoai-nguyen/pen/mdWMBeO
    y: {
    grid: {
      offset: false,
    },
    ticks: {
        align: 'end',
    },
    position: 'right',
    type: 'linear',
    min: 1450,
    max: 1810,
    // suggestedMax: 1810,
    // suggestedMin: 1450,
    ticks: {
        min: 1450,
        max: 1810,
    },
    barStart: 1450,
    title: {
        display: true,
        text: "Y-name",
        color: "blue",
        font: {
            family: "Calibri Light",
            size: 12,
            weight: 'bold',
        },
    },
},
  • Please take a look and any suggestion would be appreciated!

min/max ticks are not in the bottom/top gridlines enter image description here

Line/Scatter graphs are fine but Bar graphs enter image description here

Note: I'm using the version 3.3.2 of chart.js

Elias Soares
  • 9,884
  • 4
  • 29
  • 59

1 Answers1

0

This question was answered in ChartJS's Github discussion: https://github.com/chartjs/Chart.js/discussions/9202

Solution is to set offset=false.