Fix #805: wrong value displayed in cursor label#951
Merged
timmolter merged 1 commit intoMay 26, 2026
Conversation
- 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>
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.
Problem
Two bugs caused the cursor label to show wrong or stale values:
Stale cursor data —
Cursor.setData()repopulateddataPointListwith fresh data but never re-rancalculateMatchingDataPoints(). So while the mouse was held still, the label stayed frozen on the value seen at the lastmouseMovedevent, even after the chart repainted with new data.Wrong point selected when points overlap —
calculateMatchingDataPoints()used a plainHashMapkeyed 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 rebuildingdataPointList, callscalculateMatchingDataPoints()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
TestForIssue805inxchart-demo/.../standalone/issues/demonstrates both bugs interactively:javax.swing.Timertoggles the"live"series every 2 s — before the fix the label only updated on mouse move."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