victory icon indicating copy to clipboard operation
victory copied to clipboard

Render tick labels below negative bars

Open naveedehmad opened this issue 9 years ago • 9 comments

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

naveedehmad avatar Sep 11 '17 15:09 naveedehmad

@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

boygirl avatar Sep 12 '17 18:09 boygirl

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.

Lelith avatar Apr 10 '18 13:04 Lelith

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

boygirl avatar Apr 10 '18 22:04 boygirl

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

Lelith avatar Apr 11 '18 06:04 Lelith

@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

alisman avatar May 07 '18 21:05 alisman

I also would like to know how to do this.

wieringen avatar May 11 '18 13:05 wieringen

@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 avatar May 16 '18 14:05 Clafouti

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

alisman avatar May 16 '18 14:05 alisman

@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 😅

nazimjamil avatar Oct 09 '20 11:10 nazimjamil