axlsx 2.0.1 → 2.1.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -3
- data/Rakefile +9 -10
- data/examples/IMAGE1UP.JPEG +0 -0
- data/examples/auto_filter.rb +10 -1
- data/examples/conditional_formatting/example_conditional_formatting.rb +3 -3
- data/examples/example.rb +72 -4
- data/examples/merge_cells.rb +17 -0
- data/examples/no_grid_with_borders.rb +18 -0
- data/examples/pivot_test.rb +63 -0
- data/examples/split.rb +16 -0
- data/lib/axlsx.rb +30 -16
- data/lib/axlsx/content_type/abstract_content_type.rb +1 -1
- data/lib/axlsx/content_type/content_type.rb +1 -1
- data/lib/axlsx/doc_props/app.rb +1 -1
- data/lib/axlsx/doc_props/core.rb +5 -5
- data/lib/axlsx/drawing/axes.rb +1 -1
- data/lib/axlsx/drawing/axis.rb +12 -9
- data/lib/axlsx/drawing/bar_3D_chart.rb +13 -13
- data/lib/axlsx/drawing/bar_series.rb +9 -9
- data/lib/axlsx/drawing/bubble_chart.rb +59 -0
- data/lib/axlsx/drawing/bubble_series.rb +63 -0
- data/lib/axlsx/drawing/cat_axis.rb +5 -5
- data/lib/axlsx/drawing/chart.rb +44 -7
- data/lib/axlsx/drawing/drawing.rb +3 -1
- data/lib/axlsx/drawing/graphic_frame.rb +3 -3
- data/lib/axlsx/drawing/hyperlink.rb +1 -3
- data/lib/axlsx/drawing/line_3D_chart.rb +2 -2
- data/lib/axlsx/drawing/line_chart.rb +10 -10
- data/lib/axlsx/drawing/line_series.rb +14 -2
- data/lib/axlsx/drawing/marker.rb +1 -1
- data/lib/axlsx/drawing/num_data.rb +4 -4
- data/lib/axlsx/drawing/num_data_source.rb +6 -6
- data/lib/axlsx/drawing/num_val.rb +1 -1
- data/lib/axlsx/drawing/one_cell_anchor.rb +1 -1
- data/lib/axlsx/drawing/pic.rb +2 -3
- data/lib/axlsx/drawing/picture_locking.rb +1 -3
- data/lib/axlsx/drawing/pie_3D_chart.rb +5 -6
- data/lib/axlsx/drawing/pie_series.rb +6 -6
- data/lib/axlsx/drawing/scaling.rb +4 -4
- data/lib/axlsx/drawing/scatter_chart.rb +10 -10
- data/lib/axlsx/drawing/scatter_series.rb +26 -7
- data/lib/axlsx/drawing/ser_axis.rb +2 -2
- data/lib/axlsx/drawing/series.rb +3 -3
- data/lib/axlsx/drawing/series_title.rb +2 -2
- data/lib/axlsx/drawing/str_data.rb +3 -3
- data/lib/axlsx/drawing/str_val.rb +1 -1
- data/lib/axlsx/drawing/title.rb +3 -3
- data/lib/axlsx/drawing/val_axis.rb +1 -1
- data/lib/axlsx/drawing/vml_drawing.rb +1 -1
- data/lib/axlsx/package.rb +39 -28
- data/lib/axlsx/rels/relationship.rb +1 -1
- data/lib/axlsx/rels/relationships.rb +2 -2
- data/lib/axlsx/stylesheet/border_pr.rb +2 -2
- data/lib/axlsx/stylesheet/cell_alignment.rb +1 -3
- data/lib/axlsx/stylesheet/cell_protection.rb +1 -3
- data/lib/axlsx/stylesheet/cell_style.rb +1 -3
- data/lib/axlsx/stylesheet/color.rb +1 -3
- data/lib/axlsx/stylesheet/font.rb +1 -1
- data/lib/axlsx/stylesheet/gradient_stop.rb +1 -1
- data/lib/axlsx/stylesheet/num_fmt.rb +1 -3
- data/lib/axlsx/stylesheet/pattern_fill.rb +1 -1
- data/lib/axlsx/stylesheet/styles.rb +6 -6
- data/lib/axlsx/stylesheet/table_style_element.rb +1 -3
- data/lib/axlsx/util/accessors.rb +6 -6
- data/lib/axlsx/util/constants.rb +106 -101
- data/lib/axlsx/util/options_parser.rb +2 -1
- data/lib/axlsx/util/parser.rb +4 -4
- data/lib/axlsx/util/serialized_attributes.rb +16 -6
- data/lib/axlsx/util/simple_typed_list.rb +28 -52
- data/lib/axlsx/util/storage.rb +4 -4
- data/lib/axlsx/util/string.rb +7 -0
- data/lib/axlsx/util/validators.rb +20 -13
- data/lib/axlsx/version.rb +1 -1
- data/lib/axlsx/workbook/defined_name.rb +11 -12
- data/lib/axlsx/workbook/defined_names.rb +2 -2
- data/lib/axlsx/workbook/shared_strings_table.rb +5 -5
- data/lib/axlsx/workbook/workbook.rb +19 -12
- data/lib/axlsx/workbook/workbook_view.rb +78 -0
- data/lib/axlsx/workbook/workbook_views.rb +22 -0
- data/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb +2 -2
- data/lib/axlsx/workbook/worksheet/auto_filter/filters.rb +1 -3
- data/lib/axlsx/workbook/worksheet/break.rb +1 -3
- data/lib/axlsx/workbook/worksheet/cell.rb +128 -73
- data/lib/axlsx/workbook/worksheet/cell_serializer.rb +50 -40
- data/lib/axlsx/workbook/worksheet/cfvo.rb +1 -3
- data/lib/axlsx/workbook/worksheet/cfvos.rb +1 -1
- data/lib/axlsx/workbook/worksheet/col.rb +7 -10
- data/lib/axlsx/workbook/worksheet/col_breaks.rb +2 -2
- data/lib/axlsx/workbook/worksheet/comment.rb +5 -6
- data/lib/axlsx/workbook/worksheet/comments.rb +9 -12
- data/lib/axlsx/workbook/worksheet/conditional_formatting.rb +1 -1
- data/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb +1 -1
- data/lib/axlsx/workbook/worksheet/data_bar.rb +4 -6
- data/lib/axlsx/workbook/worksheet/data_validation.rb +6 -4
- data/lib/axlsx/workbook/worksheet/dimension.rb +2 -2
- data/lib/axlsx/workbook/worksheet/header_footer.rb +6 -8
- data/lib/axlsx/workbook/worksheet/icon_set.rb +3 -5
- data/lib/axlsx/workbook/worksheet/merged_cells.rb +2 -2
- data/lib/axlsx/workbook/worksheet/page_margins.rb +1 -3
- data/lib/axlsx/workbook/worksheet/page_set_up_pr.rb +1 -1
- data/lib/axlsx/workbook/worksheet/page_setup.rb +21 -23
- data/lib/axlsx/workbook/worksheet/pane.rb +1 -3
- data/lib/axlsx/workbook/worksheet/pivot_table.rb +17 -24
- data/lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb +4 -4
- data/lib/axlsx/workbook/worksheet/print_options.rb +1 -3
- data/lib/axlsx/workbook/worksheet/protected_range.rb +1 -3
- data/lib/axlsx/workbook/worksheet/protected_ranges.rb +1 -1
- data/lib/axlsx/workbook/worksheet/rich_text.rb +35 -0
- data/lib/axlsx/workbook/worksheet/rich_text_run.rb +254 -0
- data/lib/axlsx/workbook/worksheet/row.rb +33 -51
- data/lib/axlsx/workbook/worksheet/row_breaks.rb +2 -2
- data/lib/axlsx/workbook/worksheet/selection.rb +1 -3
- data/lib/axlsx/workbook/worksheet/sheet_data.rb +3 -1
- data/lib/axlsx/workbook/worksheet/sheet_protection.rb +1 -3
- data/lib/axlsx/workbook/worksheet/table.rb +6 -6
- data/lib/axlsx/workbook/worksheet/table_style_info.rb +1 -3
- data/lib/axlsx/workbook/worksheet/tables.rb +1 -1
- data/lib/axlsx/workbook/worksheet/worksheet.rb +59 -30
- data/lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb +3 -3
- data/test/drawing/tc_axis.rb +27 -0
- data/test/drawing/tc_bubble_chart.rb +44 -0
- data/test/drawing/tc_bubble_series.rb +21 -0
- data/test/drawing/tc_data_source.rb +6 -0
- data/test/drawing/tc_line_chart.rb +5 -5
- data/test/drawing/tc_line_series.rb +10 -2
- data/test/drawing/tc_pic.rb +4 -0
- data/test/drawing/tc_scatter_series.rb +25 -1
- data/test/tc_helper.rb +1 -1
- data/test/tc_package.rb +7 -1
- data/test/util/tc_simple_typed_list.rb +1 -2
- data/test/workbook/tc_defined_name.rb +12 -4
- data/test/workbook/tc_workbook.rb +16 -2
- data/test/workbook/tc_workbook_view.rb +50 -0
- data/test/workbook/worksheet/auto_filter/tc_filters.rb +1 -1
- data/test/workbook/worksheet/tc_break.rb +1 -1
- data/test/workbook/worksheet/tc_cell.rb +30 -4
- data/test/workbook/worksheet/tc_col.rb +2 -2
- data/test/workbook/worksheet/tc_conditional_formatting.rb +2 -2
- data/test/workbook/worksheet/tc_data_bar.rb +1 -1
- data/test/workbook/worksheet/tc_data_validation.rb +11 -11
- data/test/workbook/worksheet/tc_header_footer.rb +2 -2
- data/test/workbook/worksheet/tc_icon_set.rb +1 -1
- data/test/workbook/worksheet/tc_page_setup.rb +3 -3
- data/test/workbook/worksheet/tc_print_options.rb +1 -1
- data/test/workbook/worksheet/tc_rich_text.rb +44 -0
- data/test/workbook/worksheet/tc_rich_text_run.rb +172 -0
- data/test/workbook/worksheet/tc_row.rb +2 -2
- data/test/workbook/worksheet/tc_sheet_calc_pr.rb +1 -1
- data/test/workbook/worksheet/tc_sheet_format_pr.rb +4 -4
- data/test/workbook/worksheet/tc_sheet_protection.rb +5 -5
- data/test/workbook/worksheet/tc_sheet_view.rb +4 -4
- data/test/workbook/worksheet/tc_worksheet.rb +49 -10
- metadata +81 -55
- data/test/axlsx.qcachegrind +0 -2226
@@ -24,7 +24,7 @@ module Axlsx
|
|
24
24
|
# Serialize the contenty type to xml
|
25
25
|
def to_xml_string(node_name = '', str = '')
|
26
26
|
str << "<#{node_name} "
|
27
|
-
str << instance_values.map { |key, value|
|
27
|
+
str << instance_values.map { |key, value| Axlsx::camel(key) << '="' << value.to_s << '"' }.join(' ')
|
28
28
|
str << '/>'
|
29
29
|
end
|
30
30
|
|
@@ -16,7 +16,7 @@ module Axlsx
|
|
16
16
|
# @return [String]
|
17
17
|
def to_xml_string(str = '')
|
18
18
|
str << '<?xml version="1.0" encoding="UTF-8"?>'
|
19
|
-
str << '<Types xmlns="' << XML_NS_T << '">'
|
19
|
+
str << ('<Types xmlns="' << XML_NS_T << '">')
|
20
20
|
each { |type| type.to_xml_string(str) }
|
21
21
|
str << '</Types>'
|
22
22
|
end
|
data/lib/axlsx/doc_props/app.rb
CHANGED
@@ -222,7 +222,7 @@ module Axlsx
|
|
222
222
|
# @return [String]
|
223
223
|
def to_xml_string(str = '')
|
224
224
|
str << '<?xml version="1.0" encoding="UTF-8"?>'
|
225
|
-
str << '<Properties xmlns="' << APP_NS << '" xmlns:vt="' << APP_NS_VT << '">'
|
225
|
+
str << ('<Properties xmlns="' << APP_NS << '" xmlns:vt="' << APP_NS_VT << '">')
|
226
226
|
instance_values.each do |key, value|
|
227
227
|
node_name = Axlsx.camel(key)
|
228
228
|
str << "<#{node_name}>#{value}</#{node_name}>"
|
data/lib/axlsx/doc_props/core.rb
CHANGED
@@ -25,11 +25,11 @@ module Axlsx
|
|
25
25
|
# @return [String]
|
26
26
|
def to_xml_string(str = '')
|
27
27
|
str << '<?xml version="1.0" encoding="UTF-8"?>'
|
28
|
-
str << '<cp:coreProperties xmlns:cp="' << CORE_NS << '" xmlns:dc="' << CORE_NS_DC << '" '
|
29
|
-
str << 'xmlns:dcmitype="' << CORE_NS_DCMIT << '" xmlns:dcterms="' << CORE_NS_DCT << '" '
|
30
|
-
str << 'xmlns:xsi="' << CORE_NS_XSI << '">'
|
31
|
-
str << '<dc:creator>' << self.creator << '</dc:creator>'
|
32
|
-
str << '<dcterms:created xsi:type="dcterms:W3CDTF">' << (created || Time.now).strftime('%Y-%m-%dT%H:%M:%S') << 'Z</dcterms:created>'
|
28
|
+
str << ('<cp:coreProperties xmlns:cp="' << CORE_NS << '" xmlns:dc="' << CORE_NS_DC << '" ')
|
29
|
+
str << ('xmlns:dcmitype="' << CORE_NS_DCMIT << '" xmlns:dcterms="' << CORE_NS_DCT << '" ')
|
30
|
+
str << ('xmlns:xsi="' << CORE_NS_XSI << '">')
|
31
|
+
str << ('<dc:creator>' << self.creator << '</dc:creator>')
|
32
|
+
str << ('<dcterms:created xsi:type="dcterms:W3CDTF">' << (created || Time.now).strftime('%Y-%m-%dT%H:%M:%S') << 'Z</dcterms:created>')
|
33
33
|
str << '<cp:revision>0</cp:revision>'
|
34
34
|
str << '</cp:coreProperties>'
|
35
35
|
end
|
data/lib/axlsx/drawing/axes.rb
CHANGED
@@ -32,7 +32,7 @@ module Axlsx
|
|
32
32
|
if options[:ids]
|
33
33
|
# CatAxis must come first in the XML (for Microsoft Excel at least)
|
34
34
|
sorted = axes.sort_by { |name, axis| axis.kind_of?(CatAxis) ? 0 : 1 }
|
35
|
-
sorted.
|
35
|
+
sorted.each { |axis| str << ('<c:axId val="' << axis[1].id.to_s << '"/>') }
|
36
36
|
else
|
37
37
|
axes.each { |axis| axis[1].to_xml_string(str) }
|
38
38
|
end
|
data/lib/axlsx/drawing/axis.rb
CHANGED
@@ -150,10 +150,10 @@ module Axlsx
|
|
150
150
|
# @param [String] str
|
151
151
|
# @return [String]
|
152
152
|
def to_xml_string(str = '')
|
153
|
-
str << '<c:axId val="' << @id.to_s << '"/>'
|
153
|
+
str << ('<c:axId val="' << @id.to_s << '"/>')
|
154
154
|
@scaling.to_xml_string str
|
155
|
-
str << '<c:delete val="'<< @delete.to_s << '"/>'
|
156
|
-
str << '<c:axPos val="' << @ax_pos.to_s << '"/>'
|
155
|
+
str << ('<c:delete val="' << @delete.to_s << '"/>')
|
156
|
+
str << ('<c:axPos val="' << @ax_pos.to_s << '"/>')
|
157
157
|
str << '<c:majorGridlines>'
|
158
158
|
# TODO shape properties need to be extracted into a class
|
159
159
|
if gridlines == false
|
@@ -165,21 +165,24 @@ module Axlsx
|
|
165
165
|
end
|
166
166
|
str << '</c:majorGridlines>'
|
167
167
|
@title.to_xml_string(str) unless @title == nil
|
168
|
-
|
168
|
+
# Need to set sourceLinked to 0 if we're setting a format code on this row
|
169
|
+
# otherwise it will never take, as it will always prefer the 'General' formatting
|
170
|
+
# of the cells themselves
|
171
|
+
str << ('<c:numFmt formatCode="' << @format_code << '" sourceLinked="' << (@format_code.eql?('General') ? '1' : '0') << '"/>')
|
169
172
|
str << '<c:majorTickMark val="none"/>'
|
170
173
|
str << '<c:minorTickMark val="none"/>'
|
171
|
-
str << '<c:tickLblPos val="' << @tick_lbl_pos.to_s << '"/>'
|
174
|
+
str << ('<c:tickLblPos val="' << @tick_lbl_pos.to_s << '"/>')
|
172
175
|
# TODO - this is also being used for series colors
|
173
176
|
# time to extract this into a class spPr - Shape Properties
|
174
177
|
if @color
|
175
178
|
str << '<c:spPr><a:ln><a:solidFill>'
|
176
|
-
str << '<a:srgbClr val="' << @color << '"/>'
|
179
|
+
str << ('<a:srgbClr val="' << @color << '"/>')
|
177
180
|
str << '</a:solidFill></a:ln></c:spPr>'
|
178
181
|
end
|
179
182
|
# some potential value in implementing this in full. Very detailed!
|
180
|
-
str << '<c:txPr><a:bodyPr rot="' << @label_rotation.to_s << '"/><a:lstStyle/><a:p><a:pPr><a:defRPr/></a:pPr><a:endParaRPr/></a:p></c:txPr>'
|
181
|
-
str << '<c:crossAx val="' << @cross_axis.id.to_s << '"/>'
|
182
|
-
str << '<c:crosses val="' << @crosses.to_s << '"/>'
|
183
|
+
str << ('<c:txPr><a:bodyPr rot="' << @label_rotation.to_s << '"/><a:lstStyle/><a:p><a:pPr><a:defRPr/></a:pPr><a:endParaRPr/></a:p></c:txPr>')
|
184
|
+
str << ('<c:crossAx val="' << @cross_axis.id.to_s << '"/>')
|
185
|
+
str << ('<c:crosses val="' << @crosses.to_s << '"/>')
|
183
186
|
end
|
184
187
|
|
185
188
|
end
|
@@ -125,19 +125,19 @@ module Axlsx
|
|
125
125
|
# @param [String] str
|
126
126
|
# @return [String]
|
127
127
|
def to_xml_string(str = '')
|
128
|
-
super(str) do
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
@series.each { |ser| ser.to_xml_string(
|
134
|
-
@d_lbls.to_xml_string(
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
axes.to_xml_string(
|
139
|
-
|
140
|
-
axes.to_xml_string(
|
128
|
+
super(str) do
|
129
|
+
str << '<c:bar3DChart>'
|
130
|
+
str << ('<c:barDir val="' << bar_dir.to_s << '"/>')
|
131
|
+
str << ('<c:grouping val="' << grouping.to_s << '"/>')
|
132
|
+
str << ('<c:varyColors val="' << vary_colors.to_s << '"/>')
|
133
|
+
@series.each { |ser| ser.to_xml_string(str) }
|
134
|
+
@d_lbls.to_xml_string(str) if @d_lbls
|
135
|
+
str << ('<c:gapWidth val="' << @gap_width.to_s << '"/>') unless @gap_width.nil?
|
136
|
+
str << ('<c:gapDepth val="' << @gap_depth.to_s << '"/>') unless @gap_depth.nil?
|
137
|
+
str << ('<c:shape val="' << @shape.to_s << '"/>') unless @shape.nil?
|
138
|
+
axes.to_xml_string(str, :ids => true)
|
139
|
+
str << '</c:bar3DChart>'
|
140
|
+
axes.to_xml_string(str)
|
141
141
|
end
|
142
142
|
end
|
143
143
|
|
@@ -52,20 +52,20 @@ module Axlsx
|
|
52
52
|
# @param [String] str
|
53
53
|
# @return [String]
|
54
54
|
def to_xml_string(str = '')
|
55
|
-
super(str) do
|
55
|
+
super(str) do
|
56
56
|
|
57
57
|
colors.each_with_index do |c, index|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
58
|
+
str << '<c:dPt>'
|
59
|
+
str << ('<c:idx val="' << index.to_s << '"/>')
|
60
|
+
str << '<c:spPr><a:solidFill>'
|
61
|
+
str << ('<a:srgbClr val="' << c << '"/>')
|
62
|
+
str << '</a:solidFill></c:spPr></c:dPt>'
|
63
63
|
end
|
64
64
|
|
65
|
-
@labels.to_xml_string(
|
66
|
-
@data.to_xml_string(
|
65
|
+
@labels.to_xml_string(str) unless @labels.nil?
|
66
|
+
@data.to_xml_string(str) unless @data.nil?
|
67
67
|
# this is actually only required for shapes other than box
|
68
|
-
|
68
|
+
str << ('<c:shape val="' << shape.to_s << '"></c:shape>')
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
module Axlsx
|
3
|
+
|
4
|
+
# The BubbleChart allows you to insert a bubble chart into your worksheet
|
5
|
+
# @see Worksheet#add_chart
|
6
|
+
# @see Chart#add_series
|
7
|
+
# @see README for an example
|
8
|
+
class BubbleChart < Chart
|
9
|
+
|
10
|
+
include Axlsx::OptionsParser
|
11
|
+
|
12
|
+
# the x value axis
|
13
|
+
# @return [ValAxis]
|
14
|
+
def x_val_axis
|
15
|
+
axes[:x_val_axis]
|
16
|
+
end
|
17
|
+
alias :xValAxis :x_val_axis
|
18
|
+
|
19
|
+
# the y value axis
|
20
|
+
# @return [ValAxis]
|
21
|
+
def y_val_axis
|
22
|
+
axes[:y_val_axis]
|
23
|
+
end
|
24
|
+
alias :yValAxis :y_val_axis
|
25
|
+
|
26
|
+
# Creates a new bubble chart
|
27
|
+
def initialize(frame, options={})
|
28
|
+
@vary_colors = 0
|
29
|
+
|
30
|
+
super(frame, options)
|
31
|
+
@series_type = BubbleSeries
|
32
|
+
@d_lbls = nil
|
33
|
+
parse_options options
|
34
|
+
end
|
35
|
+
|
36
|
+
# Serializes the object
|
37
|
+
# @param [String] str
|
38
|
+
# @return [String]
|
39
|
+
def to_xml_string(str = '')
|
40
|
+
super(str) do
|
41
|
+
str << '<c:bubbleChart>'
|
42
|
+
str << ('<c:varyColors val="' << vary_colors.to_s << '"/>')
|
43
|
+
@series.each { |ser| ser.to_xml_string(str) }
|
44
|
+
d_lbls.to_xml_string(str) if @d_lbls
|
45
|
+
axes.to_xml_string(str, :ids => true)
|
46
|
+
str << '</c:bubbleChart>'
|
47
|
+
axes.to_xml_string(str)
|
48
|
+
end
|
49
|
+
str
|
50
|
+
end
|
51
|
+
|
52
|
+
# The axes for the bubble chart. BubbleChart has an x_val_axis and
|
53
|
+
# a y_val_axis
|
54
|
+
# @return [Axes]
|
55
|
+
def axes
|
56
|
+
@axes ||= Axes.new(:x_val_axis => ValAxis, :y_val_axis => ValAxis)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
module Axlsx
|
3
|
+
|
4
|
+
# A BubbleSeries defines the x/y position and bubble size of data in the chart
|
5
|
+
# @note The recommended way to manage series is to use Chart#add_series
|
6
|
+
# @see Worksheet#add_chart
|
7
|
+
# @see Chart#add_series
|
8
|
+
# @see examples/example.rb
|
9
|
+
class BubbleSeries < Series
|
10
|
+
|
11
|
+
# The x data for this series.
|
12
|
+
# @return [AxDataSource]
|
13
|
+
attr_reader :xData
|
14
|
+
|
15
|
+
# The y data for this series.
|
16
|
+
# @return [NumDataSource]
|
17
|
+
attr_reader :yData
|
18
|
+
|
19
|
+
# The bubble size for this series.
|
20
|
+
# @return [NumDataSource]
|
21
|
+
attr_reader :bubbleSize
|
22
|
+
|
23
|
+
# The fill color for this series.
|
24
|
+
# Red, green, and blue is expressed as sequence of hex digits, RRGGBB. A perceptual gamma of 2.2 is used.
|
25
|
+
# @return [String]
|
26
|
+
attr_reader :color
|
27
|
+
|
28
|
+
# Creates a new BubbleSeries
|
29
|
+
def initialize(chart, options={})
|
30
|
+
@xData, @yData, @bubbleSize = nil
|
31
|
+
super(chart, options)
|
32
|
+
@xData = AxDataSource.new(:tag_name => :xVal, :data => options[:xData]) unless options[:xData].nil?
|
33
|
+
@yData = NumDataSource.new({:tag_name => :yVal, :data => options[:yData]}) unless options[:yData].nil?
|
34
|
+
@bubbleSize = NumDataSource.new({:tag_name => :bubbleSize, :data => options[:bubbleSize]}) unless options[:bubbleSize].nil?
|
35
|
+
end
|
36
|
+
|
37
|
+
# @see color
|
38
|
+
def color=(v)
|
39
|
+
@color = v
|
40
|
+
end
|
41
|
+
|
42
|
+
# Serializes the object
|
43
|
+
# @param [String] str
|
44
|
+
# @return [String]
|
45
|
+
def to_xml_string(str = '')
|
46
|
+
super(str) do
|
47
|
+
# needs to override the super color here to push in ln/and something else!
|
48
|
+
if color
|
49
|
+
str << '<c:spPr><a:solidFill>'
|
50
|
+
str << ('<a:srgbClr val="' << color << '"/>')
|
51
|
+
str << '</a:solidFill>'
|
52
|
+
str << '<a:ln><a:solidFill>'
|
53
|
+
str << ('<a:srgbClr val="' << color << '"/></a:solidFill></a:ln>')
|
54
|
+
str << '</c:spPr>'
|
55
|
+
end
|
56
|
+
@xData.to_xml_string(str) unless @xData.nil?
|
57
|
+
@yData.to_xml_string(str) unless @yData.nil?
|
58
|
+
@bubbleSize.to_xml_string(str) unless @bubbleSize.nil?
|
59
|
+
end
|
60
|
+
str
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -71,11 +71,11 @@ module Axlsx
|
|
71
71
|
def to_xml_string(str = '')
|
72
72
|
str << '<c:catAx>'
|
73
73
|
super(str)
|
74
|
-
str << '<c:auto val="' << @auto.to_s << '"/>'
|
75
|
-
str << '<c:lblAlgn val="' << @lbl_algn.to_s << '"/>'
|
76
|
-
str << '<c:lblOffset val="' << @lbl_offset.to_i.to_s << '"/>'
|
77
|
-
str << '<c:tickLblSkip val="' << @tick_lbl_skip.to_s << '"/>'
|
78
|
-
str << '<c:tickMarkSkip val="' << @tick_mark_skip.to_s << '"/>'
|
74
|
+
str << ('<c:auto val="' << @auto.to_s << '"/>')
|
75
|
+
str << ('<c:lblAlgn val="' << @lbl_algn.to_s << '"/>')
|
76
|
+
str << ('<c:lblOffset val="' << @lbl_offset.to_i.to_s << '"/>')
|
77
|
+
str << ('<c:tickLblSkip val="' << @tick_lbl_skip.to_s << '"/>')
|
78
|
+
str << ('<c:tickMarkSkip val="' << @tick_mark_skip.to_s << '"/>')
|
79
79
|
str << '</c:catAx>'
|
80
80
|
end
|
81
81
|
|
data/lib/axlsx/drawing/chart.rb
CHANGED
@@ -11,6 +11,7 @@ module Axlsx
|
|
11
11
|
# @param [GraphicalFrame] frame The frame that holds this chart.
|
12
12
|
# @option options [Cell, String] title
|
13
13
|
# @option options [Boolean] show_legend
|
14
|
+
# @option options [Symbol] legend_position
|
14
15
|
# @option options [Array|String|Cell] start_at The X, Y coordinates defining the top left corner of the chart.
|
15
16
|
# @option options [Array|String|Cell] end_at The X, Y coordinates defining the bottom right corner of the chart.
|
16
17
|
def initialize(frame, options={})
|
@@ -20,9 +21,11 @@ module Axlsx
|
|
20
21
|
@graphic_frame.anchor.drawing.worksheet.workbook.charts << self
|
21
22
|
@series = SimpleTypedList.new Series
|
22
23
|
@show_legend = true
|
24
|
+
@legend_position = :r
|
23
25
|
@display_blanks_as = :gap
|
24
26
|
@series_type = Series
|
25
27
|
@title = Title.new
|
28
|
+
@bg_color = nil
|
26
29
|
parse_options options
|
27
30
|
start_at(*options[:start_at]) if options[:start_at]
|
28
31
|
end_at(*options[:end_at]) if options[:end_at]
|
@@ -71,6 +74,17 @@ module Axlsx
|
|
71
74
|
# @return [Boolean]
|
72
75
|
attr_reader :show_legend
|
73
76
|
|
77
|
+
# Set the location of the chart's legend
|
78
|
+
# @return [Symbol] The position of this legend
|
79
|
+
# @note
|
80
|
+
# The following are allowed
|
81
|
+
# :b
|
82
|
+
# :l
|
83
|
+
# :r
|
84
|
+
# :t
|
85
|
+
# :tr
|
86
|
+
attr_reader :legend_position
|
87
|
+
|
74
88
|
# How to display blank values
|
75
89
|
# Options are
|
76
90
|
# * gap: Display nothing
|
@@ -80,6 +94,10 @@ module Axlsx
|
|
80
94
|
# Default :gap (although this really should vary by chart type and grouping)
|
81
95
|
attr_reader :display_blanks_as
|
82
96
|
|
97
|
+
# Background color for the chart
|
98
|
+
# @return [String]
|
99
|
+
attr_reader :bg_color
|
100
|
+
|
83
101
|
# The relationship object for this chart.
|
84
102
|
# @return [Relationship]
|
85
103
|
def relationship
|
@@ -126,6 +144,9 @@ module Axlsx
|
|
126
144
|
# @param [Integer] v must be between 1 and 48
|
127
145
|
def style=(v) DataTypeValidator.validate "Chart.style", Integer, v, lambda { |arg| arg >= 1 && arg <= 48 }; @style = v; end
|
128
146
|
|
147
|
+
# @see legend_position
|
148
|
+
def legend_position=(v) RestrictionValidator.validate "Chart.legend_position", [:b, :l, :r, :t, :tr], v; @legend_position = v; end
|
149
|
+
|
129
150
|
# backwards compatibility to allow chart.to and chart.from access to anchor markers
|
130
151
|
# @note This will be disconinued in version 2.0.0. Please use the end_at method
|
131
152
|
def to
|
@@ -146,36 +167,52 @@ module Axlsx
|
|
146
167
|
@series.last
|
147
168
|
end
|
148
169
|
|
170
|
+
# Assigns a background color to chart area
|
171
|
+
def bg_color=(v)
|
172
|
+
DataTypeValidator.validate(:color, Color, Color.new(:rgb => v))
|
173
|
+
@bg_color = v
|
174
|
+
end
|
175
|
+
|
149
176
|
# Serializes the object
|
150
177
|
# @param [String] str
|
151
178
|
# @return [String]
|
152
179
|
def to_xml_string(str = '')
|
153
180
|
str << '<?xml version="1.0" encoding="UTF-8"?>'
|
154
|
-
str << '<c:chartSpace xmlns:c="' << XML_NS_C << '" xmlns:a="' << XML_NS_A << '" xmlns:r="' << XML_NS_R << '">'
|
155
|
-
str << '<c:date1904 val="' << Axlsx::Workbook.date1904.to_s << '"/>'
|
156
|
-
str << '<c:style val="' << style.to_s << '"/>'
|
181
|
+
str << ('<c:chartSpace xmlns:c="' << XML_NS_C << '" xmlns:a="' << XML_NS_A << '" xmlns:r="' << XML_NS_R << '">')
|
182
|
+
str << ('<c:date1904 val="' << Axlsx::Workbook.date1904.to_s << '"/>')
|
183
|
+
str << ('<c:style val="' << style.to_s << '"/>')
|
157
184
|
str << '<c:chart>'
|
158
185
|
@title.to_xml_string str
|
159
|
-
str << '<c:autoTitleDeleted val="' << (@title == nil).to_s << '"/>'
|
186
|
+
str << ('<c:autoTitleDeleted val="' << (@title == nil).to_s << '"/>')
|
160
187
|
@view_3D.to_xml_string(str) if @view_3D
|
161
188
|
str << '<c:floor><c:thickness val="0"/></c:floor>'
|
162
189
|
str << '<c:sideWall><c:thickness val="0"/></c:sideWall>'
|
163
190
|
str << '<c:backWall><c:thickness val="0"/></c:backWall>'
|
164
191
|
str << '<c:plotArea>'
|
165
192
|
str << '<c:layout/>'
|
166
|
-
yield
|
193
|
+
yield if block_given?
|
167
194
|
str << '</c:plotArea>'
|
168
195
|
if @show_legend
|
169
196
|
str << '<c:legend>'
|
170
|
-
str << '<c:legendPos val="
|
197
|
+
str << ('<c:legendPos val="' << @legend_position.to_s << '"/>')
|
171
198
|
str << '<c:layout/>'
|
172
199
|
str << '<c:overlay val="0"/>'
|
173
200
|
str << '</c:legend>'
|
174
201
|
end
|
175
202
|
str << '<c:plotVisOnly val="1"/>'
|
176
|
-
str << '<c:dispBlanksAs val="' << display_blanks_as.to_s << '"/>'
|
203
|
+
str << ('<c:dispBlanksAs val="' << display_blanks_as.to_s << '"/>')
|
177
204
|
str << '<c:showDLblsOverMax val="1"/>'
|
178
205
|
str << '</c:chart>'
|
206
|
+
if bg_color
|
207
|
+
str << '<c:spPr>'
|
208
|
+
str << '<a:solidFill>'
|
209
|
+
str << '<a:srgbClr val="' << bg_color << '"/>'
|
210
|
+
str << '</a:solidFill>'
|
211
|
+
str << '<a:ln>'
|
212
|
+
str << '<a:noFill/>'
|
213
|
+
str << '</a:ln>'
|
214
|
+
str << '</c:spPr>'
|
215
|
+
end
|
179
216
|
str << '<c:printSettings>'
|
180
217
|
str << '<c:headerFooter/>'
|
181
218
|
str << '<c:pageMargins b="1.0" l="0.75" r="0.75" t="1.0" header="0.5" footer="0.5"/>'
|
@@ -8,6 +8,7 @@ module Axlsx
|
|
8
8
|
require 'axlsx/drawing/bar_series.rb'
|
9
9
|
require 'axlsx/drawing/line_series.rb'
|
10
10
|
require 'axlsx/drawing/scatter_series.rb'
|
11
|
+
require 'axlsx/drawing/bubble_series.rb'
|
11
12
|
|
12
13
|
require 'axlsx/drawing/scaling.rb'
|
13
14
|
require 'axlsx/drawing/axis.rb'
|
@@ -37,6 +38,7 @@ module Axlsx
|
|
37
38
|
require 'axlsx/drawing/line_chart.rb'
|
38
39
|
require 'axlsx/drawing/line_3D_chart.rb'
|
39
40
|
require 'axlsx/drawing/scatter_chart.rb'
|
41
|
+
require 'axlsx/drawing/bubble_chart.rb'
|
40
42
|
|
41
43
|
require 'axlsx/drawing/picture_locking.rb'
|
42
44
|
require 'axlsx/drawing/pic.rb'
|
@@ -153,7 +155,7 @@ module Axlsx
|
|
153
155
|
# @return [String]
|
154
156
|
def to_xml_string(str = '')
|
155
157
|
str << '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'
|
156
|
-
str << '<xdr:wsDr xmlns:xdr="' << XML_NS_XDR << '" xmlns:a="' << XML_NS_A << '">'
|
158
|
+
str << ('<xdr:wsDr xmlns:xdr="' << XML_NS_XDR << '" xmlns:a="' << XML_NS_A << '">')
|
157
159
|
anchors.each { |anchor| anchor.to_xml_string(str) }
|
158
160
|
str << '</xdr:wsDr>'
|
159
161
|
end
|