smag icon indicating copy to clipboard operation
smag copied to clipboard

Support for user-specified y-axis range

Open bermudalocket opened this issue 5 years ago • 4 comments

Maybe something along the lines of optional flags such as smag --y-min=0 --y-max=12 ...?

A motivational example is graphing load average. A user might want to see the graph plotted in the context of the CPU's full capability, e.g. seeing the graph plotted in the range 0...12 (for 6-core hyperthreaded processor) instead of smag automatically shrinking the y-range from 1.25 to 2.00.

bermudalocket avatar Dec 01 '20 19:12 bermudalocket

This should be easy to do. Do you have any interest in trying to add the feature yourself and opening a PR? I can point you at the areas in the code you should look at.

aantn avatar Dec 02 '20 07:12 aantn

This should be easy to do. Do you have any interest in trying to add the feature yourself and opening a PR? I can point you at the areas in the code you should look at.

I haven't worked with Rust much beyond Hello World and a few Project Euler problems, but I'm more than happy to give it a shot.

bermudalocket avatar Dec 02 '20 18:12 bermudalocket

Cool, lets give this a go!

The y-axis bounds are calculated here in DataStore: https://github.com/aantn/smag/blob/main/src/datastore.rs#L72

The command-line arguments are generated automatically from the Args struct here: https://github.com/aantn/smag/blob/main/src/main.rs#L28

I would start by modifying the y-axis bounds function to use a set hardcoded number and make sure that works OK. If it does then add command line arguments by modifying the Args struct. Lastly, you'll have to access the data from the args struct when calculating the y-bounds. You can pass that to DataStore::new here: https://github.com/aantn/smag/blob/main/src/main.rs#L78

aantn avatar Dec 03 '20 11:12 aantn

Awesome, thanks. Will give this a shot tomorrow.

bermudalocket avatar Dec 04 '20 04:12 bermudalocket