Line graph: reset previous point between dataxy series to prevent unwanted poly‑line connection#665
Merged
Watson1978 merged 3 commits intotopfunky:masterfrom Jul 23, 2025
Conversation
Collaborator
|
Thanks |
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.
What problem does this PR solve?
When a
Gruff::Linegraph is built with multipledataxyseries, the lastpoint of series N is drawn as a straight line to the first point of
series N + 1.
The result is a single, continuous poly‑line instead of visually separated
series, which is misleading for end‑users. :contentReference[oaicite:0]{index=0}
How to reproduce
Current output:
A “V”‑shaped line connecting (3,4) → (0,3) instead of two independent lines.
Expected output:
Two distinct polylines that do not share a segment.
Root cause
Inside
Gruff::Line#draw_graph, the helper variablesprev_xandprev_ycache the coordinates of the previously plotted point.
They are initialised once before the outer loop that iterates over each
data_row(series).Consequently, the starting point of the next series inherits the last point of
the previous series.
What does this PR change?
A single line resets the cache at the top of the loop:
store.norm_data.each do |data_row| + prev_x = prev_y = nil data_row.coordinates.each_with_index do |(x_data, y_data), index|By setting
prev_xandprev_ytonilfor every new series, the drawinglogic starts a fresh poly‑line and no longer links series together.
Impact / backwards compatibility
Gruff::Linewith thedataxyAPI.Thanks for maintaining Gruff! Any feedback is welcome.