Skip to content

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

Closed
timmolter wants to merge 1 commit into
developfrom
timmolter/fix-805-cursor-label-wrong-value
Closed

Fix #805: wrong value displayed in cursor label#950
timmolter wants to merge 1 commit into
developfrom
timmolter/fix-805-cursor-label-wrong-value

Conversation

@timmolter
Copy link
Copy Markdown
Member

Fixes #805

Problem

Two bugs in Cursor.calculateMatchingDataPoints():

  1. Stale tooltip valuesmatchingDataPointList was only cleared inside the if (dataPoints.size() > 0) branch. When the cursor moved to a position where no data points were nearby (but still inside the plot), the old tooltip kept showing from the previous cursor position.

  2. Missing Y values for same-series multi-point hits — The HashMap deduplication kept only one DataPoint per series (the closest X), silently dropping other Y values at the same X position. This caused wrong/incomplete values in the cursor label when multiple points of the same series fell under the cursor.

Fix

  • matchingDataPointList.clear() is now called unconditionally at the start of calculateMatchingDataPoints(), so no stale values persist when the cursor is between data points.
  • Replaced the HashMap closest-X logic with a LinkedHashMap that accumulates all Y values for each series and joins them with ", ", so all values are visible in the cursor label (e.g. "1.0, 2.0"). Series insertion order is preserved.

Demo

TestForIssue805.java — two overlapping series on an XY chart; enable the cursor and hover across the chart to verify correct labels.

Two bugs in Cursor.calculateMatchingDataPoints():
1. matchingDataPointList was only cleared inside the dataPoints.size() > 0
   branch, so stale tooltip values lingered when the cursor moved between
   data points.  Now cleared unconditionally at the start of the method.
2. HashMap deduplication kept only one DataPoint per series (closest X),
   silently dropping other Y values at the same X position.  Replaced
   with a LinkedHashMap that accumulates all Y values for each series and
   joins them with ", " so all values are visible in the cursor label.

Add TestForIssue805.java demo with two overlapping series to exercise
both fixes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@timmolter
Copy link
Copy Markdown
Member Author

Superseded by a more complete fix — closing in favour of a new PR.

@timmolter timmolter closed this May 26, 2026
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