Misaligned ticks for week-based time scale
See original GitHub issueHi,
I’m trying to plot weeks in a year to a line chart (see this codesandbox) My input data point looks like:
[
{
x: "2019-W33",
y: 618940
},...
]
The xAxis:
xScale={{
type: "time",
format: "%Y-W%V"
}}
axisBottom={{
format: "%Y-W%V",
tickValues: "every week"
}}
But the axis ticks are not aligned with the line’s points and the grid columns are not equally spaced. I’m filling this as a bug but please let me know if I’m doing something wrong…
Thank you
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:8
Top Results From Across the Web
Perspective charts time scale tick marks not aligned as expected
Ignition 8.1.4 (and earlier): Time scale tick marks that don't display full time with minutes (and seconds on shorter scales) do not align ......
Read more >Data points and ticks in the scaleBand axis are not aligned
The band scale is the wrong tool in this situation. The main reason is that a band scale has an associated bandwidth.
Read more >Using a date/time scale - JpGraph
The easiest way to get a date time scale for the X-axis is to use the pre-defined " dat " scale. ... Manually...
Read more >pgfplots aligning subplots causes misaligned y-tick labels - TeX
This solution works for fixing the slight misalignment between the two plots, but it also messes up the y-tick labels, making them overlap ......
Read more >2015 Canadian Market Structure Forecast - Markets Media
the U.S. over the past several months – the time frame we are lead to ... and marketplaces are currently so misaligned that...
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
I set
useUTC: false
on thexScale
property.If it helps anyone, I currently addressed my issue with a function that produces the tick values explicitly. In my case,
point.x
values are Date objects, which are specific to a given time interval. See a CodeSandbox above for an example.start
andend
are the min and max dates included in the chart data,intervalType
is ‘week’, 'month, 'day, or ‘year’, andintervalNum
is the number of intervals (ex. 3 months) per data point.Then I call this function from the chart parameters as below:
This results in limiting the number of ticks to the
maxTicks
value. So if you havemaxTicks=12
, and 12 months of data you get 12 ticks, but if you have 13 data points, you’ll drop your number of ticks down to 6, then with 14 data points, it goes to 7 ticks, etc…