Class: Spree::SalesPerformanceReport::SaleCostPriceChart
- Inherits:
-
Object
- Object
- Spree::SalesPerformanceReport::SaleCostPriceChart
- Defined in:
- app/reports/spree/sales_performance_report/sale_cost_price_chart.rb
Instance Method Summary collapse
-
#initialize(result) ⇒ SaleCostPriceChart
constructor
A new instance of SaleCostPriceChart.
- #to_h ⇒ Object
Constructor Details
#initialize(result) ⇒ SaleCostPriceChart
Returns a new instance of SaleCostPriceChart.
2 3 4 5 6 7 8 |
# File 'app/reports/spree/sales_performance_report/sale_cost_price_chart.rb', line 2 def initialize(result) time_dim = result.time_dimension @time_series = result.observations.collect(&time_dim) @sale_price = result.observations.collect(&:sale_price) @cost_price = result.observations.collect(&:cost_price) @promotion_discount = result.observations.collect(&:promotion_discount) end |
Instance Method Details
#to_h ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/reports/spree/sales_performance_report/sale_cost_price_chart.rb', line 10 def to_h { id: 'sale-price', json: { chart: { type: 'column' }, title: { useHTML: true, text: "<span class='chart-title'>Sales Performance %</span><span class='fa fa-question-circle' data-toggle='tooltip' title='Compare the Selling price, cost price and promotional cost over a period of time'></span>" }, xAxis: { categories: @time_series }, yAxis: { title: { text: 'Value($)' } }, tooltip: { valuePrefix: '$' }, legend: { layout: 'vertical', align: 'right', verticalAlign: 'middle', borderWidth: 0 }, series: [ { name: 'Sale Price', data: @sale_price }, { name: 'Cost Price', data: @cost_price }, { name: 'Promotional Cost', data: @promotion_discount } ] } } end |