Set domain for date type
See original GitHub issueDo you want to request a feature or report a bug?
Not sure it’s bug or not, but every try was failed.
What is the current behavior?
I want to set minimum/maximum value for XAxis which is date type.
<ResponsiveContainer width="100%" height={200}>
<BarChart
width={400}
height={200}
data={data}
margin={{
top: 20,
left: 5,
bottom: 5,
right: 5
}}
>
<CartesianGrid strokeDasharray="3 3" />
<XAxis dataKey="time" tickFormatter={timeStr => moment(timeStr).format(timeFormat)} />
<YAxis dateKey="count" type="number" allowDecimals={false} tickCount={10} />
<Tooltip formatter={(value, name) => [value, startCase(name)]} />
<Bar dataKey="count" fill="#8884d8" />
</BarChart>
</ResponsiveContainer>
Key part is <XAxis /> :
<XAxis dataKey="time" tickFormatter={timeStr => moment(timeStr).format(timeFormat)} />
Let’s say I want to set minimum date to 2018-01-01 00:00:00 and max date to 2019-12-31 23:59:59. All of these won’t worked to me:
domain={['2018-01-01', '2019-12-31']}
domain={['2018-01-01 00:00:00', '2019-12-31 00:00:00']}
domain={['2018-01-01T00:00:00.000+09:00', '2019-12-31T23:59:59.999+09:00']}
domain={[new Date('2018-01-01'), new Date('2019-12-31')]}
domain={[new Date('2018-01-01').getTime(), new Date('2019-12-31').getTime()]}
domain={[moment('2018-01-01').format('YYYY-MM-DD'), moment('2019-12-31').format('YYYY-MM-DD')]}
Which versions of Recharts, and which browser / OS are affected by this issue? Did this work in previous versions of Recharts?
Recharts@1.6.2, Chrome 75, MacOS 10.13.6. Didn’t tried with previous version.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:6
- Comments:8 (1 by maintainers)
Top Results From Across the Web
How to change time format all over the domain for all users
Dear Community, We have date format like month/day/year. In order to change it to day/month/year for all users in my domain, what sould...
Read more >Using domain with datetime and date - python - Stack Overflow
Using domain with datetime and date ... I have tried using strptime , strftime no luck. How is datetime/date filtering done in Odoo?...
Read more >Date-Range Domains - what gives - Esri Community
In ArcGIS Pro, I created a new Range Domain in a file gdb configured to use the Date field type. fgdb = r"C:\Users\johnmdye\Documents\ArcGIS\ ......
Read more >how to format oracle.jbo.domain.date
Hi,. when you need to set attribute with datetime you don't need to set format. ... row.setAttribute("ShippedDate",new oracle.jbo.domain.Date( ...
Read more >Working With Dates - Using D3.js
Convert string representations of the temporal data to Date objects ... scaleTime, We set the domain of the scale by passing the array...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For anyone looking for a workaround, I was able to convert my date strings into a timestamp using moment and use those as a
type="number"
for my XAxisFor example if my data was
I changed it so it was
and my XAxis was
Where left and right are the timestamp ranges. Keep in mind though that without a domain, it is identifying the dataMin as 0, so timestamps like
1589299080
will show very far on the right. I basically took the first and last timestamps of my data and. used those for the domain range.Did you try allowDataOverflow That should help.