Skip to content

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

Open
@guptarohit

Description

Currently, when we pass data stream to cli of asciigraph it outputs the graph to stdout by default.

While this works fine in general, it becomes problematic when plotting in realtime mode as terminal retains the previous graph outputs.

To address this, it would be nice to keep only the latest plot copy in the terminal. To achieve it, clear the already plotted graph first before plotting new when we plotting realtime graph from stdin.

Possible solution: we can utilise ANSI escape sequences to move the cursor and clear the old graph. The following snippets might be helpful:

Move cursor n lines up: fmt.Sprintf("\033[%dA", n)
Clear the line: fmt.Sprintf("\033[2K")

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions