Victory: Render tick labels below negative bars

Created on 11 Sep 2017  路  9Comments  路  Source: FormidableLabs/victory

When we have negative data, x-axis tick values should be rendered below the chart and not on top of the bars where the axis is:

screen shot 2017-09-11 at 8 54 38 pm

The tick values a and b should be below the chart. Is there an option for that? Like this:

screen shot 2017-09-11 at 8 58 28 pm

Most helpful comment

@Clafouti Yes, I hadn't realized that the offset was relative to the y axis. So this is indeed the solution to this issue.

All 9 comments

@naveedehmad you can use the offsetY prop on VictoryAxis to move your dependent axis down to the bottom of your chart like in the second image. You can read more about it here: https://formidable.com/open-source/victory/docs/victory-axis#offsety

is there a way to calculate the offset based on the data? i don t have any domain for my y axis.
also it moves down the whole axis line, but i want only the labels to move and keep the axis itself on zero.

Check out this example of negative aware tick labels https://codesandbox.io/s/v6zzl6jl77

awsome thank you for your quick reply, that helped me a lot!

@boygirl we've been struggling with the following. If there's negative data, the x axis is place at zero, which brings the tick labels along with it. We want the labels and probably the axis too to be at the bottom of the chart. Is there a simple way?

image

I also would like to know how to do this.

@alisman did you try to simply put something like:

<VictoryAxis
  offsetY={10}
/>

And then play a little bit with the value of the offset.

@Clafouti Yes, I hadn't realized that the offset was relative to the y axis. So this is indeed the solution to this issue.

@Clafouti Yes, I hadn't realized that the offset was relative to the y axis. So this is indeed the solution to this issue.

Definitely works, but you lose your zero value axis. I suppose we'd need to compose another axis just for that 馃槄

Was this page helpful?
0 / 5 - 0 ratings