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

Draw as infinite #42

Open
wants to merge 4 commits into
base: draw_as_infinite
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ 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
asInfinite = [2, 'myEvent'] pick the 3rd (index:2) series and the series labelled 'myEvent' and draw it [as
infinite](http://graphite.readthedocs.org/en/1.0/functions.html#graphite.render.functions.drawAsInfinite)

# Visuals
Expand Down
23 changes: 13 additions & 10 deletions app/js/graphene.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ class Graphene.GraphiteModel extends Backbone.Model

start: ()=>
@refresh()
console.log("Starting to poll at #{@get('refresh_interval')}")
@t_index = setInterval(@refresh, @get('refresh_interval'))
#RunOnce if refresh_interval is set as 0
if 0 != @refresh_interval
console.log("Starting to poll at #{@get('refresh_interval')}")
@t_index = setInterval(@refresh, @get('refresh_interval'))

stop: ()=>
clearInterval(@t_index)
Expand All @@ -71,7 +73,7 @@ class Graphene.GraphiteModel extends Backbone.Model
success: (js) =>
console.log("got data.")
@process_data(js)
$.ajax options
$.ajax options

process_data: ()=>
return null
Expand Down Expand Up @@ -289,7 +291,7 @@ class Graphene.TimeSeriesView extends Backbone.View
initialize: ()->
@line_height = @options.line_height || 16
@animate_ms = @options.animate_ms || 500
@num_labels = @options.labels || 3
@num_labels = @options.num_labels || 3
@sort_labels = @options.labels_sort || 'desc'
@display_verticals = @options.display_verticals || false
@width = @options.width || 400
Expand All @@ -300,7 +302,7 @@ class Graphene.TimeSeriesView extends Backbone.View
@firstrun = true
@parent = @options.parent || '#parent'
@null_value = 0
@asInfinite = @options.as_infinite || []
@asInfinite = @options.asInfinite || []

@vis = d3.select(@parent).append("svg")
.attr("class", "tsview")
Expand Down Expand Up @@ -356,11 +358,12 @@ class Graphene.TimeSeriesView extends Backbone.View
# 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
if @asInfinite
_.each data, (d)=>
if _.include(@asInfinite, d.i) || _.include(@asInfintie, d.label)
_.each d.points, (p) =>
p[0] = if p[0] > 0 then dmax.ymax else 0
di += 1

#
# get first X labels
Expand Down