class GerbilCharts::Surfaces::MrtgSurface
Mrtg Line Surface
¶ ↑
MRTG like surface First data-point = SquareArea Green Second data-point = SquareLine Blue Third onwards = SquareLines with usual color base as if starting from zero
Supported global options
circle_data_points
-
Draw a solid circle around datapoints
scaling
-
:auto, :auto_y0
Public Class Methods
new(opts={})
click to toggle source
Calls superclass method
# File lib/gerbilcharts/surfaces/mrtg_surface.rb, line 15 def initialize(opts={}) super(opts) end
Public Instance Methods
int_render(g)
click to toggle source
# File lib/gerbilcharts/surfaces/mrtg_surface.rb, line 19 def int_render(g) range_options_x = parent.get_global_option(:scaling_x,:auto) range_options_y = parent.get_global_option(:scaling_y,:auto) zbucketsize = parent.get_global_option(:zero_bucketsize,nil) rx = parent.modelgroup.effective_range_x(range_options_x) ry = parent.modelgroup.effective_range_y(range_options_y) set_ajaxSurfaceContext(rx.rmax,ry.rmax,"LINE") if parent.usesAjax? parent.modelgroup.each_model_with_index do | mod, i| if i==0 style= "mrtg0" surface= :area elsif i==1 style= "mrtg1" else style= "lineitem#{i-2}" end if surface==:area g.begin_squarized_polygon firstpoint=true xpos,ypos=0,0 last_x=nil y_zero = scale_y 0,ry mod.each_tuple do |x,y| xpos = scale_x x,rx ypos = scale_y y,ry if firstpoint g.polygon_point xpos,y_zero firstpoint=false end unless zbucketsize.nil? if last_x && (x-last_x) > zbucketsize g.polygon_point scale_x(last_x,rx) ,y_zero g.polygon_point scale_x(x,rx) ,y_zero end last_x=x end g.polygon_point xpos,ypos end g.polygon_point xpos,y_zero g.end_polygon(:id => "mrtg0", "opacity"=>"0.8") else prev_ypos=nil mod.each_tuple do |x,y| xpos = scale_x x,rx ypos = scale_y y,ry prev_ypos ||= ypos g.lineto xpos,prev_ypos g.lineto xpos,ypos prev_ypos=ypos end g.endline(:id => style) end end end