Module: Ambling::Helper
- Defined in:
- lib/ambling_helper.rb
Overview
:nodoc
Defined Under Namespace
Classes: AmblingHelperError
Instance Method Summary collapse
-
#ambling_chart(chart_type, chart_options = {}, &block) ⇒ Object
Generates chart object tag with given url to fetch the xml data.
Instance Method Details
#ambling_chart(chart_type, chart_options = {}, &block) ⇒ Object
Generates chart object tag with given url to fetch the xml data. See Ambling for examples Chart Options:
-
:width
- The width of the chart -
:height
- The height of the chart -
:swf_path
- The path that contains the chart.swf. Defaults to /amcharts -
:flash_version
- Supported flash version. Defaults to 8 -
:background_color
- The chart background color. Defaults to ‘#FFFFFF’ -
:preloader_color
- The color of the preloading text. Defaults to ‘#000000’ -
:express_install
- Use the swfobject express install if the browser does not have flash installed. Defaults to true -
:id
- The id of the DOM element that will be replaced -
:settings_file
- The path to the xml settings file (could be url) -
:chart_settings
- Inline xml settings. Use one of settings_file and chart_settings -
:swf_params
- Hash of params to be set on SWFObject (with so.addParam()). -
:additional_chart_settings
- More inline xml settings. -
:data_file
- The path to the xml data file (could be url) -
:chart_data
- Inline xml data. Use one of data_file and chart_data
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/ambling_helper.rb', line 28 def ambling_chart(chart_type, = {}, &block) = { :width => "400", :height => "300", :swf_path => CHART_PATH, :flash_version => "8", :background_color => "#FFFFFF", :preloader_color => "#000000", :express_install => true, :id => "ambling_chart" }.merge!() script = "var so = new SWFObject('#{[:swf_path]}/am#{chart_type}.swf', " + "'swf_#{[:id]}', '#{[:width]}', '#{[:height]}', " + "'#{[:flash_version]}', '#{[:background_color]}');" script << "so.addVariable('path', '#{[:swf_path]}/');" script << "so.useExpressInstall('#{[:swf_path]}/expressinstall.swf');" if [:express_install] script << add_variable(, :settings_file, true) script << add_variable(, :chart_settings) script << add_variable(, :chart_id) # this is needed for controlling charts with JS script << add_variable(, :additional_chart_settings) script << add_variable(, :data_file, true) script << add_variable(, :chart_data) script << add_variable(, :preloader_color) script << add_swf_params(, :swf_params, true) script << "so.write('#{[:id]}');" html = yield content_tag('div', html, :id => [:id]) + javascript_tag(script) end |