Skip to content
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

feat: add scale option #21

Closed
josegonzalez opened this issue Nov 1, 2017 · 12 comments
Closed

feat: add scale option #21

josegonzalez opened this issue Nov 1, 2017 · 12 comments

Comments

@josegonzalez
Copy link

It would be great to be able to scale a series against a number. At the moment, I am adding a number to the end of the set, which makes everything scale against it, but also includes that number in the output.

@deeplook
Copy link
Owner

deeplook commented Nov 1, 2017

I'm not sure how much sense it would make to add any "computational" muscles to sparklines since you can always simply pass an alternative array of numbers.

@josegonzalez
Copy link
Author

I just want it to scale the sparkline to 100, since it makes more sense when you're looking at multiple time-series if they all have the same scale :)

@deeplook
Copy link
Owner

deeplook commented Nov 1, 2017

Can you give an example, maybe, to illustrate more precisely?

@josegonzalez
Copy link
Author

I have a script that outputs utilization information for databases. Here is the output, which I scale to help visualize the actual resource usage.

$ bin/rds-reservation-analyzer -C memory --threshold 75 --sort-by percentage
instance identifier                     percentage  reserve    sparklines
------------------------------------  ------------  ---------  --------------------------------------------------------------------------------------------
production-buzzfeed                        41.7224  True       ▂▁▂▁▂▁▂▁▂▂▁▂▁▂▁▂▁▂▂▁▂▁▂▂▂▁▂▁▂▁▂▁▂▂▂▂▁▂▁▂▂▂▂▁▂▁▂▂▂▁▂▁▂▁▂▁▂▁▂▁▂▂▁▁▂▂▁▂▂▁▂▂▁▂▂▁▂▂▁▂▂▂▂▂▂▁▁▁▁▂▁█
production-blart                           76.2455  False      ▅▆▁▆▄▆▁▆▆▂▆▆▆▁▆▅▆▆▃▆▆▆▆▂▁▆▆▆▅▆▃▆▁▂▆▆▆▄▆▂▃▆▁▆▆▆▆▆▁▆▅▆▁▆▃▆▁▆▆▆▁▆▆▆▁▄▆▆▃▆▁▂▆▆▁▆▆▁▆▆▁▂▆▁▆▆▅▆▆▄▆█
production-manbearpig                      88.4585  False      ▂▂▁▂▂▂▁▂▂▂▂▂▂▁▂▂▂▂▂▂▂▂▂▂▁▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▁▂▂▂▂▂▂▂▂▂▁▂▂▂▁▂▂▂▁▂▂▂▁▂▂▂▂▂▂▂▂▂▁▂▂▁▂▂▁▂▂▁▂▂▂▂▂▂▂█
production-manbearpig-replica              92.4751  False      ▄▄▁▄▄▄▁▄▄▄▄▄▄▁▄▄▄▄▄▄▄▄▄▄▁▄▄▄▄▄▄▄▅▄▄▄▄▄▄▄▄▄▁▄▄▄▄▄▅▄▄▄▁▄▄▄▁▄▄▄▁▄▄▄▁▄▄▄▄▄▄▄▄▄▁▄▄▁▄▄▂▄▄▁▄▄▄▄▄▄▄█
production-keyboard                        95.8047  False      ▁▃▂▄▁▂▁▃▁▁▂▁▂▂▂▁▂▂▁▂▁▃▁▂▂▃▁▂▁▂▁▃▁▁▁▁▃▁▃▂▁▁▁▂▂▃▂▁▁▃▁▂▂▂▁▃▂▃▁▃▁▁▃▂▂▁▃▂▁▂▁▁▃▂▂▂▁▂▂▁▂▂▁▁▁▃▁▂▂▁▂█

@deeplook
Copy link
Owner

deeplook commented Nov 1, 2017

I see, thanks! But you still have only eight values (categories) per character (nine, if you would include blanks for 0), so it's nowhere as precise as the four digits in your percentage column, but well, that's the price to pay for ASCII.

You could scale the numbers before sending them to sparklines, but that would be a challenge in something like bash, sure... Have you considered writing a little "adaptor" Python script doing this? It might be faster than getting the feature into sparklines, at least from my side, since I'm busy with lots of other things now.

@josegonzalez
Copy link
Author

Would you consider a PR for adding a scale option to this package?

@deeplook
Copy link
Owner

deeplook commented Nov 1, 2017

Sure! Just try to find a meaningful option name. And add a test, incl. Python 3! ;-)

@mkgs
Copy link
Contributor

mkgs commented Nov 1, 2017

You can get the desired result by setting the maximum keyword argument to 100

@deeplook
Copy link
Owner

deeplook commented Nov 1, 2017

@mkgs, heck, you're right! I should use my own stuff more often. ;-)

$ sparklines 1 2 3 4 1 2 3 4
▁▃▆█▁▃▆█
$ sparklines -M 10 1 2 3 4 1 2 3 4
▁▂▃▃▁▂▃▃

@deeplook deeplook closed this as completed Nov 2, 2017
@josegonzalez
Copy link
Author

Ah, looks like that exists, but isn't available in the current release? Would it be possible to make a release, as per #18?

@deeplook
Copy link
Owner

deeplook commented Nov 3, 2017

@josegonzalez I'd be happy to make a new release, but I usually wait for a few features to accumulate. In this case I think I'd like to see #9 and the newly created #24.

@josegonzalez
Copy link
Author

hokay :)

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

No branches or pull requests

3 participants