Module: Easyfsf
- Included in:
- ApplicationHelper
- Defined in:
- lib/easyfsf.rb,
lib/easyfsf/version.rb,
lib/generators/easyfsf/easyfsf_generator.rb
Defined Under Namespace
Modules: FCFChartXmlBuilder, FCFInitializer, FCFRenderer Classes: EasyfsfGenerator
Constant Summary collapse
- VERSION =
"0.0.1"
Instance Method Summary collapse
-
#render_sm_chart(chart_id, chart_type, category, datasets, options = {}, chart_width = 700, chart_height = 500, show_total = false) ⇒ Object
To render single chart or multi chart, call
render_sm_chart
Depends on parameter it render single data chart or multi data chart You can use this method as helper.
Instance Method Details
#render_sm_chart(chart_id, chart_type, category, datasets, options = {}, chart_width = 700, chart_height = 500, show_total = false) ⇒ Object
To render single chart or multi chart, call render_sm_chart
Depends on parameter it render single data chart or multi data chart You can use this method as helper
<%= render_sm_chart(“a”, “Pie2D”, [‘a’,‘b’,‘c’], [1,2,3]) %>
<%= render_sm_chart(“b”, “Column3D”, [‘a’,‘b’,‘c’], [=> “se1”, :color => “FF0000”,:value_list => [1,2,3], => “se2”, :color => “F660AB”, :value_list => [3,4,5]]) %> <%= render_sm_chart(“b”, “Column3D”, [‘a’,‘b’,‘c’], [=> “se1”, :color => “FF0000”,:value_list => [1,2,3], => “se2”, :color => “F660AB”, :value_list => [3,4,5]],{}, 500, 400, true) %>
for detail infomation visit zerohun.wordpress.com/2012/01/06/easyfsf/ for the options parameter visit docs.fusioncharts.com/charts/
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/easyfsf.rb', line 20 def render_sm_chart(chart_id, chart_type, category, datasets, = {}, chart_width = 700, chart_height = 500, show_total = false) = .clone if .present? category = FCFInitializer.standardize_category(category) datasets = FCFInitializer.standardize_datasets(datasets) if [:skipCategory].present? category = FCFInitializer.skip_category(category, 10) .delete :skipCategory end isMultiChart = datasets.length > 1 chart_swf = FCFInitializer.get_swf_file_name(chart_type, isMultiChart) = FCFInitializer.get_default_option.merge() chart_html = "" if show_total == true chart_html << "<div id=#{chart_id}Div_total><br />" datasets.each do |dataset| total = 0 dataset[:value_list].each do |value| total += value end chart_html << "<p>Total #{dataset[:seriesName]} : #{total}</p>" end chart_html << "<br /></div>" end xmlString = FCFChartXmlBuilder.smchart_xml(category, datasets, ) chart_html << FCFRenderer.render_chart("/FusionChartsFree/Charts/#{chart_swf}", xmlString, chart_id, chart_width, chart_height) return chart_html.html_safe end |