Class: MSalesDecorator

Inherits:
GraphDecoration show all
Defined in:
lib/graph_decorator.rb

Overview

a concrete decorator provides the data for the super class decorator according to the requirement of single colum or double column or triple column.

Instance Method Summary collapse

Methods inherited from GraphDecoration

#doubleChart, #multipleChart, #singleChart

Constructor Details

#initialize(real_graph) ⇒ MSalesDecorator

this functionality initialises with the data from the application models



212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
# File 'lib/graph_decorator.rb', line 212

def initialize(real_graph)
  super(real_graph)
  @y_name_1 = "Total Sale"
     @y_name_2 = "Profit"
     @y_name_3 = "Non Offered Sale"
     @y_data_1 = []
     @y_data_2 = []
     @y_data_3 = []
     @x_name = []
     @y_data = Msale.all
     @y_data.each do |pro|
        @y_data_1 << pro.totalSale
         @y_data_2 << pro.profit
         @y_data_3 << pro.nonOfferedSale
         @x_name << pro.month
     end
     #@y_data_1 = Msale.order('id desc').select("totalSale").group_by{|o| o.totalSale}.keys.take(7)
     #@y_data_2 = Msale.order('id desc').select("profit").group_by{|o| o.profit}.keys.take(7)
     #@x_name = Msale.order('id desc').select("month").group_by{|o| o.month}.keys.take(7)
     #@y_data_3 = Msale.order('id desc').select("nonOfferedSale").group_by{|o| o.nonOfferedSale}.keys.take(7)
end