class GerbilCharts::Surfaces::LineSurface
Line Surface
¶ ↑
Simple line drawing 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/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/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) butterfly = parent.get_global_option(:butterfly,false) rx = parent.modelgroup.effective_range_x(range_options_x) ry = parent.modelgroup.effective_range_y(range_options_y) ry.update(-ry.rmax) if butterfly set_ajaxSurfaceContext(rx.rmax,ry.rmax,"LINE") if parent.usesAjax? draw_ref_model_lines(g,rx,ry) draw_range_bands(g,rx,ry) draw_annotations(g,rx,ry) parent.modelgroup.each_model_with_index do |mod,i| mod.each_tuple do |x,y| y = -y if butterfly and i.odd? # the basic line xpos = scale_x x,rx ypos = scale_y y,ry if mod.count==1 ypos0 = scale_y 0,ry g.lineto xpos,ypos0 end g.lineto xpos,ypos # tooltip if parent.get_global_option(:auto_tooltips,false) and 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 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-10, y95-5, y95label, {:class => "reflinelabel", "text-anchor" => "end"}) g.textout(@bounds.right-10, y95+15, "95th pct", {:class => "reflinelabel", "text-anchor" => "end"}) end end end