Sha256: f6c64d29a7d21ccb4df69016700310d6a2e56b7d0b84fc947182d37256faa191

Contents?: true

Size: 1.52 KB

Versions: 9

Compression:

Stored size: 1.52 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
      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
        val  = 'col'

        attributes = ['val', val]

        @writer.empty_tag('c:barDir', attributes)
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
write_xlsx-0.62.0 lib/write_xlsx/chart/column.rb
write_xlsx-0.61.0 lib/write_xlsx/chart/column.rb
write_xlsx-0.60.0 lib/write_xlsx/chart/column.rb
write_xlsx-0.59.0 lib/write_xlsx/chart/column.rb
write_xlsx-0.58.0 lib/write_xlsx/chart/column.rb
write_xlsx-0.57.0 lib/write_xlsx/chart/column.rb
write_xlsx-0.56.0 lib/write_xlsx/chart/column.rb
write_xlsx-0.55.0 lib/write_xlsx/chart/column.rb
write_xlsx-0.54.0 lib/write_xlsx/chart/column.rb