Skip to content

Always generate at least 2 major ticks (#1420)#1421

Merged
swharden merged 7 commits intoScottPlot:masterfrom
bclehmann:generate-at-least-2-major-ticks
Nov 16, 2021
Merged

Always generate at least 2 major ticks (#1420)#1421
swharden merged 7 commits intoScottPlot:masterfrom
bclehmann:generate-at-least-2-major-ticks

Conversation

@bclehmann
Copy link
Member

@bclehmann bclehmann commented Nov 3, 2021

Purpose: #1420

Note that this will create minor ticks even if there are no major ticks on-screen (but the minor ticks may be above or below the drawn area).

Examples

1 major tick visible

image

0 major ticks visible

image

0 major or minor ticks visible (zoomed in between minor ticks)

image

@bclehmann

This comment has been minimized.

@bclehmann bclehmann marked this pull request as ready for review November 3, 2021 02:17
@bclehmann
Copy link
Member Author

I noticed something while looking at this code:

if (MajorTickVisible)
AxisTicksRender.RenderTickMarks(dims, gfx, visibleMajorTicks, RulerMode ? MajorTickLength * 4 : MajorTickLength, MajorTickColor, Edge, PixelOffset);
if (TickLabelVisible)
AxisTicksRender.RenderTickLabels(dims, gfx, TickCollection, TickLabelFont, Edge, TickLabelRotation, RulerMode, PixelOffset, MajorTickLength, MinorTickLength);
if (MinorTickVisible)
AxisTicksRender.RenderTickMarks(dims, gfx, visibleMinorTicks, MinorTickLength, MinorTickColor, Edge, PixelOffset);
if (MajorGridVisible)
AxisTicksRender.RenderGridLines(dims, gfx, visibleMajorTicks, MajorGridStyle, MajorGridColor, MajorGridWidth, Edge);
if (MinorGridVisible)
AxisTicksRender.RenderGridLines(dims, gfx, visibleMinorTicks, MinorGridStyle, MinorGridColor, MinorGridWidth, Edge);

These function calls operate on predominantly the same data, but some of them take double[], and some TickCollection. This could be prone to regressions or other bugs in the future, as they take different codepaths for restricting the ticks to only those that are visible.

@bclehmann

This comment has been minimized.

clarifies how ticks are added when the number of positions is less than 2 ScottPlot#1421
Ensures at least 3 ticks are always present when IntegerPositionsOnly is active so minor tick marks (and grid lines) are always drawn ScottPlot#1421 ScottPlot#1420
@swharden
Copy link
Member

Hi @bclehmann, thanks for this PR! ... and sorry for my extreme delay. I moved to a new house this month and I got hit with way more disruption to my productivity than expected 😅 Things are starting to return to normal though!

I added some extra logic which adds extra integer ticks in the case that IntegerPositionsOnly removes too many ticks after reducing positions down to integers only (the original use case for #1420).

before after
1420 1420b

@swharden
Copy link
Member

... some of them take double[], and some TickCollection. This could be prone to regressions or other bugs in the future, as they take different codepaths for restricting the ticks to only those that are visible.

This warning is well-received! This is one of many serious issues with the present tick system. I'm going to prioritize refactoring the tick system soon (#1028) since official Maui.Graphics development is moving more slowly than anticipated.

@swharden swharden linked an issue Nov 16, 2021 that may be closed by this pull request
@swharden swharden enabled auto-merge November 16, 2021 04:13
@swharden swharden merged commit 10cabc1 into ScottPlot:master Nov 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ticks: do not hide minor ticks when major ticks are off the screen

2 participants