Class: Spree::SalesPerformanceReport::ProfitLossPercentChart
- Inherits:
-
Object
- Object
- Spree::SalesPerformanceReport::ProfitLossPercentChart
- Defined in:
- app/reports/spree/sales_performance_report/profit_loss_percent_chart.rb
Instance Method Summary collapse
-
#initialize(result) ⇒ ProfitLossPercentChart
constructor
A new instance of ProfitLossPercentChart.
- #to_h ⇒ Object
Constructor Details
#initialize(result) ⇒ ProfitLossPercentChart
Returns a new instance of ProfitLossPercentChart.
2 3 4 5 6 |
# File 'app/reports/spree/sales_performance_report/profit_loss_percent_chart.rb', line 2 def initialize(result) time_dim = result.time_dimension @time_series = result.observations.collect(&time_dim) @data = result.observations.collect(&:profit_loss_percent) end |
Instance Method Details
#to_h ⇒ Object
8 9 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 |
# File 'app/reports/spree/sales_performance_report/profit_loss_percent_chart.rb', line 8 def to_h { id: 'profit-loss-percent', json: { title: { useHTML: true, text: "<span class='chart-title'>Profit/Loss %</span><span class='fa fa-question-circle' data-toggle='tooltip' title='Track the profit or loss %age to create a projection'></span>" }, xAxis: { categories: @time_series }, yAxis: { title: { text: 'Percentage(%)' } }, legend: { layout: 'vertical', align: 'right', verticalAlign: 'middle', borderWidth: 0 }, series: [ { name: 'Profit Loss Percent(%)', tooltip: { valueSuffix: '%' }, data: @data } ] } } end |