Closed bitprophet closed 13 years ago
Relevant Graphite code:
render/glyph.py:UnitSystems
defines the magnitudes
render/glyph.py:format_units()
takes in a value, a step, and a system ID and returns a two-tuple of value, prefix (though I think it should really be 'suffix'...?)
render/glyph.py:LineGraph.makeLabel()
calls format_units
to arrive at a final label string for a given value.
First obvious solution is to make the magnitude check an optional boolean kwarg in format_units
, passed down from LineGraph.makeLabel
as that's our interface to these mechanisms.
The second is to further extract things so we can have a "step-agnostic" version of the above chain -- then, at least for now, we could skip the graph prerender step entirely since all we care about is acting upon the raw data series (and don't care about the step.)
EDIT: Hm, maybe not; makeLabel
uses ySpan to determine how many decimal points to use (so, maybe removing the step check from format_units
could work, if we allow makeLabel
to use more than 2-3 decimal places...) and that does require the graph to be drawn/calculated. Unless we're able to wrench that out too. May be more work than necessary, it's not like doing all the graph calculations appears THAT heavy until it's truly drawn.
Yea, making step check skippable is easy, but of course then we run into situations where the graph's yAxis is still going from e.g. 19000245 to 19001437, but the min/max/mean values are all "19 M".
Will probably leave it at that for now -- if we make the graphs themselves skip the step check, they'll be less useful and really silly looking, but at least making the min/max/mean a "sane" suffix means one can glance at them to get context for a graph that is showing very long numbers on its yAxis.
I think this may be a Graphite specific problem, but many times one will get a graph that spans, say, 375 M to 412 M, but instead of using actual M, the graph will use K, so you'll see e.g. 375238 K => 412133 K. Much harder to parse/read.
See why this happens in Graphite and if there is a way to "fix" it solely via URL API args or if it requires Graphite changes.