Class: Spree::PromotionalCostReport::PromotionalCostChart
- Inherits:
-
Object
- Object
- Spree::PromotionalCostReport::PromotionalCostChart
- Defined in:
- app/reports/spree/promotional_cost_report/promotional_cost_chart.rb
Instance Attribute Summary collapse
-
#series ⇒ Object
Returns the value of attribute series.
-
#time ⇒ Object
Returns the value of attribute time.
Instance Method Summary collapse
-
#initialize(result) ⇒ PromotionalCostChart
constructor
A new instance of PromotionalCostChart.
- #to_h ⇒ Object
Constructor Details
#initialize(result) ⇒ PromotionalCostChart
Returns a new instance of PromotionalCostChart.
4 5 6 7 8 9 10 |
# File 'app/reports/spree/promotional_cost_report/promotional_cost_chart.rb', line 4 def initialize(result) @grouped_by_promotion = result.observations.group_by(&:promotion_name) @time_dimension = result.time_dimension self.time = [] self.time = @grouped_by_promotion.values.first.collect { |observation_value| observation_value.send(@time_dimension) } if @grouped_by_promotion.first.present? self.series = @grouped_by_promotion.collect { |promotion, values| { type: 'column', name: promotion, data: values.collect(&:promotion_discount) } } end |
Instance Attribute Details
#series ⇒ Object
Returns the value of attribute series.
2 3 4 |
# File 'app/reports/spree/promotional_cost_report/promotional_cost_chart.rb', line 2 def series @series end |
#time ⇒ Object
Returns the value of attribute time.
2 3 4 |
# File 'app/reports/spree/promotional_cost_report/promotional_cost_chart.rb', line 2 def time @time end |
Instance Method Details
#to_h ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/reports/spree/promotional_cost_report/promotional_cost_chart.rb', line 12 def to_h { id: 'promotional-cost', json: { chart: { type: 'column' }, title: { useHTML: true, text: "<span class='chart-title'>Promotional Cost</span><span class='fa fa-question-circle' data-toggle='tooltip' title=' Compare the costing for various promotions'></span>" }, xAxis: { categories: time }, yAxis: { title: { text: 'Value($)' } }, tooltip: { valuePrefix: '$' }, legend: { layout: 'vertical', align: 'right', verticalAlign: 'middle', borderWidth: 0 }, series: series } } end |