mirror of
https://github.com/mum4k/termdash.git
synced 2026-04-27 03:15:55 +03:00
[GH-ISSUE #184] Allow "no value" on lineChart #107
Labels
No labels
bug
cleanup
enhancement
enhancement
enhancement
good first issue
help wanted
help wanted
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/termdash#107
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @slok on GitHub (Apr 12, 2019).
Original GitHub issue: https://github.com/mum4k/termdash/issues/184
Originally assigned to: @slok on GitHub.
Hi!
Would be nice to allow no values on the linechart, at this moment the linechart only supports float64 values (that defaults to
0if no value) but sometimes you don't have values to render on the graph. A0and anilare two different things and could make the graph break by the Y axis getting very big (from 0 to N) in very high value graphs without very differences.An example to show the graph when we don't have values:
We have this graph on Prometheus that shows us that from 5:27 to 5:29 doesn't have values (not rendered and the Y axis doesn't show
0):Same as above but rendered using termdash:
The problem with the termdash rendering is that the "no values" are rendered with the default float64 as
0and the Y axis shows0making the scale of the graph bigger and by this harder to get insights from it.The first approach to solve this that comes to my mind is by having
*float64as value unit or similar (custom type with pointers on no values) in another method likeSeriesWithNils,SeriesWithNoValuesso it doesn't break the current API.@mum4k commented on GitHub (Apr 13, 2019):
Thank you @slok, this certainly is an interesting use case that I didn't think about.
Luckily when it comes to the API, we might have another option that results in a compatible change. The float type can also have a special value NaN, which literally means "not-a-number". So we can adjust the LineChart to skip values that are NaN.
To be able to prioritize this work, can you help me understand if this is a "nice-to-have" enhancement or something that you would require right away?
@slok commented on GitHub (Apr 13, 2019):
Hi @mum4k!
As always thank you for responding so fast, first of all, I didn't know about the NaN! thanks!
At this moment I'm developing a new application in my spare time (is private for now, I'll make it public when I have the basic functionality, but I'm near), this application is a simplified grafana for terminal, so you can load dashboards based on config files and retrieve the metrics from different datasource, configure metric colors, thresholds, timerange...
Example:
I've selected termdash as the rendering engine for the widgets, although it lacks some functionality compared to libraries like termui, the API is cleaner and I think it has better looking, so once again, congrats :)
In the case of priority, I would say that this is very important if you render high values that don't vary a lot, so in my opinion is a requirement, but doesn't need to be right away, although if it's not too complicated for a person that lacks the knowledge of the internals of the library, I could contribute with a PR.
@mum4k commented on GitHub (Apr 13, 2019):
Thank you for sharing the screenshot @slok, that looks really good!
Understood about the priority. I would say the change itself will have medium complexity. It doesn't require knowledge of the infrastructure of termdash, and should be completely contained within the implementation of the linechart. However it will need to be propagated throughout all the layers of the linechart's implementation. I would roughly outline the required changes as follows:
github.com/mum4k/termdash@a9515f2721/widgets/linechart/linechart.go (L54-L65)github.com/mum4k/termdash@a9515f2721/widgets/linechart/linechart.go (L408)I might be missing something, but that should be it in a nutshell. It is great to hear you might be willing to contribute a PR. I would suggest you look at the code in the linechart package and its surrounding libraries and see if you feel like sending the PR. Please let me know what you decide. If you prefer me doing this, considering this is important for you I can slot it in a week or two.
Also please don't hesitate to open issues for any of the missing features you mentioned. Happy to discuss further improvements we need to make. Or you could help by prioritizing any issues that already exist so we develop the right things.
@slok commented on GitHub (Apr 13, 2019):
Thanks for the tips!
Checking your steps, hacking around a little bit the code and making few changes I had good results, I need to check if I have corner cases, check the tests... but I'll do it with more calm in the following days and if everythings seems ok make the PR!
Before the changes:
After the changes:
@mum4k commented on GitHub (Apr 13, 2019):
Great news! Please feel free to ask me if you will have any questions.
@mum4k commented on GitHub (Apr 18, 2019):
Fixed in the devel branch.