Sha256: 22e5314716767c09ecb04cebe9cb4498c830be4eb184e50c2641ecef809da818
Contents?: true
Size: 1.1 KB
Versions: 3
Compression:
Stored size: 1.1 KB
Contents
class Spree::TrendingSearchReport::FrequencyDistributionPieChart attr_accessor :chart_data def initialize(result) total_occurrences = result.observations.sum(&:occurrences).to_f self.chart_data = result.observations.collect { |x| { name: x.searched_term, y: x.occurrences/total_occurrences } } end def to_h { name: 'trending-search', json: { chart: { type: 'pie' }, title: { useHTML: true, text: "<span class='chart-title'>Trending Search Keywords(Top 20)</span><span class='fa fa-question-circle' data-toggle='tooltip' title='Track the most trending keywords searched by users'></span>" }, tooltip: { pointFormat: 'Search %: <b>{point.percentage:.1f}%</b>' }, plotOptions: { pie: { allowPointSelect: true, cursor: 'pointer', dataLabels: { enabled: false }, showInLegend: true } }, series: [ { name: 'Hits', data: chart_data } ] } } end end
Version data entries
3 entries across 3 versions & 2 rubygems