Closed mBreyerBG closed 2 weeks ago
+1
+1
There is supposed to be a prop for this but nothing worked. You can try this as a workaround:
const minDesiredElems = 10;
onZoomStart: ({ event, chart }) => {
const isZoomIn = event.deltaY < 0;
const hasLessThanDesired = chart.scales.xAxes.ticks?.length <= minDesiredElems;
// reset it back in case of a big step
if (chart.scales.xAxes.ticks?.length <= minDesiredElems-1 && isZoomIn) {
chart.zoom(chart, { x: minDesiredElems });
}
// skip zoom event
if (isZoomIn && hasLessThanDesired) return false;
}
(This isn't really well tested code, but somewhat works)
+1
I have a barChart with categories. i am using drag to zoom. How can i define a minimum amount of categories, just like e.g: limits.x.minRange would work? Is this possible?! Right now i can zoom, so that only one category is visible and fills the whole chart. i want like minimum of 4 categories to be visible