Sha256: 8b8e8be74f9b1c84276eb8a328e7c9efa29d831a4e5b9ae709a7226bd811d7cf

Contents?: true

Size: 1.95 KB

Versions: 23

Compression:

Stored size: 1.95 KB

Contents

# -*- coding: utf-8 -*-
###############################################################################
#
# Column - A class for writing Excel Column charts.
#
# Used in conjunction with Chart.
#
# See formatting note in Chart.
#
# Copyright 2000-2011, John McNamara, jmcnamara@cpan.org
# Convert to ruby by Hideo NAKAMURA, cxn03651@msj.biglobe.ne.jp
#

require 'write_xlsx/package/xml_writer_simple'
require 'write_xlsx/utility'

module Writexlsx
  class Chart
    # The Column chart module also supports the following sub-types:
    #
    #     stacked
    #     percent_stacked
    # These can be specified at creation time via the add_chart() Worksheet
    # method:
    #
    #     chart = workbook.add_chart( :type => 'column', :subtype => 'stacked' )
    #
    class Column < self
      include Writexlsx::Utility

      def initialize(subtype)
        super(subtype)
        @subtype = subtype || 'clustered'
        @horiz_val_axis = 0

        # Override and reset the default axis values.
        if @subtype == 'percent_stacked'
          @y_axis.defaults[:num_format] = '0%'
        end

        set_y_axis

        # Set the available data label positions for this chart type.
        @label_position_default = 'outside_end'
        @label_positions = {
          'center'      => 'ctr',
          'inside_base' => 'inBase',
          'inside_end'  => 'inEnd',
          'outside_end' => 'outEnd'
        }
      end

      #
      # Override the virtual superclass method with a chart specific method.
      #
      def write_chart_type(params)
        # Write the c:barChart element.
        write_bar_chart(params)
      end

      #
      # Write the <c:barDir> element.
      #
      def write_bar_dir
        @writer.empty_tag('c:barDir', [ ['val', 'col'] ])
      end

      #
      # Write the <c:errDir> element. Overridden from Chart class since it is not
      # used in Bar charts.
      #
      def write_err_dir(direction)
        # do nothing
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
write_xlsx-1.00.0 lib/write_xlsx/chart/column.rb
write_xlsx-0.99.0 lib/write_xlsx/chart/column.rb
write_xlsx-0.97.0 lib/write_xlsx/chart/column.rb
write_xlsx-0.90.0 lib/write_xlsx/chart/column.rb
write_xlsx-0.89.0 lib/write_xlsx/chart/column.rb
write_xlsx-0.88.0 lib/write_xlsx/chart/column.rb
write_xlsx-0.87.0 lib/write_xlsx/chart/column.rb
write_xlsx-0.86.0 lib/write_xlsx/chart/column.rb
write_xlsx-0.85.11 lib/write_xlsx/chart/column.rb
write_xlsx-0.85.10 lib/write_xlsx/chart/column.rb
write_xlsx-0.85.9 lib/write_xlsx/chart/column.rb
write_xlsx-0.85.8 lib/write_xlsx/chart/column.rb
write_xlsx-0.85.7 lib/write_xlsx/chart/column.rb
write_xlsx-0.85.6 lib/write_xlsx/chart/column.rb
write_xlsx-0.85.5 lib/write_xlsx/chart/column.rb
write_xlsx-0.85.4 lib/write_xlsx/chart/column.rb
write_xlsx-0.85.3 lib/write_xlsx/chart/column.rb
write_xlsx-0.85.2 lib/write_xlsx/chart/column.rb
write_xlsx-0.85.1 lib/write_xlsx/chart/column.rb
write_xlsx-0.83.0 lib/write_xlsx/chart/column.rb