class GerbilCharts::Surfaces::Surface
Surface
- graph surface¶ ↑
Base class for all surfaces (line,bar,pie,area,…)
Public Class Methods
new(opts={})
click to toggle source
Calls superclass method
GerbilCharts::Surfaces::GraphElement::new
# File lib/gerbilcharts/surfaces/surface.rb, line 8 def initialize(opts={}) super(opts.merge(:class => 'surfacepanel' )) end
Public Instance Methods
draw_annotations(g,rx,ry)
click to toggle source
# File lib/gerbilcharts/surfaces/surface.rb, line 89 def draw_annotations(g,rx,ry) parent.modelgroup.annotations.each do |anno| xpos = scale_x anno[:x],rx ypos = scale_y anno[:y],ry xlab,ylab = @bounds.intersect_point( xpos + rand(-100..-30), ypos+rand(-5..+80)) g.line xpos,ypos, xlab, ylab, {:style => "stroke: #bbb"} g.textout(xlab, ylab, anno[:label], {:class => "legendtext", :style => "text-anchor:middle"}) g.circle(xpos,ypos,2) end end
draw_range_bands(g,rx,ry)
click to toggle source
# File lib/gerbilcharts/surfaces/surface.rb, line 53 def draw_range_bands(g,rx,ry) parent.modelgroup.range_bands.each do |range_band| rb_upper = range_band[:upper] rb_lower = range_band[:lower] g.begin_polygon firstpoint = nil rb_upper.each_tuple do |x,y| xpos = scale_x x,rx ypos = scale_y y,ry g.polygon_point xpos,ypos firstpoint = [xpos,ypos] if firstpoint.nil? end rb_lower.each_tuple_reverse do |x,y| xpos = scale_x x,rx ypos = scale_y y,ry g.polygon_point xpos,ypos end g.polygon_point firstpoint[0],firstpoint[1] g.end_polygon(:id => "ref_mod") end end
draw_ref_model_lines(g,rx,ry)
click to toggle source
# File lib/gerbilcharts/surfaces/surface.rb, line 19 def draw_ref_model_lines(g,rx,ry) parent.modelgroup.ref_models.each do |ref_model| ref_model.each_tuple do |x,y| xpos = scale_x x,rx ypos = scale_y y,ry g.lineto xpos,ypos end g.endline(:class => "refline") # show latest pt & label ref_model.first do |x,y| g.textout(@bounds.left+5, scale_y(y,ry)-5, ref_model.latest_formatted_val, {:class => "reflinelabel"}) end ref_model.latest do |x,y| g.textout(@bounds.right-5, scale_y(y,ry)-5, ref_model.latest_formatted_val, {:class => "reflinelabel", "text-anchor" => "end" }) g.textout(@bounds.right-5, scale_y(y,ry)+15, ref_model.name, {:class => "reflinelabel", "text-anchor" => "end" }) end end end
int_render(g)
click to toggle source
# File lib/gerbilcharts/surfaces/surface.rb, line 12 def int_render(g) end
set_ajaxSurfaceContext(mxx, mxy, type)
click to toggle source
# File lib/gerbilcharts/surfaces/surface.rb, line 15 def set_ajaxSurfaceContext(mxx, mxy, type) parent.set_ajaxContext(:axmxx => mxx, :axmxy => mxy, :axsurface => type) end