GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: Center period labels over their own period when using ticklabelindex by my-tien · Pull Request #7934 · plotly/plotly.js

Conversation

@my-tien

@my-tien my-tien commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Fixes #7876 by rewriting the way period label positioning works when using ticklabelindex.

Previously, the next labeled tick was used as the period end for the previous tick. This was problematic when using ticklabelindex, because sometimes the next labeled period is not necessarily adjacent to the last labeled period.
Now positionPeriodTicks can accept an array of periodEndTicks instead.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
my-tien added 4 commits August 4, 2026 16:01
@my-tien
Add flag useTicklabelIndex
5047961
Previously, the ticklabelindex property itself was used in boolean tests which can be confusing.
@my-tien
Make sure period labels are not positioned below a different period.
c59fa9f
@my-tien
Mock ticklabelindex-2 to test correct ticklabel placement
9fbd6c4
@my-tien
Add draftlog for PR 7934
b12f71a
@my-tien
my-tien marked this pull request as draft August 5, 2026 13:01
my-tien added 2 commits August 5, 2026 15:05
@my-tien
Add missing replacements of ticklabelindex with ax._useTicklabelIndex
c1ecb06
@my-tien
Baseline images for ticklabelindex-2 and date_axes_period2_ticklabeli…
65dbb62
…ndex
@my-tien
my-tien marked this pull request as ready for review August 5, 2026 13:32
@robertclaus
robertclaus requested a review from camdecoster August 6, 2026 19:33
@robertclaus robertclaus assigned camdecoster Aug 6, 2026
camdecoster
camdecoster requested changes Sep 23, 2026
View reviewed changes

@camdecoster camdecoster left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of this works, but there are a few changes that need to be made. I'm happy to talk through how to do some of this.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/plots/cartesian/axes.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/plots/cartesian/axes.js Outdated
Comment on lines +1013 to +1015
// for period label positioning when using `ticklabelindex`:
// for each tick in `allTicklabelVals` holds the neighboring period end tick
var periodEndTicks;

@camdecoster camdecoster Sep 23, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of saving an array of end ticks for each tick, what if we save the end tick to each tick? Then you could check for an end tick on each tick and use a different code path. You'd also be able to get rid of the new arg in positionPeriodTicks.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

my-tien reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@my-tien my-tien Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know if I didn't implement it as you intended.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/plots/cartesian/axes.js Outdated
// This minor tick will be labeled instead of the major tick.
if (isPeriod) periodEndTicks = []; // for each minor tick at the start of a labeled period this will hold the neighboring period end tick.

const labelTickValsAscending = minorTickVals

@camdecoster camdecoster Sep 23, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What should happen if there's a major tick that doesn't coincide with a minor tick? Should that also be included?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@my-tien my-tien Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, when ticklabelindex is used, only minor ticks should labeled. This step is just to handle the special case when a minor tick coincides with a major tick in which case the major tick should be labeled instead (because the minor could be removed later).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@camdecoster camdecoster Oct 5, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if the major ticks aren't displayed, they're still used when determining which tick to display. From the description for ticklabelindex:

draw the label for the minor tick that is n positions away from the major tick

Without that major tick, the count will be off.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@my-tien my-tien Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, now all major ticks and all non-overlapping minor ticks are in allTicklabelVals.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/plots/cartesian/axes.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/plots/cartesian/axes.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/plots/cartesian/axes.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@camdecoster camdecoster changed the title Fix #7876: Ticklabelindex positioning fix: Center period labels over their own period when using ticklabelindex Sep 23, 2026
This was referenced Sep 24, 2026
fix: Format date tick labels with minor-tick precision when using ticklabelindex #7935
Merged
fix: Fix missing last period label with negative ticklabelindex #7937
Open
camdecoster
camdecoster reviewed Sep 24, 2026
View reviewed changes
Comment thread src/plots/cartesian/axes.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

my-tien added 4 commits October 2, 2026 13:26
@my-tien
replace toSorted with sort
a84c7c1
@my-tien
Store periodEndTick directly in ticks that are passed to positionPeri…
029825b
…odTicks

- use ax._definedDelta in both cases, it would have been the same
@my-tien
Simplify setting of majorTick.skipLabel
9b71462
@my-tien
Fix access to periodEndTick.value in positionPeriodTicks.
5a8a7d2
camdecoster
camdecoster reviewed Oct 5, 2026
View reviewed changes

@camdecoster camdecoster left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are still a couple of things to address. I added some more context to my earlier comments.

ALso, could you please do a pass to make sure you're not using var in any of the new code?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/plots/cartesian/axes.js Outdated
// This minor tick will be labeled instead of the major tick.
if (isPeriod) periodEndTicks = []; // for each minor tick at the start of a labeled period this will hold the neighboring period end tick.

const labelTickValsAscending = minorTickVals

@camdecoster camdecoster Oct 5, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if the major ticks aren't displayed, they're still used when determining which tick to display. From the description for ticklabelindex:

draw the label for the minor tick that is n positions away from the major tick

Without that major tick, the count will be off.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/plots/cartesian/axes.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

my-tien added 3 commits October 6, 2026 17:41
@my-tien
Make sure last label isn't dropped on period axis with ticklabelindex
0ff997f
@my-tien
Fix ticklabelindex positioning if major and minor ticks aren't aligned.
93baa6e
@my-tien
Replace some var with better scoped let and const in ticklabeli…
dfd52ab
…ndex code
@my-tien
my-tien requested a review from camdecoster October 6, 2026 17:33
my-tien and others added 4 commits October 7, 2026 15:14
@my-tien
Fix ticklabelindex label positioning for minor periods < 1 day
b4d49bd
If no tickformat is specified, ax._actualDelta wasn't set and so periodX was also not set inside positionPeriodTicks.
@my-tien
Update baseline images after fixing ticklabelindex label positioning …
acad36d
…for < 1 day periods.
@camdecoster
Update formatting, comment, small refactor
7cefdcb
@camdecoster
Update draftlog
e520e67
camdecoster
camdecoster approved these changes Oct 7, 2026
View reviewed changes
@camdecoster
camdecoster merged commit 236e43f into plotly:main Oct 7, 2026
76 of 77 checks passed

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@camdecoster camdecoster camdecoster approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@camdecoster camdecoster

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[BUG]: period labels can be positioned incorrectly when using ticklabelindex with only one minor tick

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@my-tien @camdecoster
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.