Class: Writexlsx::Chart::Axis

Inherits:
Object
  • Object
show all
Includes:
Utility::Common, Utility::RichText
Defined in:
lib/write_xlsx/chart/axis.rb

Constant Summary

Constants included from Utility::Common

Utility::Common::PERL_TRUE_VALUES

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utility::RichText

#convert_font_args, #get_font_latin_attributes, #get_font_style_attributes, #params_to_font, #underline_attributes, #write_a_body_pr, #write_a_def_rpr, #write_a_end_para_rpr, #write_a_lst_style, #write_a_p_formula, #write_a_p_pr_formula, #write_def_rpr_r_pr_common, #write_tx_pr

Methods included from Utility::Common

#absolute_char, #check_parameter, #float_to_str, #ptrue?, #put_deprecate_message

Constructor Details

#initialize(chart) ⇒ Axis

Returns a new instance of Axis.



24
25
26
27
# File 'lib/write_xlsx/chart/axis.rb', line 24

def initialize(chart)
  @chart = chart
  @title = Caption.new(chart)
end

Instance Attribute Details

#crossingObject (readonly)

Returns the value of attribute crossing.



18
19
20
# File 'lib/write_xlsx/chart/axis.rb', line 18

def crossing
  @crossing
end

#defaultsObject

Returns the value of attribute defaults.



13
14
15
# File 'lib/write_xlsx/chart/axis.rb', line 13

def defaults
  @defaults
end

#display_unitsObject (readonly)

Returns the value of attribute display_units.



17
18
19
# File 'lib/write_xlsx/chart/axis.rb', line 17

def display_units
  @display_units
end

#display_units_visibleObject (readonly)

Returns the value of attribute display_units_visible.



17
18
19
# File 'lib/write_xlsx/chart/axis.rb', line 17

def display_units_visible
  @display_units_visible
end

#fillObject (readonly)

Returns the value of attribute fill.



21
22
23
# File 'lib/write_xlsx/chart/axis.rb', line 21

def fill
  @fill
end

#interval_tickObject (readonly)

Returns the value of attribute interval_tick.



20
21
22
# File 'lib/write_xlsx/chart/axis.rb', line 20

def interval_tick
  @interval_tick
end

#interval_unitObject (readonly)

Returns the value of attribute interval_unit.



19
20
21
# File 'lib/write_xlsx/chart/axis.rb', line 19

def interval_unit
  @interval_unit
end

#label_alignObject (readonly)

Returns the value of attribute label_align.



21
22
23
# File 'lib/write_xlsx/chart/axis.rb', line 21

def label_align
  @label_align
end

#label_positionObject (readonly)

Returns the value of attribute label_position.



18
19
20
# File 'lib/write_xlsx/chart/axis.rb', line 18

def label_position
  @label_position
end

#layoutObject (readonly)

Returns the value of attribute layout.



19
20
21
# File 'lib/write_xlsx/chart/axis.rb', line 19

def layout
  @layout
end

#lineObject (readonly)

Returns the value of attribute line.



21
22
23
# File 'lib/write_xlsx/chart/axis.rb', line 21

def line
  @line
end

#log_baseObject (readonly)

Returns the value of attribute log_base.



18
19
20
# File 'lib/write_xlsx/chart/axis.rb', line 18

def log_base
  @log_base
end

#major_gridlinesObject (readonly)

Returns the value of attribute major_gridlines.



20
21
22
# File 'lib/write_xlsx/chart/axis.rb', line 20

def major_gridlines
  @major_gridlines
end

#major_tick_markObject

Returns the value of attribute major_tick_mark.



15
16
17
# File 'lib/write_xlsx/chart/axis.rb', line 15

def major_tick_mark
  @major_tick_mark
end

#major_unitObject (readonly)

Returns the value of attribute major_unit.



16
17
18
# File 'lib/write_xlsx/chart/axis.rb', line 16

def major_unit
  @major_unit
end

#major_unit_typeObject (readonly)

Returns the value of attribute major_unit_type.



16
17
18
# File 'lib/write_xlsx/chart/axis.rb', line 16

def major_unit_type
  @major_unit_type
end

#maxObject

Returns the value of attribute max.



14
15
16
# File 'lib/write_xlsx/chart/axis.rb', line 14

def max
  @max
end

#minObject

Returns the value of attribute min.



14
15
16
# File 'lib/write_xlsx/chart/axis.rb', line 14

def min
  @min
end

#minor_gridlinesObject (readonly)

Returns the value of attribute minor_gridlines.



20
21
22
# File 'lib/write_xlsx/chart/axis.rb', line 20

def minor_gridlines
  @minor_gridlines
end

#minor_tick_markObject

Returns the value of attribute minor_tick_mark.



15
16
17
# File 'lib/write_xlsx/chart/axis.rb', line 15

def minor_tick_mark
  @minor_tick_mark
end

#minor_unitObject (readonly)

Returns the value of attribute minor_unit.



16
17
18
# File 'lib/write_xlsx/chart/axis.rb', line 16

def minor_unit
  @minor_unit
end

#minor_unit_typeObject (readonly)

Returns the value of attribute minor_unit_type.



16
17
18
# File 'lib/write_xlsx/chart/axis.rb', line 16

