easyfsf 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. data/.DS_Store +0 -0
  2. data/.gitignore +4 -0
  3. data/.rspec +1 -0
  4. data/CHANGELOG.md +3 -0
  5. data/Gemfile +4 -0
  6. data/README +22 -0
  7. data/Rakefile +5 -0
  8. data/easyfsf.gemspec +24 -0
  9. data/lib/easyfsf.rb +312 -0
  10. data/lib/easyfsf/application_helper.rb +3 -0
  11. data/lib/easyfsf/version.rb +3 -0
  12. data/lib/generators/easyfsf/.DS_Store +0 -0
  13. data/lib/generators/easyfsf/easyfsf_generator.rb +15 -0
  14. data/lib/generators/easyfsf/templates/.DS_Store +0 -0
  15. data/lib/generators/easyfsf/templates/app/.DS_Store +0 -0
  16. data/lib/generators/easyfsf/templates/app/assets/javascripts/.DS_Store +0 -0
  17. data/lib/generators/easyfsf/templates/app/assets/javascripts/fusion_charts.js +401 -0
  18. data/lib/generators/easyfsf/templates/public/.DS_Store +0 -0
  19. data/lib/generators/easyfsf/templates/public/FusionChartsFree/.DS_Store +0 -0
  20. data/lib/generators/easyfsf/templates/public/FusionChartsFree/.svn/all-wcprops +5 -0
  21. data/lib/generators/easyfsf/templates/public/FusionChartsFree/.svn/entries +31 -0
  22. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/.DS_Store +0 -0
  23. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/.svn/all-wcprops +137 -0
  24. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/.svn/entries +776 -0
  25. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/.svn/prop-base/FCF_Area2D.swf.svn-base +5 -0
  26. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/.svn/prop-base/FCF_Bar2D.swf.svn-base +5 -0
  27. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/.svn/prop-base/FCF_Candlestick.swf.svn-base +5 -0
  28. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/.svn/prop-base/FCF_Column2D.swf.svn-base +5 -0
  29. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/.svn/prop-base/FCF_Column3D.swf.svn-base +5 -0
  30. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/.svn/prop-base/FCF_Doughnut2D.swf.svn-base +5 -0
  31. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/.svn/prop-base/FCF_Funnel.swf.svn-base +5 -0
  32. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/.svn/prop-base/FCF_Gantt.swf.svn-base +5 -0
  33. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/.svn/prop-base/FCF_Line.swf.svn-base +5 -0
  34. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/.svn/prop-base/FCF_MSArea2D.swf.svn-base +5 -0
  35. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/.svn/prop-base/FCF_MSBar2D.swf.svn-base +5 -0
  36. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/.svn/prop-base/FCF_MSColumn2D.swf.svn-base +5 -0
  37. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/.svn/prop-base/FCF_MSColumn2DLineDY.swf.svn-base +5 -0
  38. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/.svn/prop-base/FCF_MSColumn3D.swf.svn-base +5 -0
  39. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/.svn/prop-base/FCF_MSColumn3DLineDY.swf.svn-base +5 -0
  40. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/.svn/prop-base/FCF_MSLine.swf.svn-base +5 -0
  41. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/.svn/prop-base/FCF_Pie2D.swf.svn-base +5 -0
  42. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/.svn/prop-base/FCF_Pie3D.swf.svn-base +5 -0
  43. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/.svn/prop-base/FCF_StackedArea2D.swf.svn-base +5 -0
  44. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/.svn/prop-base/FCF_StackedBar2D.swf.svn-base +5 -0
  45. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/.svn/prop-base/FCF_StackedColumn2D.swf.svn-base +5 -0
  46. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/.svn/prop-base/FCF_StackedColumn3D.swf.svn-base +5 -0
  47. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/.svn/text-base/FCF_Area2D.swf.svn-base +0 -0
  48. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/.svn/text-base/FCF_Bar2D.swf.svn-base +0 -0
  49. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/.svn/text-base/FCF_Candlestick.swf.svn-base +0 -0
  50. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/.svn/text-base/FCF_Column2D.swf.svn-base +0 -0
  51. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/.svn/text-base/FCF_Column3D.swf.svn-base +0 -0
  52. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/.svn/text-base/FCF_Doughnut2D.swf.svn-base +0 -0
  53. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/.svn/text-base/FCF_Funnel.swf.svn-base +0 -0
  54. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/.svn/text-base/FCF_Gantt.swf.svn-base +0 -0
  55. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/.svn/text-base/FCF_Line.swf.svn-base +0 -0
  56. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/.svn/text-base/FCF_MSArea2D.swf.svn-base +0 -0
  57. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/.svn/text-base/FCF_MSBar2D.swf.svn-base +0 -0
  58. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/.svn/text-base/FCF_MSColumn2D.swf.svn-base +0 -0
  59. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/.svn/text-base/FCF_MSColumn2DLineDY.swf.svn-base +0 -0
  60. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/.svn/text-base/FCF_MSColumn3D.swf.svn-base +0 -0
  61. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/.svn/text-base/FCF_MSColumn3DLineDY.swf.svn-base +0 -0
  62. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/.svn/text-base/FCF_MSLine.swf.svn-base +0 -0
  63. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/.svn/text-base/FCF_Pie2D.swf.svn-base +0 -0
  64. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/.svn/text-base/FCF_Pie3D.swf.svn-base +0 -0
  65. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/.svn/text-base/FCF_StackedArea2D.swf.svn-base +0 -0
  66. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/.svn/text-base/FCF_StackedBar2D.swf.svn-base +0 -0
  67. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/.svn/text-base/FCF_StackedColumn2D.swf.svn-base +0 -0
  68. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/.svn/text-base/FCF_StackedColumn3D.swf.svn-base +0 -0
  69. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/FCF_Area2D.swf +0 -0
  70. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/FCF_Bar2D.swf +0 -0
  71. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/FCF_Candlestick.swf +0 -0
  72. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/FCF_Column2D.swf +0 -0
  73. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/FCF_Column3D.swf +0 -0
  74. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/FCF_Doughnut2D.swf +0 -0
  75. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/FCF_Funnel.swf +0 -0
  76. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/FCF_Gantt.swf +0 -0
  77. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/FCF_Line.swf +0 -0
  78. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/FCF_MSArea2D.swf +0 -0
  79. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/FCF_MSBar2D.swf +0 -0
  80. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/FCF_MSColumn2D.swf +0 -0
  81. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/FCF_MSColumn2DLineDY.swf +0 -0
  82. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/FCF_MSColumn3D.swf +0 -0
  83. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/FCF_MSColumn3DLineDY.swf +0 -0
  84. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/FCF_MSLine.swf +0 -0
  85. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/FCF_Pie2D.swf +0 -0
  86. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/FCF_Pie3D.swf +0 -0
  87. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/FCF_StackedArea2D.swf +0 -0
  88. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/FCF_StackedBar2D.swf +0 -0
  89. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/FCF_StackedColumn2D.swf +0 -0
  90. data/lib/generators/easyfsf/templates/public/FusionChartsFree/Charts/FCF_StackedColumn3D.swf +0 -0
  91. data/master +0 -0
  92. data/spec/easyfsf/easyfsf_spec.rb +13 -0
  93. data/spec/spec_helper.rb +4 -0
  94. metadata +162 -0
