Module: Easyfsf::FCFInitializer
- Defined in:
- lib/easyfsf.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
default optinoss
{ :caption => "", :subcaption => "", :lineThickness => "5", :showValues => "0", :formatNumberScale => "0", :anchorRadius => "5", :divLineAlpha => "20" , :divLineColor => "CC3300", :showAlternateHGridColor => "1", :alternateHGridColor => "CC3300", :rotateNames => "1", :shadowAlpha => "40", :numvdivlines => "5", :chartLeftMargin => "5", :chartRightMargin => "5", :chartTopMargin => "5", :chartBottomMargin => "5", :bgColor => "FFFFFF", :alternateHGridAlpha => "5", :limitsDecimalPrecision => '0', :divLineDecimalPrecision => '0', :decimalPrecision => "0", :yAxisMaxValue => "10", :lineThickness => "2", :anchorRadius => "1" }
- ONLY_SINGLE_CHART =
to file swf files chart difinition for rendering single chart
["Pie2D", "Pie3D", "Funnel"]
- ONLY_MULTI_CHART =
chart difinition for rendering multi chart
["StackedArea2D", "StackedBar2D", "StackedColumn2D", "StackedColumn3D", "MSColumn2DLineDY", "MSColumn3DLineDY"]
- BOTH_CAPABLE_CHART =
chart difinition for rendering single and multi chart
["Line", "Area2D", "Bar2D", "Column2D", "Column3D"]
Class Method Summary collapse
- .check_category_params(category) ⇒ Object
- .check_datasets_params(datasets) ⇒ Object
- .get_default_option ⇒ Object
- .get_swf_file_name(chart_type, isMulti) ⇒ Object
-
.skip_category(category, skipSize) ⇒ Object
skipSize에 맞춰 category의 value_list를 빈 문자열로 교체합니다.
- .standardize_category(category) ⇒ Object
- .standardize_datasets(datasets) ⇒ Object
Class Method Details
.check_category_params(category) ⇒ Object
158 159 160 161 162 163 164 165 166 |
# File 'lib/easyfsf.rb', line 158 def self.check_category_params(category) if category.is_a? Array return :STRING_ARRAY if category[0].respond_to?(:to_s) end if category.is_a? Hash return :HASH if category[:value_list] end return :SOMETHING_ELSE end |
.check_datasets_params(datasets) ⇒ Object
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
# File 'lib/easyfsf.rb', line 168 def self.check_datasets_params(datasets) if datasets.is_a? Array return :NUM_ARRAY if datasets[0].is_a? Fixnum or datasets[0].is_a? Float if datasets[0].is_a? Hash datasets.each_with_index do |dataset, index| raise ArgumentError, "There is a nil value_list in datasets(name: #{dataset[:seriesName]} ,index:#{index})" if dataset[:value_list].blank? end return :HASH_ARRAY end end if datasets.is_a? Hash return :HASH if datasets[:value_list].present? end return :SOMETHING_ELSE end |
.get_default_option ⇒ Object
97 98 99 |
# File 'lib/easyfsf.rb', line 97 def self.get_default_option DEFAULT_OPTIONS end |
.get_swf_file_name(chart_type, isMulti) ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/easyfsf.rb', line 102 def self.get_swf_file_name(chart_type, isMulti) if ONLY_SINGLE_CHART.include? chart_type if isMulti raise ArgumentError, "#{chart_type} can draw only single chart data but it's multichart data" else return "FCF_#{chart_type}.swf" end end if ONLY_MULTI_CHART.include? chart_type if isMulti return "FCF_#{chart_type}.swf" else raise ArgumentError, "#{chart_type} can draw only multichart data but it's singlechart data" end end if BOTH_CAPABLE_CHART.include? chart_type if isMulti return "FCF_MS#{chart_type}.swf" else return "FCF_#{chart_type}.swf" end end raise ArgumentError, "there is no #{chart_type} type" end |
.skip_category(category, skipSize) ⇒ Object
skipSize에 맞춰 category의 value_list를 빈 문자열로 교체합니다.
186 187 188 189 190 191 192 |
# File 'lib/easyfsf.rb', line 186 def self.skip_category(category, skipSize) newValueList = category[:value_list].each_with_index.map{ |value,index| next value if (index+1)%(skipSize+1) == 1 next "" } return category.merge(:value_list => newValueList) end |
.standardize_category(category) ⇒ Object
128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/easyfsf.rb', line 128 def self.standardize_category(category) case check_category_params(category) when :STRING_ARRAY return {:value_list => category.map {|c| c.to_s}} when :HASH return category.clone else raise ArgumentError, "First parameter should be Hash, Array of String or Array of something that can be converted to String" end end |
.standardize_datasets(datasets) ⇒ Object
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/easyfsf.rb', line 141 def self.standardize_datasets(datasets) case check_datasets_params(datasets) when :NUM_ARRAY return [{:value_list => datasets}] when :HASH_ARRAY clonedDataSets = [] datasets.each do |dataset| clonedDataSets << dataset.clone end return clonedDataSets when :HASH return [datasets.clone] else raise ArgumentError, "parameters should be Hash, Array of Hash , Array of Fixum or Array of Float" end end |