class GerbilCharts::Surfaces::AreaSurface

Area Surface w/ transparency

The transparency kind of allows hidden items to be shown

Options

:scaling_x :auto, :auto_0, or array [minval,maxval]

:scaling_y

:butterfly true/false for butterfly chart (alternate models on +/- y) :zbucketsize if no data for this many ‘x’, then insert a zero

Public Class Methods

new(opts={}) click to toggle source
Calls superclass method
# File lib/gerbilcharts/surfaces/area_surface.rb, line 14
def initialize(opts={})
  super(opts)
end

Public Instance Methods

int_render(g) click to toggle source
# File lib/gerbilcharts/surfaces/area_surface.rb, line 18
def int_render(g)
  range_options_x = parent.get_global_option(:scaling_x,:auto)
  range_options_y = parent.get_global_option(:scaling_y,:auto)
  butterfly       = parent.get_global_option(:butterfly,false)
  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)


  # any filters ?
  if parent.get_global_option(:filter,false)
    g.curr_win.add_options({:filter => "url(##{parent.get_global_option(:filter,false)})" })
  end 

  set_ajaxSurfaceContext(rx.rmax,ry.rmax,"AREA") if parent.usesAjax?

  # butterfly chart
  ry.update(-ry.rmax) if butterfly 

  y_zero = scale_y 0,ry

  f_squarize = parent.get_global_option(:squarize,false)
    
  parent.modelgroup.each_model_with_index do | mod, i|

    if f_squarize
      g.begin_squarized_polygon 
    else
      g.begin_polygon
    end

    firstpoint=true
    xpos,ypos=0,0
    last_x=nil
    mod.each_tuple do |x,y|

      y =-y if butterfly and i.odd?

      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

          # tooltip
              if parent.get_global_option(:circle_data_points,false)
                opts = {:id => "item#{i}"}
        opts.store(:gerbiltooltip1, x) 
        opts.store(:gerbiltooltip2, "Val = #{GerbilCharts::Models::Presets.new.format_suffix(y)}")
                g.circle(xpos,ypos,2,opts) 
              end

      g.polygon_point xpos,ypos

      
    end
   
    g.polygon_point xpos,y_zero
    g.end_polygon(:id => "item#{i}", "opacity"=>"0.8")
  end

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

end