Skip to content

Commit 23f441d

Browse files
authored
Merge pull request ScottPlot#4900 from manaruto/fix-datetimeautomatic-inverted-axes
Fix DateTimeAutomatic tick generation for inverted axes
2 parents b0d8166 + 1489ca2 commit 23f441d

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ _Not yet on NuGet..._
66
* Bar Plot: Add `LabelsOnTop` option to allow bar labels to always be displayed and never get overlapped by other bars or plottables (#4886, #4855) @manaruto @bclehmann
77
* PolarAxis: Add support for custom background color (#4897) @CoderPM2011
88
* PolarAxis: Added support for custom spoke lengths (#4897) @CoderPM2011
9+
* Axes: Improve automatic DateTime tick generation for inverted axes (#4900, #4851) @manaruto @sunwayking
910

1011
## ScottPlot 5.0.55
1112
_Published on [NuGet](https://www.nuget.org/profiles/ScottPlot) on 2025-03-22_

src/ScottPlot5/ScottPlot5/TickGenerators/DateTimeAutomatic.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,21 +65,21 @@ private ITimeUnit GetLargerTimeUnit(ITimeUnit timeUnit)
6565

6666
public void Regenerate(CoordinateRange range, Edge edge, PixelLength size, SKPaint paint, LabelStyle labelStyle)
6767
{
68-
if (range.Span >= TimeSpan.MaxValue.Days || double.IsNaN(range.Span) || double.IsInfinity(range.Span))
68+
if (range.Length >= TimeSpan.MaxValue.Days || double.IsNaN(range.Length) || double.IsInfinity(range.Length))
6969
{
7070
// cases of extreme zoom (10,000 years)
7171
Ticks = [];
7272
return;
7373
}
7474

75-
TimeSpan span = TimeSpan.FromDays(range.Span);
75+
TimeSpan span = TimeSpan.FromDays(range.Length);
7676
ITimeUnit? timeUnit = GetAppropriateTimeUnit(span);
7777

7878
// estimate the size of the largest tick label for this unit this unit
7979
int maxExpectedTickLabelWidth = (int)Math.Max(16, span.TotalDays / MaxTickCount);
8080
int tickLabelHeight = 12;
8181
PixelSize tickLabelBounds = new(maxExpectedTickLabelWidth, tickLabelHeight);
82-
double coordinatesPerPixel = range.Span / size.Length;
82+
double coordinatesPerPixel = range.Length / size.Length;
8383

8484
while (true)
8585
{

0 commit comments

Comments
 (0)