data/.DS_Store ADDED
Binary file
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ ## v0.0.1
2
+
3
+ *initial release
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in easyfsf.gemspec
4
+ gemspec
data/README ADDED
@@ -0,0 +1,22 @@
1
+ Simplize using Fusionchartfree for ruby on rails
2
+
3
+
4
+ First you should generate swf files
5
+
6
+ rails g easyfsf
7
+
8
+
9
+ and then you can render chart by using helper method
10
+
11
+ example
12
+
13
+
14
+ <%= render_sm_chart("a", "Pie2D", ['a','b','c'], [1,2,3]) %>
15
+ <%= render_sm_chart("b", "Column3D", ['a','b','c'], [{:seriesName => "se1", :color => "FF0000",:value_list => [1,2,3]}, {:seriesName => "se2", :color => "F660AB", :value_list => [3,4,5]}]) %>
16
+
17
+
18
+ if you want better example including some images, visit http://zerohun.wordpress.com/2012/01/06/easyfsf/
19
+
20
+
21
+
22
+
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+ task default: :spec
data/easyfsf.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "easyfsf/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "easyfsf"
7
+ s.version = Easyfsf::VERSION
8
+ s.authors = ["Younghun Choi"]
9
+ s.email = ["choi0hun@gmail.com"]
10
+ s.homepage = "http://zerohun.wordpress.com/2012/01/06/easyfsf/"
11
+ s.summary = "Simplie using Fusion chart free for ruby on rails"
12
+ s.description = "one helper method render chart"
13
+
14
+ s.rubyforge_project = "easyfsf"
15
+
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+
22
+ s.add_development_dependency "rails", "~> 3.0.0"
23
+ s.add_development_dependency "rspec"
24
+ end
data/lib/easyfsf.rb ADDED
@@ -0,0 +1,312 @@
1
+ require "easyfsf/version"
2
+ require "easyfsf/application_helper" if defined? Rails
3
+ require "builder"
4
+
5
+
6
+ module Easyfsf
7
+
8
+ #To render single chart or multi chart, call <tt>render_sm_chart</tt>
9
+ #Depends on parameter it render single data chart or multi data chart
10
+ #You can use this method as helper
11
+ #
12
+ #<%= render_sm_chart("a", "Pie2D", ['a','b','c'], [1,2,3]) %>
13
+ #
14
+ #<%= render_sm_chart("b", "Column3D", ['a','b','c'], [{:seriesName => "se1", :color => "FF0000",:value_list => [1,2,3]}, {:seriesName => "se2", :color => "F660AB", :value_list => [3,4,5]}]) %>
15
+ #<%= render_sm_chart("b", "Column3D", ['a','b','c'], [{:seriesName => "se1", :color => "FF0000",:value_list => [1,2,3]}, {:seriesName => "se2", :color => "F660AB", :value_list => [3,4,5]}],{}, 500, 400, true) %>
16
+ #
17
+ #for detail infomation visit http://zerohun.wordpress.com/2012/01/06/easyfsf/
18
+ #for the options parameter visit http://docs.fusioncharts.com/charts/
19
+
20
+ def render_sm_chart(chart_id, chart_type, category, datasets, options = {}, chart_width = 700, chart_height = 500, show_total = false)
21
+
22
+ options = options.clone if options.present?
23
+ category = FCFInitializer.standardize_category(category)
24
+ datasets = FCFInitializer.standardize_datasets(datasets)
25
+
26
+ if options[:skipCategory].present?
27
+ category = FCFInitializer.skip_category(category, 10)
28
+ options.delete :skipCategory
29
+ end
30
+
31
+ isMultiChart = datasets.length > 1
32
+ chart_swf = FCFInitializer.get_swf_file_name(chart_type, isMultiChart)
33
+ options = FCFInitializer.get_default_option.merge(options)
34
+ chart_html = ""
35
+ if show_total == true
36
+ chart_html << "<div id=#{chart_id}Div_total><br />"
37
+ datasets.each do |dataset|
38
+ total = 0
39
+ dataset[:value_list].each do |value|
40
+ total += value
41
+ end
42
+ chart_html << "<p>Total #{dataset[:seriesName]} : #{total}</p>"
43
+ end
44
+ chart_html << "<br /></div>"
45
+ end
46
+ xmlString = FCFChartXmlBuilder.smchart_xml(category, datasets, options)
47
+ chart_html << FCFRenderer.render_chart("/FusionChartsFree/Charts/#{chart_swf}", xmlString, chart_id, chart_width, chart_height)
48
+ return chart_html.html_safe
49
+ end
50
+
51
+
52
+
53
+ module FCFInitializer
54
+ #default optinoss
55
+ DEFAULT_OPTIONS = {
56
+ :caption => "",
57
+ :subcaption => "",
58
+ :lineThickness => "5",
59
+ :showValues => "0",
60
+ :formatNumberScale => "0",
61
+ :anchorRadius => "5",
62
+ :divLineAlpha => "20" ,
63
+ :divLineColor => "CC3300",
64
+ :showAlternateHGridColor => "1",
65
+ :alternateHGridColor => "CC3300",
66
+ :rotateNames => "1",
67
+ :shadowAlpha => "40",
68
+ :numvdivlines => "5",
69
+ :chartLeftMargin => "5",
70
+ :chartRightMargin => "5",
71
+ :chartTopMargin => "5",
72
+ :chartBottomMargin => "5",
73
+ :bgColor => "FFFFFF",
74
+ :alternateHGridAlpha => "5",
75
+ :limitsDecimalPrecision => '0',
76
+ :divLineDecimalPrecision => '0',
77
+ :decimalPrecision => "0",
78
+ :yAxisMaxValue => "10",
79
+ :lineThickness => "2",
80
+ :anchorRadius => "1"
81
+ }
82
+
83
+
84
+
85
+ #to file swf files
86
+ #chart difinition for rendering single chart
87
+ ONLY_SINGLE_CHART = ["Pie2D", "Pie3D", "Funnel"]
88
+
89
+ #chart difinition for rendering multi chart
90
+ ONLY_MULTI_CHART = ["StackedArea2D", "StackedBar2D", "StackedColumn2D",
91
+ "StackedColumn3D", "MSColumn2DLineDY", "MSColumn3DLineDY"]
92
+
93
+ #chart difinition for rendering single and multi chart
94
+ BOTH_CAPABLE_CHART = ["Line", "Area2D", "Bar2D", "Column2D", "Column3D"]
95
+ @chartIdList = []
96
+
97
+ def self.get_default_option
98
+ DEFAULT_OPTIONS
99
+ end
100
+
101
+
102
+ def self.get_swf_file_name(chart_type, isMulti)
103
+ if ONLY_SINGLE_CHART.include? chart_type
104
+ if isMulti
105
+ raise ArgumentError, "#{chart_type} can draw only single chart data but it's multichart data"
106
+ else
107
+ return "FCF_#{chart_type}.swf"
108
+ end
109
+ end
110
+ if ONLY_MULTI_CHART.include? chart_type
111
+ if isMulti
112
+ return "FCF_#{chart_type}.swf"
113
+ else
114
+ raise ArgumentError, "#{chart_type} can draw only multichart data but it's singlechart data"
115
+ end
116
+ end
117
+ if BOTH_CAPABLE_CHART.include? chart_type
118
+ if isMulti
119
+ return "FCF_MS#{chart_type}.swf"
120
+ else
121
+ return "FCF_#{chart_type}.swf"
122
+ end
123
+ end
124
+ raise ArgumentError, "there is no #{chart_type} type"
125
+ end
126
+
127
+
128
+ def self.standardize_category(category)
129
+ case check_category_params(category)
130
+ when :STRING_ARRAY
131
+ return {:value_list => category.map {|c| c.to_s}}
132
+ when :HASH
133
+ return category.clone
134
+ else
135
+ raise ArgumentError,
136
+ "First parameter should be Hash, Array of String or Array of something that can be converted to String"
137
+ end
138
+ end
139
+
140
+
141
+ def self.standardize_datasets(datasets)
142
+ case check_datasets_params(datasets)
143
+ when :NUM_ARRAY
144
+ return [{:value_list => datasets}]
145
+ when :HASH_ARRAY
146
+ clonedDataSets = []
147
+ datasets.each do |dataset|
148
+ clonedDataSets << dataset.clone
149
+ end
150
+ return clonedDataSets
151
+ when :HASH
152
+ return [datasets.clone]
153
+ else
154
+ raise ArgumentError,
155
+ "parameters should be Hash, Array of Hash , Array of Fixum or Array of Float"
156
+ end
157
+ end
158
+ def self.check_category_params(category)
159
+ if category.is_a? Array
160
+ return :STRING_ARRAY if category[0].respond_to?(:to_s)
161
+ end
162
+ if category.is_a? Hash
163
+ return :HASH if category[:value_list]
164
+ end
165
+ return :SOMETHING_ELSE
166
+ end
167
+
168
+ def self.check_datasets_params(datasets)
169
+ if datasets.is_a? Array
170
+ return :NUM_ARRAY if datasets[0].is_a? Fixnum or datasets[0].is_a? Float
171
+ if datasets[0].is_a? Hash
172
+ datasets.each_with_index do |dataset, index|
173
+ raise ArgumentError,
174
+ "There is a nil value_list in datasets(name: #{dataset[:seriesName]} ,index:#{index})" if dataset[:value_list].blank?
175
+ end
176
+ return :HASH_ARRAY
177
+ end
178
+ end
179
+ if datasets.is_a? Hash
180
+ return :HASH if datasets[:value_list].present?
181
+ end
182
+ return :SOMETHING_ELSE
183
+ end
184
+
185
+ #skipSize에 맞춰 category의 value_list를 빈 문자열로 교체합니다.
186
+ def self.skip_category(category, skipSize)
187
+ newValueList = category[:value_list].each_with_index.map{ |value,index|
188
+ next value if (index+1)%(skipSize+1) == 1
189
+ next ""
190
+ }
191
+ return category.merge(:value_list => newValueList)
192
+ end
193
+ end
194
+
195
+ module FCFRenderer
196
+ #차트의 xml 데이타를 <fusionchatfree />형식으로 나타내어서 javascript 코드에서 파싱해서
197
+ #차트를 그려줄 수 있게끔 합니다.
198
+ def self.render_chart(chart_swf, chart_xml, chart_id , chart_width, chart_height)
199
+ chart_width=chart_width.to_s
200
+ chart_height=chart_height.to_s
201
+ htmlString = ""
202
+ htmlString << "<div id='#{chart_id}Div' class='fusionchart'>\n\t\t\t\tChart.\n\t\t"
203
+ htmlString << "<fusionchartfree swf='#{chart_swf}' chart_id='#{chart_id}' chart_width='#{chart_width}' chart_height='#{chart_height}' chart_xml='#{chart_xml}' />"
204
+ htmlString << "</div>"
205
+ return htmlString
206
+ end
207
+ end
208
+
209
+ module FCFChartXmlBuilder
210
+
211
+ # for randomize color
212
+ @FC_ColorCounter=0;
213
+ @arr_FCColors=["1941A5", "AFD8F8", "F6BD0F", "8BBA00", "A66EDD", "F984A1",
214
+ "CCCC00", "999999", "0099CC", "FF0000", "006F00", "0099FF",
215
+ "FF66CC", "669966", "7C7CB4", "FF9933", "9900FF", "99FFCC",
216
+ "CCCCFF", "669900"]
217
+
218
+ # Generate xml for chart
219
+ # examples
220
+ #
221
+ # for single charts
222
+ #<graph yAxisName='Sales Figure'
223
+ # caption='Top 5 Sales Person'
224
+ # numberPrefix='$'
225
+ # decimalPrecision='1'
226
+ # divlinedecimalPrecision='0'
227
+ # limitsdecimalPrecision='0'>
228
+ # <set name='Alex' value='25000' color='AFD8F8'/>
229
+ # <set name='Mark' value='35000' color='F6BD0F'/>
230
+ # <set name='John' value='31300' color='008E8E'/>
231
+ #
232
+ #</graph>
233
+ #
234
+ # for multi charts
235
+ #<graph yAxisName='Sales Figure'
236
+ # caption='Top 5 Sales Person'
237
+ # numberPrefix='$'
238
+ # decimalPrecision='1'
239
+ # divlinedecimalPrecision='0'
240
+ # limitsdecimalPrecision='0'>
241
+ # <categories>
242
+ # <category name="Jan"/>
243
+ # <category name="Feb"/>
244
+ # <category name="Apr"/>
245
+ # </categories>
246
+ # <dataset seriesName="Current Year" color="A66EDD">
247
+ # <set value="1127654"/>
248
+ # <set value="1226234"/>
249
+ # <set value="1311565"/>
250
+ #
251
+ # </dataset>
252
+ # <dataset seriesName="Previous Year" color="F6BD0F">
253
+ # <set value="927654"/>
254
+ # <set value="1126234"/>
255
+ # <set value="1111565"/>
256
+ #
257
+ # </dataset>
258
+ #</graph>
259
+
260
+ def self.smchart_xml(category, datasets, options = {})
261
+ if options[:sectionSize].present?
262
+ category[:value_list] = erase_sections(category[:value_list], options[:sectionSize])
263
+ options.delete :sectionSize
264
+ end
265
+
266
+ xml = ::Builder::XmlMarkup.new(:indent=>0)
267
+ #pOptions[:caption] = getCaption(valueDatas)
268
+ xml.graph(options) do
269
+ if datasets.length == 1
270
+ category[:value_list].length.times do |index|
271
+ dataset = datasets[0]
272
+ color = category[:color_list].blank? ? "":category[:color_list][index]
273
+ xml.set(:name => category[:value_list][index],
274
+ :value => dataset[:value_list][index],
275
+ :color => color)
276
+ end
277
+ else
278
+ xml.categories do
279
+ category[:value_list].length.times do |index|
280
+ xml.category(:name => category[:value_list][index])
281
+ end
282
+ end
283
+ datasets.each do |dataset|
284
+ dataset[:color] = dataset[:color].blank? ? get_FC_color : dataset[:color]
285
+ valueList = dataset[:value_list].clone
286
+ dataset.delete :value_list
287
+ xml.dataset(dataset) do
288
+ valueList.each do |value|
289
+ xml.set(:value => value)
290
+ end
291
+ end
292
+ end
293
+ end
294
+ end
295
+ xmlString = xml.to_s
296
+ return xmlString[0..xmlString.length - 8]
297
+ end
298
+
299
+
300
+
301
+ def self.get_FC_color
302
+ #Update index
303
+ @FC_ColorCounter=@FC_ColorCounter+1
304
+ counter = @FC_ColorCounter % (@arr_FCColors.size)
305
+ #Return color
306
+ return @arr_FCColors[counter]
307
+ end
308
+ end
309
+
310
+ end
311
+
312
+
@@ -0,0 +1,3 @@
1
+ module ApplicationHelper
2
+ include Easyfsf
3
+ end
@@ -0,0 +1,3 @@
1
+ module Easyfsf
2
+ VERSION = "0.0.1"
3
+ end
Binary file
@@ -0,0 +1,15 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/rails/app/app_generator'
3
+ require 'rails/version'
4
+
5
+ module Easyfsf
6
+ class EasyfsfGenerator < Rails::Generators::Base
7
+ source_root File.expand_path("../templates", __FILE__)
8
+ def copy_temeplate_files
9
+
10
+ directory 'app'
11
+ directory 'public'
12
+
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,401 @@
1
+ /**
2
+ * FusionCharts: Flash Player detection and Chart embedding.
3
+ * Version 1.2.3F ( 22 November 2008) - Specialized for FusionChartsFREE
4
+ * Checking Flash Version >=6 and added updateChartXML() for FREE Charts.
5
+ * Version: 1.2.3 (1st September, 2008) - Added Fix for % and & characters, scaled dimensions, fixes in to properly handling of double quotes and single quotes in setDataXML() function.
6
+ * Version: 1.2.2 (10th July, 2008) - Added Fix for % scaled dimensions, fixes in setDataXML() and setDataURL() functions
7
+ * Version: 1.2.1 (21st December, 2007) - Added setting up Transparent/opaque mode: setTransparent() function
8
+ * Version: 1.2 (1st November, 2007) - Added FORM fixes for IE
9
+ * Version: 1.1 (29th June, 2007) - Added Player detection, New conditional fixes for IE
10
+ *
11
+ * Morphed from SWFObject (http://blog.deconcept.com/swfobject/) under MIT License:
12
+ * http://www.opensource.org/licenses/mit-license.php
13
+ *
14
+ */
15
+ if(typeof infosoftglobal == "undefined") var infosoftglobal = new Object();
16
+ if(typeof infosoftglobal.FusionChartsUtil == "undefined") infosoftglobal.FusionChartsUtil = new Object();
17
+ infosoftglobal.FusionCharts = function(swf, id, w, h, debugMode, registerWithJS, c, scaleMode, lang, detectFlashVersion, autoInstallRedirect){
18
+ if (!document.getElementById) { return; }
19
+
20
+ //Flag to see whether data has been set initially
21
+ this.initialDataSet = false;
22
+
23
+ //Create container objects
24
+ this.params = new Object();
25
+ this.variables = new Object();
26
+ this.attributes = new Array();
27
+
28
+ //Set attributes for the SWF
29
+ if(swf) { this.setAttribute('swf', swf); }
30
+ if(id) { this.setAttribute('id', id); }
31
+
32
+ w=w.toString().replace(/\%$/,"%25");
33
+ if(w) { this.setAttribute('width', w); }
34
+ h=h.toString().replace(/\%$/,"%25");
35
+ if(h) { this.setAttribute('height', h); }
36
+
37
+
38
+ //Set background color
39
+ if(c) { this.addParam('bgcolor', c); }
40
+
41
+ //Set Quality
42
+ this.addParam('quality', 'high');
43
+
44
+ //Add scripting access parameter
45
+ this.addParam('allowScriptAccess', 'always');
46
+
47
+ //Pass width and height to be appended as chartWidth and chartHeight
48
+ this.addVariable('chartWidth', w);
49
+ this.addVariable('chartHeight', h);
50
+
51
+ //Whether in debug mode
52
+ debugMode = debugMode ? debugMode : 0;
53
+ this.addVariable('debugMode', debugMode);
54
+ //Pass DOM ID to Chart
55
+ this.addVariable('DOMId', id);
56
+ //Whether to registed with JavaScript
57
+ registerWithJS = registerWithJS ? registerWithJS : 0;
58
+ this.addVariable('registerWithJS', registerWithJS);
59
+
60
+ //Scale Mode of chart
61
+ scaleMode = scaleMode ? scaleMode : 'noScale';
62
+ this.addVariable('scaleMode', scaleMode);
63
+
64
+ //Application Message Language
65
+ lang = lang ? lang : 'EN';
66
+ this.addVariable('lang', lang);
67
+
68
+ //Whether to auto detect and re-direct to Flash Player installation
69
+ this.detectFlashVersion = detectFlashVersion?detectFlashVersion:1;
70
+ this.autoInstallRedirect = autoInstallRedirect?autoInstallRedirect:1;
71
+
72
+ //Ger Flash Player version
73
+ this.installedVer = infosoftglobal.FusionChartsUtil.getPlayerVersion();
74
+
75
+ if (!window.opera && document.all && this.installedVer.major > 7) {
76
+ // Only add the onunload cleanup if the Flash Player version supports External Interface and we are in IE
77
+ infosoftglobal.FusionCharts.doPrepUnload = true;
78
+ }
79
+ }
80
+
81
+ infosoftglobal.FusionCharts.prototype = {
82
+ setAttribute: function(name, value){
83
+ this.attributes[name] = value;
84
+ },
85
+ getAttribute: function(name){
86
+ return this.attributes[name];
87
+ },
88
+ addParam: function(name, value){
89
+ this.params[name] = value;
90
+ },
91
+ getParams: function(){
92
+ return this.params;
93
+ },
94
+ addVariable: function(name, value){
95
+ this.variables[name] = value;
96
+ },
97
+ getVariable: function(name){
98
+ return this.variables[name];
99
+ },
100
+ getVariables: function(){
101
+ return this.variables;
102
+ },
103
+ getVariablePairs: function(){
104
+ var variablePairs = new Array();
105
+ var key;
106
+ var variables = this.getVariables();
107
+ for(key in variables){
108
+ variablePairs.push(key +"="+ variables[key]);
109
+ }
110
+ return variablePairs;
111
+ },
112
+ getSWFHTML: function() {
113
+ var swfNode = "";
114
+ if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) {
115
+ // netscape plugin architecture
116
+ swfNode = '<embed wmode="transparent" type="application/x-shockwave-flash" src="'+ this.getAttribute('swf') +'" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'" ';
117
+ swfNode += ' id="'+ this.getAttribute('id') +'" name="'+ this.getAttribute('id') +'" ';
118
+ var params = this.getParams();
119
+ for(var key in params){ swfNode += [key] +'="'+ params[key] +'" '; }
120
+ var pairs = this.getVariablePairs().join("&");
121
+ if (pairs.length > 0){ swfNode += 'flashvars="'+ pairs +'"'; }
122
+ swfNode += '/>';
123
+ } else { // PC IE
124
+ swfNode = '<object id="'+ this.getAttribute('id') +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'">';
125
+ swfNode += '<param name="movie" value="'+ this.getAttribute('swf') +'" />';
126
+ swfNode += '<param name="wmode" value="transparent">'
127
+ var params = this.getParams();
128
+ for(var key in params) {
129
+ swfNode += '<param name="'+ key +'" value="'+ params[key] +'" />';
130
+ }
131
+ var pairs = this.getVariablePairs().join("&");
132
+ if(pairs.length > 0) {swfNode += '<param name="flashvars" value="'+ pairs +'" />';}
133
+ swfNode += "</object>";
134
+ }
135
+ return swfNode;
136
+ },
137
+ setDataURL: function(strDataURL){
138
+ //This method sets the data URL for the chart.
139
+ //If being set initially
140
+ if (this.initialDataSet==false){
141
+ this.addVariable('dataURL',strDataURL);
142
+ //Update flag
143
+ this.initialDataSet = true;
144
+ }else{
145
+ //Else, we update the chart data using External Interface
146
+ //Get reference to chart object
147
+ var chartObj = infosoftglobal.FusionChartsUtil.getChartObject(this.getAttribute('id'));
148
+
149
+ if (!chartObj.setDataURL)
150
+ {
151
+ __flash__addCallback(chartObj, "setDataURL");
152
+ }
153
+
154
+ chartObj.setDataURL(strDataURL);
155
+ }
156
+ },
157
+ //This function :
158
+ //fixes the double quoted attributes to single quotes
159
+ //Encodes all quotes inside attribute values
160
+ //Encodes % to %25 and & to %26;
161
+ encodeDataXML: function(strDataXML){
162
+
163
+ var regExpReservedCharacters=["\\$","\\+"];
164
+ var arrDQAtt=strDataXML.match(/=\s*\".*?\"/g);
165
+ if (arrDQAtt){
166
+ for(var i=0;i<arrDQAtt.length;i++){
167
+ var repStr=arrDQAtt[i].replace(/^=\s*\"|\"$/g,"");
168
+ repStr=repStr.replace(/\'/g,"%26apos;");
169
+ var strTo=strDataXML.indexOf(arrDQAtt[i]);
170
+ var repStrr="='"+repStr+"'";
171
+ var strStart=strDataXML.substring(0,strTo);
172
+ var strEnd=strDataXML.substring(strTo+arrDQAtt[i].length);
173
+ var strDataXML=strStart+repStrr+strEnd;
174
+ }
175
+ }
176
+
177
+ strDataXML=strDataXML.replace(/\"/g,"%26quot;");
178
+ strDataXML=strDataXML.replace(/%(?![\da-f]{2}|[\da-f]{4})/ig,"%25");
179
+ strDataXML=strDataXML.replace(/\&/g,"%26");
180
+
181
+ return strDataXML;
182
+
183
+ },
184
+ setDataXML: function(strDataXML){
185
+ //If being set initially
186
+ if (this.initialDataSet==false){
187
+ //This method sets the data XML for the chart INITIALLY.
188
+ this.addVariable('dataXML',this.encodeDataXML(strDataXML));
189
+ //Update flag
190
+ this.initialDataSet = true;
191
+ }else{
192
+ //Else, we update the chart data using External Interface
193
+ //Get reference to chart object
194
+ var chartObj = infosoftglobal.FusionChartsUtil.getChartObject(this.getAttribute('id'));
195
+ chartObj.setDataXML(strDataXML);
196
+ }
197
+ },
198
+ setTransparent: function(isTransparent){
199
+ //Sets chart to transparent mode when isTransparent is true (default)
200
+ //When no parameter is passed, we assume transparent to be true.
201
+ if(typeof isTransparent=="undefined") {
202
+ isTransparent=true;
203
+ }
204
+ //Set the property
205
+ if(isTransparent)
206
+ this.addParam('WMode', 'transparent');
207
+ else
208
+ this.addParam('WMode', 'Opaque');
209
+ },
210
+ remove: function(chartId){},
211
+
212
+ render: function(elementId){
213
+ //First check for installed version of Flash Player - we need a minimum of 6
214
+ if((this.detectFlashVersion==1) && (this.installedVer.major < 6)){
215
+ if (this.autoInstallRedirect==1){
216
+ //If we can auto redirect to install the player?
217
+ var installationConfirm = window.confirm("You need Adobe Flash Player 6 (or above) to view the charts. It is a free and lightweight installation from Adobe.com. Please click on Ok to install the same.");
218
+ if (installationConfirm){
219
+ window.location = "http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash";
220
+ }else{
221
+ return false;
222
+ }
223
+ }else{
224
+ //Else, do not take an action. It means the developer has specified a message in the DIV (and probably a link).
225
+ //So, expect the developers to provide a course of way to their end users.
226
+ //window.alert("You need Adobe Flash Player 8 (or above) to view the charts. It is a free and lightweight installation from Adobe.com. ");
227
+ return false;
228
+ }
229
+ }else{
230
+ //Render the chart
231
+ var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId;
232
+ n.innerHTML = this.getSWFHTML();
233
+
234
+ //Added <FORM> compatibility
235
+ //Check if it's added in Mozilla embed array or if already exits
236
+ if(!document.embeds[this.getAttribute('id')] && !window[this.getAttribute('id')])
237
+ window[this.getAttribute('id')]=document.getElementById(this.getAttribute('id'));
238
+ //or else document.forms[formName/formIndex][chartId]
239
+ return true;
240
+ }
241
+ }
242
+ }
243
+
244
+ /* ---- detection functions ---- */
245
+ infosoftglobal.FusionChartsUtil.getPlayerVersion = function(){
246
+ var PlayerVersion = new infosoftglobal.PlayerVersion([0,0,0]);
247
+ if(navigator.plugins && navigator.mimeTypes.length){
248
+ var x = navigator.plugins["Shockwave Flash"];
249
+ if(x && x.description) {
250
+ PlayerVersion = new infosoftglobal.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
251
+ }
252
+ }else if (navigator.userAgent && navigator.userAgent.indexOf("Windows CE") >= 0){
253
+ //If Windows CE
254
+ var axo = 1;
255
+ var counter = 3;
256
+ while(axo) {
257
+ try {
258
+ counter++;
259
+ axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+ counter);
260
+ PlayerVersion = new infosoftglobal.PlayerVersion([counter,0,0]);
261
+ } catch (e) {
262
+ axo = null;
263
+ }
264
+ }
265
+ } else {
266
+ // Win IE (non mobile)
267
+ // Do minor version lookup in IE, but avoid Flash Player 6 crashing issues
268
+ try{
269
+ var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
270
+ }catch(e){
271
+ try {
272
+ var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
273
+ PlayerVersion = new infosoftglobal.PlayerVersion([6,0,21]);
274
+ axo.AllowScriptAccess = "always"; // error if player version < 6.0.47 (thanks to Michael Williams @ Adobe for this code)
275
+ } catch(e) {
276
+ if (PlayerVersion.major == 6) {
277
+ return PlayerVersion;
278
+ }
279
+ }
280
+ try {
281
+ axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
282
+ } catch(e) {}
283
+ }
284
+ if (axo != null) {
285
+ PlayerVersion = new infosoftglobal.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
286
+ }
287
+ }
288
+ return PlayerVersion;
289
+ }
290
+ infosoftglobal.PlayerVersion = function(arrVersion){
291
+ this.major = arrVersion[0] != null ? parseInt(arrVersion[0]) : 0;
292
+ this.minor = arrVersion[1] != null ? parseInt(arrVersion[1]) : 0;
293
+ this.rev = arrVersion[2] != null ? parseInt(arrVersion[2]) : 0;
294
+ }
295
+ // ------------ Fix for Out of Memory Bug in IE in FP9 ---------------//
296
+ /* Fix for video streaming bug */
297
+ infosoftglobal.FusionChartsUtil.cleanupSWFs = function() {
298
+ var objects = document.getElementsByTagName("OBJECT");
299
+ for (var i = objects.length - 1; i >= 0; i--) {
300
+ objects[i].style.display = 'none';
301
+ for (var x in objects[i]) {
302
+ if (typeof objects[i][x] == 'function') {
303
+ objects[i][x] = function(){};
304
+ }
305
+ }
306
+ }
307
+ }
308
+ // Fixes bug in fp9
309
+ if (infosoftglobal.FusionCharts.doPrepUnload) {
310
+ if (!infosoftglobal.unloadSet) {
311
+ infosoftglobal.FusionChartsUtil.prepUnload = function() {
312
+ __flash_unloadHandler = function(){};
313
+ __flash_savedUnloadHandler = function(){};
314
+ window.attachEvent("onunload", infosoftglobal.FusionChartsUtil.cleanupSWFs);
315
+ }
316
+ window.attachEvent("onbeforeunload", infosoftglobal.FusionChartsUtil.prepUnload);
317
+ infosoftglobal.unloadSet = true;
318
+ }
319
+ }
320
+ /* Add document.getElementById if needed (mobile IE < 5) */
321
+ if (!document.getElementById && document.all) { document.getElementById = function(id) { return document.all[id]; }}
322
+ /* Add Array.push if needed (ie5) */
323
+ if (Array.prototype.push == null) { Array.prototype.push = function(item) { this[this.length] = item; return this.length; }}
324
+
325
+ /* Function to return Flash Object from ID */
326
+ infosoftglobal.FusionChartsUtil.getChartObject = function(id)
327
+ {
328
+ var chartRef=null;
329
+ if (navigator.appName.indexOf("Microsoft Internet")==-1) {
330
+ if (document.embeds && document.embeds[id])
331
+ chartRef = document.embeds[id];
332
+ else
333
+ chartRef = window.document[id];
334
+ }
335
+ else {
336
+ chartRef = window[id];
337
+ }
338
+ if (!chartRef)
339
+ chartRef = document.getElementById(id);
340
+
341
+ return chartRef;
342
+ }
343
+ /*
344
+ Function to update chart's data at client side (FOR FusionCharts vFREE and 2.x
345
+ */
346
+ infosoftglobal.FusionChartsUtil.updateChartXML = function(chartId, strXML){
347
+ //Get reference to chart object
348
+ var chartObj = infosoftglobal.FusionChartsUtil.getChartObject(chartId);
349
+ //Set dataURL to null
350
+ chartObj.SetVariable("_root.dataURL","");
351
+ //Set the flag
352
+ chartObj.SetVariable("_root.isNewData","1");
353
+ //Set the actual data
354
+ chartObj.SetVariable("_root.newData",strXML);
355
+ //Go to the required frame
356
+ chartObj.TGotoLabel("/", "JavaScriptHandler");
357
+ }
358
+
359
+ /* Aliases for easy usage */
360
+ var getChartFromId = infosoftglobal.FusionChartsUtil.getChartObject;
361
+ var updateChartXML = infosoftglobal.FusionChartsUtil.updateChartXML;
362
+ var FusionCharts = infosoftglobal.FusionCharts;
363
+
364
+ /*
365
+ * <fusionchartfree> 엘리먼트를 파싱해서 attibute에 맞춰 차트를 생성합니다.
366
+ */
367
+
368
+ function render_element(element){
369
+ var $chart = $(element)
370
+ var chart_id = $chart.attr("chart_id");
371
+ var chart_swf = $chart.attr("swf")
372
+ var chart_width = $chart.attr("chart_width");
373
+ var chart_height = $chart.attr("chart_height");
374
+ var chart_xml = $chart.attr("chart_xml");
375
+ var chart_object = new FusionCharts(chart_swf, chart_id, chart_width, chart_height, "0", "0");
376
+ var div_id_ar = []
377
+ div_id_ar[div_id_ar.length] = chart_id
378
+ div_id_ar[div_id_ar.length] = 'Div'
379
+ var div_id_str = div_id_ar.join("")
380
+ chart_object.setDataXML(chart_xml);
381
+ chart_object.render(div_id_str)
382
+ }
383
+ $(document).ready(function(){
384
+ var chart_list = $("fusionchartfree");
385
+ var chart_options = {};
386
+
387
+ chart_list.each(function(index, element){
388
+ var chart_id = $(element).attr('id');
389
+ var chart_xml = $(element).attr('chart_xml');
390
+ var attributes = chart_xml.attributes
391
+ chart_options[chart_id] = ""
392
+ for(var key in attributes){
393
+ chart_options[chart_id] += ( attributes[key].name + "="+ attributes[key].value + ';')
394
+ }
395
+ render_element(element);
396
+ });
397
+ jQuery.data(document.body, 'fusion chart free option', chart_options);
398
+ });
399
+
400
+
401
+