class GerbilCharts::Charts::ChartBase

Chart base - sets up a container for surfaces

You can put together various chart elements and create your own chart types. In fact, all the charts in this module are nothing but a composition of various surfaces

The logic goes something like this :

  1. A reddish gradient background

  2. A stacked area surface to represent our data

  3. Title overlay

  4. Vertical labels on WEST

  5. Horiz labels on SOUTH

  6. Legend on EAST

*A note on stylesheets*

GerbilCharts uses a color scheme from a stylesheet. The stylesheets contain the coloring for each model.

Options common for all charts

:width

Width of the generated SVG chart in pixels

:height

Height of the generated SVG chart in pixels

:style

CSS Stylesheet to use for the chart (default = brushmetal.css see public gem directory)

Use "inline:css_name" to embed the stylesheet inline  default is to use xref
:scaling_x

Allowed values are :auto, :auto_0, and an array [min,max] (default = :auto)

:scaling_y

Allowed values are :auto, :auto_0, and an array [min,max] (default = :auto)

:circle_data_points

Draws a tiny circle around datapoints for tooltips

:enabletimetracker

Time tracker javascript selector (default = false)

:enablelinkpivots

Link Pivot box javascript selector (default = false)

Constants

ORIENT_EAST
ORIENT_NORTH

orientations (same as Surfaces::)

ORIENT_NORTHEAST
ORIENT_NORTHWEST
ORIENT_OVERLAY
ORIENT_OVERLAY_NORTH
ORIENT_OVERLAY_SOUTH
ORIENT_SOUTH
ORIENT_SOUTHEAST
ORIENT_SOUTHWEST
ORIENT_WEST

Attributes

feature_linkpivots[R]
feature_timetracker[R]
legend_width[R]
renderopts[R]
thechart[R]

Public Class Methods

new(opt={}) click to toggle source
# File lib/gerbilcharts/charts/chart_base.rb, line 57
def initialize(opt={})

  # suck out local options
  @enabletimetracker=false
  if opt[:enabletimetracker]
      @feature_timetracker=opt[:enabletimetracker]
      opt.delete :enabletimetracker
  end

  @enablelinkpivots=false
  if opt[:enablelinkpivots]
      @feature_linkpivots=opt[:enablelinkpivots]
      opt.delete :enablelinkpivots
  end
  
  @feature_circledatapoints=false
  if opt[:circle_data_points]
      @feature_circledatapoints=opt[:circle_data_points]
  end
  
  
  # pass on options to chart object
  @thechart = GerbilCharts::Surfaces::Chart.new(opt)
  @renderopts = {}

      # common relative widths
      @legend_width = [opt[:width]/4,100].max

      @gerbilfilter = opt[:filter] || ""
end

Public Instance Methods

create_chart_elements() click to toggle source

all sub charts override this to create custom layouts

# File lib/gerbilcharts/charts/chart_base.rb, line 142
def create_chart_elements
      
end
modelgroup=(themodelgroup) click to toggle source
# File lib/gerbilcharts/charts/chart_base.rb, line 101
def modelgroup=(themodelgroup)
      setmodelgroup(themodelgroup)
end
render(outfile) click to toggle source
# File lib/gerbilcharts/charts/chart_base.rb, line 113
def render(outfile)
  @renderopts.merge!( :file => outfile )
  render_base
end
render_all(opts) click to toggle source
# File lib/gerbilcharts/charts/chart_base.rb, line 118
def render_all(opts)
  @renderopts.merge!(opts)  
  render_base
end
render_base() click to toggle source

render options

:file => filename
:string => return a string
# File lib/gerbilcharts/charts/chart_base.rb, line 108
def render_base
  create_chart_elements
  @thechart.render(@renderopts)
end
render_frag(xfrag) click to toggle source

render xfrag

# File lib/gerbilcharts/charts/chart_base.rb, line 124
def render_frag(xfrag)
  @renderopts.merge!( :xfrag => xfrag )
  render_base
end
render_string() click to toggle source

render string

# File lib/gerbilcharts/charts/chart_base.rb, line 130
def render_string
  @renderopts.merge!( :string => "" )
  render_base
      @renderopts[:string]
end
setAjaxContext(h) click to toggle source

Ajax context (custom parameters required by server)

# File lib/gerbilcharts/charts/chart_base.rb, line 152
def setAjaxContext(h)
  @thechart.set_ajaxContext(h)
end
setAjaxOptions(h) click to toggle source

Ajax options (callback frequecy, URL, etc)

# File lib/gerbilcharts/charts/chart_base.rb, line 147
def setAjaxOptions(h)
  @thechart.set_ajaxOptions(h)
end
set_renderoptions=(opts) click to toggle source
# File lib/gerbilcharts/charts/chart_base.rb, line 88
def set_renderoptions=(opts)
      @renderopts.merge!(opts)
end
sethref(href) click to toggle source

click chart title to go somewhere else

# File lib/gerbilcharts/charts/chart_base.rb, line 137
def sethref(href)
  @thechart.sethref(href)
end
setmodelgroup(themodel) click to toggle source
# File lib/gerbilcharts/charts/chart_base.rb, line 92
def setmodelgroup(themodel)
  @thechart.set_modelgroup(themodel)
  
  # automatically set hrefs
  if themodel.hasHref?
    sethref(themodel.href)
  end
end