def minor_unit_type
  @minor_unit_type
end

#num_fontObject (readonly)

Returns the value of attribute num_font.



19
20
21
# File 'lib/write_xlsx/chart/axis.rb', line 19

def num_font
  @num_font
end

#num_formatObject

Returns the value of attribute num_format.



14
15
16
# File 'lib/write_xlsx/chart/axis.rb', line 14

def num_format
  @num_format
end

#num_format_linkedObject (readonly)

Returns the value of attribute num_format_linked.



19
20
21
# File 'lib/write_xlsx/chart/axis.rb', line 19

def num_format_linked
  @num_format_linked
end

#positionObject

Returns the value of attribute position.



14
15
16
# File 'lib/write_xlsx/chart/axis.rb', line 14

def position
  @position
end

#position_axisObject (readonly)

Returns the value of attribute position_axis.



18
19
20
# File 'lib/write_xlsx/chart/axis.rb', line 18

def position_axis
  @position_axis
end

#reverseObject (readonly)

Returns the value of attribute reverse.



20
21
22
# File 'lib/write_xlsx/chart/axis.rb', line 20

def reverse
  @reverse
end

#text_axisObject (readonly)

Returns the value of attribute text_axis.



21
22
23
# File 'lib/write_xlsx/chart/axis.rb', line 21

def text_axis
  @text_axis
end

#titleObject (readonly)

Returns the value of attribute title.



22
23
24
# File 'lib/write_xlsx/chart/axis.rb', line 22

def title
  @title
end

#visibleObject (readonly)

Returns the value of attribute visible.



18
19
20
# File 'lib/write_xlsx/chart/axis.rb', line 18

def visible
  @visible
end

Instance Method Details

#apply_axis_display_options(args) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/write_xlsx/chart/axis.rb', line 53

def apply_axis_display_options(args)
  set_major_minor_gridlines(args)
  set_display_units(args)
  set_display_units_visible(args)
  set_position(args)
  set_position_axis

  if ptrue?(args[:text_axis])
    @chart.date_category = false
    @text_axis = true
  end
end

#apply_axis_format_options(args) ⇒ Object



66
67
68
69
70
# File 'lib/write_xlsx/chart/axis.rb', line 66

def apply_axis_format_options(args)
  @num_font = convert_font_args(args[:num_font])
  @line = @chart.line_properties(args[:line])
  @fill = @chart.fill_properties(args[:fill])
end

#apply_axis_options(args) ⇒ Object



42
43
44
45
46
47
48
49
50
51
# File 'lib/write_xlsx/chart/axis.rb', line 42

def apply_axis_options(args)
  %i[
    reverse min max minor_unit major_unit minor_unit_type
    major_unit_type log_base crossing position_axis
    label_position num_format num_format_linked interval_unit
    interval_tick line fill label_align
  ].each { |val| instance_variable_set("@#{val}", args[val]) }

  @visible = args[:visible] || 1
end

#apply_axis_tick_options(args) ⇒ Object



72
73
74
75
# File 'lib/write_xlsx/chart/axis.rb', line 72

def apply_axis_tick_options(args)
  @major_tick_mark = get_tick_type(args[:major_tick_mark])
  @minor_tick_mark = get_tick_type(args[:minor_tick_mark])
end

#apply_axis_title_options(args) ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/write_xlsx/chart/axis.rb', line 77

def apply_axis_title_options(args)
  # Set the axis title properties.
  @title.apply_text_options(
    name:         args[:name],
    name_formula: args[:name_formula],
    data:         args[:data],
    name_font:    args[:name_font],
    layout:       args[:name_layout]
  )

  # Set the format properties.
  @title.apply_format_options(
    line:     args[:name_line],
    border:   args[:name_border],
    fill:     args[:name_fill],
    pattern:  args[:name_pattern],
    gradient: args[:name_gradient]
  )
end

#apply_options(params) ⇒ Object

Convert user defined axis values into axis instance.



32
33
34
35
36
37
38
39
40
# File 'lib/write_xlsx/chart/axis.rb', line 32

def apply_options(params) # :nodoc:
  args      = (defaults || {}).merge(params)

  apply_axis_options(args)
  apply_axis_display_options(args)
  apply_axis_format_options(args)
  apply_axis_tick_options(args)
  apply_axis_title_options(args)
end

#write_cat_number_format(writer, cat_has_num_fmt) ⇒ Object

Write the <c:numFmt> element. Special case handler for category axes which don't always have a number format.



111
112
113
114
115
# File 'lib/write_xlsx/chart/axis.rb', line 111

def write_cat_number_format(writer, cat_has_num_fmt)
  return unless user_defined_num_fmt_set? || cat_has_num_fmt

  writer.empty_tag('c:numFmt', num_fmt_attributes)
end

#write_number_format(writer) ⇒ Object

Write the <c:numberFormat> element. Note: It is assumed that if a user defined number format is supplied (i.e., non-default) then the sourceLinked attribute is 0. The user can override this if required.



103
104
105
# File 'lib/write_xlsx/chart/axis.rb', line 103

def write_number_format(writer) # :nodoc:
  writer.empty_tag('c:numFmt', num_fmt_attributes)
end