write_xlsx 0.56.0 → 0.57.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/README.rdoc +3 -0
- data/lib/write_xlsx/chart.rb +60 -174
- data/lib/write_xlsx/version.rb +1 -1
- data/test/helper.rb +6 -0
- data/test/regression/test_chart_gridlines05.rb +51 -0
- data/test/regression/test_chart_gridlines06.rb +56 -0
- data/test/regression/test_chart_gridlines07.rb +71 -0
- data/test/regression/test_chart_gridlines08.rb +50 -0
- data/test/regression/test_chart_gridlines09.rb +70 -0
- data/test/regression/xlsx_files/chart_gridlines05.xlsx +0 -0
- data/test/regression/xlsx_files/chart_gridlines06.xlsx +0 -0
- data/test/regression/xlsx_files/chart_gridlines07.xlsx +0 -0
- data/test/regression/xlsx_files/chart_gridlines08.xlsx +0 -0
- data/test/regression/xlsx_files/chart_gridlines09.xlsx +0 -0
- metadata +22 -2
data/README.rdoc
CHANGED
@@ -74,6 +74,9 @@ the first worksheet in an Excel XML spreadsheet called ruby.xlsx:
|
|
74
74
|
workbook.close
|
75
75
|
|
76
76
|
== Recent change
|
77
|
+
2013-02-10 v0.57.0
|
78
|
+
Add major and minor axis chart gridline formatting.
|
79
|
+
|
77
80
|
2013-02-09 v0.56.0
|
78
81
|
Fix for issue where chart creation order had to be the same as the insertion order or charts would be out of sync.
|
79
82
|
Fixed issue where gridlines didn't work in Scatter and Stock charts.
|
data/lib/write_xlsx/chart.rb
CHANGED
@@ -718,6 +718,9 @@ def add_series(params)
|
|
718
718
|
# :reverse
|
719
719
|
# :log_base
|
720
720
|
# :label_position
|
721
|
+
# :major_gridlines
|
722
|
+
# :minor_gridlines
|
723
|
+
# :visible
|
721
724
|
#
|
722
725
|
# These are explained below. Some properties are only applicable to value
|
723
726
|
# or category axes, as indicated. See "Value and Category Axes" for an
|
@@ -897,52 +900,6 @@ def set_plotarea(params)
|
|
897
900
|
|
898
901
|
# TODO. Need to refactor for XLSX format.
|
899
902
|
return
|
900
|
-
|
901
|
-
return if params.empty?
|
902
|
-
|
903
|
-
area = @plotarea
|
904
|
-
|
905
|
-
# Set the plotarea visibility.
|
906
|
-
if params[:visible]
|
907
|
-
area[:_visible] = params[:visible]
|
908
|
-
return unless area[:_visible]
|
909
|
-
end
|
910
|
-
|
911
|
-
# TODO. could move this out of if statement.
|
912
|
-
area[:_bg_color_index] = 0x08
|
913
|
-
|
914
|
-
# Set the chart background colour.
|
915
|
-
if params[:color]
|
916
|
-
index, rgb = get_color_indices(params[:color])
|
917
|
-
if index
|
918
|
-
area[:_fg_color_index] = index
|
919
|
-
area[:_fg_color_rgb] = rgb
|
920
|
-
area[:_bg_color_index] = 0x08
|
921
|
-
area[:_bg_color_rgb] = 0x000000
|
922
|
-
end
|
923
|
-
|
924
|
-
end
|
925
|
-
|
926
|
-
# Set the border line colour.
|
927
|
-
if params[:line_color]
|
928
|
-
index, rgb = get_color_indices(params[:line_color])
|
929
|
-
if index
|
930
|
-
area[:_line_color_index] = index
|
931
|
-
area[:_line_color_rgb] = rgb
|
932
|
-
end
|
933
|
-
end
|
934
|
-
|
935
|
-
# Set the border line pattern.
|
936
|
-
if params[:line_pattern]
|
937
|
-
pattern = get_line_pattern(params[:line_pattern])
|
938
|
-
area[:_line_pattern] = pattern
|
939
|
-
end
|
940
|
-
|
941
|
-
# Set the border line weight.
|
942
|
-
if params[:line_weight]
|
943
|
-
weight = get_line_weight(params[:line_weight])
|
944
|
-
area[:_line_weight] = weight
|
945
|
-
end
|
946
903
|
end
|
947
904
|
|
948
905
|
#
|
@@ -958,58 +915,6 @@ def set_plotarea(params)
|
|
958
915
|
def set_chartarea(params)
|
959
916
|
# TODO. Need to refactor for XLSX format.
|
960
917
|
return
|
961
|
-
|
962
|
-
return if params.empty?
|
963
|
-
|
964
|
-
area = @chartarea
|
965
|
-
|
966
|
-
# Embedded automatic line weight has a different default value.
|
967
|
-
area[:_line_weight] = 0xFFFF if @embedded
|
968
|
-
|
969
|
-
# Set the chart background colour.
|
970
|
-
if params[:color]
|
971
|
-
index, rgb = get_color_indices(params[:color])
|
972
|
-
if index
|
973
|
-
area[:_fg_color_index] = index
|
974
|
-
area[:_fg_color_rgb] = rgb
|
975
|
-
area[:_bg_color_index] = 0x08
|
976
|
-
area[:_bg_color_rgb] = 0x000000
|
977
|
-
area[:_area_pattern] = 1
|
978
|
-
area[:_area_options] = 0x0000 if @embedded
|
979
|
-
area[:_visible] = 1
|
980
|
-
end
|
981
|
-
end
|
982
|
-
|
983
|
-
# Set the border line colour.
|
984
|
-
if params[:line_color]
|
985
|
-
index, rgb = get_color_indices(params[:line_color])
|
986
|
-
if index
|
987
|
-
area[:_line_color_index] = index
|
988
|
-
area[:_line_color_rgb] = rgb
|
989
|
-
area[:_line_pattern] = 0x00
|
990
|
-
area[:_line_options] = 0x0000
|
991
|
-
area[:_visible] = 1
|
992
|
-
end
|
993
|
-
end
|
994
|
-
|
995
|
-
# Set the border line pattern.
|
996
|
-
if params[:line_pattern]
|
997
|
-
pattern = get_line_pattern(params[:line_pattern])
|
998
|
-
area[:_line_pattern] = pattern
|
999
|
-
area[:_line_options] = 0x0000
|
1000
|
-
area[:_line_color_index] = 0x4F unless params[:line_color]
|
1001
|
-
area[:_visible] = 1
|
1002
|
-
end
|
1003
|
-
|
1004
|
-
# Set the border line weight.
|
1005
|
-
if params[:line_weight]
|
1006
|
-
weight = get_line_weight(params[:line_weight])
|
1007
|
-
area[:_line_weight] = weight
|
1008
|
-
area[:_line_options] = 0x0000
|
1009
|
-
area[:_line_pattern] = 0x00 unless params[:line_pattern]
|
1010
|
-
area[:_line_color_index] = 0x4F unless params[:line_color]
|
1011
|
-
area[:_visible] = 1
|
1012
|
-
end
|
1013
918
|
end
|
1014
919
|
|
1015
920
|
#
|
@@ -1060,10 +965,6 @@ def show_hidden_data
|
|
1060
965
|
#
|
1061
966
|
def set_embedded_config_data
|
1062
967
|
@embedded = 1
|
1063
|
-
|
1064
|
-
# TODO. We may be able to remove this after refactoring.
|
1065
|
-
|
1066
|
-
@chartarea = default_chartarea_property_for_embedded
|
1067
968
|
end
|
1068
969
|
|
1069
970
|
#
|
@@ -1144,7 +1045,12 @@ def convert_axis_args(axis, params) # :nodoc:
|
|
1144
1045
|
|
1145
1046
|
# Map major_gridlines properties.
|
1146
1047
|
if arg[:major_gridlines] && ptrue?(arg[:major_gridlines][:visible])
|
1147
|
-
axis[:_major_gridlines] =
|
1048
|
+
axis[:_major_gridlines] = get_gridline_properties(arg[:major_gridlines])
|
1049
|
+
end
|
1050
|
+
|
1051
|
+
# Map minor_gridlines properties.
|
1052
|
+
if arg[:minor_gridlines] && ptrue?(arg[:minor_gridlines][:visible])
|
1053
|
+
axis[:_minor_gridlines] = get_gridline_properties(arg[:minor_gridlines])
|
1148
1054
|
end
|
1149
1055
|
|
1150
1056
|
# Only use the first letter of bottom, top, left or right.
|
@@ -1295,72 +1201,6 @@ def get_palette_color(index) # :nodoc:
|
|
1295
1201
|
sprintf("%02X%02X%02X", *rgb)
|
1296
1202
|
end
|
1297
1203
|
|
1298
|
-
#
|
1299
|
-
# Get the Excel chart index for line pattern that corresponds to the user
|
1300
|
-
# defined value.
|
1301
|
-
#
|
1302
|
-
def get_line_pattern(value) # :nodoc:
|
1303
|
-
value = value.downcase
|
1304
|
-
default = 0
|
1305
|
-
|
1306
|
-
patterns = {
|
1307
|
-
0 => 5,
|
1308
|
-
1 => 0,
|
1309
|
-
2 => 1,
|
1310
|
-
3 => 2,
|
1311
|
-
4 => 3,
|
1312
|
-
5 => 4,
|
1313
|
-
6 => 7,
|
1314
|
-
7 => 6,
|
1315
|
-
8 => 8,
|
1316
|
-
'solid' => 0,
|
1317
|
-
'dash' => 1,
|
1318
|
-
'dot' => 2,
|
1319
|
-
'dash-dot' => 3,
|
1320
|
-
'dash-dot-dot' => 4,
|
1321
|
-
'none' => 5,
|
1322
|
-
'dark-gray' => 6,
|
1323
|
-
'medium-gray' => 7,
|
1324
|
-
'light-gray' => 8
|
1325
|
-
}
|
1326
|
-
|
1327
|
-
if patterns.has_key(:value)
|
1328
|
-
pattern = patterns[:value]
|
1329
|
-
else
|
1330
|
-
pattern = default
|
1331
|
-
end
|
1332
|
-
|
1333
|
-
pattern
|
1334
|
-
end
|
1335
|
-
|
1336
|
-
#
|
1337
|
-
# Get the Excel chart index for line weight that corresponds to the user
|
1338
|
-
# defined value.
|
1339
|
-
#
|
1340
|
-
def get_line_weight(value) # :nodoc:
|
1341
|
-
value = value.downcase
|
1342
|
-
default = 0
|
1343
|
-
|
1344
|
-
weights = {
|
1345
|
-
1 => -1,
|
1346
|
-
2 => 0,
|
1347
|
-
3 => 1,
|
1348
|
-
4 => 2,
|
1349
|
-
'hairline' => -1,
|
1350
|
-
'narrow' => 0,
|
1351
|
-
'medium' => 1,
|
1352
|
-
'wide' => 2
|
1353
|
-
}
|
1354
|
-
|
1355
|
-
if weights[:value]
|
1356
|
-
weight = weights[:value]
|
1357
|
-
else
|
1358
|
-
weight = default
|
1359
|
-
end
|
1360
|
-
|
1361
|
-
weight
|
1362
|
-
end
|
1363
|
-
|
1364
1204
|
#
|
1365
1205
|
# Convert user defined line properties to the structure required internally.
|
1366
1206
|
#
|
@@ -1485,6 +1325,19 @@ def get_trendline_properties(trendline) # :nodoc:
|
|
1485
1325
|
return trendline
|
1486
1326
|
end
|
1487
1327
|
|
1328
|
+
#
|
1329
|
+
# Convert user defined gridline properties to the structure required internally.
|
1330
|
+
#
|
1331
|
+
def get_gridline_properties(args)
|
1332
|
+
# Set the visible property for the gridline.
|
1333
|
+
gridline = { :_visible => args[:visible] }
|
1334
|
+
|
1335
|
+
# Set the line properties for the gridline.
|
1336
|
+
gridline[:_line] = get_line_properties(args[:line])
|
1337
|
+
|
1338
|
+
gridline
|
1339
|
+
end
|
1340
|
+
|
1488
1341
|
#
|
1489
1342
|
# Convert user defined labels properties to the structure required internally.
|
1490
1343
|
#
|
@@ -1586,9 +1439,6 @@ def get_font_latin_attributes(font)
|
|
1586
1439
|
# Setup the default properties for a chart.
|
1587
1440
|
#
|
1588
1441
|
def set_default_properties # :nodoc:
|
1589
|
-
@chartarea = default_chartarea_property
|
1590
|
-
@plotarea = default_plotarea_property
|
1591
|
-
|
1592
1442
|
# Set the default axis properties.
|
1593
1443
|
@x_axis[:_defaults] = {
|
1594
1444
|
:num_format => 'General',
|
@@ -2050,6 +1900,9 @@ def write_cat_axis(params) # :nodoc:
|
|
2050
1900
|
# Write the c:majorGridlines element.
|
2051
1901
|
write_major_gridlines(x_axis[:_major_gridlines])
|
2052
1902
|
|
1903
|
+
# Write the c:minorGridlines element.
|
1904
|
+
write_minor_gridlines(x_axis[:_minor_gridlines])
|
1905
|
+
|
2053
1906
|
# Write the axis title elements.
|
2054
1907
|
if title = x_axis[:_formula]
|
2055
1908
|
write_title_formula(title, @x_axis[:_data_id], horiz, @x_axis[:_name_font])
|
@@ -2115,6 +1968,9 @@ def write_val_axis(params) # :nodoc:
|
|
2115
1968
|
# Write the c:majorGridlines element.
|
2116
1969
|
write_major_gridlines(y_axis[:_major_gridlines])
|
2117
1970
|
|
1971
|
+
# Write the c:minorGridlines element.
|
1972
|
+
write_minor_gridlines(y_axis[:_minor_gridlines])
|
1973
|
+
|
2118
1974
|
# Write the axis title elements.
|
2119
1975
|
if title = y_axis[:_formula]
|
2120
1976
|
write_title_formula(title, y_axis[:_data_id], horiz, y_axis[:_name_font])
|
@@ -2181,6 +2037,9 @@ def write_cat_val_axis(params) # :nodoc:
|
|
2181
2037
|
# Write the c:majorGridlines element.
|
2182
2038
|
write_major_gridlines(x_axis[:_major_gridlines])
|
2183
2039
|
|
2040
|
+
# Write the c:minorGridlines element.
|
2041
|
+
write_minor_gridlines(x_axis[:_minor_gridlines])
|
2042
|
+
|
2184
2043
|
# Write the axis title elements.
|
2185
2044
|
if title = x_axis[:_formula]
|
2186
2045
|
write_title_formula(title, y_axis[:_data_id], horiz, x_axis[:_name_font])
|
@@ -2284,6 +2143,9 @@ def write_date_axis(params) # :nodoc:
|
|
2284
2143
|
# Write the c:majorGridlines element.
|
2285
2144
|
write_major_gridlines(x_axis[:_major_gridlines])
|
2286
2145
|
|
2146
|
+
# Write the c:minorGridlines element.
|
2147
|
+
write_minor_gridlines(x_axis[:_minor_gridlines])
|
2148
|
+
|
2287
2149
|
# Write the axis title elements.
|
2288
2150
|
if title = x_axis[:_formula]
|
2289
2151
|
write_title_formula(title, x_axis[:_data_id], nil, x_axis[:_name_font])
|
@@ -2565,7 +2427,31 @@ def write_major_gridlines(gridlines) # :nodoc:
|
|
2565
2427
|
return unless gridlines
|
2566
2428
|
return unless ptrue?(gridlines[:_visible])
|
2567
2429
|
|
2568
|
-
|
2430
|
+
if gridlines[:_line] && ptrue?(gridlines[:_line][:_defined])
|
2431
|
+
@writer.tag_elements('c:majorGridlines') do
|
2432
|
+
# Write the c:spPr element.
|
2433
|
+
write_sp_pr(gridlines)
|
2434
|
+
end
|
2435
|
+
else
|
2436
|
+
@writer.empty_tag('c:majorGridlines')
|
2437
|
+
end
|
2438
|
+
end
|
2439
|
+
|
2440
|
+
#
|
2441
|
+
# Write the <c:minorGridlines> element.
|
2442
|
+
#
|
2443
|
+
def write_minor_gridlines(gridlines) # :nodoc:
|
2444
|
+
return unless gridlines
|
2445
|
+
return unless ptrue?(gridlines[:_visible])
|
2446
|
+
|
2447
|
+
if gridlines[:_line] && ptrue?(gridlines[:_line][:_defined])
|
2448
|
+
@writer.tag_elements('c:minorGridlines') do
|
2449
|
+
# Write the c:spPr element.
|
2450
|
+
write_sp_pr(gridlines)
|
2451
|
+
end
|
2452
|
+
else
|
2453
|
+
@writer.empty_tag('c:minorGridlines')
|
2454
|
+
end
|
2569
2455
|
end
|
2570
2456
|
|
2571
2457
|
#
|
@@ -3075,7 +2961,7 @@ def write_a_ln(line) # :nodoc:
|
|
3075
2961
|
if ptrue?(line[:none])
|
3076
2962
|
# Write the a:noFill element.
|
3077
2963
|
write_a_no_fill
|
3078
|
-
|
2964
|
+
elsif ptrue?(line[:color])
|
3079
2965
|
# Write the a:solidFill element.
|
3080
2966
|
write_a_solid_fill(line)
|
3081
2967
|
end
|
data/lib/write_xlsx/version.rb
CHANGED
data/test/helper.rb
CHANGED
@@ -112,6 +112,12 @@ def compare_xlsx(exp_filename, got_filename, ignore_members = nil, ignore_elemen
|
|
112
112
|
sub(/ +\/>/, ' />')
|
113
113
|
end
|
114
114
|
|
115
|
+
# Remove Chart pageMargin dimensions which are almost always different.
|
116
|
+
if exp_members[i].name =~ %r!xl/charts/chart\d.xml!
|
117
|
+
exp_xml_str = exp_xml_str.sub(/<c:pageMargins[^>]*>/, '<c:pageMargins/>')
|
118
|
+
got_xml_str = got_xml_str.sub(/<c:pageMargins[^>]*>/, '<c:pageMargins/>')
|
119
|
+
end
|
120
|
+
|
115
121
|
if exp_members[i].name =~ /.vml$/
|
116
122
|
got_xml = got_to_array(got_xml_str)
|
117
123
|
exp_xml = vml_str_to_array(exp_xml_str)
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
class TestChartGridlines05 < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
setup_dir_var
|
7
|
+
end
|
8
|
+
|
9
|
+
def teardown
|
10
|
+
File.delete(@xlsx) if File.exist?(@xlsx)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_chart_gridlines05
|
14
|
+
@xlsx = 'chart_gridlines05.xlsx'
|
15
|
+
workbook = WriteXLSX.new(@xlsx)
|
16
|
+
worksheet = workbook.add_worksheet
|
17
|
+
chart = workbook.add_chart(:type => 'column', :embedded => 1)
|
18
|
+
|
19
|
+
# For testing, copy the randomly generated axis ids in the target xls file.
|
20
|
+
chart.instance_variable_set(:@axis_ids, [80072064, 79959168])
|
21
|
+
|
22
|
+
data = [
|
23
|
+
[ 1, 2, 3, 4, 5 ],
|
24
|
+
[ 2, 4, 6, 8, 10 ],
|
25
|
+
[ 3, 6, 9, 12, 15 ]
|
26
|
+
]
|
27
|
+
|
28
|
+
worksheet.write('A1', data)
|
29
|
+
|
30
|
+
chart.add_series(:values => '=Sheet1!$A$1:$A$5')
|
31
|
+
chart.add_series(:values => '=Sheet1!$B$1:$B$5')
|
32
|
+
chart.add_series(:values => '=Sheet1!$C$1:$C$5')
|
33
|
+
|
34
|
+
chart.set_x_axis(
|
35
|
+
:major_gridlines => { :visible => 1 },
|
36
|
+
:minor_gridlines => { :visible => 1 }
|
37
|
+
)
|
38
|
+
chart.set_y_axis(
|
39
|
+
:major_gridlines => { :visible => 1 },
|
40
|
+
:minor_gridlines => { :visible => 1 }
|
41
|
+
)
|
42
|
+
|
43
|
+
worksheet.insert_chart('E9', chart)
|
44
|
+
|
45
|
+
workbook.close
|
46
|
+
compare_xlsx_for_regression(
|
47
|
+
File.join(@regression_output, @xlsx),
|
48
|
+
@xlsx
|
49
|
+
)
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
class TestChartGridlines06 < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
setup_dir_var
|
7
|
+
end
|
8
|
+
|
9
|
+
def teardown
|
10
|
+
File.delete(@xlsx) if File.exist?(@xlsx)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_chart_gridlines06
|
14
|
+
@xlsx = 'chart_gridlines06.xlsx'
|
15
|
+
workbook = WriteXLSX.new(@xlsx)
|
16
|
+
worksheet = workbook.add_worksheet
|
17
|
+
chart = workbook.add_chart(:type => 'scatter', :embedded => 1)
|
18
|
+
|
19
|
+
# For testing, copy the randomly generated axis ids in the target xls file.
|
20
|
+
chart.instance_variable_set(:@axis_ids, [82812288, 46261376])
|
21
|
+
|
22
|
+
data = [
|
23
|
+
[ 1, 2, 3, 4, 5 ],
|
24
|
+
[ 2, 4, 6, 8, 10 ],
|
25
|
+
[ 3, 6, 9, 12, 15 ]
|
26
|
+
]
|
27
|
+
|
28
|
+
worksheet.write('A1', data)
|
29
|
+
|
30
|
+
chart.add_series(
|
31
|
+
:categories => '=Sheet1!$A$1:$A$5',
|
32
|
+
:values => '=Sheet1!$B$1:$B$5'
|
33
|
+
)
|
34
|
+
chart.add_series(
|
35
|
+
:categories => '=Sheet1!$A$1:$A$5',
|
36
|
+
:values => '=Sheet1!$C$1:$C$5'
|
37
|
+
)
|
38
|
+
|
39
|
+
chart.set_x_axis(
|
40
|
+
:major_gridlines => { :visible => 1 },
|
41
|
+
:minor_gridlines => { :visible => 1 }
|
42
|
+
)
|
43
|
+
chart.set_y_axis(
|
44
|
+
:major_gridlines => { :visible => 1 },
|
45
|
+
:minor_gridlines => { :visible => 1 }
|
46
|
+
)
|
47
|
+
|
48
|
+
worksheet.insert_chart('E9', chart)
|
49
|
+
|
50
|
+
workbook.close
|
51
|
+
compare_xlsx_for_regression(
|
52
|
+
File.join(@regression_output, @xlsx),
|
53
|
+
@xlsx
|
54
|
+
)
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
class TestChartGridlines07 < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
setup_dir_var
|
7
|
+
end
|
8
|
+
|
9
|
+
def teardown
|
10
|
+
File.delete(@xlsx) if File.exist?(@xlsx)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_chart_gridlines07
|
14
|
+
@xlsx = 'chart_gridlines07.xlsx'
|
15
|
+
workbook = WriteXLSX.new(@xlsx)
|
16
|
+
worksheet = workbook.add_worksheet
|
17
|
+
chart = workbook.add_chart(:type => 'stock', :embedded => 1)
|
18
|
+
date_format = workbook.add_format(:num_format => 14)
|
19
|
+
|
20
|
+
# For testing, copy the randomly generated axis ids in the target xls file.
|
21
|
+
chart.instance_variable_set(:@axis_ids, [59313152, 59364096])
|
22
|
+
|
23
|
+
data = [
|
24
|
+
[ '2007-01-01T', '2007-01-02T', '2007-01-03T', '2007-01-04T', '2007-01-05T' ],
|
25
|
+
[ 27.2, 25.03, 19.05, 20.34, 18.5 ],
|
26
|
+
[ 23.49, 19.55, 15.12, 17.84, 16.34 ],
|
27
|
+
[ 25.45, 23.05, 17.32, 20.45, 17.34 ]
|
28
|
+
]
|
29
|
+
|
30
|
+
(0..4).each do |row|
|
31
|
+
worksheet.write_date_time(row, 0, data[0][row], date_format)
|
32
|
+
worksheet.write(row, 1, data[1][row])
|
33
|
+
worksheet.write(row, 2, data[2][row])
|
34
|
+
worksheet.write(row, 3, data[3][row])
|
35
|
+
end
|
36
|
+
|
37
|
+
worksheet.set_column('A:D', 11)
|
38
|
+
|
39
|
+
chart.add_series(
|
40
|
+
:categories => '=Sheet1!$A$1:$A$5',
|
41
|
+
:values => '=Sheet1!$B$1:$B$5'
|
42
|
+
)
|
43
|
+
chart.add_series(
|
44
|
+
:categories => '=Sheet1!$A$1:$A$5',
|
45
|
+
:values => '=Sheet1!$C$1:$C$5'
|
46
|
+
)
|
47
|
+
chart.add_series(
|
48
|
+
:categories => '=Sheet1!$A$1:$A$5',
|
49
|
+
:values => '=Sheet1!$D$1:$D$5'
|
50
|
+
)
|
51
|
+
|
52
|
+
chart.set_x_axis(
|
53
|
+
:major_gridlines => { :visible => 1 },
|
54
|
+
:minor_gridlines => { :visible => 1 }
|
55
|
+
)
|
56
|
+
chart.set_y_axis(
|
57
|
+
:major_gridlines => { :visible => 1 },
|
58
|
+
:minor_gridlines => { :visible => 1 }
|
59
|
+
)
|
60
|
+
|
61
|
+
worksheet.insert_chart('E9', chart)
|
62
|
+
|
63
|
+
workbook.close
|
64
|
+
compare_xlsx_for_regression(
|
65
|
+
File.join(@regression_output, @xlsx),
|
66
|
+
@xlsx,
|
67
|
+
[],
|
68
|
+
{'xl/charts/chart1.xml' => ['<c:formatCode']}
|
69
|
+
)
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
class TestChartGridlines08 < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
setup_dir_var
|
7
|
+
end
|
8
|
+
|
9
|
+
def teardown
|
10
|
+
File.delete(@xlsx) if File.exist?(@xlsx)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_chart_gridlines08
|
14
|
+
@xlsx = 'chart_gridlines08.xlsx'
|
15
|
+
workbook = WriteXLSX.new(@xlsx)
|
16
|
+
worksheet = workbook.add_worksheet
|
17
|
+
chart = workbook.add_chart(:type => 'radar', :embedded => 1)
|
18
|
+
|
19
|
+
# For testing, copy the randomly generated axis ids in the target xls file.
|
20
|
+
chart.instance_variable_set(:@axis_ids, [60019072, 60020608])
|
21
|
+
|
22
|
+
data = [
|
23
|
+
[ 1, 2, 3, 4, 5 ],
|
24
|
+
[ 2, 4, 6, 8, 10 ],
|
25
|
+
[ 3, 6, 9, 12, 15 ],
|
26
|
+
]
|
27
|
+
|
28
|
+
|
29
|
+
worksheet.write('A1', data)
|
30
|
+
|
31
|
+
chart.add_series(:values => '=Sheet1!$A$1:$A$5')
|
32
|
+
chart.add_series(:values => '=Sheet1!$B$1:$B$5')
|
33
|
+
chart.add_series(:values => '=Sheet1!$C$1:$C$5')
|
34
|
+
|
35
|
+
chart.set_y_axis(
|
36
|
+
:major_gridlines => { :visible => 1 },
|
37
|
+
:minor_gridlines => { :visible => 1 }
|
38
|
+
)
|
39
|
+
|
40
|
+
chart.instance_variable_get(:@y_axis)[:_major_tick_mark] = 'cross'
|
41
|
+
|
42
|
+
worksheet.insert_chart('E9', chart)
|
43
|
+
|
44
|
+
workbook.close
|
45
|
+
compare_xlsx_for_regression(
|
46
|
+
File.join(@regression_output, @xlsx),
|
47
|
+
@xlsx
|
48
|
+
)
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
class TestChartGridlines09 < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
setup_dir_var
|
7
|
+
end
|
8
|
+
|
9
|
+
def teardown
|
10
|
+
File.delete(@xlsx) if File.exist?(@xlsx)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_chart_gridlines09
|
14
|
+
@xlsx = 'chart_gridlines09.xlsx'
|
15
|
+
workbook = WriteXLSX.new(@xlsx)
|
16
|
+
worksheet = workbook.add_worksheet
|
17
|
+
chart = workbook.add_chart(:type => 'column', :embedded => 1)
|
18
|
+
|
19
|
+
# For testing, copy the randomly generated axis ids in the target xls file.
|
20
|
+
chart.instance_variable_set(:@axis_ids, [48744320, 49566848])
|
21
|
+
|
22
|
+
data = [
|
23
|
+
[ 1, 2, 3, 4, 5 ],
|
24
|
+
[ 2, 4, 6, 8, 10 ],
|
25
|
+
[ 3, 6, 9, 12, 15 ],
|
26
|
+
]
|
27
|
+
|
28
|
+
worksheet.write('A1', data)
|
29
|
+
|
30
|
+
chart.add_series(:values => '=Sheet1!$A$1:$A$5')
|
31
|
+
chart.add_series(:values => '=Sheet1!$B$1:$B$5')
|
32
|
+
chart.add_series(:values => '=Sheet1!$C$1:$C$5')
|
33
|
+
|
34
|
+
chart.set_x_axis(
|
35
|
+
:major_gridlines => {
|
36
|
+
:visible => 1,
|
37
|
+
:line => {
|
38
|
+
:color => 'red',
|
39
|
+
:width => 0.5,
|
40
|
+
:dash_type => 'square_dot'
|
41
|
+
}
|
42
|
+
},
|
43
|
+
:minor_gridlines => {
|
44
|
+
:visible => 1,
|
45
|
+
:line => { :color => 'yellow' }
|
46
|
+
}
|
47
|
+
)
|
48
|
+
chart.set_y_axis(
|
49
|
+
:major_gridlines => {
|
50
|
+
:visible => 1,
|
51
|
+
:line => {
|
52
|
+
:width => 1.25,
|
53
|
+
:dash_type => 'dash'
|
54
|
+
}
|
55
|
+
},
|
56
|
+
:minor_gridlines => {
|
57
|
+
:visible => 1,
|
58
|
+
:line => { :color => '#00B050' }
|
59
|
+
}
|
60
|
+
)
|
61
|
+
|
62
|
+
worksheet.insert_chart('E9', chart)
|
63
|
+
|
64
|
+
workbook.close
|
65
|
+
compare_xlsx_for_regression(
|
66
|
+
File.join(@regression_output, @xlsx),
|
67
|
+
@xlsx
|
68
|
+
)
|
69
|
+
end
|
70
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: write_xlsx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.57.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rubyzip
|
@@ -425,6 +425,11 @@ files:
|
|
425
425
|
- test/regression/test_chart_gridlines02.rb
|
426
426
|
- test/regression/test_chart_gridlines03.rb
|
427
427
|
- test/regression/test_chart_gridlines04.rb
|
428
|
+
- test/regression/test_chart_gridlines05.rb
|
429
|
+
- test/regression/test_chart_gridlines06.rb
|
430
|
+
- test/regression/test_chart_gridlines07.rb
|
431
|
+
- test/regression/test_chart_gridlines08.rb
|
432
|
+
- test/regression/test_chart_gridlines09.rb
|
428
433
|
- test/regression/test_chart_line01.rb
|
429
434
|
- test/regression/test_chart_line02.rb
|
430
435
|
- test/regression/test_chart_name01.rb
|
@@ -715,6 +720,11 @@ files:
|
|
715
720
|
- test/regression/xlsx_files/chart_gridlines02.xlsx
|
716
721
|
- test/regression/xlsx_files/chart_gridlines03.xlsx
|
717
722
|
- test/regression/xlsx_files/chart_gridlines04.xlsx
|
723
|
+
- test/regression/xlsx_files/chart_gridlines05.xlsx
|
724
|
+
- test/regression/xlsx_files/chart_gridlines06.xlsx
|
725
|
+
- test/regression/xlsx_files/chart_gridlines07.xlsx
|
726
|
+
- test/regression/xlsx_files/chart_gridlines08.xlsx
|
727
|
+
- test/regression/xlsx_files/chart_gridlines09.xlsx
|
718
728
|
- test/regression/xlsx_files/chart_line01.xlsx
|
719
729
|
- test/regression/xlsx_files/chart_line02.xlsx
|
720
730
|
- test/regression/xlsx_files/chart_name01.xlsx
|
@@ -1314,6 +1324,11 @@ test_files:
|
|
1314
1324
|
- test/regression/test_chart_gridlines02.rb
|
1315
1325
|
- test/regression/test_chart_gridlines03.rb
|
1316
1326
|
- test/regression/test_chart_gridlines04.rb
|
1327
|
+
- test/regression/test_chart_gridlines05.rb
|
1328
|
+
- test/regression/test_chart_gridlines06.rb
|
1329
|
+
- test/regression/test_chart_gridlines07.rb
|
1330
|
+
- test/regression/test_chart_gridlines08.rb
|
1331
|
+
- test/regression/test_chart_gridlines09.rb
|
1317
1332
|
- test/regression/test_chart_line01.rb
|
1318
1333
|
- test/regression/test_chart_line02.rb
|
1319
1334
|
- test/regression/test_chart_name01.rb
|
@@ -1604,6 +1619,11 @@ test_files:
|
|
1604
1619
|
- test/regression/xlsx_files/chart_gridlines02.xlsx
|
1605
1620
|
- test/regression/xlsx_files/chart_gridlines03.xlsx
|
1606
1621
|
- test/regression/xlsx_files/chart_gridlines04.xlsx
|
1622
|
+
- test/regression/xlsx_files/chart_gridlines05.xlsx
|
1623
|
+
- test/regression/xlsx_files/chart_gridlines06.xlsx
|
1624
|
+
- test/regression/xlsx_files/chart_gridlines07.xlsx
|
1625
|
+
- test/regression/xlsx_files/chart_gridlines08.xlsx
|
1626
|
+
- test/regression/xlsx_files/chart_gridlines09.xlsx
|
1607
1627
|
- test/regression/xlsx_files/chart_line01.xlsx
|
1608
1628
|
- test/regression/xlsx_files/chart_line02.xlsx
|
1609
1629
|
- test/regression/xlsx_files/chart_name01.xlsx
|