Chartjs-Why is Chart js first bar too small or not showing at all?

3๐Ÿ‘

โœ…

By default, the axes start at your minimum value. Set ticks.beginAtZero to true on your Y-axis to display and your first bar will be visible:

var options = {
  scales: {
    yAxes: [{
      display: true,
      ticks: {
        beginAtZero: true
      }
    }],
    xAxes: [{
      display: false
    }]
  },
  legend: {
    display: false
  }
};
var dataD = {
  labels: ["2020-09-01 18:05:33", "2020-10-13 11:08:28"],
  datasets: [{
    label: "PA",
    data: [132, 139],
    backgroundColor: "#4cb6cb"
  }]
};

var methods = new Chart($("#line192"), {
  type: "bar",
  data: dataD,
  animation: true,
  options: options
});

Here is the fixed jsfiddle

Leave a comment