axlsx 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.yardopts +5 -2
- data/CHANGELOG.md +78 -0
- data/LICENSE +1 -1
- data/README.md +132 -331
- data/Rakefile +17 -5
- data/examples/basic_charts.rb +54 -0
- data/examples/chart_colors.rb +88 -0
- data/examples/conditional_formatting/example_conditional_formatting.rb +72 -0
- data/examples/conditional_formatting/getting_barred.rb +37 -0
- data/examples/conditional_formatting/hitting_the_high_notes.rb +37 -0
- data/examples/conditional_formatting/scaled_colors.rb +39 -0
- data/examples/conditional_formatting/stop_and_go.rb +37 -0
- data/examples/data_validation.rb +50 -0
- data/examples/example.rb +300 -152
- data/examples/example.xlsx +0 -0
- data/examples/example_streamed.xlsx +0 -0
- data/examples/extractive.pdf +0 -0
- data/examples/extractive.rb +45 -0
- data/examples/no-use_autowidth.xlsx +0 -0
- data/examples/sample.png +0 -0
- data/examples/scraping_html.rb +91 -0
- data/examples/shared_strings_example.xlsx +0 -0
- data/examples/sheet_protection.rb +10 -0
- data/examples/sheet_view.rb +34 -0
- data/examples/skydrive/real_example.rb +63 -0
- data/examples/two_cell_anchor_image.rb +11 -0
- data/lib/axlsx/content_type/content_type.rb +2 -0
- data/lib/axlsx/content_type/default.rb +30 -15
- data/lib/axlsx/content_type/override.rb +29 -14
- data/lib/axlsx/doc_props/app.rb +161 -104
- data/lib/axlsx/doc_props/core.rb +9 -5
- data/lib/axlsx/drawing/ax_data_source.rb +26 -0
- data/lib/axlsx/drawing/axis.rb +106 -35
- data/lib/axlsx/drawing/bar_3D_chart.rb +49 -45
- data/lib/axlsx/drawing/bar_series.rb +25 -7
- data/lib/axlsx/drawing/cat_axis.rb +50 -22
- data/lib/axlsx/drawing/chart.rb +69 -56
- data/lib/axlsx/drawing/d_lbls.rb +100 -0
- data/lib/axlsx/drawing/drawing.rb +28 -12
- data/lib/axlsx/drawing/graphic_frame.rb +2 -1
- data/lib/axlsx/drawing/line_3D_chart.rb +3 -10
- data/lib/axlsx/drawing/line_series.rb +20 -4
- data/lib/axlsx/drawing/num_data.rb +52 -0
- data/lib/axlsx/drawing/num_data_source.rb +61 -0
- data/lib/axlsx/drawing/num_val.rb +32 -0
- data/lib/axlsx/drawing/pic.rb +44 -4
- data/lib/axlsx/drawing/pie_3D_chart.rb +10 -7
- data/lib/axlsx/drawing/pie_series.rb +18 -4
- data/lib/axlsx/drawing/scatter_chart.rb +12 -18
- data/lib/axlsx/drawing/scatter_series.rb +28 -2
- data/lib/axlsx/drawing/ser_axis.rb +1 -1
- data/lib/axlsx/drawing/series.rb +1 -1
- data/lib/axlsx/drawing/str_data.rb +42 -0
- data/lib/axlsx/drawing/str_val.rb +33 -0
- data/lib/axlsx/drawing/title.rb +21 -9
- data/lib/axlsx/drawing/two_cell_anchor.rb +46 -9
- data/lib/axlsx/drawing/view_3D.rb +44 -31
- data/lib/axlsx/drawing/vml_drawing.rb +42 -0
- data/lib/axlsx/drawing/vml_shape.rb +125 -0
- data/lib/axlsx/package.rb +44 -16
- data/lib/axlsx/rels/relationship.rb +3 -3
- data/lib/axlsx/rels/relationships.rb +1 -11
- data/lib/axlsx/stylesheet/color.rb +0 -1
- data/lib/axlsx/stylesheet/dxf.rb +79 -0
- data/lib/axlsx/stylesheet/font.rb +2 -1
- data/lib/axlsx/stylesheet/gradient_fill.rb +1 -1
- data/lib/axlsx/stylesheet/styles.rb +143 -50
- data/lib/axlsx/stylesheet/table_style.rb +3 -3
- data/lib/axlsx/stylesheet/xf.rb +2 -0
- data/lib/axlsx/util/constants.rb +36 -0
- data/lib/axlsx/util/simple_typed_list.rb +15 -21
- data/lib/axlsx/util/validators.rb +122 -5
- data/lib/axlsx/version.rb +2 -7
- data/lib/axlsx/workbook/defined_name.rb +174 -0
- data/lib/axlsx/workbook/defined_names.rb +21 -0
- data/lib/axlsx/workbook/shared_strings_table.rb +12 -13
- data/lib/axlsx/workbook/workbook.rb +71 -13
- data/lib/axlsx/workbook/worksheet/auto_filter.rb +34 -0
- data/lib/axlsx/workbook/worksheet/cell.rb +45 -36
- data/lib/axlsx/workbook/worksheet/cfvo.rb +62 -0
- data/lib/axlsx/workbook/worksheet/col.rb +17 -1
- data/lib/axlsx/workbook/worksheet/color_scale.rb +76 -0
- data/lib/axlsx/workbook/worksheet/cols.rb +20 -0
- data/lib/axlsx/workbook/worksheet/comment.rb +101 -0
- data/lib/axlsx/workbook/worksheet/comments.rb +85 -0
- data/lib/axlsx/workbook/worksheet/conditional_formatting.rb +82 -0
- data/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb +216 -0
- data/lib/axlsx/workbook/worksheet/conditional_formattings.rb +25 -0
- data/lib/axlsx/workbook/worksheet/data_bar.rb +97 -0
- data/lib/axlsx/workbook/worksheet/data_validation.rb +245 -0
- data/lib/axlsx/workbook/worksheet/data_validations.rb +28 -0
- data/lib/axlsx/workbook/worksheet/dimension.rb +65 -0
- data/lib/axlsx/workbook/worksheet/icon_set.rb +83 -0
- data/lib/axlsx/workbook/worksheet/merged_cells.rb +35 -0
- data/lib/axlsx/workbook/worksheet/page_setup.rb +113 -0
- data/lib/axlsx/workbook/worksheet/pane.rb +144 -0
- data/lib/axlsx/workbook/worksheet/print_options.rb +63 -0
- data/lib/axlsx/workbook/worksheet/protected_range.rb +46 -0
- data/lib/axlsx/workbook/worksheet/protected_ranges.rb +34 -0
- data/lib/axlsx/workbook/worksheet/row.rb +69 -12
- data/lib/axlsx/workbook/worksheet/selection.rb +111 -0
- data/lib/axlsx/workbook/worksheet/sheet_data.rb +25 -0
- data/lib/axlsx/workbook/worksheet/sheet_pr.rb +24 -0
- data/lib/axlsx/workbook/worksheet/sheet_protection.rb +224 -0
- data/lib/axlsx/workbook/worksheet/sheet_view.rb +379 -0
- data/lib/axlsx/workbook/worksheet/table.rb +3 -3
- data/lib/axlsx/workbook/worksheet/tables.rb +31 -0
- data/lib/axlsx/workbook/worksheet/worksheet.rb +379 -233
- data/lib/axlsx/workbook/worksheet/worksheet_comments.rb +57 -0
- data/lib/axlsx/workbook/worksheet/worksheet_drawing.rb +64 -0
- data/lib/axlsx.rb +31 -16
- data/test/benchmark.rb +30 -38
- data/test/content_type/tc_content_type.rb +1 -6
- data/test/doc_props/tc_app.rb +31 -1
- data/test/doc_props/tc_core.rb +3 -1
- data/test/drawing/tc_axis.rb +46 -3
- data/test/drawing/tc_bar_3D_chart.rb +12 -12
- data/test/drawing/tc_bar_series.rb +17 -13
- data/test/drawing/tc_cat_axis.rb +3 -3
- data/test/drawing/tc_cat_axis_data.rb +23 -13
- data/test/drawing/tc_chart.rb +29 -11
- data/test/drawing/tc_d_lbls.rb +47 -0
- data/test/drawing/tc_data_source.rb +17 -0
- data/test/drawing/tc_drawing.rb +11 -5
- data/test/drawing/tc_hyperlink.rb +4 -5
- data/test/drawing/tc_line_series.rb +9 -11
- data/test/drawing/tc_named_axis_data.rb +27 -0
- data/test/drawing/tc_num_data.rb +31 -0
- data/test/drawing/tc_num_val.rb +29 -0
- data/test/drawing/tc_pic.rb +22 -2
- data/test/drawing/tc_pie_3D_chart.rb +4 -8
- data/test/drawing/tc_pie_series.rb +11 -13
- data/test/drawing/tc_scatter_chart.rb +6 -1
- data/test/drawing/tc_scatter_series.rb +6 -5
- data/test/drawing/tc_series.rb +1 -1
- data/test/drawing/tc_str_data.rb +18 -0
- data/test/drawing/tc_str_val.rb +21 -0
- data/test/drawing/tc_title.rb +16 -0
- data/test/drawing/tc_two_cell_anchor.rb +2 -3
- data/test/drawing/tc_view_3D.rb +18 -18
- data/test/drawing/tc_vml_drawing.rb +25 -0
- data/test/drawing/tc_vml_shape.rb +100 -0
- data/test/profile.rb +2 -1
- data/test/rels/tc_relationship.rb +1 -0
- data/test/stylesheet/tc_dxf.rb +81 -0
- data/test/stylesheet/tc_gradient_fill.rb +8 -0
- data/test/stylesheet/tc_pattern_fill.rb +7 -1
- data/test/stylesheet/tc_styles.rb +163 -3
- data/test/stylesheet/tc_table_style.rb +8 -0
- data/test/stylesheet/tc_table_style_element.rb +10 -1
- data/test/tc_helper.rb +1 -0
- data/test/tc_package.rb +93 -17
- data/test/util/tc_simple_typed_list.rb +13 -0
- data/test/util/tc_validators.rb +95 -9
- data/test/workbook/tc_defined_name.rb +41 -0
- data/test/workbook/tc_workbook.rb +5 -3
- data/test/workbook/worksheet/table/tc_table.rb +3 -11
- data/test/workbook/worksheet/tc_cell.rb +52 -18
- data/test/workbook/worksheet/tc_cfvo.rb +31 -0
- data/test/workbook/worksheet/tc_col.rb +9 -0
- data/test/workbook/worksheet/tc_color_scale.rb +29 -0
- data/test/workbook/worksheet/tc_comment.rb +57 -0
- data/test/workbook/worksheet/tc_comments.rb +57 -0
- data/test/workbook/worksheet/tc_conditional_formatting.rb +217 -0
- data/test/workbook/worksheet/tc_data_bar.rb +39 -0
- data/test/workbook/worksheet/tc_data_validation.rb +265 -0
- data/test/workbook/worksheet/tc_date_time_converter.rb +11 -5
- data/test/workbook/worksheet/tc_icon_set.rb +45 -0
- data/test/workbook/worksheet/tc_page_setup.rb +138 -0
- data/test/workbook/worksheet/tc_pane.rb +94 -0
- data/test/workbook/worksheet/tc_print_options.rb +72 -0
- data/test/workbook/worksheet/tc_protected_range.rb +17 -0
- data/test/workbook/worksheet/tc_row.rb +44 -13
- data/test/workbook/worksheet/tc_selection.rb +94 -0
- data/test/workbook/worksheet/tc_sheet_protection.rb +117 -0
- data/test/workbook/worksheet/tc_sheet_view.rb +214 -0
- data/test/workbook/worksheet/tc_worksheet.rb +147 -50
- metadata +216 -148
- data/examples/example.csv +0 -1000
- data/examples/example.rb~ +0 -112
- data/lib/axlsx/drawing/cat_axis_data.rb +0 -34
- data/lib/axlsx/drawing/hlink_click.rb~ +0 -0
- data/lib/axlsx/drawing/hyperlink.rb~ +0 -64
- data/lib/axlsx/drawing/named_axis_data.rb +0 -36
- data/lib/axlsx/drawing/picture_locking.rb~ +0 -36
- data/lib/axlsx/drawing/val_axis_data.rb +0 -27
- data/lib/axlsx/stylesheet/#num_fmt.rb# +0 -69
- data/lib/axlsx/util/cbf.rb +0 -333
- data/lib/axlsx/util/cfb.rb~ +0 -201
- data/lib/axlsx/util/ms_off_crypto.rb +0 -189
- data/lib/axlsx/util/ms_off_crypto.rb~ +0 -3
- data/lib/axlsx/util/ms_offcrypto.rb~ +0 -0
- data/lib/axlsx/util/parser.rb~ +0 -6
- data/lib/axlsx/util/storage.rb~ +0 -0
- data/lib/axlsx/workbook/shared_strings_table.rb~ +0 -69
- data/lib/axlsx/workbook/worksheet/col.rb~ +0 -0
- data/lib/axlsx/workbook/worksheet/shared_strings_table.rb~ +0 -0
- data/lib/axlsx/workbook/worksheet/table.rb~ +0 -97
- data/lib/schema/dc.xsd~ +0 -118
- data/lib/schema/dcterms.xsd~ +0 -331
- data/lib/schema/opc-coreProperties.xsd~ +0 -50
- data/test/#benchmark.txt# +0 -7
- data/test/#tc_helper.rb# +0 -3
- data/test/benchmark.rb~ +0 -0
- data/test/benchmark.txt +0 -6
- data/test/benchmark.txt~ +0 -6
- data/test/drawing/tc_val_axis_data.rb +0 -17
- data/test/example.csv +0 -1000
- data/test/example.xlsx +0 -0
- data/test/example_streamed.xlsx +0 -0
- data/test/tc_axlsx.rb~ +0 -0
- data/test/tc_helper.rb~ +0 -3
- data/test/workbook/worksheet/table/tc_table.rb~ +0 -72
- data/test/workbook/worksheet/tc_col.rb~ +0 -10
|
@@ -10,24 +10,29 @@ module Axlsx
|
|
|
10
10
|
|
|
11
11
|
# the category axis
|
|
12
12
|
# @return [CatAxis]
|
|
13
|
-
attr_reader :
|
|
13
|
+
attr_reader :cat_axis
|
|
14
|
+
alias :catAxis :cat_axis
|
|
14
15
|
|
|
15
|
-
# the
|
|
16
|
+
# the value axis
|
|
16
17
|
# @return [ValAxis]
|
|
17
|
-
attr_reader :
|
|
18
|
+
attr_reader :val_axis
|
|
19
|
+
alias :valAxis :val_axis
|
|
18
20
|
|
|
19
21
|
# The direction of the bars in the chart
|
|
20
22
|
# must be one of [:bar, :col]
|
|
21
23
|
# @return [Symbol]
|
|
22
|
-
attr_reader :
|
|
24
|
+
attr_reader :bar_dir
|
|
25
|
+
alias :barDir :bar_dir
|
|
23
26
|
|
|
24
27
|
# space between bar or column clusters, as a percentage of the bar or column width.
|
|
25
28
|
# @return [String]
|
|
26
|
-
attr_reader :
|
|
29
|
+
attr_reader :gap_depth
|
|
30
|
+
alias :gapDepth :gap_depth
|
|
27
31
|
|
|
28
32
|
# space between bar or column clusters, as a percentage of the bar or column width.
|
|
29
33
|
# @return [String]
|
|
30
|
-
attr_reader :
|
|
34
|
+
attr_reader :gap_width
|
|
35
|
+
alias :gapWidth :gap_width
|
|
31
36
|
|
|
32
37
|
#grouping for a column, line, or area chart.
|
|
33
38
|
# must be one of [:percentStacked, :clustered, :standard, :stacked]
|
|
@@ -46,38 +51,42 @@ module Axlsx
|
|
|
46
51
|
# @param [GraphicFrame] frame The workbook that owns this chart.
|
|
47
52
|
# @option options [Cell, String] title
|
|
48
53
|
# @option options [Boolean] show_legend
|
|
49
|
-
# @option options [Symbol]
|
|
54
|
+
# @option options [Symbol] bar_dir
|
|
50
55
|
# @option options [Symbol] grouping
|
|
51
|
-
# @option options [String]
|
|
52
|
-
# @option options [String]
|
|
56
|
+
# @option options [String] gap_width
|
|
57
|
+
# @option options [String] gap_depth
|
|
53
58
|
# @option options [Symbol] shape
|
|
54
|
-
# @option options [Integer]
|
|
55
|
-
# @option options [String]
|
|
56
|
-
# @option options [Integer]
|
|
57
|
-
# @option options [String]
|
|
58
|
-
# @option options [Boolean]
|
|
59
|
+
# @option options [Integer] rot_x
|
|
60
|
+
# @option options [String] h_percent
|
|
61
|
+
# @option options [Integer] rot_y
|
|
62
|
+
# @option options [String] depth_percent
|
|
63
|
+
# @option options [Boolean] r_ang_ax
|
|
59
64
|
# @option options [Integer] perspective
|
|
60
65
|
# @see Chart
|
|
61
66
|
# @see View3D
|
|
62
67
|
def initialize(frame, options={})
|
|
63
|
-
@
|
|
68
|
+
@bar_dir = :bar
|
|
64
69
|
@grouping = :clustered
|
|
65
|
-
@
|
|
66
|
-
@
|
|
67
|
-
@
|
|
68
|
-
@
|
|
69
|
-
@
|
|
70
|
+
@shape = :box
|
|
71
|
+
@gap_width = 150
|
|
72
|
+
@gap_width, @gap_depth, @shape = nil, nil, nil
|
|
73
|
+
@cat_ax_id = rand(8 ** 8)
|
|
74
|
+
@val_ax_id = rand(8 ** 8)
|
|
75
|
+
@cat_axis = CatAxis.new(@cat_ax_id, @val_ax_id)
|
|
76
|
+
@val_axis = ValAxis.new(@val_ax_id, @cat_ax_id, :tick_lbl_pos => :low, :ax_pos => :l)
|
|
70
77
|
super(frame, options)
|
|
71
78
|
@series_type = BarSeries
|
|
72
|
-
@
|
|
79
|
+
@view_3D = View3D.new({:r_ang_ax=>1}.merge(options))
|
|
80
|
+
@d_lbls = nil
|
|
73
81
|
end
|
|
74
82
|
|
|
75
83
|
# The direction of the bars in the chart
|
|
76
84
|
# must be one of [:bar, :col]
|
|
77
|
-
def
|
|
78
|
-
RestrictionValidator.validate "Bar3DChart.
|
|
79
|
-
@
|
|
85
|
+
def bar_dir=(v)
|
|
86
|
+
RestrictionValidator.validate "Bar3DChart.bar_dir", [:bar, :col], v
|
|
87
|
+
@bar_dir = v
|
|
80
88
|
end
|
|
89
|
+
alias :barDir= :bar_dir=
|
|
81
90
|
|
|
82
91
|
#grouping for a column, line, or area chart.
|
|
83
92
|
# must be one of [:percentStacked, :clustered, :standard, :stacked]
|
|
@@ -87,16 +96,18 @@ module Axlsx
|
|
|
87
96
|
end
|
|
88
97
|
|
|
89
98
|
# space between bar or column clusters, as a percentage of the bar or column width.
|
|
90
|
-
def
|
|
91
|
-
RegexValidator.validate "Bar3DChart.
|
|
92
|
-
@
|
|
99
|
+
def gap_width=(v)
|
|
100
|
+
RegexValidator.validate "Bar3DChart.gap_width", GAP_AMOUNT_PERCENT, v
|
|
101
|
+
@gap_width=(v)
|
|
93
102
|
end
|
|
103
|
+
alias :gapWidth= :gap_width=
|
|
94
104
|
|
|
95
105
|
# space between bar or column clusters, as a percentage of the bar or column width.
|
|
96
|
-
def
|
|
97
|
-
RegexValidator.validate "Bar3DChart.
|
|
98
|
-
@
|
|
106
|
+
def gap_depth=(v)
|
|
107
|
+
RegexValidator.validate "Bar3DChart.gap_didth", GAP_AMOUNT_PERCENT, v
|
|
108
|
+
@gap_depth=(v)
|
|
99
109
|
end
|
|
110
|
+
alias :gapDepth= :gap_depth=
|
|
100
111
|
|
|
101
112
|
# The shabe of the bars or columns
|
|
102
113
|
# must be one of [:cone, :coneToMax, :box, :cylinder, :pyramid, :pyramidToMax]
|
|
@@ -111,27 +122,20 @@ module Axlsx
|
|
|
111
122
|
def to_xml_string(str = '')
|
|
112
123
|
super(str) do |str_inner|
|
|
113
124
|
str_inner << '<c:bar3DChart>'
|
|
114
|
-
str_inner << '<c:barDir val="' <<
|
|
125
|
+
str_inner << '<c:barDir val="' << bar_dir.to_s << '"/>'
|
|
115
126
|
str_inner << '<c:grouping val="' << grouping.to_s << '"/>'
|
|
116
127
|
str_inner << '<c:varyColors val="1"/>'
|
|
117
128
|
@series.each { |ser| ser.to_xml_string(str_inner) }
|
|
118
|
-
|
|
119
|
-
str_inner << '<c:
|
|
120
|
-
str_inner << '<c:
|
|
121
|
-
str_inner << '<c:showCatName val="0"/>'
|
|
122
|
-
str_inner << '<c:showSerName val="0"/>'
|
|
123
|
-
str_inner << '<c:showPercent val="0"/>'
|
|
124
|
-
str_inner << '<c:showBubbleSize val="0"/>'
|
|
125
|
-
str_inner << '</c:dLbls>'
|
|
126
|
-
str_inner << '<c:gapWidth val="' << @gapWidth.to_s << '"/>' unless @gapWidth.nil?
|
|
127
|
-
str_inner << '<c:gapDepth val="' << @gapDepth.to_s << '"/>' unless @gapDepth.nil?
|
|
129
|
+
@d_lbls.to_xml_string(str) if @d_lbls
|
|
130
|
+
str_inner << '<c:gapWidth val="' << @gap_width.to_s << '"/>' unless @gap_width.nil?
|
|
131
|
+
str_inner << '<c:gapDepth val="' << @gap_depth.to_s << '"/>' unless @gap_depth.nil?
|
|
128
132
|
str_inner << '<c:shape val="' << @shape.to_s << '"/>' unless @shape.nil?
|
|
129
|
-
str_inner << '<c:axId val="' << @
|
|
130
|
-
str_inner << '<c:axId val="' << @
|
|
133
|
+
str_inner << '<c:axId val="' << @cat_ax_id.to_s << '"/>'
|
|
134
|
+
str_inner << '<c:axId val="' << @val_ax_id.to_s << '"/>'
|
|
131
135
|
str_inner << '<c:axId val="0"/>'
|
|
132
136
|
str_inner << '</c:bar3DChart>'
|
|
133
|
-
@
|
|
134
|
-
@
|
|
137
|
+
@cat_axis.to_xml_string str_inner
|
|
138
|
+
@val_axis.to_xml_string str_inner
|
|
135
139
|
end
|
|
136
140
|
end
|
|
137
141
|
end
|
|
@@ -8,7 +8,7 @@ module Axlsx
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
# The data for this series.
|
|
11
|
-
# @return [
|
|
11
|
+
# @return [NumDataSource]
|
|
12
12
|
attr_reader :data
|
|
13
13
|
|
|
14
14
|
# The labels for this series.
|
|
@@ -20,21 +20,29 @@ module Axlsx
|
|
|
20
20
|
# @return [Symbol]
|
|
21
21
|
attr_reader :shape
|
|
22
22
|
|
|
23
|
+
# An array of rgb colors to apply to your bar chart.
|
|
24
|
+
attr_reader :colors
|
|
25
|
+
|
|
23
26
|
# Creates a new series
|
|
24
27
|
# @option options [Array, SimpleTypedList] data
|
|
25
28
|
# @option options [Array, SimpleTypedList] labels
|
|
26
29
|
# @option options [String] title
|
|
27
30
|
# @option options [String] shape
|
|
31
|
+
# @option options [String] colors an array of colors to use when rendering each data point
|
|
28
32
|
# @param [Chart] chart
|
|
29
33
|
def initialize(chart, options={})
|
|
30
34
|
@shape = :box
|
|
35
|
+
@colors = []
|
|
31
36
|
super(chart, options)
|
|
32
|
-
self.labels =
|
|
33
|
-
self.data =
|
|
37
|
+
self.labels = AxDataSource.new({:data => options[:labels]}) unless options[:labels].nil?
|
|
38
|
+
self.data = NumDataSource.new(options) unless options[:data].nil?
|
|
34
39
|
end
|
|
35
40
|
|
|
41
|
+
# @see colors
|
|
42
|
+
def colors=(v) DataTypeValidator.validate "BarSeries.colors", [Array], v; @colors = v end
|
|
43
|
+
|
|
36
44
|
# The shabe of the bars or columns
|
|
37
|
-
# must be one of [:
|
|
45
|
+
# must be one of [:cone, :coneToMax, :box, :cylinder, :pyramid, :pyramidToMax]
|
|
38
46
|
def shape=(v)
|
|
39
47
|
RestrictionValidator.validate "BarSeries.shape", [:cone, :coneToMax, :box, :cylinder, :pyramid, :pyramidToMax], v
|
|
40
48
|
@shape = v
|
|
@@ -45,19 +53,29 @@ module Axlsx
|
|
|
45
53
|
# @return [String]
|
|
46
54
|
def to_xml_string(str = '')
|
|
47
55
|
super(str) do |str_inner|
|
|
56
|
+
|
|
57
|
+
colors.each_with_index do |c, index|
|
|
58
|
+
str_inner << '<c:dPt>'
|
|
59
|
+
str_inner << '<c:idx val="' << index.to_s << '"/>'
|
|
60
|
+
str_inner << '<c:spPr><a:solidFill>'
|
|
61
|
+
str_inner << '<a:srgbClr val="' << c << '"/>'
|
|
62
|
+
str_inner << '</a:solidFill></c:spPr></c:dPt>'
|
|
63
|
+
end
|
|
64
|
+
|
|
48
65
|
@labels.to_xml_string(str_inner) unless @labels.nil?
|
|
49
66
|
@data.to_xml_string(str_inner) unless @data.nil?
|
|
50
|
-
|
|
67
|
+
# this is actually only required for shapes other than box
|
|
68
|
+
str_inner << '<c:shape val="' << shape.to_s << '"></c:shape>'
|
|
51
69
|
end
|
|
52
70
|
end
|
|
53
71
|
|
|
54
72
|
private
|
|
55
73
|
|
|
56
74
|
# assigns the data for this series
|
|
57
|
-
def data=(v) DataTypeValidator.validate "Series.data", [
|
|
75
|
+
def data=(v) DataTypeValidator.validate "Series.data", [NumDataSource], v; @data = v; end
|
|
58
76
|
|
|
59
77
|
# assigns the labels for this series
|
|
60
|
-
def labels=(v) DataTypeValidator.validate "Series.labels", [
|
|
78
|
+
def labels=(v) DataTypeValidator.validate "Series.labels", [AxDataSource], v; @labels = v; end
|
|
61
79
|
|
|
62
80
|
end
|
|
63
81
|
|
|
@@ -3,6 +3,26 @@ module Axlsx
|
|
|
3
3
|
#A CatAxis object defines a chart category axis
|
|
4
4
|
class CatAxis < Axis
|
|
5
5
|
|
|
6
|
+
# Creates a new CatAxis object
|
|
7
|
+
# @param [Integer] ax_id the id of this axis. Inherited
|
|
8
|
+
# @param [Integer] cross_ax the id of the perpendicular axis. Inherited
|
|
9
|
+
# @option options [Symbol] ax_pos. Inherited
|
|
10
|
+
# @option options [Symbol] tick_lbl_pos. Inherited
|
|
11
|
+
# @option options [Symbol] crosses. Inherited
|
|
12
|
+
# @option options [Boolean] auto
|
|
13
|
+
# @option options [Symbol] lbl_algn
|
|
14
|
+
# @option options [Integer] lbl_offset
|
|
15
|
+
# @option options [Integer] tick_lbl_skip
|
|
16
|
+
# @option options [Integer] tick_mark_skip
|
|
17
|
+
def initialize(ax_id, cross_ax, options={})
|
|
18
|
+
@tick_lbl_skip = 1
|
|
19
|
+
@tick_mark_skip = 1
|
|
20
|
+
self.auto = 1
|
|
21
|
+
self.lbl_algn = :ctr
|
|
22
|
+
self.lbl_offset = "100"
|
|
23
|
+
super(ax_id, cross_ax, options)
|
|
24
|
+
end
|
|
25
|
+
|
|
6
26
|
# From the docs: This element specifies that this axis is a date or text axis based on the data that is used for the axis labels, not a specific choice.
|
|
7
27
|
# @return [Boolean]
|
|
8
28
|
attr_reader :auto
|
|
@@ -10,42 +30,48 @@ module Axlsx
|
|
|
10
30
|
# specifies how the perpendicular axis is crossed
|
|
11
31
|
# must be one of [:ctr, :l, :r]
|
|
12
32
|
# @return [Symbol]
|
|
13
|
-
attr_reader :
|
|
33
|
+
attr_reader :lbl_algn
|
|
34
|
+
alias :lblAlgn :lbl_algn
|
|
14
35
|
|
|
15
36
|
# The offset of the labels
|
|
16
37
|
# must be between a string between 0 and 1000
|
|
17
38
|
# @return [Integer]
|
|
18
|
-
attr_reader :
|
|
39
|
+
attr_reader :lbl_offset
|
|
40
|
+
alias :lblOffset :lbl_offset
|
|
41
|
+
|
|
42
|
+
# The number of tick lables to skip between labels
|
|
43
|
+
# @return [Integer]
|
|
44
|
+
attr_reader :tick_lbl_skip
|
|
45
|
+
alias :tickLblSkip :tick_lbl_skip
|
|
46
|
+
|
|
47
|
+
# The number of tickmarks to be skipped before the next one is rendered.
|
|
48
|
+
# @return [Boolean]
|
|
49
|
+
attr_reader :tick_mark_skip
|
|
50
|
+
alias :tickMarkSkip :tick_mark_skip
|
|
19
51
|
|
|
20
52
|
# regex for validating label offset
|
|
21
|
-
LBL_OFFSET_REGEX = /0*(([0-9])|([1-9][0-9])|([1-9][0-9][0-9])|1000)
|
|
53
|
+
LBL_OFFSET_REGEX = /0*(([0-9])|([1-9][0-9])|([1-9][0-9][0-9])|1000)/
|
|
22
54
|
|
|
23
|
-
#
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
# @
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
# @option options [Symbol] lblAlgn
|
|
31
|
-
# @option options [Integer] lblOffset
|
|
32
|
-
def initialize(axId, crossAx, options={})
|
|
33
|
-
self.auto = 1
|
|
34
|
-
self.lblAlgn = :ctr
|
|
35
|
-
self.lblOffset = "100%"
|
|
36
|
-
super(axId, crossAx, options)
|
|
37
|
-
end
|
|
55
|
+
# @see tick_lbl_skip
|
|
56
|
+
def tick_lbl_skip=(v) Axlsx::validate_unsigned_int(v); @tick_lbl_skip = v; end
|
|
57
|
+
alias :tickLblSkip= :tick_lbl_skip=
|
|
58
|
+
|
|
59
|
+
# @see tick_mark_skip
|
|
60
|
+
def tick_mark_skip=(v) Axlsx::validate_unsigned_int(v); @tick_mark_skip = v; end
|
|
61
|
+
alias :tickMarkSkip= :tick_mark_skip=
|
|
38
62
|
|
|
39
63
|
# From the docs: This element specifies that this axis is a date or text axis based on the data that is used for the axis labels, not a specific choice.
|
|
40
64
|
def auto=(v) Axlsx::validate_boolean(v); @auto = v; end
|
|
41
65
|
|
|
42
66
|
# specifies how the perpendicular axis is crossed
|
|
43
67
|
# must be one of [:ctr, :l, :r]
|
|
44
|
-
def
|
|
68
|
+
def lbl_algn=(v) RestrictionValidator.validate "#{self.class}.lbl_algn", [:ctr, :l, :r], v; @lbl_algn = v; end
|
|
69
|
+
alias :lblAlgn= :lbl_algn=
|
|
45
70
|
|
|
46
71
|
# The offset of the labels
|
|
47
72
|
# must be between a string between 0 and 1000
|
|
48
|
-
def
|
|
73
|
+
def lbl_offset=(v) RegexValidator.validate "#{self.class}.lbl_offset", LBL_OFFSET_REGEX, v; @lbl_offset = v; end
|
|
74
|
+
alias :lblOffset= :lbl_offset=
|
|
49
75
|
|
|
50
76
|
# Serializes the object
|
|
51
77
|
# @param [String] str
|
|
@@ -54,8 +80,10 @@ module Axlsx
|
|
|
54
80
|
str << '<c:catAx>'
|
|
55
81
|
super(str)
|
|
56
82
|
str << '<c:auto val="' << @auto.to_s << '"/>'
|
|
57
|
-
str << '<c:lblAlgn val="' << @
|
|
58
|
-
str << '<c:lblOffset val="' << @
|
|
83
|
+
str << '<c:lblAlgn val="' << @lbl_algn.to_s << '"/>'
|
|
84
|
+
str << '<c:lblOffset val="' << @lbl_offset.to_i.to_s << '"/>'
|
|
85
|
+
str << '<c:tickLblSkip val="' << @tick_lbl_skip.to_s << '"/>'
|
|
86
|
+
str << '<c:tickMarkSkip val="' << @tick_mark_skip.to_s << '"/>'
|
|
59
87
|
str << '</c:catAx>'
|
|
60
88
|
end
|
|
61
89
|
|
data/lib/axlsx/drawing/chart.rb
CHANGED
|
@@ -1,13 +1,37 @@
|
|
|
1
1
|
# encoding: UTF-8
|
|
2
2
|
module Axlsx
|
|
3
|
+
|
|
3
4
|
# A Chart is the superclass for specific charts
|
|
4
5
|
# @note Worksheet#add_chart is the recommended way to create charts for your worksheets.
|
|
5
6
|
# @see README for examples
|
|
6
7
|
class Chart
|
|
7
8
|
|
|
9
|
+
# Creates a new chart object
|
|
10
|
+
# @param [GraphicalFrame] frame The frame that holds this chart.
|
|
11
|
+
# @option options [Cell, String] title
|
|
12
|
+
# @option options [Boolean] show_legend
|
|
13
|
+
# @option options [Array|String|Cell] start_at The X, Y coordinates defining the top left corner of the chart.
|
|
14
|
+
# @option options [Array|String|Cell] end_at The X, Y coordinates defining the bottom right corner of the chart.
|
|
15
|
+
def initialize(frame, options={})
|
|
16
|
+
@style = 18
|
|
17
|
+
@view_3D = nil
|
|
18
|
+
@graphic_frame=frame
|
|
19
|
+
@graphic_frame.anchor.drawing.worksheet.workbook.charts << self
|
|
20
|
+
@series = SimpleTypedList.new Series
|
|
21
|
+
@show_legend = true
|
|
22
|
+
@series_type = Series
|
|
23
|
+
@title = Title.new
|
|
24
|
+
options.each do |o|
|
|
25
|
+
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
|
26
|
+
end
|
|
27
|
+
start_at(*options[:start_at]) if options[:start_at]
|
|
28
|
+
end_at(*options[:end_at]) if options[:end_at]
|
|
29
|
+
yield self if block_given?
|
|
30
|
+
end
|
|
8
31
|
|
|
9
32
|
# The 3D view properties for the chart
|
|
10
|
-
attr_reader :
|
|
33
|
+
attr_reader :view_3D
|
|
34
|
+
alias :view3D :view_3D
|
|
11
35
|
|
|
12
36
|
# A reference to the graphic frame that owns this chart
|
|
13
37
|
# @return [GraphicFrame]
|
|
@@ -22,7 +46,10 @@ module Axlsx
|
|
|
22
46
|
attr_reader :series_type
|
|
23
47
|
|
|
24
48
|
#TODO data labels!
|
|
25
|
-
|
|
49
|
+
def d_lbls
|
|
50
|
+
@d_lbls ||= DLbls.new(self.class)
|
|
51
|
+
end
|
|
52
|
+
|
|
26
53
|
|
|
27
54
|
# The title object for the chart.
|
|
28
55
|
# @return [Title]
|
|
@@ -37,27 +64,6 @@ module Axlsx
|
|
|
37
64
|
# @return [Boolean]
|
|
38
65
|
attr_reader :show_legend
|
|
39
66
|
|
|
40
|
-
# Creates a new chart object
|
|
41
|
-
# @param [GraphicalFrame] frame The frame that holds this chart.
|
|
42
|
-
# @option options [Cell, String] title
|
|
43
|
-
# @option options [Boolean] show_legend
|
|
44
|
-
def initialize(frame, options={})
|
|
45
|
-
@style = 2
|
|
46
|
-
@view3D = nil
|
|
47
|
-
@graphic_frame=frame
|
|
48
|
-
@graphic_frame.anchor.drawing.worksheet.workbook.charts << self
|
|
49
|
-
@series = SimpleTypedList.new Series
|
|
50
|
-
@show_legend = true
|
|
51
|
-
@series_type = Series
|
|
52
|
-
@title = Title.new
|
|
53
|
-
options.each do |o|
|
|
54
|
-
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
|
55
|
-
end
|
|
56
|
-
start_at(*options[:start_at]) if options[:start_at]
|
|
57
|
-
end_at(*options[:end_at]) if options[:start_at]
|
|
58
|
-
yield self if block_given?
|
|
59
|
-
end
|
|
60
|
-
|
|
61
67
|
# The index of this chart in the workbooks charts collection
|
|
62
68
|
# @return [Integer]
|
|
63
69
|
def index
|
|
@@ -87,7 +93,6 @@ module Axlsx
|
|
|
87
93
|
# @return [Boolean]
|
|
88
94
|
def show_legend=(v) Axlsx::validate_boolean(v); @show_legend = v; end
|
|
89
95
|
|
|
90
|
-
|
|
91
96
|
# The style for the chart.
|
|
92
97
|
# see ECMA Part 1 §21.2.2.196
|
|
93
98
|
# @param [Integer] v must be between 1 and 48
|
|
@@ -118,14 +123,14 @@ module Axlsx
|
|
|
118
123
|
# @return [String]
|
|
119
124
|
def to_xml_string(str = '')
|
|
120
125
|
str << '<?xml version="1.0" encoding="UTF-8"?>'
|
|
121
|
-
str << '<c:chartSpace xmlns:c="' << XML_NS_C << '" xmlns:a="' << XML_NS_A << '">'
|
|
126
|
+
str << '<c:chartSpace xmlns:c="' << XML_NS_C << '" xmlns:a="' << XML_NS_A << '" xmlns:r="' << XML_NS_R << '">'
|
|
122
127
|
str << '<c:date1904 val="' << Axlsx::Workbook.date1904.to_s << '"/>'
|
|
123
128
|
str << '<c:style val="' << style.to_s << '"/>'
|
|
124
129
|
str << '<c:chart>'
|
|
125
130
|
@title.to_xml_string str
|
|
126
131
|
# do these need the c: namespace as well???
|
|
127
|
-
str << '<c:autoTitleDeleted val="
|
|
128
|
-
@
|
|
132
|
+
str << '<c:autoTitleDeleted val="' << (@title == nil).to_s << '"/>'
|
|
133
|
+
@view_3D.to_xml_string(str) if @view_3D
|
|
129
134
|
str << '<c:floor><c:thickness val="0"/></c:floor>'
|
|
130
135
|
str << '<c:sideWall><c:thickness val="0"/></c:sideWall>'
|
|
131
136
|
str << '<c:backWall><c:thickness val="0"/></c:backWall>'
|
|
@@ -144,49 +149,57 @@ module Axlsx
|
|
|
144
149
|
str << '<c:dispBlanksAs val="zero"/>'
|
|
145
150
|
str << '<c:showDLblsOverMax val="1"/>'
|
|
146
151
|
str << '</c:chart>'
|
|
152
|
+
str << '<c:printSettings>'
|
|
153
|
+
str << '<c:headerFooter/>'
|
|
154
|
+
str << '<c:pageMargins b="1.0" l="0.75" r="0.75" t="1.0" header="0.5" footer="0.5"/>'
|
|
155
|
+
str << '<c:pageSetup/>'
|
|
156
|
+
str << '</c:printSettings>'
|
|
147
157
|
str << '</c:chartSpace>'
|
|
148
158
|
end
|
|
149
159
|
|
|
150
|
-
# This is a short cut method to set the start
|
|
160
|
+
# This is a short cut method to set the anchor start marker position
|
|
151
161
|
# If you need finer granularity in positioning use
|
|
152
|
-
#
|
|
153
|
-
#
|
|
162
|
+
#
|
|
163
|
+
# This helper method acceps a fairly wide range of inputs exampled
|
|
164
|
+
# below
|
|
165
|
+
#
|
|
166
|
+
# @example
|
|
167
|
+
#
|
|
168
|
+
# start_at 0, 5 # The anchor start marker is set to 6th row of
|
|
169
|
+
# the first column
|
|
170
|
+
#
|
|
171
|
+
# start_at [0, 5] # The anchor start marker is set to start on the 6th row
|
|
172
|
+
# of the first column
|
|
173
|
+
#
|
|
174
|
+
# start_at "C1" # The anchor start marker is set to start on the first row
|
|
175
|
+
# of the third column
|
|
176
|
+
#
|
|
177
|
+
# start_at sheet.rows.first.cells.last # The anchor start
|
|
178
|
+
# marker is set to the location of a specific cell.
|
|
179
|
+
#
|
|
180
|
+
# @param [Array|String|Cell] x the column, coordinates, string
|
|
181
|
+
# reference or cell to use in setting the start marker position.
|
|
154
182
|
# @param [Integer] y The row
|
|
155
183
|
# @return [Marker]
|
|
156
|
-
def start_at(x, y=0)
|
|
157
|
-
|
|
158
|
-
@graphic_frame.anchor.from.col = x
|
|
159
|
-
@graphic_frame.anchor.from.row = y
|
|
184
|
+
def start_at(x=0, y=0)
|
|
185
|
+
@graphic_frame.anchor.start_at(x, y)
|
|
160
186
|
end
|
|
161
187
|
|
|
162
188
|
# This is a short cut method to set the end anchor position
|
|
163
189
|
# If you need finer granularity in positioning use
|
|
164
190
|
# graphic_frame.anchor.to.colOff / rowOff
|
|
165
|
-
# @param [Integer] x The column
|
|
166
|
-
# @param [Integer] y The row
|
|
191
|
+
# @param [Integer] x The column - default 10
|
|
192
|
+
# @param [Integer] y The row - default 10
|
|
167
193
|
# @return [Marker]
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
@graphic_frame.anchor.
|
|
171
|
-
@graphic_frame.anchor.to.row = y
|
|
194
|
+
# @see start_at
|
|
195
|
+
def end_at(x=10, y=10)
|
|
196
|
+
@graphic_frame.anchor.end_at(x, y)
|
|
172
197
|
end
|
|
173
198
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
if x.is_a?(String)
|
|
178
|
-
x, y = *Axlsx::name_to_indices(x)
|
|
179
|
-
end
|
|
180
|
-
if x.is_a?(Cell)
|
|
181
|
-
x, y = *x.pos
|
|
182
|
-
end
|
|
183
|
-
if x.is_a?(Array)
|
|
184
|
-
x, y = *x
|
|
185
|
-
end
|
|
186
|
-
[x, y]
|
|
187
|
-
end
|
|
188
|
-
|
|
189
|
-
def view3D=(v) DataTypeValidator.validate "#{self.class}.view3D", View3D, v; @view3D = v; end
|
|
199
|
+
# sets the view_3D object for the chart
|
|
200
|
+
def view_3D=(v) DataTypeValidator.validate "#{self.class}.view_3D", View3D, v; @view_3D = v; end
|
|
201
|
+
alias :view3D= :view_3D=
|
|
190
202
|
|
|
191
203
|
end
|
|
204
|
+
|
|
192
205
|
end
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
module Axlsx
|
|
2
|
+
# There are more elements in the dLbls spec that allow for
|
|
3
|
+
# customizations and formatting. For now, I am just implementing the
|
|
4
|
+
# basics.
|
|
5
|
+
|
|
6
|
+
#The DLbls class manages serialization of data labels
|
|
7
|
+
# showLeaderLines and leaderLines are not currently implemented
|
|
8
|
+
class DLbls
|
|
9
|
+
|
|
10
|
+
# These attributes are all boolean so I'm doing a bit of a hand
|
|
11
|
+
# waving magic show to set up the attriubte accessors
|
|
12
|
+
# @note
|
|
13
|
+
# not all charts support all methods!
|
|
14
|
+
# Bar3DChart and Line3DChart and ScatterChart do not support d_lbl_pos or show_leader_lines
|
|
15
|
+
#
|
|
16
|
+
BOOLEAN_ATTRIBUTES = [:show_legend_key, :show_val, :show_cat_name, :show_ser_name, :show_percent, :show_bubble_size, :show_leader_lines]
|
|
17
|
+
|
|
18
|
+
# creates a new DLbls object
|
|
19
|
+
def initialize(chart_type, options={})
|
|
20
|
+
raise ArgumentError, 'chart_type must inherit from Chart' unless chart_type.superclass == Chart
|
|
21
|
+
@chart_type = chart_type
|
|
22
|
+
initialize_defaults
|
|
23
|
+
options.each do |o|
|
|
24
|
+
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Initialize all the values to false as Excel requires them to
|
|
29
|
+
# explicitly be disabled or all will show.
|
|
30
|
+
def initialize_defaults
|
|
31
|
+
BOOLEAN_ATTRIBUTES.each do |attr|
|
|
32
|
+
self.send("#{attr}=", false)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# The chart type that is using this data lables instance.
|
|
37
|
+
# This affects the xml output as not all chart types support the
|
|
38
|
+
# same data label attributes.
|
|
39
|
+
attr_reader :chart_type
|
|
40
|
+
|
|
41
|
+
# The position of the data labels in the chart
|
|
42
|
+
# @see d_lbl_pos= for a list of allowed values
|
|
43
|
+
# @return [Symbol]
|
|
44
|
+
def d_lbl_pos
|
|
45
|
+
return unless @chart_type == Pie3DChart
|
|
46
|
+
@d_lbl_pos ||= :bestFit
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# @see DLbls#d_lbl_pos
|
|
50
|
+
# Assigns the label postion for this data labels on this chart.
|
|
51
|
+
# Allowed positions are :bestFilt, :b, :ctr, :inBase, :inEnd, :l,
|
|
52
|
+
# :outEnd, :r and :t
|
|
53
|
+
# The default is :bestFit
|
|
54
|
+
# @param [Symbol] label_position the postion you want to use.
|
|
55
|
+
def d_lbl_pos=(label_position)
|
|
56
|
+
return unless @chart_type == Pie3DChart
|
|
57
|
+
Axlsx::RestrictionValidator.validate 'DLbls#d_lbl_pos', [:bestFit, :b, :ctr, :inBase, :inEnd, :l, :outEnd, :r, :t], label_position
|
|
58
|
+
@d_lbl_pos = label_position
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# Dynamically create accessors for boolean attriubtes
|
|
62
|
+
BOOLEAN_ATTRIBUTES.each do |attr|
|
|
63
|
+
class_eval %{
|
|
64
|
+
# The #{attr} attribute reader
|
|
65
|
+
# @return [Boolean]
|
|
66
|
+
attr_reader :#{attr}
|
|
67
|
+
|
|
68
|
+
# The #{attr} writer
|
|
69
|
+
# @param [Boolean] value The value to assign to #{attr}
|
|
70
|
+
# @return [Boolean]
|
|
71
|
+
def #{attr}=(value)
|
|
72
|
+
Axlsx::validate_boolean(value)
|
|
73
|
+
@#{attr} = value
|
|
74
|
+
end
|
|
75
|
+
}
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
# serializes the data labels
|
|
80
|
+
# @return [String]
|
|
81
|
+
def to_xml_string(str = '')
|
|
82
|
+
validate_attributes_for_chart_type
|
|
83
|
+
str << '<c:dLbls>'
|
|
84
|
+
%w(d_lbl_pos show_legend_key show_val show_cat_name show_ser_name show_percent show_bubble_size show_leader_lines).each do |key|
|
|
85
|
+
next unless instance_values.keys.include?(key) && instance_values[key] != nil
|
|
86
|
+
str << "<c:#{Axlsx::camel(key, false)} val='#{instance_values[key]}' />"
|
|
87
|
+
end
|
|
88
|
+
str << '</c:dLbls>'
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# nills out d_lbl_pos and show_leader_lines as these attributes, while valid in the spec actually chrash excel for any chart type other than pie charts.
|
|
92
|
+
def validate_attributes_for_chart_type
|
|
93
|
+
return if @chart_type == Pie3DChart
|
|
94
|
+
@d_lbl_pos = nil
|
|
95
|
+
@show_leader_lines = nil
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
end
|
|
100
|
+
end
|