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: "Profit/Loss" }, 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