Open
Conversation
Author
|
I've added the ability to override colors, even though it requires extending Here is an example of that (to be put in a rails initializer) class CustomAnnotations < Blazer::Annotations
def call(result)
min, max = result.rows.map(&:first).minmax
super + weekends(min, max)
end
private
def weekends(min, max)
(min.to_date..max.to_date).select(&:on_weekend?).each_slice(2).map do |weekend|
{
min_date: weekend[0],
max_date: weekend[1].end_of_day,
label: "", # Empty labels are not rendered
color: "#FAFAFA",
}
end
end
end
Blazer.annotations = CustomAnnotationsResults in (notice that it works with existing annotations): |
Annotations are lines and boxes that show up on line charts with time axis. They can be used to mark events and periods.
dd40653 to
7350520
Compare
dgmora
added a commit
to dgmora/blazer
that referenced
this pull request
Feb 16, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

I'd like to propose an annotations mechanism which allows overlaying data on top of the line charts with a temporal axis.
The main use case is to keep a log of events (whether they are points in time or ranges) and to see the effect of those events on multiple metrics we track in Blazer. A good example would be to track deployments, a marketing campaign duration or holidays and overlay them on top of revenue or visits data.
Here is an example:
blazer.yml
Result

Developed together with @twratajczak
Fixes #403