Chartjs-Display maximum value of an axis

2👍

Use suggestedMax (For linear charts):

https://www.chartjs.org/docs/latest/axes/cartesian/linear.html#axis-range-settings

For example:

ticks: {
  suggestedMax: 100
}
/* data */
var data = {
  labels: ["Africa", "Asia", "Europe", "America"],
  datasets: [{
    /* data */
    label: "Data label",
    backgroundColor: ["#3e95cd", "#8e5ea2","#3cba9f", "violet"],
    data: [5.0,6.7,7.5, 8.6, 3.3, 4.4, 4.5]
  }]
};


var options = {
  responsive: true,
  title: {
    text: 'Hello',
    display: true
  },
  scales: {
    xAxes: [{
      stacked: false,
      ticks: {

      },
    }],
    yAxes: [{
      stacked: true,
      ticks: {
        suggestedMax: 100
      }
    }]
  }
};

var myChart = new Chart(document.getElementById("chart"), {
  type: 'bar',
  data: data,
  options: options
});
<canvas id="chart"></canvas>

<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.min.js"></script>

stacked: https://www.chartjs.org/docs/latest/charts/bar.html#stacked-bar-chart

Related StackOverflow Q:
How to set max and min value for Y axis

Leave a comment