Giter VIP home page Giter VIP logo

plot's Introduction

Plot

plot on the command line

$ seq 1 5 | plot -d5
       5.00 ┤   ╭─
       4.00 ┤  ╭╯
       3.00 ┤ ╭╯
       2.00 ┤╭╯
       1.00 ┼╯

Monitor linux network usage:

card=wlan0
plot -d10 -f -p "avg:5|roc:5" \
    -c l -i "/sys/class/net/$card/statistics/rx_packets:r" \
    -c r -i "/sys/class/net/$card/statistics/tx_packets:r"

output of the above command

Building

compile:

$ meson build
$ meson compile -C build

install:

$ meson install -C build

Testing

$ meson test -C build

or, if you want to watch the tests,

$ meson test -C build -v --num-processes 1

Usage

For the cli, see plot -h or man plot.

See include/plot/plot.h for library documentation. Real documentation is a TODO.

Credits

Inspired by asciichart

plot's People

Contributors

adriandc avatar annacrombie avatar holmanb avatar mussonero avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

plot's Issues

Integration with ncurses?

Hello there,

I've just come across your porting and it seems really interesting!

I need a few time to check your code and see if it can fit my needs, but I'd like to know first if it is possible to integrate a plot like this inside a ncurses window interface.
For example something like some text and a data table at the top of the window and the plot with the flowing data at the bottom.

Many thanks for your time!

Make plot available as library

Abstract

Within a recent project, I required a simple solution to plot data into the shell. Plot does offer exactly this functionality in a reasonable and good way. However, my intended application will not easily allow to integrate and run plot as a standalone executable. Therefore, I would like to adapt the build-system of plot to such needs and make it a shared-library which can be linked into other executables.
This issue is about asking if this application and approach may be relevant for others as well and should be implemented to plot at all.

Intention and scope

The intention of these changes is to not affect the functionality of the plot-executable at all. Also, I have currently not the intention to add further functionality or extend interfaces of the project. My request is really just limited to offer the fundamental functionalities of plot, as a standalone shared library.

Specifically, the functions and types that should be exported by the library are defined in the following headers:

  • display.h
  • follow.h
  • input.h
  • plot.h
  • util.h

Disclaimer

I know that introducing fundamental requirements into a project is typically not welcomed, for good reason. Therefore, I would have no problem to just apply the changes on a fork of plot. By doing so, the original scope and functionality of plot would be entirely unaffected.

Foreseeable changes

  • Introducing a library-target into the build-system
  • Making a pkg-config target available
  • Introducing tests for the library interface/code (and adding a C test-framework as dependency)

Is it possible to have a custom width stretch and shrink on the x axis (like height) instead of acting as a delimiter?

I.e. if I have 20 data points, the plot is 20 characters max in width and increasing that does nothing to the graph, decreasing just limits the maximum amount of rendered characters. Whereas de/increasing height stretches and compress on the Y-Axis, why the difference and would it be possible to have width behave the same as heights?

P.S.
I looked at plot_fill_canvas and answered part of my question, there is no easy way, at least not for me :-) I think it would be nice to have ratio work on both axis if you ever get around to it. For now I'll figure out how I can "pad" my data to get at least terminal wide graphs.

Generic Parsing

(copied/editied from second half of #13)

Generic Parsing

Motivation

Many counters exposed to userspace by the linux kernel are exported as a file that is not simply a file with a number in it, but has either 1. multiple counters or 2 with surrounding text. Many files exposed via /proc/ are examples of this.

Presently plot expects the input value that it receives (stdout or file) to be a number represented as a string that can be converted to a double via strtod().

It would be really nice if plot supported a generic parsing functionality for extracting numbers from text. What I have in mind is adding an option
where one could specify a name for a parser in C that is either provided, or custom-written.

Plot output not full

$ seq 1 200 | plot -c C -x 5:0:0:3:blue -y 10:3:3 -d 50:200 -b 0:250
Seems to give only first 128 values.

Screenshot from 2021-09-27 07-24-34

License

Hello! I love what I'm seeing of plot so far, but I do not see a license. Has this project been released under any particular license?

rate of change / customizeable parsers

I have a question regarding intended scope and extensibility of plot.

Rate of Change

the example script for plotting tx/rx counters is but one example of this

Plotting counters of various types is a common activity that I see myself using plot for. However, it currently doesn't provide the ability to handle rate of change - the burden of calculating rate of change presently depends on some external program that usually does something like the monitor() function in the example script.

Since this seems (at least to me) like a common use case, it would be nice to add an option such as:

-r plot rate of change

which maybe does something like:

(val - old_val) /  sleep_time

to get a unit of "counters per second"

Generic Parsing

Presently plot expects the input value that it receives (stdout or file) to be a number represented as a string that can be converted to a double via strtod() (input.c:39).

Many counters exposed to userspace by the linux kernel are exported as a file that is not simply a file with a number in it, but has either 1. multiple counters or 2. surrounding text. Many files exposed via /proc/ are examples of this.

It would be really nice if plot supported a generic parsing functionality for extracting numbers from text. What I have in mind is:

-p regex:parse-string|<custom parser name>

where one could pass in PCRE regex to specify an extraction or optionally a name for a parser in C that they manually write

y label and y axis gets color at line intercept point

This is a fun little project!

Currently the Y axis and label that correspond to the leftmost data point of a line get printed with the color of that data point. This is distracting when using -f on data sets that are highly variable. This seems non-ideal.

image
image

Following stdin not drawing graph

First of all, I am very glad I found this wonderful tool.

I fail to make plot draw graphs as values come in at stdin while it does work if I use files. For instance, in Bash for i in {0..9}; do echo $i ; sleep .5; done| plot will show the graph only after 5s. If I write the sequence of numbers to a file in the background plot -f -i file works as expected. plot starts showing and updating the graph as the first number is written to the file. Did I miss something in the docs?

plot 0.5.1, Kernel 5.10.0, Bash 5.1.4

-d [width]:[height] is wrong

The docs say:

-d [width]:[height] - set plot dimensions

Actually, it seems to be

-d [height]:[width] - set plot dimensions

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.