Sha256: c980953d753ccb71d67b600a05109a620fc66f0da2238532235cd2c97f968f05

Contents?: true

Size: 1.37 KB

Versions: 4

Compression:

Stored size: 1.37 KB

Contents

# encoding: UTF-8
module Axlsx
  # A LineSeries defines the title, data and labels for line charts
  # @note The recommended way to manage series is to use Chart#add_series
  # @see Worksheet#add_chart
  # @see Chart#add_series
  class LineSeries < Series

    # The data for this series.
    # @return [ValAxisData]
    attr_reader :data

    # The labels for this series.
    # @return [CatAxisData]
    attr_reader :labels

    # Creates a new series
    # @option options [Array, SimpleTypedList] data
    # @option options [Array, SimpleTypedList] labels
    # @param [Chart] chart
    def initialize(chart, options={})
      @labels, @data = nil, nil
      super(chart, options)
      @labels = CatAxisData.new(options[:labels]) unless options[:labels].nil?
      @data = ValAxisData.new(options[:data]) unless options[:data].nil?
    end

    # Serializes the object
    # @param [String] str
    # @return [String]
    def to_xml_string(str = '')
      super(str) do
        @labels.to_xml_string(str) unless @labels.nil?
        @data.to_xml_string(str) unless @data.nil?
      end
    end

    private

    # assigns the data for this series
    def data=(v) DataTypeValidator.validate "Series.data", [SimpleTypedList], v; @data = v; end

    # assigns the labels for this series
    def labels=(v) DataTypeValidator.validate "Series.labels", [SimpleTypedList], v; @labels = v; end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
axlsx-1.1.3 lib/axlsx/drawing/line_series.rb
axlsx-1.1.2 lib/axlsx/drawing/line_series.rb
axlsx-1.1.1 lib/axlsx/drawing/line_series.rb
axlsx-1.1.0 lib/axlsx/drawing/line_series.rb