-
Notifications
You must be signed in to change notification settings - Fork 290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Thresholds and Colors #94
base: master
Are you sure you want to change the base?
Conversation
Inspiration and Attribution: Shout out to Alexandre Pretto Nunes (https://github.com/apretto)! Alexandre's PR (holman@206a69d) with the "fire" palette was the inspiration behind these features. Much thanks! Additional shout out to user79743 for the ansi color table code from: http://unix.stackexchange.com/questions/269077/tput-setaf-color-table-how-to-determine-color-codes Thank you kindly! Description: I use sparkline every day. Usually to provide quick and dirty graphs for spot checking peaks/valleys in data returned from various tools' apis (splunk, tealeaf, etc). Many of these tools can also return thresholds with the data and I often find that min/max must be checked in order to understand the scale of the peaks vs. valleys. Additionally, I like ansi colors in general - bash is life. This commit provides a middle class (eat the rich) feature set to compel spark's output to be more pleasant on the eyes and potentially speed up analysis of data from the shell. Features: Graph Name/Title, Threshold, Threshold Color, Threshold Inversion, Ansi Color Table, and Color Palettes Feature Details: Graph Name/Title (-n "<graph_name>"): Optional graph header with customizable title and min/max value. -- usage example: ./spark -n "The Graph Title" <data> Color Palette (-p <color_palette|ansi_csv): Multiple pre-existing palettes to add color to each tick. Palettes can also be specified as an 8 element comma-seperated list of ansi integer color codes (to be passed to tput). - Built-in color palettes: fire, ice, earth, smoke, pride, lolcat -- usage example: ./spark -p ice <data> - Customizable color palette: Comma-separated 8 element list ansi color codes (0-255) -- usage example: ./spark -p 212,213,214,215,216,217,218,219 <data> Threshold Value (-t <threshold_value>): All values greater than or equal (or less than or equal with the inversion switch - see below) to the threshold value will result in ticks of the specified threshold color (see below). Threshold Color (-c <color|ansi_integer>): Apply color to all ticks for values exceeding threshold. This will override any colors specified in the color palette. As with the color palette option, the threshold color option supports ansi integer color codes. -- usage example: ./spark -c red -t 5 <data> -- usage example: ./spark -c 1 -t 5 <data> Threshold Inversion (-i): Invert the threshold logic from "greater than or equal" to "less than or equal". -- usage example: ./spark -c red -t 5 -i Ansi Color Table (-a): Output a table of ansi colors for ease of color lookups. -- usage example: ./spark -a
This is a fantastic enhancement. When its going to be accepted? |
this is very cool. but it sure adds a bunch to the code. sigh |
I actually have added more recently - including a switch for different output syntax for escaping properly for PS1 support. At this point maybe I should fork? |
@abrist at this point - maybe bash is not the right language? 100 lines -> 240 lines is a bit I also wanted to compare 2 spark lines, and color based upon what had changed from previous values. So there seems to be a lot of different ways to color sparklines. For me, a sparkline is a simple/small graph that plots multiple data sets on the same graph. The x is linked between the two graphing functions but it has 2 different y values. (one for each function) Said another way, it displays 2+ different values in a single graph. It can use color, background color, opacity, height, symbols, and many other things to get the effect. the original graph just did one function - and that is displayed with height. Your talking about adding another variable by using foreground color. (can probably do opacity depending upon the author) I do wonder if it makes sense to pass in the second data set like the first is passed in. CORRECTION: You are adding color to make the existing dataset easier to understand. Introducing thresholds may make the user interface easier to code. (that way the normalization is not the job of the author) I did notice there is https://github.com/rrrene/sparkr but that too has been abandoned. There is probably a node project as well if that is your language of choice. (looks like you are a C person) It would be nice if you could incorporate with one of those projects and/or ask to take over them if you have a bunch of ideas. also interestingly, it looks like the ruby project does the data approach similar to how I proposed. |
@kbrock I agree that there are more projects in more robust languages out there, though I am partial to bash as it has little in the way of dependencies. My additions were aimed at providing a better interface for understanding the data. The color palettes were just a fun extra. I probably won't pick up an orphaned project to implement these features as they are working fine for my needs in my fork's branch. I do think I will update it at some point with a few of the more recent additions. I do like your suggestions for more data points, either for better granularity of ticks (by color), or even to superimpose multiple data points per tick. But, that is definitely out of scope for my current needs. These days I mostly use a pleasant color palette, thresholds, and the PS1 syntax addition I have yet to commit. Edit: I do not shy away from long shell scripts, though I do understand why most folk are reticent about shell script lengths. It is my suspicion that this PR is still open due to the number of line additions in the diff, and I am alright with that. To each their own :) FOSS is wonderful in this regard. |
Inspiration and Attribution:
Shout out to Alexandre Pretto Nunes (https://github.com/apretto)! Alexandre's PR (206a69d) with the "fire" palette was the inspiration behind these features. Much thanks!
Additional shout out to user79743 for the ansi color table code from: http://unix.stackexchange.com/questions/269077/tput-setaf-color-table-how-to-determine-color-codes
Thank you both kindly!
Description:
I use sparkline every day. Usually to provide quick and dirty graphs for spot checking peaks/valleys in data returned from various tools' apis (splunk, tealeaf, etc).
Many of these tools can also return thresholds with the data and I often find that min/max must be checked in order to understand the scale of the peaks vs. valleys.
Additionally, I like ansi colors in general - bash is life.
This commit provides a middle class (eat the rich) feature set to compel spark's output to be more pleasant on the eyes and potentially speed up analysis of data from the shell.
Features: Graph Name/Title, Threshold, Threshold Color, Threshold Inversion, Ansi Color Table, and Color Palettes
Feature Details:
Graph Name/Title (-n "<graph_name>"): Optional graph header with customizable title and min/max value.
-- usage example: ./spark -n "The Graph Title"
Color Palette (-p <color_palette|ansi_csv): Multiple pre-existing palettes to add color to each tick. Palettes can also be specified as an 8 element comma-seperated list of ansi integer color codes (to be passed to tput).
-- usage example: ./spark -p ice
-- usage example: ./spark -p 212,213,214,215,216,217,218,219
Threshold Value (-t <threshold_value>): All values greater than or equal (or less than or equal with the inversion switch - see below) to the threshold value will result in ticks of the specified threshold color (see below).
Threshold Color (-c <color|ansi_integer>): Apply color to all ticks for values exceeding threshold. This will override any colors specified in the color palette. As with the color palette option, the threshold color option supports ansi integer color codes.
-- usage example: ./spark -c red -t 5
-- usage example: ./spark -c 1 -t 5
Threshold Inversion (-i): Invert the threshold logic from "greater than or equal" to "less than or equal".
-- usage example: ./spark -c red -t 5 -i
Ansi Color Table (-a): Output a table of ansi colors for ease of color lookups.
-- usage example: ./spark -a