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

multi-color graphs #589

Open
incanus opened this issue Aug 4, 2024 · 4 comments
Open

multi-color graphs #589

incanus opened this issue Aug 4, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@incanus
Copy link

incanus commented Aug 4, 2024

I searched and didn't see a history of discussion about this feature, but I would be interested in the ability to plot values of varying color (fill, at least) for graphs. For example, graphing CPU a certain color, but then yellow when >80% and red when >90%.

Has this been looked into at all? Just wondering as I might take a crack at it and submit a PR if there is interest.

@incanus
Copy link
Author

incanus commented Aug 5, 2024

Ok, looking into the source, I can see that this is non-trivial, but would be doable. The first-pass approach would be:

  • Make the graph struct allocate and track an additional member of type uint32_t* alongside its existing y value float* storage (so graph->width * sizeof(uint32_t) additional RAM allocation).
  • Each graph_push_back() could potentially push a color value into this member for each data point. A 0 or some other infrequently-used value could be set to indicate to use the default graph color for that y value.
  • The graph_draw() would probably require the most work, since potentially many CGPath could have to be drawn instead of just one to fill.
  • Changes to handle_domain_push() to parse out the pushed values, including an optional data point color.

I might still give it a shot, but just wanted to summarize for anyone else thinking about it. And totally understandable @FelixKratz if this is out of scope & you want to close the issue.

@incanus
Copy link
Author

incanus commented Aug 5, 2024

Alternatively, another way to tackle this could be the ability to set one or more threshold/color combinations, then instead of storing the color for a data point, it could be drawn based on meeting thresholds instead.

@FelixKratz
Copy link
Owner

I think from the code point-of-view this is doable, I however wonder what a proper syntax for this would look like?

@FelixKratz FelixKratz added the enhancement New feature or request label Aug 6, 2024
@incanus
Copy link
Author

incanus commented Aug 6, 2024

I hadn’t yet checked for support of optional arguments, but for direct color I imagined it would just be:

sketchybar push <name> <data point> <optional point-specific color>

For the idea of thresholds, the syntax does get messier. Maybe an added property syntax like this?

sketchybar —set <name> graph.fill_color=0xffffcccc graph.fill_threshold=90:0xffff000000:80:0xffffff00

(or 0.9 or whatever makes the most sense for range)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants