Axis scaleTime Interval
See original GitHub issuehttps://github.com/d3/d3-scale#time_ticks
According to the d3 docs an interval may be supplied to the ticks. I have used <AxisBottom numTicks={timeYear} />
which seems to work as expected but fails props validation:
Warning: Failed prop type: Invalid prop `numTicks` of type `function` supplied to `Axis`, expected `number`.
Relevant https://github.com/hshoff/vx/blob/master/packages/vx-axis/src/axis/Axis.js#L82
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Axis scaleTime Interval · Issue #310 · airbnb/visx - GitHub
The problem is that if the data is only a few points (where one point is each year) then the axis automatically switches...
Read more >d3.scaleTime - Observable
The default range is the usual interval [0,1]. range = Array(2) [0, 1]. Time scales are commonly used for charts where one axis...
Read more >Offset x-axis ticks with scaleTime - Stack Overflow
Save this question. Show activity on this post. I'm trying to figure out how I can offset the x-axis ticks, as shown in...
Read more >Working with D3 Time Series Axes - Developer.com
In today's article, we'll learn how to use the scaleTime() function to present time series data on the x axis of a chart....
Read more >Working With Dates - Using D3.js
Once we have the axis function, we call it to draw the axis. var xScale = d3.scaleTime() .domain(domain) .range([25, 555]); var xAxis =...
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
Hi @hshoff thanks for your help. I don’t fully understand how to use tickValues for the bottom axis in conjunction with scaleTime. The problem is that if the data is only a few points (where one point is each year) then the axis automatically switches to month ticks. I’d like to use https://github.com/d3/d3-time#_interval to constrain the axis ticks to be just the years. You can see what I mean in the example where i’ve constrained the data to one point per year for only two years. Do I need to iterate the data and manually come up with an array of
tickValues
to pass to<Axis />
? Is it possible that tickValues could take a function which reduces the input data to a sensible array of tick values? Then you’d be able to do something like<Axis tickValues={timeYear} />
.I agree with @esetnik. Be nice to not use
tickValues
as an alternative when d3scaleTime.ticks()
can accept either anumber
or aTimeInterval
.https://github.com/d3/d3-scale#time_ticks
Noob question, but can the type be simply updated to a union of
number | TimeInterval
?