[BoxPlot] How to create an offset with time based X axis #1063
-
I'm working on a boxplot graph and i have some difficulties with xAxis : const xValues = props.fakeData.data.map((item) => item.boxPlot.x)
const xScaleDomain = getMinMax(xValues)
const xScale = scaleUtc({
domain: xScaleDomain,
range: [0, width],
clamp: true,
})
Does some know i can make something like padding that my graph stay in the bounds ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey @LoiKos 👋 thanks for checking out Band scales support a If you need a time scale, you will have to manually add a margin on the left/right of the chart so that your labels don't get clipped (content in SVGs gets clipped by HTML parents, which is why your labels are cutoff). Looks like you're already using a bottom margin to accommodate the x-axis, so you'd just need to do the same for the left/right (check this demo for a real example). |
Beta Was this translation helpful? Give feedback.
Hey @LoiKos 👋 thanks for checking out
visx
. I think the answer to this depends on whether you need ascaleUtc
(time) scale, or if you would consider aband
scale which will evenly spacestring
s representing your dates.Band scales support a
padding
which will leave space on the sides for you (see this discussion for more #1035). Note that this is the type of scale we use in ourBoxPlot
demo.If you need a time scale, you will have to manually add a margin on the left/right of the chart so that your labels don't get clipped (content in SVGs gets clipped by HTML parents, which is why your labels are cutoff). Looks like you're already using a bottom margin to accommodate the x-axis, so you'd…