Skip to content

Commit

Permalink
First stab at drawAsInfinite.
Browse files Browse the repository at this point in the history
This implementation differs from Graphite's dashboard mainly because we're still drawing
the series as data.
In the case of DAI, we'll transform the _data_ itself in the semantics of DAI, and let
the visual aspects result from it (being that the graph is drawn from ymin to ymax on > 0
data points
).
  • Loading branch information
jondot committed May 26, 2012
1 parent e7082ea commit 77d9f79
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ description.
padding = the kind of padding you need
title = box title
label_formatter = and a formatter, as before.

as_infinite = [2] pick the 3rd (index:2) series and draw it [as
infinite](http://graphite.readthedocs.org/en/1.0/functions.html#graphite.render.functions.drawAsInfinite)

# Visuals

Expand Down
16 changes: 16 additions & 0 deletions app/js/graphene.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ class Graphene.TimeSeriesView extends Backbone.View
@firstrun = true
@parent = @options.parent || '#parent'
@null_value = 0
@asInfinite = @options.as_infinite || []

@vis = d3.select(@parent).append("svg")
.attr("class", "tsview")
Expand Down Expand Up @@ -346,6 +347,21 @@ class Graphene.TimeSeriesView extends Backbone.View
line = d3.svg.line().x((d) -> x(d[1])).y((d) -> y(d[0]))
area = d3.svg.area().x((d) -> x(d[1])).y0(@height - 1).y1((d) -> y(d[0]))


#
# post-processing
# data transofrmation for view purposes
#
# 1. DrawAsInfinite: if a series is marked as such, we'll transform
# a > 0 value to infinity (here the max value in graph) or 0 otherwise.
#
di = 0
_.each data, (d)=>
if @asInfinite && _.include(@asInfinite, di)
_.each d.points, (p) =>
p[0] = if p[0] > 0 then dmax.ymax else 0
di += 1

#
# get first X labels
#
Expand Down
2 changes: 1 addition & 1 deletion build/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion graphene.min.js

Large diffs are not rendered by default.

0 comments on commit 77d9f79

Please sign in to comment.