Comments (6)
You can definitely keep the XAxis, hide it with hide
, then place a reference line at 0. There's not an easy way to make ticks for that line though.
I'll try to see if there are any options to make a custom axis in a bit, currently replying from my phone so can't test anything
from recharts.
Hmm.. I don't think it's right to say that the X axis should always be at 0. In fact, I think most of the time with negative values it should stay at the bottom of the chart like it is. The axis would end up getting in the way and the labels would be hard to read.
Take another charting library for example https://www.highcharts.com/demo/highcharts/column-negative
Can you give a mockup of what you want? I'm not sure it's going to look good with the axis and its labels in the middle of the chart
from recharts.
Hmm.. I don't think it's right to say that the X axis should always be at 0. In fact, I think most of the time with negative values it should stay at the bottom of the chart like it is. The axis would end up getting in the way and the labels would be hard to read.
Take another charting library for example https://www.highcharts.com/demo/highcharts/column-negative
Can you give a mockup of what you want? I'm not sure it's going to look good with the axis and its labels in the middle of the chart
Hi,
I would want something like below. the x-axis line should be at zero. Is there a way to achieve this using workaround reference lines and custom ticks .
from recharts.
You can definitely keep the XAxis, hide it with
hide
, then place a reference line at 0. There's not an easy way to make ticks for that line though.I'll try to see if there are any options to make a custom axis in a bit, currently replying from my phone so can't test anything
I have tried to acheive with reference line and custom tick. But need to identify the exact position of zero tick so that i can postion the custom ticks to y position.
const CustomXAxisTicks = ({ x, payload }: any) => { console.log(x); return ( <g transform={
translate(${x},${0})}> <text x={0} y={0} dy={16} textAnchor={'middle'} fill="#666"> {payload.value} </text> </g> ); };
<ReferenceLine y={0} stroke={'black'} />
See this example
https://stackblitz.com/edit/vitejs-vite-e7d1ag?file=src%2FApp.tsx
from recharts.
Ok so this solution is very very hacky and very much a workaround but in lieu of anything else
from recharts.
edited the title to make the issue easier to find later
from recharts.
Related Issues (20)
- Remove Customized component HOT 1
- Export and document hooks
- Support React 19 HOT 21
- Use CodeSandbox Storybook Add-on HOT 16
- [bug] min XAxis domain values over 0 get ignored HOT 6
- how to reduce the size of xaxis? HOT 7
- Position LabelList content based on dimensions of chart or its container HOT 2
- Add tests, documentation, and storybooks for Treemap nesting HOT 2
- Move Axis map to Redux
- BarChart not rendering inside ResponsiveContainer HOT 14
- React 19. No render inside ResponsiveContainer HOT 1
- Add tests for ZAxis HOT 4
- Unable to interact with sub-charts using keyboard in the pie chart. HOT 1
- Add padding/spacing to value labels on the left as they are overlapping with the Y-Axis HOT 1
- <Brush/> ariaLabel not showing HOT 2
- ReferenceLine missing props type annotation HOT 1
- PieChart Tooltip appears outside of the screen HOT 13
- Fixed the issue `Can't find variable: ResizeObserver` HOT 5
- Brush with BarChart: Data shown is different than selection made in visual brush range HOT 6
- Inconsistent data points in chart after using Brush
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from recharts.