Sha256: 34c604611d598858d7f14692199ebb5455c6948c970b8fc7c3e8d62d1b58b8de

Contents?: true

Size: 1.2 KB

Versions: 1

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true

require_relative './xlsx_func_testcase'

class TestChartPie < XlsxWriterTestCase
  DATA = [[2, 60], [4, 30], [6, 10]].freeze

  test 'chart_pie02' do |wb|
    wb.add_worksheet do |ws|
      DATA.each { |row| ws.add_row row }

      wb.add_chart(XlsxWriter::Workbook::Chart::PIE) do |chart|
        chart.add_series '=Sheet1!$A$1:$A$3', '=Sheet1!$B$1:$B$3'
        chart.legend_set_font bold: true, italic: true, baseline: -1

        ws.insert_chart('E9', chart)
      end
    end
  end

  test 'chart_pie03' do |wb|
    wb.add_worksheet do |ws|
      DATA.each { |row| ws.add_row row }

      wb.add_chart(XlsxWriter::Workbook::Chart::PIE) do |chart|
        chart.add_series '=Sheet1!$A$1:$A$3', '=Sheet1!$B$1:$B$3'
        chart.legend_delete_series [1]

        ws.insert_chart('E9', chart)
      end
    end
  end

  test 'chart_pie04' do |wb|
    wb.add_worksheet do |ws|
      DATA.each { |row| ws.add_row row }

      wb.add_chart(XlsxWriter::Workbook::Chart::PIE) do |chart|
        chart.add_series '=Sheet1!$A$1:$A$3', '=Sheet1!$B$1:$B$3'
        chart.legend_position = XlsxWriter::Workbook::Chart::LEGEND_OVERLAY_RIGHT

        ws.insert_chart('E9', chart)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
xlsxwriter-0.2.2 test/test_chart_pie.rb