write_xlsx 1.12.3 → 1.15.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.
Files changed (118) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +22 -0
  3. data/Changes +23 -0
  4. data/README.md +1 -1
  5. data/lib/write_xlsx/chart/area.rb +2 -2
  6. data/lib/write_xlsx/chart/axis.rb +55 -32
  7. data/lib/write_xlsx/chart/axis_writer.rb +528 -0
  8. data/lib/write_xlsx/chart/bar.rb +2 -2
  9. data/lib/write_xlsx/chart/caption.rb +16 -9
  10. data/lib/write_xlsx/chart/chart_area.rb +121 -0
  11. data/lib/write_xlsx/chart/column.rb +2 -2
  12. data/lib/write_xlsx/chart/d_pt_point_writer.rb +14 -0
  13. data/lib/write_xlsx/chart/doughnut.rb +0 -3
  14. data/lib/write_xlsx/chart/formatting_writer.rb +652 -0
  15. data/lib/write_xlsx/chart/initialization.rb +100 -0
  16. data/lib/write_xlsx/chart/line.rb +4 -3
  17. data/lib/write_xlsx/chart/pie.rb +6 -2
  18. data/lib/write_xlsx/chart/radar.rb +2 -2
  19. data/lib/write_xlsx/chart/scatter.rb +4 -3
  20. data/lib/write_xlsx/chart/series.rb +35 -15
  21. data/lib/write_xlsx/chart/series_data.rb +132 -0
  22. data/lib/write_xlsx/chart/series_writer.rb +318 -0
  23. data/lib/write_xlsx/chart/settings.rb +226 -0
  24. data/lib/write_xlsx/chart/stock.rb +2 -2
  25. data/lib/write_xlsx/chart/table.rb +50 -0
  26. data/lib/write_xlsx/chart/xml_writer.rb +305 -0
  27. data/lib/write_xlsx/chart.rb +286 -2477
  28. data/lib/write_xlsx/chartsheet.rb +35 -83
  29. data/lib/write_xlsx/constants.rb +11 -0
  30. data/lib/write_xlsx/drawing.rb +5 -3
  31. data/lib/write_xlsx/format/alignment_state.rb +39 -0
  32. data/lib/write_xlsx/format/alignment_style.rb +92 -0
  33. data/lib/write_xlsx/format/border_state.rb +47 -0
  34. data/lib/write_xlsx/format/border_style.rb +116 -0
  35. data/lib/write_xlsx/format/fill_state.rb +26 -0
  36. data/lib/write_xlsx/format/fill_style.rb +52 -0
  37. data/lib/write_xlsx/format/font_state.rb +74 -0
  38. data/lib/write_xlsx/format/font_style.rb +172 -0
  39. data/lib/write_xlsx/format/format_state.rb +65 -0
  40. data/lib/write_xlsx/format/number_format_state.rb +20 -0
  41. data/lib/write_xlsx/format/number_format_style.rb +28 -0
  42. data/lib/write_xlsx/format/protection_state.rb +20 -0
  43. data/lib/write_xlsx/format/protection_style.rb +28 -0
  44. data/lib/write_xlsx/format.rb +1093 -426
  45. data/lib/write_xlsx/formats.rb +0 -2
  46. data/lib/write_xlsx/image_property.rb +4 -1
  47. data/lib/write_xlsx/inserted_chart.rb +1 -1
  48. data/lib/write_xlsx/object_positioning.rb +203 -0
  49. data/lib/write_xlsx/package/app.rb +3 -3
  50. data/lib/write_xlsx/package/button.rb +6 -2
  51. data/lib/write_xlsx/package/comments.rb +11 -3
  52. data/lib/write_xlsx/package/conditional_format.rb +7 -3
  53. data/lib/write_xlsx/package/content_types.rb +2 -2
  54. data/lib/write_xlsx/package/core.rb +2 -2
  55. data/lib/write_xlsx/package/custom.rb +3 -2
  56. data/lib/write_xlsx/package/metadata.rb +2 -2
  57. data/lib/write_xlsx/package/packager.rb +0 -3
  58. data/lib/write_xlsx/package/relationships.rb +2 -2
  59. data/lib/write_xlsx/package/rich_value.rb +4 -2
  60. data/lib/write_xlsx/package/rich_value_rel.rb +2 -2
  61. data/lib/write_xlsx/package/rich_value_structure.rb +2 -2
  62. data/lib/write_xlsx/package/rich_value_types.rb +3 -3
  63. data/lib/write_xlsx/package/shared_strings.rb +2 -2
  64. data/lib/write_xlsx/package/styles.rb +13 -9
  65. data/lib/write_xlsx/package/table.rb +8 -2
  66. data/lib/write_xlsx/package/theme.rb +0 -3
  67. data/lib/write_xlsx/package/vml.rb +2 -2
  68. data/lib/write_xlsx/page_setup.rb +192 -0
  69. data/lib/write_xlsx/shape.rb +97 -100
  70. data/lib/write_xlsx/sheets.rb +9 -4
  71. data/lib/write_xlsx/sparkline.rb +2 -2
  72. data/lib/write_xlsx/utility/cell_reference.rb +124 -0
  73. data/lib/write_xlsx/utility/chart_formatting.rb +262 -0
  74. data/lib/write_xlsx/utility/common.rb +44 -0
  75. data/lib/write_xlsx/utility/date_time.rb +113 -0
  76. data/lib/write_xlsx/utility/dimensions.rb +40 -0
  77. data/lib/write_xlsx/utility/drawing.rb +136 -0
  78. data/lib/write_xlsx/utility/rich_text.rb +184 -0
  79. data/lib/write_xlsx/utility/sheetname_quoting.rb +73 -0
  80. data/lib/write_xlsx/utility/string_width.rb +45 -0
  81. data/lib/write_xlsx/utility/url.rb +27 -0
  82. data/lib/write_xlsx/utility/xml_primitives.rb +32 -0
  83. data/lib/write_xlsx/version.rb +1 -1
  84. data/lib/write_xlsx/workbook/chart_data.rb +188 -0
  85. data/lib/write_xlsx/workbook/format_preparation.rb +199 -0
  86. data/lib/write_xlsx/workbook/initialization.rb +223 -0
  87. data/lib/write_xlsx/workbook/package_preparation.rb +231 -0
  88. data/lib/write_xlsx/workbook/workbook_writer.rb +164 -0
  89. data/lib/write_xlsx/workbook.rb +143 -981
  90. data/lib/write_xlsx/worksheet/asset_manager.rb +60 -0
  91. data/lib/write_xlsx/worksheet/autofilter.rb +390 -0
  92. data/lib/write_xlsx/worksheet/cell_data.rb +13 -6
  93. data/lib/write_xlsx/worksheet/cell_data_manager.rb +47 -0
  94. data/lib/write_xlsx/worksheet/cell_data_store.rb +61 -0
  95. data/lib/write_xlsx/worksheet/columns.rb +204 -0
  96. data/lib/write_xlsx/worksheet/comments_support.rb +61 -0
  97. data/lib/write_xlsx/worksheet/conditional_formats.rb +30 -0
  98. data/lib/write_xlsx/worksheet/data_validation.rb +9 -1
  99. data/lib/write_xlsx/worksheet/data_writing.rb +1017 -0
  100. data/lib/write_xlsx/worksheet/drawing_methods.rb +308 -0
  101. data/lib/write_xlsx/worksheet/drawing_preparation.rb +290 -0
  102. data/lib/write_xlsx/worksheet/drawing_relations.rb +76 -0
  103. data/lib/write_xlsx/worksheet/drawing_xml_writer.rb +50 -0
  104. data/lib/write_xlsx/worksheet/formatting.rb +418 -0
  105. data/lib/write_xlsx/worksheet/hyperlink.rb +9 -1
  106. data/lib/write_xlsx/worksheet/initialization.rb +146 -0
  107. data/lib/write_xlsx/worksheet/panes.rb +64 -0
  108. data/lib/write_xlsx/worksheet/print_options.rb +72 -0
  109. data/lib/write_xlsx/worksheet/protection.rb +65 -0
  110. data/lib/write_xlsx/worksheet/rich_text_helpers.rb +78 -0
  111. data/lib/write_xlsx/worksheet/row_col_sizing.rb +69 -0
  112. data/lib/write_xlsx/worksheet/rows.rb +84 -0
  113. data/lib/write_xlsx/worksheet/selection.rb +41 -0
  114. data/lib/write_xlsx/worksheet/xml_writer.rb +1246 -0
  115. data/lib/write_xlsx/worksheet.rb +376 -4530
  116. metadata +66 -4
  117. data/lib/write_xlsx/utility.rb +0 -986
  118. data/lib/write_xlsx/worksheet/page_setup.rb +0 -192
