Sha256: 9b6bca5ee2dc1760944e631f2beecbf7dd3965185a07cb5fd38fa60be83fdd51

Contents?: true

Size: 1006 Bytes

Versions: 3

Compression:

Stored size: 1006 Bytes

Contents

class Spree::SalesPerformanceReport::ProfitLossPercentChart
  def initialize(result)
    time_dim = result.time_dimension
    @time_series = result.observations.collect(&time_dim)
    @data = result.observations.collect(&:profit_loss_percent)
  end

  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
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
spree_admin_insights-3.2.0 app/reports/spree/sales_performance_report/profit_loss_percent_chart.rb
solidus_admin_insights-2.1.1 app/reports/spree/sales_performance_report/profit_loss_percent_chart.rb
solidus_admin_insights-2.1.0 app/reports/spree/sales_performance_report/profit_loss_percent_chart.rb