0

I am displaying a graph but when the value is less the graphs are not shown I want a minimum height so they can be displayed.

I am using chartjs to display the graphs.

      My html : 
    <canvas id="chartContainer"></canvas>

My angular code:

  $scope.options = {
        onClick: SPEND_BY_SUPPLIER,
        tooltips: {
            callbacks: {
                label: function(tooltipItem, data) {
                    var label = data.datasets[tooltipItem.datasetIndex].label || '';

                    if (label) {
                        label += ': ';
                    }
                    label += tooltipItem.yLabel;
                    return label + " " + $scope.SPEND_SUP_LIST[0].CURRENCY_CODE;
                }
            }
        },
        scales: {
            xAxes: [
                {
                    ticks: {
                        callback: function (label, index, labels) {
                            return label +" " + $scope.SPEND_SUP_LIST[0].CURRENCY_CODE;
                        }
                    },
                    scaleLabel: {
                        display: true,
                    }
                }
            ]
        }
    };
    new Chart(document.getElementById("chartContainer"), {
        type: 'horizontalBar',
        data: {
            labels: $scope.label_SPEND_SUP_LIST,
            datasets: [
              {
                  backgroundColor: ["#3e95cd", "#8e5ea2", "#3cba9f", "#e8c3b9", "#c45850"],
                  data: $scope.data_SPEND_SUP_LIST
              }
            ]
        },
        options: $scope.options,
    });

I want to set mimimum height for those graphs whose values are very less,please support.

sourav sahu
  • 23
  • 1
  • 1
  • 9

1 Answers1

0

Your question is not very clear but perhaps you are looking for the beginAtZero tick option.

If this is not set to true then (at least) one of your points will be 'invisible' as it'll sit on the border of the chart area. This is because Chart.js will, by default, use the lowest value in your dataset as the min scale value.

options: {
  scales: {
    yAxes: [{
      ticks: {
        beginAtZero: true
      }
    }]
  }
}
timclutton
  • 12,682
  • 3
  • 33
  • 43