Sha256: 87f0bb1d0bb048a15894acdf2b7ae11640122c6b54d96746975a912a9529fd3d

Contents?: true

Size: 897 Bytes

Versions: 7

Compression:

Stored size: 897 Bytes

Contents

# frozen_string_literal: true

require 'spout/models/graphables/default'

module Spout
  module Models
    module Graphables
      class ChoicesVsChoices < Spout::Models::Graphables::Default

        def categories
          filtered_domain_options(@chart_variable).collect(&:display_name)
        end

        def units
          'percent'
        end

        def series
          filtered_domain_options(@variable).collect do |option|
            filtered_subjects = @subjects.select{ |s| s.send(@variable.id) == option.value }
            data = filtered_domain_options(@chart_variable).collect do |chart_option|
              filtered_subjects.select{ |s| s.send(@chart_variable.id) == chart_option.value }.count
            end
            { name: option.display_name, data: data }
          end
        end

        def stacking
          'percent'
        end

      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
spout-0.12.1 lib/spout/models/graphables/choices_vs_choices.rb
spout-0.12.0 lib/spout/models/graphables/choices_vs_choices.rb
spout-0.12.0.rc2 lib/spout/models/graphables/choices_vs_choices.rb
spout-0.12.0.rc lib/spout/models/graphables/choices_vs_choices.rb
spout-0.12.0.beta2 lib/spout/models/graphables/choices_vs_choices.rb
spout-0.12.0.beta1 lib/spout/models/graphables/choices_vs_choices.rb
spout-0.11.1 lib/spout/models/graphables/choices_vs_choices.rb