Module: CellSet::SeriesList

Included in:
CellSet
Defined in:
lib/cell_set/series_list.rb

Instance Method Summary collapse

Instance Method Details

#to_series_list(options = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/cell_set/series_list.rb', line 3

def to_series_list(options={})
  defaults = {
      :labels => {
          :axis_ordinal => 0,
          :depth => @axes[0].positions[0].members.length - 1
      },
      :data => {
          :axis_ordinal => 1
      },
      :name => {
          :depth => @axes[1].positions[0].members.length - 1
      }
  }

  if options.has_key?(:labels) && options[:labels].has_key?(:axis_ordinal)
    unless options[:labels][:axis_ordinal] == 0 || options[:labels].has_key?(:depth)
      options[:labels][:depth] = @axes[options[:labels][:axis_ordinal]].positions[0].members.length - 1
    end
  end

  if options.has_key?(:data) && options[:data].has_key?(:axis_ordinal)
    unless options[:data][:axis_ordinal] == 1 || (options.has_key?(:name) && options[:name].has_key?(:depth))
      options[:name] = {} unless options.has_key?(:name)
      options[:name][:depth] = @axes[options[:data][:axis_ordinal]].positions[0].members.length - 1
    end
  end

  series_options = defaults.deep_merge(options)

  series_list(series_options)
end