Class: Spree::PaymentMethodTransactionsReport::PaymentMethodRevenueDistributionChart
- Inherits:
-
Object
- Object
- Spree::PaymentMethodTransactionsReport::PaymentMethodRevenueDistributionChart
- Defined in:
- app/reports/spree/payment_method_transactions_report/payment_method_revenue_distribution_chart.rb
Instance Method Summary collapse
-
#initialize(result) ⇒ PaymentMethodRevenueDistributionChart
constructor
A new instance of PaymentMethodRevenueDistributionChart.
- #to_h ⇒ Object
Constructor Details
#initialize(result) ⇒ PaymentMethodRevenueDistributionChart
Returns a new instance of PaymentMethodRevenueDistributionChart.
2 3 4 5 6 7 8 9 |
# File 'app/reports/spree/payment_method_transactions_report/payment_method_revenue_distribution_chart.rb', line 2 def initialize(result) @time_dimension = result.time_dimension @grouped_by_payment_method = result.observations.group_by(&:payment_method_name) @time_series = [] if @grouped_by_payment_method.values.first.present? @time_series = @grouped_by_payment_method.values.first.collect { |observation| observation.send(@time_dimension) } end end |
Instance Method Details
#to_h ⇒ Object
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 |
# File 'app/reports/spree/payment_method_transactions_report/payment_method_revenue_distribution_chart.rb', line 11 def to_h { id: 'payment-methods', json: { chart: { type: 'column' }, title: { useHTML: true, text: "<span class='chart-title'>Payment Methods</span><span class='fa fa-question-circle' data-toggle='tooltip' title=' Compare the revenue generated by different Payment methods such as CC, Check etc.'></span>" }, xAxis: { categories: @time_series }, yAxis: { title: { text: 'value($)' } }, tooltip: { valuePrefix: '$' }, legend: { layout: 'vertical', align: 'right', verticalAlign: 'middle', borderWidth: 0 }, series: @grouped_by_payment_method.collect { |key, value| { name: key, data: value.map(&:payment_amount) } } } } end |