Fix #805: wrong value displayed in cursor label#950
Closed
timmolter wants to merge 1 commit into
Closed
Conversation
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>
Member
Author
|
Superseded by a more complete fix — closing in favour of a new PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #805
Problem
Two bugs in
Cursor.calculateMatchingDataPoints():Stale tooltip values —
matchingDataPointListwas only cleared inside theif (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.Missing Y values for same-series multi-point hits — The
HashMapdeduplication kept only oneDataPointper 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 ofcalculateMatchingDataPoints(), so no stale values persist when the cursor is between data points.HashMapclosest-X logic with aLinkedHashMapthat 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.