class GerbilCharts::Surfaces::SquareLineSurface

Square Line Surface

Squarized line surface Control the color,thickness of the line via the stylesheet item lineitem1, lineitem2 etc

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/square_line_surface.rb, line 13
def initialize(opts={})
  super(opts)
end

Public Instance Methods

int_render(g) click to toggle source
# File lib/gerbilcharts/surfaces/square_line_surface.rb, line 17
def int_render(g)
    
  range_options_x = parent.get_global_option(:scaling_x,:auto)
  range_options_y = parent.get_global_option(:scaling_y,:auto)
  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|
    
    prev_ypos=nil
    mod.each_tuple do |x,y|

      # the basic line
      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

      # datapoint and a tooltip
      opts = {:id => "item#{i}"}
      if parent.get_global_option(:auto_tooltips,false)
        opts.store(:gerbiltooltip1, x)
        opts.store(:gerbiltooltip2, "Val = #{GerbilCharts::Models::Presets.new.format_suffix(y)}")
      end
      g.circle(xpos,ypos,2,opts) if parent.get_global_option(:circle_data_points,false)
    end
    g.endline(:id => "lineitem#{i}")
    
    # 95th percentile line and label
    if parent.get_global_option(:show_95th_percentile,false)
      metrics=mod.get_statistical_analysis
      y95  = scale_y metrics[5],ry
      g.line( @bounds.left,  y95,  @bounds.right, y95,  {:id=>"lineitem#{i}"} )
      y95label = mod.formatted_val(metrics[5])
      g.textout(@bounds.right-30, y95-5, y95label, 
                    {:class => "reflinelabel", "text-anchor" => "end"})
      g.textout(@bounds.right-30, y95+15, "95th pct", 
                    {:class => "reflinelabel", "text-anchor" => "end"})
    end 

  end
    
  draw_ref_model_lines(g,rx,ry) 
  draw_range_bands(g,rx,ry) 
  draw_annotations(g,rx,ry) 

end