Sha256: 2270ab39c8d64f140b37c81e9d7a23e7cebfd9f5224b3919b62c3dbdefa091f4

Contents?: true

Size: 1.41 KB

Versions: 4

Compression:

Stored size: 1.41 KB

Contents

require 'tc_helper.rb'

class TestBarSeries < Test::Unit::TestCase

  def setup
    p = Axlsx::Package.new
    @ws = p.workbook.add_worksheet :name=>"hmmm"
    @chart = @ws.drawing.add_chart Axlsx::Bar3DChart, :title => "fishery"
    @series = @chart.add_series :data=>[0,1,2], :labels=>["zero", "one", "two"], :title=>"bob", :colors => ['FF0000', '00FF00', '0000FF'], :shape => :cone
  end

  def test_initialize
    assert_equal(@series.title.text, "bob", "series title has been applied")
    assert_equal(@series.data.class, Axlsx::NumDataSource, "data option applied")
    assert_equal(@series.shape, :cone, "series shape has been applied")
    assert(@series.data.is_a?(Axlsx::NumDataSource))
    assert(@series.labels.is_a?(Axlsx::AxDataSource))
  end

  def test_colors
    assert_equal(@series.colors.size, 3)
  end

  def test_shape
    assert_raise(ArgumentError, "require valid shape") { @series.shape = :teardropt }
    assert_nothing_raised("allow valid shape") { @series.shape = :box }
    assert(@series.shape == :box)
  end

  def test_to_xml_string
    doc = Nokogiri::XML(@chart.to_xml_string)
    @series.colors.each_with_index do |color, index|
      assert_equal(doc.xpath("//c:dPt/c:idx[@val='#{index}']").size,1)
      assert_equal(doc.xpath("//c:dPt/c:spPr/a:solidFill/a:srgbClr[@val='#{@series.colors[index]}']").size,1)
    end
    assert_equal(doc.xpath("//c:shape[@val='#{@series.shape.to_s}']").size, 1)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
axlsx-1.1.7 test/drawing/tc_bar_series.rb
axlsx-1.1.6 test/drawing/tc_bar_series.rb
axlsx-1.1.5 test/drawing/tc_bar_series.rb
axlsx-1.1.4 test/drawing/tc_bar_series.rb