Sha256: f99d8d8d7a2d941814b0ad3517680ea84d9c07b0a51a934902051d58d69d3c09
Contents?: true
Size: 1.23 KB
Versions: 3
Compression:
Stored size: 1.23 KB
Contents
class Spree::PromotionalCostReport::UsageCountChart attr_accessor :time, :series def initialize(result) @grouped_by_promotion = result.observations.group_by(&:promotion_name) @time_dimension = result.time_dimension self.time = [] if @grouped_by_promotion.values.first.present? self.time = @grouped_by_promotion.values.first.collect { |observation_value| observation_value.send(@time_dimension) } end self.series = @grouped_by_promotion.collect { |promotion, values| { type: 'column', name: promotion, data: values.collect(&:usage_count) } } end def to_h { id: 'promotion-usage-count', json: { chart: { type: 'spline' }, title: { useHTML: true, text: "<span class='chart-title'>Promotion Usage Count</span><span class='fa fa-question-circle' data-toggle='tooltip' title='Compare the usage of individual promotions'></span>" }, xAxis: { categories: time }, yAxis: { title: { text: 'Count' } }, tooltip: { valuePrefix: '#' }, legend: { layout: 'vertical', align: 'right', verticalAlign: 'middle', borderWidth: 0 }, series: series } } end end
Version data entries
3 entries across 3 versions & 2 rubygems