[Chartjs]-ChartJs bar chart bar value displaying lower then Y axis value in pdf?

1👍

I had the similar issue while converting html to pdf in IronPdf. I have managed to resolve it by setting animation option to false. So in your case it would be:

var xValues = ["Italy", "France", "Spain", "USA", "Argentina"];
var yValues = [3, 5, 8, 9, 5];
var barColors = ["#E85900", "#E85900","#E85900","#E85900","#E85900"];

new Chart("myChart", {
  type: "bar",
  data: {
    labels: xValues,
    datasets: [{
      axis: 'y',
      backgroundColor: barColors,
      data: yValues,
    }]
  },
  options: {
    animation: false,
    legend: {display: false},
    scales: {
        xAxes: [{
            barThickness: 65,  // number (pixels) or 'flex'
        }],
        yAxes: [{
            ticks: {
                stepSize: 1,
                beginAtZero:true,
                suggestedMax: 9
            }
        }]
    },
    plugins: {
      datalabels: {
        anchor: 'end',
        align: 'top',
        formatter: Math.round,
        font: {
          weight: 'bold'
        }
      }
    }
  }
});

Leave a comment