@@ -0,0 +1,318 @@
1
+ # -*- coding: utf-8 -*-
2
+ # frozen_string_literal: true
3
+
4
+ ###############################################################################
5
+ #
6
+ # series_writer.rb - series and cache XML output helpers
7
+ #
8
+ ###############################################################################
9
+
10
+ module Writexlsx
11
+ class Chart
12
+ module SeriesWriter
13
+ private
14
+
15
+ #
16
+ # Write the series elements.
17
+ #
18
+ def write_series(series) # :nodoc:
19
+ write_ser(series)
20
+ end
21
+
22
+ #
23
+ # Write the <c:ser> element.
24
+ #
25
+ def write_ser(series) # :nodoc:
26
+ @writer.tag_elements('c:ser') do
27
+ write_ser_base(series) do
28
+ write_c_invert_if_negative(series.invert_if_negative)
29
+ end
30
+ # Write the c:cat element.
31
+ write_cat(series)
32
+ # Write the c:val element.
33
+ write_val(series)
34
+ # Write the c:smooth element.
35
+ write_c_smooth(series.smooth) if ptrue?(@smooth_allowed)
36
+ # Write the c:extLst element.
37
+ write_ext_lst_inverted_fill(series.inverted_color) if series.inverted_color
38
+ end
39
+ @series_index += 1
40
+ end
41
+
42
+ def write_ser_base(series)
43
+ # Write the c:idx element.
44
+ write_idx(@series_index)
45
+ # Write the c:order element.
46
+ write_order(@series_index)
47
+ # Write the series name.
48
+ write_series_name(series)
49
+ # Write the c:spPr element.
50
+ write_sp_pr(series)
51
+ # Write the c:marker element.
52
+ write_marker(series.marker)
53
+
54
+ yield if block_given?
55
+
56
+ # Write the c:dPt element.
57
+ write_d_pt(series.points)
58
+ # Write the c:dLbls element.
59
+ write_d_lbls(series.labels)
60
+ # Write the c:trendline element.
61
+ write_trendline(series.trendline)
62
+ # Write the c:errBars element.
63
+ write_error_bars(series.error_bars)
64
+ end
65
+
66
+ #
67
+ # Write the <c:idx> element.
68
+ #
69
+ def write_idx(val) # :nodoc:
70
+ @writer.empty_tag('c:idx', [['val', val]])
71
+ end
72
+
73
+ #
74
+ # Write the <c:order> element.
75
+ #
76
+ def write_order(val) # :nodoc:
77
+ @writer.empty_tag('c:order', [['val', val]])
78
+ end
79
+
80
+ #
81
+ # Write the series name.
82
+ #
83
+ def write_series_name(series) # :nodoc:
84
+ if series.name_formula
85
+ write_tx_formula(series.name_formula, series.name_id)
86
+ elsif series.name
87
+ write_tx_value(series.name)
88
+ end
89
+ end
90
+
91
+ #
92
+ # Write the <c:cat> element.
93
+ #
94
+ def write_cat(series) # :nodoc:
95
+ formula = series.categories
96
+ data_id = series.cat_data_id
97
+
98
+ data = @formula_data[data_id] if data_id
99
+
100
+ # Ignore <c:cat> elements for charts without category values.
101
+ return unless formula
102
+
103
+ @writer.tag_elements('c:cat') do
104
+ # Check the type of cached data.
105
+ type = get_data_type(data)
106
+ if type == 'str'
107
+ @cat_has_num_fmt = false
108
+ # Write the c:strRef element.
109
+ write_str_ref(formula, data, type)
110
+ elsif type == 'multi_str'
111
+ @cat_has_num_fmt = false
112
+ # Write the c:multiLvLStrRef element.
113
+ write_multi_lvl_str_ref(formula, data)
114
+ else
115
+ @cat_has_num_fmt = true
116
+ # Write the c:numRef element.
117
+ write_num_ref(formula, data, type)
118
+ end
119
+ end
120
+ end
121
+
122
+ #
123
+ # Write the <c:val> element.
124
+ #
125
+ def write_val(series) # :nodoc:
126
+ write_val_base(series.values, series.val_data_id, 'c:val')
127
+ end
128
+
129
+ def write_val_base(formula, data_id, tag) # :nodoc:
130
+ data = @formula_data[data_id]
131
+
132
+ @writer.tag_elements(tag) do
133
+ # Unlike Cat axes data should only be numeric.
134
+
135
+ # Write the c:numRef element.
136
+ write_num_ref(formula, data, 'num')
137
+ end
138
+ end
139
+
140
+ #
141
+ # Write the <c:numRef> or <c:strRef> element.
142
+ #
143
+ def write_num_or_str_ref(tag, formula, data, type) # :nodoc:
144
+ @writer.tag_elements(tag) do
145
+ # Write the c:f element.
146
+ write_series_formula(formula)
147
+ if type == 'num'
148
+ # Write the c:numCache element.
149
+ write_num_cache(data)
150
+ elsif type == 'str'
151
+ # Write the c:strCache element.
152
+ write_str_cache(data)
153
+ end
154
+ end
155
+ end
156
+
157
+ #
158
+ # Write the <c:numRef> element.
159
+ #
160
+ def write_num_ref(formula, data, type) # :nodoc:
161
+ write_num_or_str_ref('c:numRef', formula, data, type)
162
+ end
163
+
164
+ #
165
+ # Write the <c:strRef> element.
166
+ #
167
+ def write_str_ref(formula, data, type) # :nodoc:
168
+ write_num_or_str_ref('c:strRef', formula, data, type)
169
+ end
170
+
171
+ #
172
+ # Write the <c:multiLvLStrRef> element.
173
+ #
174
+ def write_multi_lvl_str_ref(formula, data)
175
+ return if data.empty?
176
+
177
+ @writer.tag_elements('c:multiLvlStrRef') do
178
+ # Write the c:f element.
179
+ write_series_formula(formula)
180
+
181
+ @writer.tag_elements('c:multiLvlStrCache') do
182
+ # Write the c:ptCount element.
183
+ write_pt_count(data.last.size)
184
+
185
+ # Write the data arrays in reverse order.
186
+ data.reverse.each do |arr|
187
+ @writer.tag_elements('c:lvl') do
188
+ # Write the c:pt element.
189
+ arr.each_with_index { |a, i| write_pt(i, a) }
190
+ end
191
+ end
192
+ end
193
+ end
194
+ end
195
+
196
+ #
197
+ # Write the <c:numLit> element for literal number list elements.
198
+ #
199
+ def write_num_lit(data)
200
+ write_num_base('c:numLit', data)
201
+ end
202
+
203
+ #
204
+ # Write the <c:f> element.
205
+ #
206
+ def write_series_formula(formula) # :nodoc:
207
+ # Strip the leading '=' from the formula.
208
+ formula = formula.sub(/^=/, '')
209
+
210
+ @writer.data_element('c:f', formula)
211
+ end
212
+
213
+ #
214
+ # Write the <c:numCache> element.
215
+ #
216
+ def write_num_cache(data) # :nodoc:
217
+ write_num_base('c:numCache', data)
218
+ end
219
+
220
+ def write_num_base(tag, data)
221
+ @writer.tag_elements(tag) do
222
+ # Write the c:formatCode element.
223
+ write_format_code('General')
224
+
225
+ # Write the c:ptCount element.
226
+ count = if data
227
+ data.size
228
+ else
229
+ 0
230
+ end
231
+ write_pt_count(count)
232
+
233
+ data.each_with_index do |token, i|
234
+ # Write non-numeric data as 0.
235
+ if token &&
236
+ token.to_s !~ /^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/
237
+ token = 0
238
+ end
239
+
240
+ # Write the c:pt element.
241
+ write_pt(i, token)
242
+ end
243
+ end
244
+ end
245
+
246
+ #
247
+ # Write the <c:strCache> element.
248
+ #
249
+ def write_str_cache(data) # :nodoc:
250
+ @writer.tag_elements('c:strCache') do
251
+ write_pt_count(data.size)
252
+ write_pts(data)
253
+ end
254
+ end
255
+
256
+ def write_pts(data)
257
+ data.each_index { |i| write_pt(i, data[i]) }
258
+ end
259
+
260
+ #
261
+ # Write the <c:formatCode> element.
262
+ #
263
+ def write_format_code(data) # :nodoc:
264
+ @writer.data_element('c:formatCode', data)
265
+ end
266
+
267
+ #
268
+ # Write the <c:ptCount> element.
269
+ #
270
+ def write_pt_count(val) # :nodoc:
271
+ @writer.empty_tag('c:ptCount', [['val', val]])
272
+ end
273
+
274
+ #
275
+ # Write the <c:pt> element.
276
+ #
277
+ def write_pt(idx, value) # :nodoc:
278
+ return unless value
279
+
280
+ attributes = [['idx', idx]]
281
+
282
+ @writer.tag_elements('c:pt', attributes) { write_v(value) }
283
+ end
284
+
285
+ #
286
+ # Write the <c:v> element.
287
+ #
288
+ def write_v(data) # :nodoc:
289
+ @writer.data_element('c:v', data)
290
+ end
291
+
292
+ #
293
+ # Write the <c:axId> elements for the primary or secondary axes.
294
+ #
295
+ def write_axis_ids(params)
296
+ # Generate the axis ids.
297
+ add_axis_ids(params)
298
+
299
+ if params[:primary_axes] == 0
300
+ # Write the axis ids for the secondary axes.
301
+ write_axis_id(@axis2_ids[0])
302
+ write_axis_id(@axis2_ids[1])
303
+ else
304
+ # Write the axis ids for the primary axes.
305
+ write_axis_id(@axis_ids[0])
306
+ write_axis_id(@axis_ids[1])
307
+ end
308
+ end
309
+
310
+ #
311
+ # Write the <c:axId> element.
312
+ #
313
+ def write_axis_id(val) # :nodoc:
314
+ @writer.empty_tag('c:axId', [['val', val]])
315
+ end
316
+ end
317
+ end
318
+ end
@@ -0,0 +1,226 @@
1
+ # -*- coding: utf-8 -*-
2
+ # frozen_string_literal: true
3
+
4
+ ###############################################################################
5
+ #
6
+ # settings.rb - common chart facade and orchestration
7
+ #
8
+ ###############################################################################
9
+
10
+ module Writexlsx
11
+ class Chart
12
+ module Settings
13
+ #
14
+ # Add a series and it's properties to a chart.
15
+ #
16
+ def add_series(params)
17
+ # Check that the required input has been specified.
18
+ raise "Must specify ':values' in add_series" unless params.has_key?(:values)
19
+
20
+ raise "Must specify ':categories' in add_series for this chart type" if @requires_category != 0 && !params.has_key?(:categories)
21
+
22
+ raise "The maximum number of series that can be added to an Excel Chart is 255." if @series.size == 255
23
+
24
+ @series << Series.new(self, params)
25
+
26
+ # Set the secondary axis properties.
27
+ x2_axis = params[:x2_axis]
28
+ y2_axis = params[:y2_axis]
29
+
30
+ # Store secondary status for combined charts.
31
+ @is_secondary = true if ptrue?(x2_axis) || ptrue?(y2_axis)
32
+
33
+ # Set the gap and overlap for Bar/Column charts.
34
+ if params[:gap]
35
+ if ptrue?(y2_axis)
36
+ @series_gap_2 = params[:gap]
37
+ else
38
+ @series_gap_1 = params[:gap]
39
+ end
40
+ end
41
+
42
+ # Set the overlap for Bar/Column charts.
43
+ if params[:overlap]
44
+ if ptrue?(y2_axis)
45
+ @series_overlap_2 = params[:overlap]
46
+ else
47
+ @series_overlap_1 = params[:overlap]
48
+ end
49
+ end
50
+ end
51
+
52
+ #
53
+ # Set the properties of the x-axis.
54
+ #
55
+ def set_x_axis(params = {})
56
+ @date_category = true if ptrue?(params[:date_axis])
57
+ @x_axis.apply_options(params)
58
+ end
59
+
60
+ #
61
+ # Set the properties of the Y-axis.
62
+ #
63
+ # The set_y_axis() method is used to set properties of the Y axis.
64
+ # The properties that can be set are the same as for set_x_axis,
65
+ #
66
+ def set_y_axis(params = {})
67
+ @date_category = true if ptrue?(params[:date_axis])
68
+ @y_axis.apply_options(params)
69
+ end
70
+
71
+ #
72
+ # Set the properties of the secondary X-axis.
73
+ #
74
+ def set_x2_axis(params = {})
75
+ @date_category = true if ptrue?(params[:date_axis])
76
+ @x2_axis.apply_options(params)
77
+ end
78
+
79
+ #
80
+ # Set the properties of the secondary Y-axis.
81
+ #
82
+ def set_y2_axis(params = {})
83
+ @date_category = true if ptrue?(params[:date_axis])
84
+ @y2_axis.apply_options(params)
85
+ end
86
+
87
+ #
88
+ # Set the properties of the chart title.
89
+ #
90
+ def set_title(params)
91
+ @title ||= Caption.new(self)
92
+ @title.apply_text_options(params)
93
+ @title.apply_format_options(params)
94
+ end
95
+
96
+ #
97
+ # Set the properties of the chart legend.
98
+ #
99
+ def set_legend(params)
100
+ # Convert the user default properties to internal properties.
101
+ legend_properties(params)
102
+ end
103
+
104
+ #
105
+ # Set the properties of the chart plotarea.
106
+ #
107
+ def set_plotarea(params)
108
+ # Convert the user defined properties to internal properties.
109
+ @plotarea = ChartArea.new(params)
110
+ end
111
+
112
+ #
113
+ # Set the properties of the chart chartarea.
114
+ #
115
+ def set_chartarea(params)
116
+ # Convert the user defined properties to internal properties.
117
+ @chartarea = ChartArea.new(params)
118
+ end
119
+
120
+ #
121
+ # Set on of the 42 built-in Excel chart styles. The default style is 2.
122
+ #
123
+ def set_style(style_id = 2)
124
+ style_id = 2 if style_id < 1 || style_id > 48
125
+ @style_id = style_id
126
+ end
127
+
128
+ #
129
+ # Set the option for displaying blank data in a chart. The default is 'gap'.
130
+ #
131
+ def show_blanks_as(option)
132
+ return unless option
133
+
134
+ raise "Unknown show_blanks_as() option '#{option}'\n" unless %i[gap zero span].include?(option.to_sym)
135
+
136
+ @show_blanks = option
137
+ end
138
+
139
+ #
140
+ # Display data in hidden rows or columns on the chart.
141
+ #
142
+ def show_hidden_data
143
+ @show_hidden_data = true
144
+ end
145
+
146
+ #
147
+ # Set dimensions for scale for the chart.
148
+ #
149
+ def set_size(params = {})
150
+ @width = params[:width] if params[:width]
151
+ @height = params[:height] if params[:height]
152
+ @x_scale = params[:x_scale] if params[:x_scale]
153
+ @y_scale = params[:y_scale] if params[:y_scale]
154
+ @x_offset = params[:x_offset] if params[:x_offset]
155
+ @y_offset = params[:y_offset] if params[:y_offset]
156
+ end
157
+
158
+ # Backward compatibility with poorly chosen method name.
159
+ alias size set_size
160
+
161
+ #
162
+ # The set_table method adds a data table below the horizontal axis with the
163
+ # data used to plot the chart.
164
+ #
165
+ def set_table(params = {})
166
+ @table = Table.new(params)
167
+ @table.palette = @palette
168
+ end
169
+
170
+ #
171
+ # Set properties for the chart up-down bars.
172
+ #
173
+ def set_up_down_bars(params = {})
174
+ # Map border to line.
175
+ %i[up down].each do |up_down|
176
+ if params[up_down]
177
+ params[up_down][:line] = params[up_down][:border] if params[up_down][:border]
178
+ else
179
+ params[up_down] = {}
180
+ end
181
+ end
182
+
183
+ # Set the up and down bar properties.
184
+ @up_down_bars = {
185
+ _up: Chartline.new(params[:up]),
186
+ _down: Chartline.new(params[:down])
187
+ }
188
+ end
189
+
190
+ #
191
+ # Set properties for the chart drop lines.
192
+ #
193
+ def set_drop_lines(params = {})
194
+ @drop_lines = Chartline.new(params)
195
+ end
196
+
197
+ #
198
+ # Set properties for the chart high-low lines.
199
+ #
200
+ def set_high_low_lines(params = {})
201
+ @hi_low_lines = Chartline.new(params)
202
+ end
203
+
204
+ #
205
+ # Add another chart to create a combined chart.
206
+ #
207
+ def combine(chart)
208
+ @combined = chart
209
+ end
210
+
211
+ #
212
+ # Setup the default configuration data for an embedded chart.
213
+ #
214
+ def set_embedded_config_data
215
+ @embedded = true
216
+ end
217
+
218
+ #
219
+ # Set the option for displaying #N/A as an empty cell in a chart.
220
+ #
221
+ def show_na_as_empty_cell
222
+ @show_na_as_empty = true
223
+ end
224
+ end
225
+ end
226
+ end
@@ -15,7 +15,7 @@
15
15
 
