-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: Support for scaleTime? #63
Comments
Thanks! @slestang |
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! |
Thanks! I 'll think about supporting scaleTime. |
@slestang |
Thanks @xile611 |
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 :( |
I am trying to graph a time-series with recharts and thing will be better/simpler if I could use the D3 timeScale (x axis values are Date).
I look into the code to see where scale where set and I try to replace the scalePoint by scaleTime in getFormatAxisMap(). But it doesn't work (it would be too easy). It throw an error in getTicksOfAxis() because scaleTime obviously doesn't have the bandwidth method. I suppose that is far to be the only issue of changing the scale.
Do you have any idea if making the scale customizable or having an option to specify that we want a time scale on one of the axis will be difficult to implement?
The text was updated successfully, but these errors were encountered: