XYChart with scaled time Axis #1179
-
Can I have bottom axis in XYChart with scaled date ticks like in Brush chart? I have this code in my project and it doesn`t work
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hey @EsaxCO, in |
Beta Was this translation helpful? Give feedback.
-
A fast way to "auto scale" in XYChart: import { ParentSize } from '@visx/responsive'
//...
// use ParentSize to provide 'width'
<ParentSize>
{({ width, height }) => {
return (
//...
<Axis
key={'date'}
orientation="bottom"
numTicks={width > 520 ? 7 : 3}
/> |
Beta Was this translation helpful? Give feedback.
Hey @EsaxCO, in
@visx/xychart
you shouldn't be passing/computingscale
to theAxis
component yourself (only if you are separately using the@visx/axis
packages.XYChart
computes the scales based on child series data, and scales are determined by thexScale/yScale
config you pass theXYChart
component itself. You can check the https://airbnb.io/visx/xychart codesandbox for implementation details. All scale config maps to@visx/scale
package's config.