Scale axis with zoom
See original GitHub issueWhen using the zoom component I would like to apply the transform matrix to my axis so that they represent the new visible domain. How would I go about this using vx?
// Scales aren't necessarily linear and time
const xScale = scaleTime({
range: [0, xMax],
domain: extent(data, x)
});
const yScale = scaleLinear({
range: [yMax, 0],
domain: [0, max(data, y)]
});
<Zoom
width={width}
height={height}
scaleXMin={1}
scaleXMax={4}
scaleYMin={1}
scaleYMax={4}
transformMatrix={initialTransform}
>
{zoom =>
<svg width={width} height={height}>
<Group>
<Group transform={zoom.toString()}>
{renderLine()} // Code rendering actual graph that can be zoomed
</Group>
// Axis live outside group with zoom transform
<AxisLeft
scale={???} // What goes here?
top={0}
left={0}
/>
<AxisBottom
scale={???} // What goes here?
top={yMax}
/>
</Group>
}
</Zoom>
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:6
Top Results From Across the Web
Scale axis with zoom #1138 - airbnb/visx - GitHub
Yup, here is a method I'm using to scale my Axis based on the zoom. Its all about updating the domain to what...
Read more >Pan & Zoom Axes / D3 - Observable
Pan & Zoom Axes. This example demonstrates using d3-zoom to drive changes to scales' domains via transform.rescaleX and transform.rescaleY. The ...
Read more >Zooming/Rescaling the Graphs Work Area
To rescale only one axis, hold down Shift and drag a tic mark on the axis. ... From the Window / Zoom menu,...
Read more >AxisScaleView.Zoom Method - Microsoft Learn
Sets a new axis data view and/or position based on the specified start position, view size, unit of measurement and save state.
Read more >Zooming and Scrolling - KST Plot
Y-Zoom Maximum, Shift+M, Sets the y axis scale such that the y values for all data points are between the minimum and maximum...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yup, here is a method I’m using to scale my Axis based on the zoom. Its all about updating the domain to what is now visible due to the zoom area.
Correction, this is working for me for both linear and time. The trick was just to convert everything to pixel values, apply the transforms, then convert back to the domain.