write_xlsx 0.75.0 → 0.76.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.
- checksums.yaml +4 -4
- data/Changes +4 -0
- data/Gemfile +8 -2
- data/README.md +4 -2
- data/lib/write_xlsx/chart/axis.rb +69 -96
- data/lib/write_xlsx/chart/bar.rb +18 -21
- data/lib/write_xlsx/chart/caption.rb +1 -1
- data/lib/write_xlsx/chart/column.rb +1 -5
- data/lib/write_xlsx/chart/line.rb +2 -16
- data/lib/write_xlsx/chart/pie.rb +18 -40
- data/lib/write_xlsx/chart/radar.rb +2 -5
- data/lib/write_xlsx/chart/scatter.rb +24 -32
- data/lib/write_xlsx/chart/series.rb +218 -236
- data/lib/write_xlsx/chart/stock.rb +15 -27
- data/lib/write_xlsx/chart.rb +303 -392
- data/lib/write_xlsx/chartsheet.rb +22 -20
- data/lib/write_xlsx/colors.rb +9 -15
- data/lib/write_xlsx/drawing.rb +26 -28
- data/lib/write_xlsx/format.rb +15 -15
- data/lib/write_xlsx/package/comments.rb +1 -1
- data/lib/write_xlsx/package/conditional_format.rb +8 -8
- data/lib/write_xlsx/package/relationships.rb +4 -15
- data/lib/write_xlsx/package/styles.rb +9 -16
- data/lib/write_xlsx/shape.rb +1 -15
- data/lib/write_xlsx/sparkline.rb +1 -1
- data/lib/write_xlsx/utility.rb +69 -13
- data/lib/write_xlsx/version.rb +1 -1
- data/lib/write_xlsx/workbook.rb +19 -7
- data/lib/write_xlsx/worksheet/cell_data.rb +1 -1
- data/lib/write_xlsx/worksheet/hyperlink.rb +39 -37
- data/lib/write_xlsx/worksheet.rb +44 -72
- data/lib/write_xlsx/zip_file_utils.rb +99 -0
- data/test/chart/test_add_series.rb +5 -5
- data/test/chart/test_write_d_lbls.rb +1 -1
- data/test/chart/test_write_major_gridlines.rb +1 -1
- data/test/chart/test_write_marker.rb +1 -1
- data/test/chart/test_write_number_format.rb +1 -1
- data/test/helper.rb +7 -4
- data/test/regression/klt.csv +4 -0
- data/test/regression/test_chart_column07.rb +44 -0
- data/test/regression/test_chart_column08.rb +46 -0
- data/test/regression/test_chart_date01.rb +57 -0
- data/test/regression/test_chart_date02.rb +59 -0
- data/test/regression/test_chart_date03.rb +59 -0
- data/test/regression/test_chart_date04.rb +61 -0
- data/test/regression/test_chart_stock01.rb +1 -6
- data/test/regression/test_chart_title02.rb +44 -0
- data/test/regression/test_escapes01.rb +1 -1
- data/test/regression/test_escapes02.rb +1 -1
- data/test/regression/test_escapes03.rb +1 -1
- data/test/regression/test_escapes04.rb +1 -1
- data/test/regression/test_escapes05.rb +1 -1
- data/test/regression/test_escapes06.rb +1 -1
- data/test/regression/test_escapes07.rb +1 -1
- data/test/regression/test_escapes08.rb +1 -1
- data/test/regression/test_set_column09.rb +31 -0
- data/test/regression/test_shared_strings_encoding.rb +103 -0
- data/test/regression/xlsx_files/chart_column07.xlsx +0 -0
- data/test/regression/xlsx_files/chart_column08.xlsx +0 -0
- data/test/regression/xlsx_files/chart_date01.xlsx +0 -0
- data/test/regression/xlsx_files/chart_date02.xlsx +0 -0
- data/test/regression/xlsx_files/chart_date03.xlsx +0 -0
- data/test/regression/xlsx_files/chart_date04.xlsx +0 -0
- data/test/regression/xlsx_files/chart_title02.xlsx +0 -0
- data/test/regression/xlsx_files/set_column09.xlsx +0 -0
- data/test/regression/xlsx_files/shared_strings_encoding.xlsx +0 -0
- data/test/worksheet/test_write_hyperlink.rb +10 -15
- data/write_xlsx.gemspec +0 -3
- metadata +48 -39
- data/test/worksheet/test_set_column.rb +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15e9357295f571cfc282263876abdaf83e28e652
|
4
|
+
data.tar.gz: 264a4bd65b91a39bc4cdabb518291a7df5894376
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70bb93acf8c0ecb36ecc45e0c5cb4c1c64c502252878cd3d4bf1c4ab1ad9dd0940dd673cc67c1200d5964597207c678f0996deb4c2466e5bf7f1afb20390903f
|
7
|
+
data.tar.gz: 3759ae9b833ca5e0138098b552370f9c7ab1daae3670c52a4b3539298de2d7aa219021eec5d9a9a475e12871bcd342799e17274acfb009d8028baf331fca8466
|
data/Changes
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
# write_xlsx
|
2
2
|
|
3
|
+
[](http://badge.fury.io/rb/write_xlsx)
|
4
|
+
|
3
5
|
gem to create a new file in the Excel 2007+ XLSX format, and you can use the
|
4
6
|
same interface as writeexcel gem. write_xlsx is converted from Perl's module
|
5
|
-
[Excel::Writer::XLSX-0.
|
7
|
+
[Excel::Writer::XLSX-0.76](https://github.com/jmcnamara/excel-writer-xlsx) .
|
6
8
|
|
7
9
|
## Description
|
8
10
|
|
@@ -82,7 +84,7 @@ the first worksheet in an Excel XML spreadsheet called ruby.xlsx:
|
|
82
84
|
Original Perl module was written by John McNamara(jmcnamara@cpan.org).
|
83
85
|
|
84
86
|
Converted to ruby by Hideo NAKAMURA(cxn03651@msj.biglobe.ne.jp)
|
85
|
-
Copyright (c) 2012-
|
87
|
+
Copyright (c) 2012-2014 Hideo NAKAMURA.
|
86
88
|
|
87
89
|
See LICENSE.txt for further details.
|
88
90
|
|
@@ -8,12 +8,12 @@ module Writexlsx
|
|
8
8
|
class Axis < Caption
|
9
9
|
include Writexlsx::Utility
|
10
10
|
|
11
|
-
attr_accessor :defaults
|
12
|
-
attr_accessor :min, :max
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
attr_accessor :defaults
|
12
|
+
attr_accessor :min, :max, :num_format, :position, :major_tick_mark
|
13
|
+
attr_reader :minor_unit, :major_unit, :minor_unit_type, :major_unit_type
|
14
|
+
attr_reader :log_base, :crossing, :position_axis, :label_position, :visible
|
15
|
+
attr_reader :num_format_linked, :num_font, :layout, :interval_unit
|
16
|
+
attr_reader :major_gridlines, :minor_gridlines, :reverse
|
17
17
|
|
18
18
|
#
|
19
19
|
# Convert user defined axis values into axis instance.
|
@@ -22,36 +22,79 @@ module Writexlsx
|
|
22
22
|
super
|
23
23
|
args = (defaults || {}).merge(params)
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
@minor_unit_type = args[:minor_unit_type]
|
31
|
-
@major_unit_type = args[:major_unit_type]
|
32
|
-
@log_base = args[:log_base]
|
33
|
-
@crossing = args[:crossing]
|
34
|
-
@position_axis = args[:position_axis]
|
35
|
-
@label_position = args[:label_position]
|
36
|
-
@num_format = args[:num_format]
|
37
|
-
@num_format_linked = args[:num_format_linked]
|
38
|
-
@interval_unit = args[:interval_unit]
|
25
|
+
[
|
26
|
+
:reverse, :min, :max, :minor_unit, :major_unit, :minor_unit_type,
|
27
|
+
:major_unit_type, :log_base, :crossing, :position_axis, :label_position,
|
28
|
+
:num_format, :num_format_linked, :interval_unit, :major_tick_mark
|
29
|
+
].each { |val| instance_variable_set("@#{val}", args[val]) }
|
39
30
|
@visible = args[:visible] || 1
|
40
31
|
|
32
|
+
set_major_minor_gridlines(args)
|
33
|
+
set_position(args)
|
34
|
+
set_position_axis
|
35
|
+
set_font_properties(args)
|
36
|
+
set_axis_name_layout(args)
|
37
|
+
end
|
38
|
+
|
39
|
+
#
|
40
|
+
# Write the <c:numberFormat> element. Note: It is assumed that if a user
|
41
|
+
# defined number format is supplied (i.e., non-default) then the sourceLinked
|
42
|
+
# attribute is 0. The user can override this if required.
|
43
|
+
#
|
44
|
+
|
45
|
+
def write_number_format(writer) # :nodoc:
|
46
|
+
writer.empty_tag('c:numFmt', num_fmt_attributes)
|
47
|
+
end
|
48
|
+
|
49
|
+
#
|
50
|
+
# Write the <c:numFmt> element. Special case handler for category axes which
|
51
|
+
# don't always have a number format.
|
52
|
+
#
|
53
|
+
def write_cat_number_format(writer, cat_has_num_fmt)
|
54
|
+
return unless user_defined_num_fmt_set? || cat_has_num_fmt
|
55
|
+
|
56
|
+
writer.empty_tag('c:numFmt', num_fmt_attributes)
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def user_defined_num_fmt_set?
|
62
|
+
@defaults && @num_format != @defaults[:num_format]
|
63
|
+
end
|
64
|
+
|
65
|
+
def source_linked
|
66
|
+
value = 1
|
67
|
+
value = 0 if user_defined_num_fmt_set?
|
68
|
+
value = 1 if @num_format_linked
|
69
|
+
|
70
|
+
value
|
71
|
+
end
|
72
|
+
|
73
|
+
def num_fmt_attributes
|
74
|
+
[
|
75
|
+
['formatCode', @num_format],
|
76
|
+
['sourceLinked', source_linked]
|
77
|
+
]
|
78
|
+
end
|
79
|
+
|
80
|
+
def set_major_minor_gridlines(args)
|
41
81
|
# Map major/minor_gridlines properties.
|
42
82
|
[:major_gridlines, :minor_gridlines].each do |lines|
|
43
83
|
if args[lines] && ptrue?(args[lines][:visible])
|
44
|
-
instance_variable_set("@#{lines}",
|
84
|
+
instance_variable_set("@#{lines}", Gridline.new(args[lines]))
|
45
85
|
else
|
46
86
|
instance_variable_set("@#{lines}", nil)
|
47
87
|
end
|
48
88
|
end
|
49
|
-
|
89
|
+
end
|
50
90
|
|
91
|
+
def set_position(args)
|
51
92
|
# Only use the first letter of bottom, top, left or right.
|
52
93
|
@position = args[:position]
|
53
94
|
@position = @position.downcase[0, 1] if @position
|
95
|
+
end
|
54
96
|
|
97
|
+
def set_position_axis
|
55
98
|
# Set the position for a category axis on or between the tick marks.
|
56
99
|
if @position_axis
|
57
100
|
if @position_axis == 'on_tick'
|
@@ -63,85 +106,15 @@ module Writexlsx
|
|
63
106
|
@position_axis = nil
|
64
107
|
end
|
65
108
|
end
|
109
|
+
end
|
66
110
|
|
67
|
-
|
111
|
+
def set_font_properties(args)
|
68
112
|
@num_font = @chart.convert_font_args(args[:num_font])
|
69
113
|
@name_font = @chart.convert_font_args(args[:name_font])
|
70
|
-
|
71
|
-
# Set the axis name layout.
|
72
|
-
@layout = @chart.layout_properties(args[:name_layout], 1)
|
73
114
|
end
|
74
115
|
|
75
|
-
|
76
|
-
|
77
|
-
# defined number format is supplied (i.e., non-default) then the sourceLinked
|
78
|
-
# attribute is 0. The user can override this if required.
|
79
|
-
#
|
80
|
-
|
81
|
-
def write_number_format(writer) # :nodoc:
|
82
|
-
source_linked = 1
|
83
|
-
|
84
|
-
# Check if a user defined number format has been set.
|
85
|
-
if @defaults && @num_format != @defaults[:num_format]
|
86
|
-
source_linked = 0
|
87
|
-
end
|
88
|
-
|
89
|
-
# User override of sourceLinked.
|
90
|
-
if ptrue?(@num_format_linked)
|
91
|
-
source_linked = 1
|
92
|
-
end
|
93
|
-
|
94
|
-
attributes = [
|
95
|
-
['formatCode', @num_format],
|
96
|
-
['sourceLinked', source_linked]
|
97
|
-
]
|
98
|
-
|
99
|
-
writer.empty_tag('c:numFmt', attributes)
|
100
|
-
end
|
101
|
-
|
102
|
-
#
|
103
|
-
# Write the <c:numFmt> element. Special case handler for category axes which
|
104
|
-
# don't always have a number format.
|
105
|
-
#
|
106
|
-
def write_cat_number_format(writer, cat_has_num_fmt)
|
107
|
-
source_linked = 1
|
108
|
-
default_format = true
|
109
|
-
|
110
|
-
# Check if a user defined number format has been set.
|
111
|
-
if @defaults && @num_format != @defaults[:num_format]
|
112
|
-
source_linked = 0
|
113
|
-
default_format = false
|
114
|
-
end
|
115
|
-
|
116
|
-
# User override of linkedSource.
|
117
|
-
if @num_format_linked
|
118
|
-
source_linked = 1
|
119
|
-
end
|
120
|
-
|
121
|
-
# Skip if cat doesn't have a num format (unless it is non-default).
|
122
|
-
if !cat_has_num_fmt && default_format
|
123
|
-
return ''
|
124
|
-
end
|
125
|
-
|
126
|
-
attributes = [
|
127
|
-
['formatCode', @num_format],
|
128
|
-
['sourceLinked', source_linked]
|
129
|
-
]
|
130
|
-
|
131
|
-
writer.empty_tag('c:numFmt', attributes)
|
132
|
-
end
|
133
|
-
|
134
|
-
#
|
135
|
-
# Convert user defined gridline properties to the structure required internally.
|
136
|
-
#
|
137
|
-
def gridline_properties(args)
|
138
|
-
# Set the visible property for the gridline.
|
139
|
-
gridline = { :_visible => args[:visible] }
|
140
|
-
|
141
|
-
# Set the line properties for the gridline.
|
142
|
-
gridline[:_line] = @chart.line_properties(args[:line])
|
143
|
-
|
144
|
-
gridline
|
116
|
+
def set_axis_name_layout(args)
|
117
|
+
@layout = @chart.layout_properties(args[:name_layout], 1)
|
145
118
|
end
|
146
119
|
end
|
147
120
|
end
|
data/lib/write_xlsx/chart/bar.rb
CHANGED
@@ -27,23 +27,8 @@ module Writexlsx
|
|
27
27
|
@horiz_val_axis = 0
|
28
28
|
@horiz_cat_axis = 1
|
29
29
|
@show_crosses = false
|
30
|
-
|
31
30
|
# Override and reset the default axis values.
|
32
|
-
|
33
|
-
@x_axis.defaults[:major_gridlines] = { :visible => 1 }
|
34
|
-
else
|
35
|
-
@x_axis.defaults = { :major_gridlines => { :visible => 1 } }
|
36
|
-
end
|
37
|
-
if @y_axis.defaults
|
38
|
-
@y_axis.defaults[:major_gridlines] = { :visible => 0 }
|
39
|
-
else
|
40
|
-
@y_axis.defaults = { :major_gridlines => { :visible => 0 } }
|
41
|
-
end
|
42
|
-
|
43
|
-
if @subtype == 'percent_stacked'
|
44
|
-
@x_axis.defaults[:num_format] = '0%'
|
45
|
-
end
|
46
|
-
|
31
|
+
axis_defaults_set
|
47
32
|
set_x_axis
|
48
33
|
set_y_axis
|
49
34
|
end
|
@@ -68,11 +53,7 @@ module Writexlsx
|
|
68
53
|
# Write the <c:barDir> element.
|
69
54
|
#
|
70
55
|
def write_bar_dir
|
71
|
-
val
|
72
|
-
|
73
|
-
attributes = [ ['val', val] ]
|
74
|
-
|
75
|
-
@writer.empty_tag('c:barDir', attributes)
|
56
|
+
@writer.empty_tag('c:barDir', [ ['val', 'bar'] ])
|
76
57
|
end
|
77
58
|
|
78
59
|
#
|
@@ -82,6 +63,22 @@ module Writexlsx
|
|
82
63
|
def write_err_dir(direction)
|
83
64
|
# do nothing
|
84
65
|
end
|
66
|
+
|
67
|
+
private
|
68
|
+
|
69
|
+
def axis_defaults_set
|
70
|
+
if @x_axis.defaults
|
71
|
+
@x_axis.defaults[:major_gridlines] = { :visible => 1 }
|
72
|
+
else
|
73
|
+
@x_axis.defaults = { :major_gridlines => { :visible => 1 } }
|
74
|
+
end
|
75
|
+
if @y_axis.defaults
|
76
|
+
@y_axis.defaults[:major_gridlines] = { :visible => 0 }
|
77
|
+
else
|
78
|
+
@y_axis.defaults = { :major_gridlines => { :visible => 0 } }
|
79
|
+
end
|
80
|
+
@x_axis.defaults[:num_format] = '0%' if @subtype == 'percent_stacked'
|
81
|
+
end
|
85
82
|
end
|
86
83
|
end
|
87
84
|
end
|
@@ -12,7 +12,7 @@ module Writexlsx
|
|
12
12
|
|
13
13
|
def merge_with_hash(params) # :nodoc:
|
14
14
|
@name, @formula = @chart.process_names(params[:name], params[:name_formula])
|
15
|
-
@data_id = @chart.
|
15
|
+
@data_id = @chart.data_id(@formula, params[:data])
|
16
16
|
@name_font = @chart.convert_font_args(params[:name_font])
|
17
17
|
@layout = @chart.layout_properties(params[:layout], 1)
|
18
18
|
|
@@ -18,10 +18,11 @@ module Writexlsx
|
|
18
18
|
class Chart
|
19
19
|
class Line < self
|
20
20
|
include Writexlsx::Utility
|
21
|
+
include Writexlsx::WriteDPtPoint
|
21
22
|
|
22
23
|
def initialize(subtype)
|
23
24
|
super(subtype)
|
24
|
-
@default_marker =
|
25
|
+
@default_marker = Marker.new(:type => 'none')
|
25
26
|
@smooth_allowed = 1
|
26
27
|
end
|
27
28
|
|
@@ -62,21 +63,6 @@ module Writexlsx
|
|
62
63
|
write_axis_ids(params)
|
63
64
|
end
|
64
65
|
end
|
65
|
-
|
66
|
-
#
|
67
|
-
# Write an individual <c:dPt> element. Override the parent method to add
|
68
|
-
# markers.
|
69
|
-
#
|
70
|
-
def write_d_pt_point(index, point)
|
71
|
-
@writer.tag_elements('c:dPt') do
|
72
|
-
# Write the c:idx element.
|
73
|
-
write_idx(index)
|
74
|
-
@writer.tag_elements('c:marker') do
|
75
|
-
# Write the c:spPr element.
|
76
|
-
write_sp_pr(point)
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
66
|
end
|
81
67
|
end
|
82
68
|
end
|
data/lib/write_xlsx/chart/pie.rb
CHANGED
@@ -28,13 +28,12 @@ module Writexlsx
|
|
28
28
|
|
29
29
|
def initialize(subtype)
|
30
30
|
super(subtype)
|
31
|
-
@vary_data_color = 1
|
32
31
|
end
|
33
32
|
|
34
33
|
#
|
35
34
|
# Override the virtual superclass method with a chart specific method.
|
36
35
|
#
|
37
|
-
def write_chart_type
|
36
|
+
def write_chart_type
|
38
37
|
# Write the c:areaChart element.
|
39
38
|
write_pie_chart
|
40
39
|
end
|
@@ -63,7 +62,7 @@ module Writexlsx
|
|
63
62
|
def write_plot_area
|
64
63
|
@writer.tag_elements('c:plotArea') do
|
65
64
|
# Write the c:layout element.
|
66
|
-
write_layout(@plotarea
|
65
|
+
write_layout(@plotarea.layout, 'plot')
|
67
66
|
# Write the subclass chart type element.
|
68
67
|
write_chart_type
|
69
68
|
end
|
@@ -76,41 +75,32 @@ module Writexlsx
|
|
76
75
|
#
|
77
76
|
def write_legend
|
78
77
|
position = @legend_position
|
79
|
-
|
80
|
-
overlay = 0
|
78
|
+
allowed = %w(right left top bottom)
|
81
79
|
delete_series = @legend_delete_series || []
|
82
80
|
|
83
|
-
if
|
84
|
-
position.sub
|
85
|
-
overlay =
|
81
|
+
if @legend_position =~ /^overlay_/
|
82
|
+
position = @legend_position.sub(/^overlay_/, '')
|
83
|
+
overlay = true
|
84
|
+
else
|
85
|
+
position = @legend_position
|
86
|
+
overlay = false
|
86
87
|
end
|
87
88
|
|
88
|
-
allowed = {
|
89
|
-
'right' => 'r',
|
90
|
-
'left' => 'l',
|
91
|
-
'top' => 't',
|
92
|
-
'bottom' => 'b'
|
93
|
-
}
|
94
|
-
|
95
89
|
return if position == 'none'
|
96
|
-
return unless allowed.
|
97
|
-
|
98
|
-
position = allowed[position]
|
90
|
+
return unless allowed.include?(position)
|
99
91
|
|
100
92
|
@writer.tag_elements('c:legend') do
|
101
93
|
# Write the c:legendPos element.
|
102
|
-
write_legend_pos(position)
|
94
|
+
write_legend_pos(position[0])
|
103
95
|
# Remove series labels from the legend.
|
104
|
-
|
105
|
-
|
106
|
-
write_legend_entry(index)
|
107
|
-
end
|
96
|
+
# Write the c:legendEntry element.
|
97
|
+
delete_series.each { |index| write_legend_entry(index) }
|
108
98
|
# Write the c:layout element.
|
109
99
|
write_layout(@legend_layout, 'legend')
|
110
100
|
# Write the c:overlay element.
|
111
|
-
write_overlay if overlay
|
101
|
+
write_overlay if overlay
|
112
102
|
# Write the c:txPr element. Over-ridden.
|
113
|
-
write_tx_pr_legend(0,
|
103
|
+
write_tx_pr_legend(0, @legend_font)
|
114
104
|
end
|
115
105
|
end
|
116
106
|
|
@@ -149,11 +139,7 @@ module Writexlsx
|
|
149
139
|
# Write the <a:pPr> element for legends.
|
150
140
|
#
|
151
141
|
def write_a_p_pr_legend(font)
|
152
|
-
rtl
|
153
|
-
|
154
|
-
attributes = [ ['rtl', rtl] ]
|
155
|
-
|
156
|
-
@writer.tag_elements('a:pPr', attributes) do
|
142
|
+
@writer.tag_elements('a:pPr', [ ['rtl', 0] ]) do
|
157
143
|
# Write the a:defRPr element.
|
158
144
|
write_a_def_rpr(font)
|
159
145
|
end
|
@@ -163,22 +149,14 @@ module Writexlsx
|
|
163
149
|
# Write the <c:varyColors> element.
|
164
150
|
#
|
165
151
|
def write_vary_colors
|
166
|
-
val
|
167
|
-
|
168
|
-
attributes = [ ['val', val] ]
|
169
|
-
|
170
|
-
@writer.empty_tag('c:varyColors', attributes)
|
152
|
+
@writer.empty_tag('c:varyColors', [ ['val', 1] ])
|
171
153
|
end
|
172
154
|
|
173
155
|
#
|
174
156
|
# Write the <c:firstSliceAng> element.
|
175
157
|
#
|
176
158
|
def write_first_slice_ang
|
177
|
-
val
|
178
|
-
|
179
|
-
attributes = [ ['val', val] ]
|
180
|
-
|
181
|
-
@writer.empty_tag('c:firstSliceAng', attributes)
|
159
|
+
@writer.empty_tag('c:firstSliceAng', [ ['val', 0] ])
|
182
160
|
end
|
183
161
|
end
|
184
162
|
end
|
@@ -32,7 +32,7 @@ module Writexlsx
|
|
32
32
|
super(subtype)
|
33
33
|
@subtype = subtype || 'marker'
|
34
34
|
if @subtype == 'marker'
|
35
|
-
@default_marker =
|
35
|
+
@default_marker = Marker.new(:type => 'none')
|
36
36
|
end
|
37
37
|
|
38
38
|
# Override and reset the default axis values.
|
@@ -80,10 +80,7 @@ module Writexlsx
|
|
80
80
|
#
|
81
81
|
def write_radar_style
|
82
82
|
val = 'marker'
|
83
|
-
|
84
|
-
if @subtype == 'filled'
|
85
|
-
val = 'filled'
|
86
|
-
end
|
83
|
+
val = 'filled' if @subtype == 'filled'
|
87
84
|
|
88
85
|
attributes = [ ['val', val] ]
|
89
86
|
|
@@ -34,6 +34,7 @@ module Writexlsx
|
|
34
34
|
#
|
35
35
|
class Scatter < self
|
36
36
|
include Writexlsx::Utility
|
37
|
+
include Writexlsx::WriteDPtPoint
|
37
38
|
|
38
39
|
def initialize(subtype)
|
39
40
|
super(subtype)
|
@@ -64,15 +65,8 @@ module Writexlsx
|
|
64
65
|
return if series.empty?
|
65
66
|
|
66
67
|
style = 'lineMarker'
|
67
|
-
subtype = @subtype
|
68
|
-
|
69
68
|
# Set the user defined chart subtype
|
70
|
-
|
71
|
-
when 'marker_only', 'straight_with_markers', 'straight'
|
72
|
-
style = 'lineMarker'
|
73
|
-
when 'smooth_with_markers', 'smooth'
|
74
|
-
style = 'smoothMarker'
|
75
|
-
end
|
69
|
+
style = 'smoothMarker' if ['smooth_with_markers', 'smooth'].include?(@subtype)
|
76
70
|
|
77
71
|
# Add default formatting to the series data.
|
78
72
|
modify_series_formatting
|
@@ -82,10 +76,8 @@ module Writexlsx
|
|
82
76
|
write_scatter_style(style)
|
83
77
|
# Write the series elements.
|
84
78
|
series.each {|s| write_series(s)}
|
85
|
-
|
86
79
|
# Write the c:marker element.
|
87
80
|
write_marker_value
|
88
|
-
|
89
81
|
# Write the c:axId elements
|
90
82
|
write_axis_ids(params)
|
91
83
|
end
|
@@ -141,7 +133,7 @@ module Writexlsx
|
|
141
133
|
def write_plot_area
|
142
134
|
@writer.tag_elements('c:plotArea') do
|
143
135
|
# Write the c:layout element.
|
144
|
-
write_layout(@plotarea
|
136
|
+
write_layout(@plotarea.layout, 'plot')
|
145
137
|
|
146
138
|
# Write the subclass chart type elements for primary and secondary axes
|
147
139
|
write_chart_type(:primary_axes => 1)
|
@@ -227,9 +219,7 @@ module Writexlsx
|
|
227
219
|
# Write the <c:scatterStyle> element.
|
228
220
|
#
|
229
221
|
def write_scatter_style(val)
|
230
|
-
|
231
|
-
|
232
|
-
@writer.empty_tag('c:scatterStyle', attributes)
|
222
|
+
@writer.empty_tag('c:scatterStyle', [ ['val', val] ])
|
233
223
|
end
|
234
224
|
|
235
225
|
#
|
@@ -237,44 +227,46 @@ module Writexlsx
|
|
237
227
|
# specified by the user.
|
238
228
|
#
|
239
229
|
def modify_series_formatting
|
240
|
-
subtype = @subtype
|
241
|
-
|
242
230
|
# The default scatter style "markers only" requires a line type
|
243
|
-
if subtype == 'marker_only'
|
231
|
+
if @subtype == 'marker_only'
|
244
232
|
# Go through each series and define default values.
|
245
233
|
@series.each do |series|
|
246
234
|
# Set a line type unless there is already a user defined type.
|
247
|
-
|
248
|
-
series.line =
|
235
|
+
unless series.line_defined?
|
236
|
+
series.line = line_properties(:width => 2.25, :none => 1, :_defined => 1)
|
249
237
|
end
|
250
238
|
end
|
251
239
|
end
|
252
240
|
|
253
241
|
# Turn markers off for subtypes that don't have them
|
254
|
-
unless subtype =~ /marker/
|
242
|
+
unless @subtype =~ /marker/
|
255
243
|
# Go through each series and define default values.
|
256
244
|
@series.each do |series|
|
257
245
|
# Set a marker type unless there is already a user defined type.
|
258
246
|
unless ptrue?(series.marker)
|
259
|
-
series.marker =
|
247
|
+
series.marker = Marker.new(:type => 'none', :_defined => 1)
|
260
248
|
end
|
261
249
|
end
|
262
250
|
end
|
263
251
|
end
|
264
252
|
|
265
253
|
#
|
266
|
-
# Write
|
267
|
-
#
|
254
|
+
# Write the <c:valAx> element.
|
255
|
+
# This is for the second valAx in scatter plots.
|
268
256
|
#
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
257
|
+
# Usually the X axis.
|
258
|
+
#
|
259
|
+
def write_cat_val_axis(params) # :nodoc:
|
260
|
+
axis_ids = params[:axis_ids]
|
261
|
+
return unless axis_ids && !axis_ids.empty?
|
262
|
+
|
263
|
+
x_axis = params[:y_axis]
|
264
|
+
y_axis = params[:x_axis]
|
265
|
+
axis_ids_0 = axis_ids[1]
|
266
|
+
axis_ids_1 = axis_ids[0]
|
267
|
+
position = y_axis.position || params[:position] || @val_axis_position
|
268
|
+
|
269
|
+
write_val_axis_base(x_axis, y_axis, axis_ids_0, axis_ids_1, position)
|
278
270
|
end
|
279
271
|
end
|
280
272
|
end
|