d3fc icon indicating copy to clipboard operation
d3fc copied to clipboard

Question: Zoom Extent

Open hyundotio opened this issue 2 years ago • 3 comments

Hi all,

I'm trying to limit the zoom so the max zoomability on the canvas (both X and Y +maybe some padding) are derived from the provided data.

I tried

...
const yExtFunc = fc.extentLinear().accessors([(d: DataLine) => d.max, (d: DataLine) => d.min]);
const xExtFunc = fc.extentTime().accessors([(d: DataLine) => d.time]);
const xExtent = xExtFunc(data);
const yExtent = yExtFunc(data);

const zoom = fc.zoom().extent([xExtent, yExtent]).on('zoom', render);

But the Zoom is still zoomable in+out to infinity. I tried to look for examples but it didn't seem like there are any examples with min/max limits on zooming.

Any help would be appreciated. Thank you!

hyundotio avatar Aug 01 '22 19:08 hyundotio

You can set the extent via the scaleExtent property. See the following code snippet:

https://github.com/d3fc/d3fc/tree/master/packages/d3fc-axis#label-rotation--offset

From the following example: https://github.com/d3fc/d3fc/tree/master/packages/d3fc-axis#label-rotation--offset

ColinEberhardt avatar Aug 03 '22 07:08 ColinEberhardt

any solution for this ?

fikrihanda avatar Feb 24 '23 05:02 fikrihanda

@ColinEberhardt It doesn't look like that link demonstrates scaleExtent any more. Is there an updated example of min/max zoom limits?

tradingcage avatar Nov 07 '23 12:11 tradingcage