Sha256: 4374e39643280171c68325262f2767b2d2242d5878e32855c21abf9f24b91974

Contents?: true

Size: 944 Bytes

Versions: 3

Compression:

Stored size: 944 Bytes

Contents

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

  def to_h
    {
      id: 'profit-loss',
      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 value'></span>"
        },
        xAxis: { categories: @time_series },
        yAxis: {
          title: { text: 'Value($)' }
        },
        legend: {
          layout: 'vertical',
          align: 'right',
          verticalAlign: 'middle',
          borderWidth: 0
        },
        series: [
          {
            name: 'Profit Loss',
            tooltip: { valuePrefix: '$' },
            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_chart.rb
solidus_admin_insights-2.1.1 app/reports/spree/sales_performance_report/profit_loss_chart.rb
solidus_admin_insights-2.1.0 app/reports/spree/sales_performance_report/profit_loss_chart.rb