Skip to content

fix(cli): clear previous graph before plotting in realtime mode#79

Open
zhengshui wants to merge 1 commit into
guptarohit:masterfrom
zhengshui:fix/issue-44-realtime-graph-clearing
Open

fix(cli): clear previous graph before plotting in realtime mode#79
zhengshui wants to merge 1 commit into
guptarohit:masterfrom
zhengshui:fix/issue-44-realtime-graph-clearing

Conversation

@zhengshui
Copy link
Copy Markdown

Summary

This PR fixes issue #44 by improving the realtime graph clearing behavior.

Changes

  • Added lastGraphLines variable to track the previous graph height
  • Added clearPreviousGraph() function that clears only the previous graph lines instead of clearing the entire screen using ANSI escape sequences
  • This reduces screen flicker in realtime mode

How it works

  1. After each graph is plotted, we record the number of lines in lastGraphLines
  2. Before plotting the next graph, we use ANSI escape sequences to:
    • Move cursor up by lastGraphLines
    • Clear each previous line
    • Move cursor back to start position

Verification

go test ./...
# Build and test realtime mode
echo -e "1\n2\n3\n4\n5\n6\n7\n8\n9\n10" | go run ./cmd/asciigraph -r

All tests pass.

Closes #44

- Add lastGraphLines to track previous graph height
- Add clearPreviousGraph function to clear only previous graph lines
  instead of clearing entire screen
- This improves realtime plotting by reducing screen flicker

Fixes guptarohit#44
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.

CLI: for realtime data stream, clear old graph before plotting new data

1 participant