[Chartjs]-Chart.js. Values in a big range. The smallest values are not available

2πŸ‘

βœ…

ability to click and hover over on each Bar

Unfortunately, bars don’t have a pointHitDetectionRadius equivalent. But you can override the inRange function for Chart.Rectangle to give a little more vertical detection range.

Chart.Rectangle.prototype.inRange = function (chartX, chartY) {
    return (chartX >= this.x - this.width / 2 && chartX <= this.x + this.width / 2) && (chartY >= this.y && chartY <= (this.base + 5));
};

I’ve extended the vertical area 5 units downward from the x axis, but you could change it to above the axis as well (just subtract it from this.y)

Fiddle – https://jsfiddle.net/etLfr9ka/

Please all ideas how to display them on one chart

As long as you don’t set barShowStroke to false you would see a stroke for even 0 values.

The alternative would be pick a framework that supports logarithmic scales or one that allows you to split the y scale into sections – however IMO this would be a bad idea.

Leave a comment