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 :
-
A reddish gradient background
-
A stacked area surface to represent our data
-
Title overlay
-
Vertical labels on WEST
-
Horiz labels on SOUTH
-
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
Public Class Methods
# 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
all sub charts override this to create custom layouts
# File lib/gerbilcharts/charts/chart_base.rb, line 142 def create_chart_elements end
# File lib/gerbilcharts/charts/chart_base.rb, line 101 def modelgroup=(themodelgroup) setmodelgroup(themodelgroup) end
# File lib/gerbilcharts/charts/chart_base.rb, line 113 def render(outfile) @renderopts.merge!( :file => outfile ) render_base end
# File lib/gerbilcharts/charts/chart_base.rb, line 118 def render_all(opts) @renderopts.merge!(opts) render_base end
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 xfrag
# File lib/gerbilcharts/charts/chart_base.rb, line 124 def render_frag(xfrag) @renderopts.merge!( :xfrag => xfrag ) render_base end
render string
# File lib/gerbilcharts/charts/chart_base.rb, line 130 def render_string @renderopts.merge!( :string => "" ) render_base @renderopts[:string] end
Ajax context (custom parameters required by server)
# File lib/gerbilcharts/charts/chart_base.rb, line 152 def setAjaxContext(h) @thechart.set_ajaxContext(h) end
Ajax options (callback frequecy, URL, etc)
# File lib/gerbilcharts/charts/chart_base.rb, line 147 def setAjaxOptions(h) @thechart.set_ajaxOptions(h) end
# File lib/gerbilcharts/charts/chart_base.rb, line 88 def set_renderoptions=(opts) @renderopts.merge!(opts) end
click chart title to go somewhere else
# File lib/gerbilcharts/charts/chart_base.rb, line 137 def sethref(href) @thechart.sethref(href) end
# 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