Add a way to draw a horizontal line

Bug #512093 reported by chrismd
18
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Graphite
Fix Released
Undecided
Unassigned

Bug Description

Need to add a function for drawing a horizontal line (like to indicate a threshold). Could simply add a new rendering function that creates a fake series object with a constant value.

Revision history for this message
AcidTonic (peoriaguy87) wrote :

I might be willing to implement this if a fix is beyond 1 month away....

Also another option needs to be to not really draw the line.... forcing the graph to scale and show the value indicated by the line.... Such as always displaying the graph from 0 to the current value.

That is useful for viewing data in small time fragments, like -2minutes for graphs that update every 2 seconds via lan connection. Normally the graph scales directly to the size of the smallest datapoint if it doesnt change for 2 minutes. When viewing rates of change and not so much the current value, the graph changing scale so quickly skews the change of data somewhat.

For dashboards like mine I'd rather be able to force a certain scale by setting two invisible datapoints that draw a horizontal line but dont export when using raw_data. Also like I said being able to have invisible lines will also be handy.

Thoughts? Comments? Suggestions?

Revision history for this message
chrismd (chrismd) wrote :

You could simulate an invisible line by using a fully transparent color via the colorList option. For example, colorList=red,ffffff00 (it's RGBA in hex) would draw the first graph element red and the second would be invisible.

But you don't even need to do that to make the graph scale how you want, you could simply use the yMax parameter to force the graph to show the Y axis up to a certain value.

But back to your original request for drawing an actual line, yes I think that would be very useful. I will eventually get around to implementing it because it is something I also want to use, but if you would be willing to work on it I'd be very grateful and it would probably get done much sooner. It would simply be a new function in webapp/graphite/render/functions.py that creates a fake series object. The tricky part is that functions are currently only passed whatever arguments you give them in the URL, so in this case just the constant value. In order to create a working TimeSeries object it has to know the time range of the request as well. Ideally the entire request context should be available to the functions; that would make this feature very easy to implement. But as it is right now there is no good way to do this without making a pile of messy code (functions.py) much messier :(

I suppose just adding a keyword arg to all of them wouldn't be *that* messy but I've wanted to redo that whole module for a while. Unfortunately I have not made the time, so for the near-term I think the most practical solution would be to past the request context (the requestOptions from render/views.py) down to the functions.

Revision history for this message
chrismd (chrismd) wrote :

This has been implemented in trunk as a function called threshold(). It can take 3 arguments, the first is the value of the threshold (required), second is a legend label for the threshold (optional, defaults to the numeric value), and third is the color of the line (optional). The color can be specified the same way as the colorList option works, "red", "00ff00", etc...

Changed in graphite:
status: New → Fix Committed
chrismd (chrismd)
Changed in graphite:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Related questions

Remote bug watches

Bug watches keep track of this bug in other bug trackers.