Module: Easyfsf::FCFChartXmlBuilder
- Defined in:
- lib/easyfsf.rb
Class Method Summary collapse
- .get_FC_color ⇒ Object
-
.smchart_xml(category, datasets, options = {}) ⇒ Object
Generate xml for chart examples.
Class Method Details
.get_FC_color ⇒ Object
301 302 303 304 305 306 307 |
# File 'lib/easyfsf.rb', line 301 def self.get_FC_color #Update index @FC_ColorCounter=@FC_ColorCounter+1 counter = @FC_ColorCounter % (@arr_FCColors.size) #Return color return @arr_FCColors[counter] end |
.smchart_xml(category, datasets, options = {}) ⇒ Object
Generate xml for chart examples
for single charts <graph yAxisName=‘Sales Figure’
caption='Top 5 Sales Person'
numberPrefix='$'
decimalPrecision='1'
divlinedecimalPrecision='0'
limitsdecimalPrecision='0'>
<set name='Alex' value='25000' color='AFD8F8'/>
<set name='Mark' value='35000' color='F6BD0F'/>
<set name='John' value='31300' color='008E8E'/>
</graph>
for multi charts <graph yAxisName=‘Sales Figure’
caption='Top 5 Sales Person'
numberPrefix='$'
decimalPrecision='1'
divlinedecimalPrecision='0'
limitsdecimalPrecision='0'>
<categories>
<category name="Jan"/>
<category name="Feb"/>
<category name="Apr"/>
</categories>
<dataset seriesName="Current Year" color="A66EDD">
<set value="1127654"/>
<set value="1226234"/>
<set value="1311565"/>
</dataset>
<dataset seriesName="Previous Year" color="F6BD0F">
<set value="927654"/>
<set value="1126234"/>
<set value="1111565"/>
</dataset>
</graph>
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 |
# File 'lib/easyfsf.rb', line 260 def self.smchart_xml(category, datasets, = {}) if [:sectionSize].present? category[:value_list] = erase_sections(category[:value_list], [:sectionSize]) .delete :sectionSize end xml = ::Builder::XmlMarkup.new(:indent=>0) #pOptions[:caption] = getCaption(valueDatas) xml.graph() do if datasets.length == 1 category[:value_list].length.times do |index| dataset = datasets[0] color = category[:color_list].blank? ? "":category[:color_list][index] xml.set(:name => category[:value_list][index], :value => dataset[:value_list][index], :color => color) end else xml.categories do category[:value_list].length.times do |index| xml.category(:name => category[:value_list][index]) end end datasets.each do |dataset| dataset[:color] = dataset[:color].blank? ? get_FC_color : dataset[:color] valueList = dataset[:value_list].clone dataset.delete :value_list xml.dataset(dataset) do valueList.each do |value| xml.set(:value => value) end end end end end xmlString = xml.to_s return xmlString[0..xmlString.length - 8] end |