Class: ProductDecorator

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. another concrete decorator

Instance Method Summary collapse

Methods inherited from GraphDecoration

#doubleChart, #multipleChart, #singleChart

Constructor Details

#initialize(real_graph) ⇒ ProductDecorator

this functionality initialises with the data from the application models



291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
# File 'lib/graph_decorator.rb', line 291

def initialize(real_graph)
  super(real_graph)
  @y_name_1 = "Actual Price"
       @y_name_2 = "Offer Price"
       @y_data_1 = []
       @y_data_2 = []
       @y_data_3 = []
       @x_name = []
       @y_data = Product.all
       @y_data.each do |pro|
        @y_data_1 << pro.price
        @y_data_2 << pro.offerPrice
        @y_data_3 << pro.quantityAvailable
        @x_name << pro.name
       end
       #@y_data_1 = Product.select("price").group_by{|o| o.price}.keys
       #@y_data_2 = Product.select("offerPrice").group_by{|o| o.offerPrice}.keys
       #@x_name = Product.select("name").group_by{|o| o.name}.keys
       #@y_data_3 = Product.select("quantityAvailable").group_by{|o| o.quantityAvailable}.keys
       @y_name_3 = "Quantity Available"
end