Class: Spree::SalesTaxReport::MonthlySalesTaxComparisonChart
- Inherits:
-
Object
- Object
- Spree::SalesTaxReport::MonthlySalesTaxComparisonChart
- Defined in:
- app/reports/spree/sales_tax_report/monthly_sales_tax_comparison_chart.rb
Instance Method Summary collapse
-
#initialize(result) ⇒ MonthlySalesTaxComparisonChart
constructor
A new instance of MonthlySalesTaxComparisonChart.
- #to_h ⇒ Object
Constructor Details
#initialize(result) ⇒ MonthlySalesTaxComparisonChart
Returns a new instance of MonthlySalesTaxComparisonChart.
2 3 4 5 6 7 8 9 10 |
# File 'app/reports/spree/sales_tax_report/monthly_sales_tax_comparison_chart.rb', line 2 def initialize(result) @time_dimension = result.time_dimension @grouped_by_zone_name = result.observations.group_by(&:zone_name) @time_series = [] if @grouped_by_zone_name.first.present? @time_series = @grouped_by_zone_name.values.first.collect { |observation| observation.send(@time_dimension) } end @chart_series = @grouped_by_zone_name.map { |zone_name, observations| { type: 'column', name: zone_name, data: observations.collect(&:sales_tax) } } 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 36 |
# File 'app/reports/spree/sales_tax_report/monthly_sales_tax_comparison_chart.rb', line 12 def to_h { id: 'sale-tax', json: { chart: { type: 'column' }, title: { useHTML: true, text: "<span class='chart-title'>Monthly Sales Tax Comparison</span><span class='fa fa-question-circle' data-toggle='tooltip' title='Compare the Sales tax collected from different Zones'></span>" }, xAxis: { categories: @time_series }, yAxis: { title: { text: 'Value($)' } }, tooltip: { valuePrefix: '$' }, legend: { layout: 'vertical', align: 'right', verticalAlign: 'middle', borderWidth: 0 }, series: @chart_series } } end |