Sha256: b91388e90af67b6fa4cffb09bbd3da3d1c12c7d87ccdbd42dadcaae857dbdf9f

Contents?: true

Size: 895 Bytes

Versions: 13

Compression:

Stored size: 895 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

13 entries across 13 versions & 1 rubygems

Version Path
spout-1.0.0 lib/spout/models/graphables/choices_vs_choices.rb
spout-1.0.0.beta3 lib/spout/models/graphables/choices_vs_choices.rb
spout-1.0.0.beta2 lib/spout/models/graphables/choices_vs_choices.rb
spout-1.0.0.beta1 lib/spout/models/graphables/choices_vs_choices.rb
spout-0.14.1 lib/spout/models/graphables/choices_vs_choices.rb
spout-0.14.0 lib/spout/models/graphables/choices_vs_choices.rb
spout-0.14.0.rc lib/spout/models/graphables/choices_vs_choices.rb
spout-0.14.0.beta3 lib/spout/models/graphables/choices_vs_choices.rb
spout-0.14.0.beta2 lib/spout/models/graphables/choices_vs_choices.rb
spout-0.14.0.beta1 lib/spout/models/graphables/choices_vs_choices.rb
spout-0.13.0 lib/spout/models/graphables/choices_vs_choices.rb
spout-0.13.0.beta2 lib/spout/models/graphables/choices_vs_choices.rb
spout-0.13.0.beta1 lib/spout/models/graphables/choices_vs_choices.rb