16
16
  require 'write_xlsx/package/xml_writer_simple'
17
17
  require 'write_xlsx/chart'
18
- require 'write_xlsx/utility'
18
+ require 'write_xlsx/utility/xml_primitives'
19
19
 
20
20
  module Writexlsx
21
21
  class Chart
@@ -24,7 +24,7 @@ module Writexlsx
24
24
  # A series must be added for each of these data sources.
25
25
  #
26
26
  class Stock < self
27
- include Writexlsx::Utility
27
+ include Writexlsx::Utility::XmlPrimitives
28
28
 
29
29
  def initialize(subtype)
30
30
  super
@@ -0,0 +1,50 @@
1
+ # -*- coding: utf-8 -*-
2
+ # frozen_string_literal: true
3
+
4
+ require 'write_xlsx/utility/common'
5
+ require 'write_xlsx/utility/chart_formatting'
6
+ require 'write_xlsx/utility/rich_text'
7
+
8
+ module Writexlsx
9
+ class Chart
10
+ class Table
11
+ include Writexlsx::Utility::Common
12
+ include Writexlsx::Utility::ChartFormatting
13
+ include Writexlsx::Utility::RichText
14
+
15
+ attr_reader :horizontal, :vertical, :outline, :show_keys, :font
16
+
17
+ def initialize(params = {})
18
+ @horizontal = true
19
+ @vertical = true
20
+ @outline = true
21
+ @show_keys = false
22
+ @horizontal = params[:horizontal] if params.has_key?(:horizontal)
23
+ @vertical = params[:vertical] if params.has_key?(:vertical)
24
+ @outline = params[:outline] if params.has_key?(:outline)
25
+ @show_keys = params[:show_keys] if params.has_key?(:show_keys)
26
+ @font = convert_font_args(params[:font])
27
+ end
28
+
29
+ attr_writer :palette
30
+
31
+ def write_d_table(writer)
32
+ @writer = writer
33
+ @writer.tag_elements('c:dTable') do
34
+ @writer.empty_tag('c:showHorzBorder', attributes) if ptrue?(horizontal)
35
+ @writer.empty_tag('c:showVertBorder', attributes) if ptrue?(vertical)
36
+ @writer.empty_tag('c:showOutline', attributes) if ptrue?(outline)
37
+ @writer.empty_tag('c:showKeys', attributes) if ptrue?(show_keys)
38
+ # Write the table font.
39
+ write_tx_pr(font) if ptrue?(font)
40
+ end
41
+ end
42
+
43
+ private
44
+
45
+ def attributes
46
+ [['val', 1]]
47
+ end
48
+ end
49
+ end
50
+ end