Comments (7)
It might be useful for other people that want to use recharts for timeseries that I specify my other work-around.
By default XAxis is of type category so I cannot specify it's domain and it isn't linear; if I have points every minutes with a 5 minutes hole in in the middle, the graph will display a hole of a duration of 1minute :-( .
I try using a number axis and specify the domain but it doesn't work because of the way recharts is done.
So I end up using a category x axis but I manually ensure that they are a point every minutes of my whole domain, with some point having an undefined value.
from recharts.
@slestang
Maybe your case can be implemented by set customized ticks
and tickFormatter
in XAxis
.
from recharts.
Thanks! @slestang
Can you show me your code, and how you want to use recharts?
from recharts.
My slightly simplified Chart component:
const Chart = ({ values }) =>
<div style={{ height: '10rem' }}>
<ResponsiveContainer >
<LineChart
data={values}
margin={{ top: 5, right: 0, bottom: 0, left: 0 }}
>
<Line type="linear" dataKey="value" stroke="#8884d8" dot={false} />
<CartesianGrid stroke="#ccc" strokeDasharray="5 5" />
<XAxis dataKey="time" tickFormatter={tickFormatDate}/>
<YAxis dataKey="value" tickFormatter={twoDigitsWithMetricPrefix}/>
<Tooltip
formatter={twoDigitsWithMetricPrefix}
labelFormatter={tickFormatDate}
wrapperStyle={{ width: 100, backgroundColor: '#ccc' }}
/>
</LineChart>
</ResponsiveContainer>
</div>
Where values is an array of {time: Date, value: Number} and tickFormatDate is a function very close to d3.time.format.multi(formats).
The component is working but the ticks aren't at round time:
A similar chart using NVD3 with ticks each 5 minutes:
I also like to be able to choose the number of ticks for each axis, or precise that I want more of them.
Thanks for your work!
from recharts.
Thanks! I 'll think about supporting scaleTime.
from recharts.
Thanks @xile611
It works with a minor modification, my time property need to be a timestamp instead of Date.
from recharts.
It might be useful for other people that want to use recharts for timeseries that I specify my other work-around.
By default XAxis is of type category so I cannot specify it's domain and it isn't linear; if I have points every minutes with a 5 minutes hole in in the middle, the graph will display a hole of a duration of 1minute :-( .
I try using a number axis and specify the domain but it doesn't work because of the way recharts is done.
So I end up using a category x axis but I manually ensure that they are a point every minutes of my whole domain, with some point having an undefined value.
I know this is old... But how did you ensure points every 5 min? I tried setting ticks for my domain manually, but it doesn't work :(
from recharts.
Related Issues (20)
- Tooltip deprecation HOT 1
- Negative interval number HOT 5
- Getting lowest and highest possible x and y in a line chart? HOT 22
- Tooltip first render HOT 7
- YAxis is missing if value = null || undefined HOT 2
- different name on tooltip from xaxis on barchart HOT 4
- Better API documentation HOT 3
- Issues with typing Legend props HOT 7
- Stacking Xaxis dataKey text HOT 3
- AreaChart and LineChart do not show the values correctly HOT 1
- Question on exporting `useChartWidth` and similar api HOT 2
- BarChart : Without BarSize bug, with BarSize another Bug HOT 2
- Adjust the colour of the dot at the cursor of the tooltip (AreaChart) HOT 3
- Lines directly on the lower or upper bound of a Y-axis with custom domain and allowDataOverflow gets partially clipped out of view HOT 4
- Active bar and tooltip persist despite mouse cursor leaving chart area HOT 4
- Is there any way to position=insideMiddle? HOT 5
- Brush component is missing property `data` HOT 3
- Stacked chart round some bars HOT 2
- Points property not generating for Area Chart in v2.12.6 HOT 5
- recharts responsive pie chart with legend HOT 2
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.