Skip to content

Fix #805: wrong value displayed in cursor label#951

Merged
timmolter merged 1 commit into
developfrom
timmolter/fix-issue-805-cursor-label-wrong-value
May 26, 2026
Merged

Fix #805: wrong value displayed in cursor label#951
timmolter merged 1 commit into
developfrom
timmolter/fix-issue-805-cursor-label-wrong-value

Conversation

@timmolter
Copy link
Copy Markdown
Member

Problem

Two bugs caused the cursor label to show wrong or stale values:

  1. Stale cursor dataCursor.setData() repopulated dataPointList with fresh data but never re-ran calculateMatchingDataPoints(). So while the mouse was held still, the label stayed frozen on the value seen at the last mouseMoved event, even after the chart repainted with new data.

  2. Wrong point selected when points overlapcalculateMatchingDataPoints() used a plain HashMap keyed by series name, keeping only the single closest-X point. When two points of the same series fell under the cursor simultaneously, the other Y value was silently dropped (and the surviving one wasn't necessarily the correct one).

Fix

  • Cursor.setData() — after rebuilding dataPointList, calls calculateMatchingDataPoints() immediately (when the mouse is inside the plot) so the label is always current on every repaint.
  • Cursor.calculateMatchingDataPoints() — now accumulates all matching Y values per series and joins them with ", " when there are multiple, so no value is lost.

Demo

TestForIssue805 in xchart-demo/.../standalone/issues/ demonstrates both bugs interactively:

  • A javax.swing.Timer toggles the "live" series every 2 s — before the fix the label only updated on mouse move.
  • An "overlap" series has two points at X = 3.0 and X = 3.1 with Y = 10 and Y = 90 — before the fix only one value was shown.

Closes #805

- Cursor.setData() now calls calculateMatchingDataPoints() when the
  mouse is inside the plot, so the label refreshes on every repaint
  rather than waiting for the next mouseMoved event.
- calculateMatchingDataPoints() now collects all matching points per
  series and combines their Y values into a comma-separated string
  when multiple points fall under the cursor simultaneously.
- Add TestForIssue805 demo reproducing both bugs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@timmolter timmolter merged commit fb9daa7 into develop May 26, 2026
1 check passed
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.

Fix wrong value displayed in cursor label

1 participant