write_xlsx 0.62.0 → 0.64.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. data/README.rdoc +14 -1
  2. data/examples/chart_data_tools.rb +215 -0
  3. data/examples/chart_pie.rb +36 -5
  4. data/examples/sparklines2.rb +1 -1
  5. data/examples/tab_colors.rb +3 -3
  6. data/lib/write_xlsx/chart.rb +559 -516
  7. data/lib/write_xlsx/chart/area.rb +4 -1
  8. data/lib/write_xlsx/chart/axis.rb +132 -0
  9. data/lib/write_xlsx/chart/bar.rb +17 -9
  10. data/lib/write_xlsx/chart/column.rb +9 -1
  11. data/lib/write_xlsx/chart/line.rb +24 -0
  12. data/lib/write_xlsx/chart/radar.rb +2 -2
  13. data/lib/write_xlsx/chart/scatter.rb +19 -0
  14. data/lib/write_xlsx/chart/stock.rb +10 -3
  15. data/lib/write_xlsx/drawing.rb +43 -44
  16. data/lib/write_xlsx/package/vml.rb +21 -14
  17. data/lib/write_xlsx/shape.rb +173 -22
  18. data/lib/write_xlsx/sparkline.rb +524 -0
  19. data/lib/write_xlsx/version.rb +1 -1
  20. data/lib/write_xlsx/workbook.rb +183 -115
  21. data/lib/write_xlsx/worksheet.rb +821 -1073
  22. data/lib/write_xlsx/worksheet/cell_data.rb +132 -0
  23. data/lib/write_xlsx/worksheet/print_style.rb +51 -0
  24. data/test/chart/test_add_series.rb +31 -6
  25. data/test/chart/test_write_d_lbls.rb +18 -18
  26. data/test/chart/test_write_number_format.rb +20 -24
  27. data/test/drawing/test_drawing_shape_01.rb +1 -1
  28. data/test/drawing/test_drawing_shape_02.rb +2 -2
  29. data/test/drawing/test_drawing_shape_03.rb +5 -5
  30. data/test/drawing/test_drawing_shape_04.rb +3 -3
  31. data/test/drawing/test_drawing_shape_05.rb +4 -4
  32. data/test/drawing/test_drawing_shape_07.rb +2 -2
  33. data/test/perl_output/chart_data_tools.xlsx +0 -0
  34. data/test/perl_output/chart_pie.xlsx +0 -0
  35. data/test/regression/disabled_test_vml04.rb +2 -2
  36. data/test/regression/test_chart_drop_lines01.rb +46 -0
  37. data/test/regression/test_chart_drop_lines02.rb +51 -0
  38. data/test/regression/test_chart_drop_lines03.rb +46 -0
  39. data/test/regression/test_chart_drop_lines04.rb +64 -0
  40. data/test/regression/test_chart_errorbars01.rb +47 -0
  41. data/test/regression/test_chart_errorbars02.rb +57 -0
  42. data/test/regression/test_chart_errorbars03.rb +53 -0
  43. data/test/regression/test_chart_errorbars04.rb +48 -0
  44. data/test/regression/test_chart_errorbars05.rb +47 -0
  45. data/test/regression/test_chart_errorbars06.rb +47 -0
  46. data/test/regression/test_chart_errorbars07.rb +66 -0
  47. data/test/regression/test_chart_font02.rb +1 -1
  48. data/test/regression/test_chart_font06.rb +1 -1
  49. data/test/regression/test_chart_gridlines04.rb +2 -1
  50. data/test/regression/test_chart_gridlines08.rb +2 -1
  51. data/test/regression/test_chart_points01.rb +37 -0
  52. data/test/regression/test_chart_points02.rb +40 -0
  53. data/test/regression/test_chart_points03.rb +42 -0
  54. data/test/regression/test_chart_points04.rb +52 -0
  55. data/test/regression/test_chart_points05.rb +49 -0
  56. data/test/regression/test_chart_points06.rb +49 -0
  57. data/test/regression/test_chartsheet05.rb +1 -1
  58. data/test/regression/test_chartsheet06.rb +1 -1
  59. data/test/regression/test_comment01.rb +1 -1
  60. data/test/regression/test_comment02.rb +1 -1
  61. data/test/regression/test_comment03.rb +1 -1
  62. data/test/regression/test_comment04.rb +2 -2
  63. data/test/regression/test_comment06.rb +1 -1
  64. data/test/regression/test_comment07.rb +1 -1
  65. data/test/regression/test_comment08.rb +1 -1
  66. data/test/regression/test_comment09.rb +1 -1
  67. data/test/regression/test_comment10.rb +1 -1
  68. data/test/regression/test_default_row04.rb +1 -1
  69. data/test/regression/test_escapes02.rb +1 -1
  70. data/test/regression/test_hyperlink15.rb +2 -2
  71. data/test/regression/test_shape_connect01.rb +6 -6
  72. data/test/regression/test_shape_connect02.rb +6 -6
  73. data/test/regression/test_shape_connect03.rb +11 -11
  74. data/test/regression/test_shape_connect04.rb +10 -10
  75. data/test/regression/test_shape_scale01.rb +2 -2
  76. data/test/regression/test_shape_stencil01.rb +3 -3
  77. data/test/regression/test_tab_color01.rb +1 -1
  78. data/test/regression/test_table04.rb +1 -1
  79. data/test/regression/test_table05.rb +1 -1
  80. data/test/regression/test_table06.rb +1 -1
  81. data/test/regression/test_vml01.rb +1 -1
  82. data/test/regression/test_vml02.rb +1 -1
  83. data/test/regression/test_vml03.rb +2 -2
  84. data/test/regression/xlsx_files/chart_drop_lines01.xlsx +0 -0
  85. data/test/regression/xlsx_files/chart_drop_lines02.xlsx +0 -0
  86. data/test/regression/xlsx_files/chart_drop_lines03.xlsx +0 -0
  87. data/test/regression/xlsx_files/chart_drop_lines04.xlsx +0 -0
  88. data/test/regression/xlsx_files/chart_errorbars01.xlsx +0 -0
  89. data/test/regression/xlsx_files/chart_errorbars02.xlsx +0 -0
  90. data/test/regression/xlsx_files/chart_errorbars03.xlsx +0 -0
  91. data/test/regression/xlsx_files/chart_errorbars04.xlsx +0 -0
  92. data/test/regression/xlsx_files/chart_errorbars05.xlsx +0 -0
  93. data/test/regression/xlsx_files/chart_errorbars06.xlsx +0 -0
  94. data/test/regression/xlsx_files/chart_errorbars07.xlsx +0 -0
  95. data/test/regression/xlsx_files/chart_points01.xlsx +0 -0
  96. data/test/regression/xlsx_files/chart_points02.xlsx +0 -0
  97. data/test/regression/xlsx_files/chart_points03.xlsx +0 -0
  98. data/test/regression/xlsx_files/chart_points04.xlsx +0 -0
  99. data/test/regression/xlsx_files/chart_points05.xlsx +0 -0
  100. data/test/regression/xlsx_files/chart_points06.xlsx +0 -0
  101. data/test/regression/xlsx_files/chart_stock02.xlsx +0 -0
  102. data/test/test_example_match.rb +278 -57
  103. data/test/worksheet/test_convert_date_time_02.rb +427 -433
  104. data/test/worksheet/test_convert_date_time_03.rb +1 -1
  105. data/test/worksheet/test_write_sheet_pr.rb +2 -2
  106. data/test/worksheet/test_write_sheet_view1.rb +2 -2
  107. metadata +80 -10
@@ -26,23 +26,18 @@ def assemble_xml_file(worksheet)
26
26
  z_index = 1
27
27
  vml_shape_id = worksheet.vml_shape_id
28
28
  unless worksheet.buttons_data.empty?
29
- # Write the v:shapetype element.
30
- write_button_shapetype
31
- worksheet.buttons_data.each do |button|
32
- # Write the v:shape element.
33
- vml_shape_id += 1
34
- button.write_shape(@writer, vml_shape_id, z_index)
35
- z_index += 1
29
+ vml_shape_id, z_index =
30
+ write_shape_type_and_shape(
31
+ worksheet.buttons_data,
32
+ vml_shape_id, z_index) do
33
+ write_button_shapetype
36
34
  end
37
35
  end
38
36
  unless worksheet.comments_array.empty?
39
- # Write the v:shapetype element.
40
- write_comment_shapetype
41
- worksheet.comments_array.each do |comment|
42
- # Write the v:shape element.
43
- vml_shape_id += 1
44
- comment.write_shape(@writer, vml_shape_id, z_index)
45
- z_index += 1
37
+ write_shape_type_and_shape(
38
+ worksheet.comments_array,
39
+ vml_shape_id, z_index) do
40
+ write_comment_shapetype
46
41
  end
47
42
  end
48
43
  end
@@ -52,6 +47,18 @@ def assemble_xml_file(worksheet)
52
47
 
53
48
  private
54
49
 
50
+ def write_shape_type_and_shape(data, vml_shape_id, z_index)
51
+ # Write the v:shapetype element.
52
+ yield
53
+ data.each do |obj|
54
+ # Write the v:shape element.
55
+ vml_shape_id += 1
56
+ obj.write_shape(@writer, vml_shape_id, z_index)
57
+ z_index += 1
58
+ end
59
+ [vml_shape_id, z_index]
60
+ end
61
+
55
62
  #
56
63
  # Write the <xml> element. This is the root element of VML.
57
64
  #
@@ -5,16 +5,23 @@ module Writexlsx
5
5
  #
6
6
  # Shape - A class for writing Excel shapes.
7
7
  #
8
- # Used in conjunction with Excel::Writer::XLSX.
8
+ # Used in conjunction with WriteXLSX.
9
9
  #
10
10
  # Copyright 2000-2012, John McNamara, jmcnamara@cpan.org
11
11
  # Converted to ruby by Hideo NAKAMURA, cxn03651@msj.biglobe.ne.jp
12
12
  #
13
13
  class Shape
14
14
 
15
- attr_reader :connect, :editAs, :type, :start, :start_index, :end, :end_index
16
- attr_reader :tx_box, :fill, :rotation, :flip_h, :flip_v
17
- attr_accessor :name
15
+ attr_reader :edit_as, :type, :drawing
16
+ attr_reader :tx_box, :fill, :line, :format
17
+ attr_reader :align, :valign
18
+ attr_accessor :name, :connect, :type, :id, :start, :end, :rotation
19
+ attr_accessor :flip_h, :flip_v, :adjustments, :palette, :text, :stencil
20
+ attr_accessor :row_start, :row_end, :column_start, :column_end
21
+ attr_accessor :x1, :x2, :y1, :y2, :x_abs, :y_abs, :start_index, :end_index
22
+ attr_accessor :x_offset, :y_offset, :width, :height, :scale_x, :scale_y
23
+ attr_accessor :width_emu, :height_emu, :element, :line_weight, :line_type
24
+ attr_accessor :start_side, :end_side
18
25
 
19
26
  def initialize(properties = {})
20
27
  @writer = Package::XMLWriterSimple.new
@@ -28,7 +35,7 @@ def initialize(properties = {})
28
35
  @drawing = 0
29
36
 
30
37
  # OneCell or Absolute: options to move and/or size with cells.
31
- @editAs = ''
38
+ @edit_as = nil
32
39
 
33
40
  # Auto-incremented, unless supplied by user.
34
41
  @id = 0
@@ -70,7 +77,7 @@ def initialize(properties = {})
70
77
 
71
78
  # An alternate way to create a text box, because Excel allows it.
72
79
  # It is just a rectangle with text.
73
- @tx_box = 0
80
+ @tx_box = false
74
81
 
75
82
  # Shape outline colour, or 0 for noFill (default black).
76
83
  @line = '000000'
@@ -128,15 +135,6 @@ def set_properties(properties)
128
135
  # Strip leading "-" from Tk style properties e.g. -color => 'red'.
129
136
  k = key.to_s.sub(/^-/, '')
130
137
  self.instance_variable_set("@#{key}", value)
131
- =begin
132
- if key.to_s == 'format'
133
- @format = value
134
- elsif value.respond_to?(:coerce)
135
- eval "@#{k} = #{value}"
136
- else
137
- eval "@#{k} = %!#{value}!"
138
- end
139
- =end
140
138
  end
141
139
  end
142
140
 
@@ -147,13 +145,6 @@ def adjustments=(args)
147
145
  @adjustments = *args
148
146
  end
149
147
 
150
- def [](attr)
151
- self.instance_variable_get("@#{attr}")
152
- end
153
-
154
- def []=(attr, value)
155
- self.instance_variable_set("@#{attr}", value)
156
- end
157
148
  #
158
149
  # Convert from an Excel internal colour index to a XML style #RRGGBB index
159
150
  # based on the default or user defined values in the Workbook palette.
@@ -168,5 +159,165 @@ def get_palette_color(index)
168
159
 
169
160
  sprintf("%02X%02X%02X", *rgb)
170
161
  end
162
+
163
+ #
164
+ # Calculate the vertices that define the position of a shape object within
165
+ # the worksheet in EMUs. Save the vertices with the object.
166
+ #
167
+ # The vertices are expressed as English Metric Units (EMUs). There are 12,700
168
+ # EMUs per point. Therefore, 12,700 * 3 /4 = 9,525 EMUs per pixel.
169
+ #
170
+ def calc_position_emus(worksheet)
171
+ c_start, r_start, xx1, yy1, c_end, r_end, xx2, yy2, x_abslt, y_abslt =
172
+ worksheet.position_object_pixels(
173
+ @column_start,
174
+ @row_start,
175
+ @x_offset,
176
+ @y_offset,
177
+ @width * @scale_x,
178
+ @height * @scale_y,
179
+ @drawing
180
+ )
181
+
182
+ # Now that x2/y2 have been calculated with a potentially negative
183
+ # width/height we use the absolute value and convert to EMUs.
184
+ @width_emu = (@width * 9_525).abs.to_i
185
+ @height_emu = (@height * 9_525).abs.to_i
186
+
187
+ @column_start = c_start.to_i
188
+ @row_start = r_start.to_i
189
+ @column_end = c_end.to_i
190
+ @row_end = r_end.to_i
191
+
192
+ # Convert the pixel values to EMUs. See above.
193
+ @x1 = (xx1 * 9_525).to_i
194
+ @y1 = (yy1 * 9_525).to_i
195
+ @x2 = (xx2 * 9_525).to_i
196
+ @y2 = (yy2 * 9_525).to_i
197
+ @x_abs = (x_abslt * 9_525).to_i
198
+ @y_abs = (y_abslt * 9_525).to_i
199
+ end
200
+
201
+ def set_position(row_start, column_start, x_offset, y_offset, x_scale, y_scale)
202
+ @row_start = row_start
203
+ @column_start = column_start
204
+ @x_offset = x_offset || 0
205
+ @y_offset = y_offset || 0
206
+
207
+ # Override shape scale if supplied as an argument. Otherwise, use the
208
+ # existing shape scale factors.
209
+ @scale_x = x_scale if x_scale
210
+ @scale_y = y_scale if y_scale
211
+ end
212
+
213
+ #
214
+ # Re-size connector shapes if they are connected to other shapes.
215
+ #
216
+ def auto_locate_connectors(shapes, shape_hash)
217
+ # Valid connector shapes.
218
+ connector_shapes = {
219
+ :straightConnector => 1,
220
+ :Connector => 1,
221
+ :bentConnector => 1,
222
+ :curvedConnector => 1,
223
+ :line => 1
224
+ }
225
+
226
+ shape_base = @type.chop.to_sym # Remove the number of segments from end of type.
227
+ @connect = connector_shapes[shape_base] ? 1 : 0
228
+ return if @connect == 0
229
+
230
+ # Both ends have to be connected to size it.
231
+ return if @start == 0 && @end == 0
232
+
233
+ # Both ends need to provide info about where to connect.
234
+ return if @start_side == 0 && @end_side == 0
235
+
236
+ sid = @start
237
+ eid = @end
238
+
239
+ slink_id = shape_hash[sid] || 0
240
+ sls = shapes.fetch(slink_id, Shape.new)
241
+ elink_id = shape_hash[eid] || 0
242
+ els = shapes.fetch(elink_id, Shape.new)
243
+
244
+ # Assume shape connections are to the middle of an object, and
245
+ # not a corner (for now).
246
+ connect_type = @start_side + @end_side
247
+ smidx = sls.x_offset + sls.width / 2
248
+ emidx = els.x_offset + els.width / 2
249
+ smidy = sls.y_offset + sls.height / 2
250
+ emidy = els.y_offset + els.height / 2
251
+ netx = (smidx - emidx).abs
252
+ nety = (smidy - emidy).abs
253
+
254
+ if connect_type == 'bt'
255
+ sy = sls.y_offset + sls.height
256
+ ey = els.y_offset
257
+
258
+ @width = (emidx - smidx).to_i.abs
259
+ @x_offset = [smidx, emidx].min.to_i
260
+ @height =
261
+ (els.y_offset - (sls.y_offset + sls.height)).to_i.abs
262
+ @y_offset =
263
+ [sls.y_offset + sls.height, els.y_offset].min.to_i
264
+ @flip_h = smidx < emidx ? 1 : 0
265
+ @rotation = 90
266
+
267
+ if sy > ey
268
+ @flip_v = 1
269
+
270
+ # Create 3 adjustments for an end shape vertically above a
271
+ # start @ Adjustments count from the upper left object.
272
+ if @adjustments.empty?
273
+ @adjustments = [-10, 50, 110]
274
+ end
275
+ @type = 'bentConnector5'
276
+ end
277
+ elsif connect_type == 'rl'
278
+ @width =
279
+ (els.x_offset - (sls.x_offset + sls.width)).to_i.abs
280
+ @height = (emidy - smidy).to_i.abs
281
+ @x_offset =
282
+ [sls.x_offset + sls.width, els.x_offset].min
283
+ @y_offset = [smidy, emidy].min
284
+
285
+ @flip_h = 1 if smidx < emidx && smidy > emidy
286
+ @flip_h = 1 if smidx > emidx && smidy < emidy
287
+
288
+ if smidx > emidx
289
+ # Create 3 adjustments for an end shape to the left of a
290
+ # start @
291
+ if @adjustments.empty?
292
+ @adjustments = [-10, 50, 110]
293
+ end
294
+ @type = 'bentConnector5'
295
+ end
296
+ end
297
+ end
298
+
299
+ #
300
+ # Check shape attributes to ensure they are valid.
301
+ #
302
+ def validate(index)
303
+ unless %w[l ctr r just].include?(@align)
304
+ raise "Shape #{index} (#{@type}) alignment (#{@align}) not in ['l', 'ctr', 'r', 'just']\n"
305
+ end
306
+
307
+ unless %w[t ctr b].include?(@valign)
308
+ raise "Shape #{index} (#{@type}) vertical alignment (#{@valign}) not in ['t', 'ctr', 'v']\n"
309
+ end
310
+ end
311
+
312
+ def dimensions
313
+ [
314
+ @column_start, @row_start,
315
+ @x1, @y1,
316
+ @column_end, @row_end,
317
+ @x2, @y2,
318
+ @x_abs, @y_abs,
319
+ @width_emu, @height_emu
320
+ ]
321
+ end
171
322
  end
172
323
  end
@@ -0,0 +1,524 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'write_xlsx/utility'
3
+
4
+ module Writexlsx
5
+ ###############################################################################
6
+ #
7
+ # Sparkline - A class for handle Excel sparkline
8
+ #
9
+ # Used in conjunction with WriteXLSX.
10
+ #
11
+ # Copyright 2000-2012, John McNamara, jmcnamara@cpan.org
12
+ # Converted to ruby by Hideo NAKAMURA, cxn03651@msj.biglobe.ne.jp
13
+ #
14
+ class Sparkline
15
+ include Writexlsx::Utility
16
+
17
+ attr_accessor :locations, :ranges
18
+ attr_accessor :date_axis, :series_color, :negative_color, :markers_color
19
+ attr_accessor :first_color, :last_color, :high_color, :low_color
20
+
21
+ def initialize(ws, param, sheetname)
22
+ @color = {}
23
+
24
+ # Check for valid input parameters.
25
+ param.each_key do |k|
26
+ unless valid_sparkline_parameter[k]
27
+ raise "Unknown parameter '#{k}' in add_sparkline()"
28
+ end
29
+ end
30
+ [:location, :range].each do |required_key|
31
+ unless param[required_key]
32
+ raise "Parameter '#{required_key}' is required in add_sparkline()"
33
+ end
34
+ end
35
+
36
+ # Handle the sparkline type.
37
+ type = param[:type] || 'line'
38
+ unless ['line', 'column', 'win_loss'].include?(type)
39
+ raise "Parameter ':type' must be 'line', 'column' or 'win_loss' in add_sparkline()"
40
+ end
41
+ type = 'stacked' if type == 'win_loss'
42
+ @type = type
43
+
44
+ # We handle single location/range values or array refs of values.
45
+ @locations = [param[:location]].flatten
46
+ @ranges = [param[:range]].flatten
47
+
48
+ if @ranges.size != @locations.size
49
+ raise "Must have the same number of location and range parameters in add_sparkline()"
50
+ end
51
+
52
+ # Cleanup the input ranges.
53
+ @ranges.collect! do |range|
54
+ # Remove the absolute reference $ symbols.
55
+ range = range.gsub(/\$/, '')
56
+ # Convert a simple range into a full Sheet1!A1:D1 range.
57
+ range = "#{sheetname}!#{range}" unless range =~ /!/
58
+ range
59
+ end
60
+ # Cleanup the input locations.
61
+ @locations.collect! { |location| location.gsub(/\$/, '') }
62
+
63
+ # Map options.
64
+ @high = param[:high_point]
65
+ @low = param[:low_point]
66
+ @negative = param[:negative_points]
67
+ @first = param[:first_point]
68
+ @last = param[:last_point]
69
+ @markers = param[:markers]
70
+ @min = param[:min]
71
+ @max = param[:max]
72
+ @axis = param[:axis]
73
+ @reverse = param[:reverse]
74
+ @hidden = param[:show_hidden]
75
+ @weight = param[:weight]
76
+
77
+ # Map empty cells options.
78
+ @empty = case param[:empty_cells] || ''
79
+ when 'zero'
80
+ 0
81
+ when 'connect'
82
+ 'span'
83
+ else
84
+ 'gap'
85
+ end
86
+
87
+ # Map the date axis range.
88
+ date_range = param[:date_axis]
89
+ if ptrue?(date_range) && !(date_range =~ /!/)
90
+ date_range = "#{sheetname}!#{date_range}"
91
+ end
92
+ @date_axis = date_range
93
+
94
+ # Set the sparkline styles.
95
+ style = spark_styles[param[:style] || 0]
96
+
97
+ @series_color = style[:series]
98
+ @negative_color = style[:negative]
99
+ @markers_color = style[:markers]
100
+ @first_color = style[:first]
101
+ @last_color = style[:last]
102
+ @high_color = style[:high]
103
+ @low_color = style[:low]
104
+
105
+ # Override the style colours with user defined colors.
106
+ [:series_color, :negative_color, :markers_color, :first_color, :last_color, :high_color, :low_color].each do |user_color|
107
+ set_spark_color(user_color, ptrue?(param[user_color]) ? ws.get_palette_color(param[user_color]) : nil)
108
+ end
109
+ end
110
+
111
+ def count
112
+ @locations.size
113
+ end
114
+
115
+ def group_attributes
116
+ cust_max = cust_max_min(@max) if @max
117
+ cust_min = cust_max_min(@min) if @min
118
+
119
+ a = []
120
+ a << 'manualMax' << @max if @max && @max != 'group'
121
+ a << 'manualMin' << @min if @min && @min != 'group'
122
+
123
+ # Ignore the default type attribute (line).
124
+ a << 'type' << @type if @type != 'line'
125
+
126
+ a << 'lineWeight' << @weight if @weight
127
+ a << 'dateAxis' << 1 if @date_axis
128
+ a << 'displayEmptyCellsAs' << @empty if ptrue?(@empty)
129
+
130
+ a << 'markers' << 1 if @markers
131
+ a << 'high' << 1 if @high
132
+ a << 'low' << 1 if @low
133
+ a << 'first' << 1 if @first
134
+ a << 'last' << 1 if @last
135
+ a << 'negative' << 1 if @negative
136
+ a << 'displayXAxis' << 1 if @axis
137
+ a << 'displayHidden' << 1 if @hidden
138
+ a << 'minAxisType' << cust_min if cust_min
139
+ a << 'maxAxisType' << cust_max if cust_max
140
+ a << 'rightToLeft' << 1 if @reverse
141
+ a
142
+ end
143
+
144
+ private
145
+
146
+ def set_spark_color(user_color, palette_color)
147
+ return unless palette_color
148
+
149
+ instance_variable_set("@#{user_color}", { :_rgb => palette_color })
150
+ end
151
+
152
+ def cust_max_min(max_min) # :nodoc:
153
+ max_min == 'group' ? 'group' : 'custom'
154
+ end
155
+
156
+ def valid_sparkline_parameter # :nodoc:
157
+ {
158
+ :location => 1,
159
+ :range => 1,
160
+ :type => 1,
161
+ :high_point => 1,
162
+ :low_point => 1,
163
+ :negative_points => 1,
164
+ :first_point => 1,
165
+ :last_point => 1,
166
+ :markers => 1,
167
+ :style => 1,
168
+ :series_color => 1,
169
+ :negative_color => 1,
170
+ :markers_color => 1,
171
+ :first_color => 1,
172
+ :last_color => 1,
173
+ :high_color => 1,
174
+ :low_color => 1,
175
+ :max => 1,
176
+ :min => 1,
177
+ :axis => 1,
178
+ :reverse => 1,
179
+ :empty_cells => 1,
180
+ :show_hidden => 1,
181
+ :date_axis => 1,
182
+ :weight => 1
183
+ }
184
+ end
185
+
186
+ def spark_styles # :nodoc:
187
+ [
188
+ { # 0
189
+ :series => { :_theme => "4", :_tint => "-0.499984740745262" },
190
+ :negative => { :_theme => "5" },
191
+ :markers => { :_theme => "4", :_tint => "-0.499984740745262" },
192
+ :first => { :_theme => "4", :_tint => "0.39997558519241921" },
193
+ :last => { :_theme => "4", :_tint => "0.39997558519241921" },
194
+ :high => { :_theme => "4" },
195
+ :low => { :_theme => "4" }
196
+ },
197
+ { # 1
198
+ :series => { :_theme => "4", :_tint => "-0.499984740745262" },
199
+ :negative => { :_theme => "5" },
200
+ :markers => { :_theme => "4", :_tint => "-0.499984740745262" },
201
+ :first => { :_theme => "4", :_tint => "0.39997558519241921" },
202
+ :last => { :_theme => "4", :_tint => "0.39997558519241921" },
203
+ :high => { :_theme => "4" },
204
+ :low => { :_theme => "4" }
205
+ },
206
+ { # 2
207
+ :series => { :_theme => "5", :_tint => "-0.499984740745262" },
208
+ :negative => { :_theme => "6" },
209
+ :markers => { :_theme => "5", :_tint => "-0.499984740745262" },
210
+ :first => { :_theme => "5", :_tint => "0.39997558519241921" },
211
+ :last => { :_theme => "5", :_tint => "0.39997558519241921" },
212
+ :high => { :_theme => "5" },
213
+ :low => { :_theme => "5" }
214
+ },
215
+ { # 3
216
+ :series => { :_theme => "6", :_tint => "-0.499984740745262" },
217
+ :negative => { :_theme => "7" },
218
+ :markers => { :_theme => "6", :_tint => "-0.499984740745262" },
219
+ :first => { :_theme => "6", :_tint => "0.39997558519241921" },
220
+ :last => { :_theme => "6", :_tint => "0.39997558519241921" },
221
+ :high => { :_theme => "6" },
222
+ :low => { :_theme => "6" }
223
+ },
224
+ { # 4
225
+ :series => { :_theme => "7", :_tint => "-0.499984740745262" },
226
+ :negative => { :_theme => "8" },
227
+ :markers => { :_theme => "7", :_tint => "-0.499984740745262" },
228
+ :first => { :_theme => "7", :_tint => "0.39997558519241921" },
229
+ :last => { :_theme => "7", :_tint => "0.39997558519241921" },
230
+ :high => { :_theme => "7" },
231
+ :low => { :_theme => "7" }
232
+ },
233
+ { # 5
234
+ :series => { :_theme => "8", :_tint => "-0.499984740745262" },
235
+ :negative => { :_theme => "9" },
236
+ :markers => { :_theme => "8", :_tint => "-0.499984740745262" },
237
+ :first => { :_theme => "8", :_tint => "0.39997558519241921" },
238
+ :last => { :_theme => "8", :_tint => "0.39997558519241921" },
239
+ :high => { :_theme => "8" },
240
+ :low => { :_theme => "8" }
241
+ },
242
+ { # 6
243
+ :series => { :_theme => "9", :_tint => "-0.499984740745262" },
244
+ :negative => { :_theme => "4" },
245
+ :markers => { :_theme => "9", :_tint => "-0.499984740745262" },
246
+ :first => { :_theme => "9", :_tint => "0.39997558519241921" },
247
+ :last => { :_theme => "9", :_tint => "0.39997558519241921" },
248
+ :high => { :_theme => "9" },
249
+ :low => { :_theme => "9" }
250
+ },
251
+ { # 7
252
+ :series => { :_theme => "4", :_tint => "-0.249977111117893" },
253
+ :negative => { :_theme => "5" },
254
+ :markers => { :_theme => "5", :_tint => "-0.249977111117893" },
255
+ :first => { :_theme => "5", :_tint => "-0.249977111117893" },
256
+ :last => { :_theme => "5", :_tint => "-0.249977111117893" },
257
+ :high => { :_theme => "5", :_tint => "-0.249977111117893" },
258
+ :low => { :_theme => "5", :_tint => "-0.249977111117893" }
259
+ },
260
+ { # 8
261
+ :series => { :_theme => "5", :_tint => "-0.249977111117893" },
262
+ :negative => { :_theme => "6" },
263
+ :markers => { :_theme => "6", :_tint => "-0.249977111117893" },
264
+ :first => { :_theme => "6", :_tint => "-0.249977111117893" },
265
+ :last => { :_theme => "6", :_tint => "-0.249977111117893" },
266
+ :high => { :_theme => "6", :_tint => "-0.249977111117893" },
267
+ :low => { :_theme => "6", :_tint => "-0.249977111117893" }
268
+ },
269
+ { # 9
270
+ :series => { :_theme => "6", :_tint => "-0.249977111117893" },
271
+ :negative => { :_theme => "7" },
272
+ :markers => { :_theme => "7", :_tint => "-0.249977111117893" },
273
+ :first => { :_theme => "7", :_tint => "-0.249977111117893" },
274
+ :last => { :_theme => "7", :_tint => "-0.249977111117893" },
275
+ :high => { :_theme => "7", :_tint => "-0.249977111117893" },
276
+ :low => { :_theme => "7", :_tint => "-0.249977111117893" }
277
+ },
278
+ { # 10
279
+ :series => { :_theme => "7", :_tint => "-0.249977111117893" },
280
+ :negative => { :_theme => "8" },
281
+ :markers => { :_theme => "8", :_tint => "-0.249977111117893" },
282
+ :first => { :_theme => "8", :_tint => "-0.249977111117893" },
283
+ :last => { :_theme => "8", :_tint => "-0.249977111117893" },
284
+ :high => { :_theme => "8", :_tint => "-0.249977111117893" },
285
+ :low => { :_theme => "8", :_tint => "-0.249977111117893" }
286
+ },
287
+ { # 11
288
+ :series => { :_theme => "8", :_tint => "-0.249977111117893" },
289
+ :negative => { :_theme => "9" },
290
+ :markers => { :_theme => "9", :_tint => "-0.249977111117893" },
291
+ :first => { :_theme => "9", :_tint => "-0.249977111117893" },
292
+ :last => { :_theme => "9", :_tint => "-0.249977111117893" },
293
+ :high => { :_theme => "9", :_tint => "-0.249977111117893" },
294
+ :low => { :_theme => "9", :_tint => "-0.249977111117893" }
295
+ },
296
+ { # 12
297
+ :series => { :_theme => "9", :_tint => "-0.249977111117893" },
298
+ :negative => { :_theme => "4" },
299
+ :markers => { :_theme => "4", :_tint => "-0.249977111117893" },
300
+ :first => { :_theme => "4", :_tint => "-0.249977111117893" },
301
+ :last => { :_theme => "4", :_tint => "-0.249977111117893" },
302
+ :high => { :_theme => "4", :_tint => "-0.249977111117893" },
303
+ :low => { :_theme => "4", :_tint => "-0.249977111117893" }
304
+ },
305
+ { # 13
306
+ :series => { :_theme => "4" },
307
+ :negative => { :_theme => "5" },
308
+ :markers => { :_theme => "4", :_tint => "-0.249977111117893" },
309
+ :first => { :_theme => "4", :_tint => "-0.249977111117893" },
310
+ :last => { :_theme => "4", :_tint => "-0.249977111117893" },
311
+ :high => { :_theme => "4", :_tint => "-0.249977111117893" },
312
+ :low => { :_theme => "4", :_tint => "-0.249977111117893" }
313
+ },
314
+ { # 14
315
+ :series => { :_theme => "5" },
316
+ :negative => { :_theme => "6" },
317
+ :markers => { :_theme => "5", :_tint => "-0.249977111117893" },
318
+ :first => { :_theme => "5", :_tint => "-0.249977111117893" },
319
+ :last => { :_theme => "5", :_tint => "-0.249977111117893" },
320
+ :high => { :_theme => "5", :_tint => "-0.249977111117893" },
321
+ :low => { :_theme => "5", :_tint => "-0.249977111117893" }
322
+ },
323
+ { # 15
324
+ :series => { :_theme => "6" },
325
+ :negative => { :_theme => "7" },
326
+ :markers => { :_theme => "6", :_tint => "-0.249977111117893" },
327
+ :first => { :_theme => "6", :_tint => "-0.249977111117893" },
328
+ :last => { :_theme => "6", :_tint => "-0.249977111117893" },
329
+ :high => { :_theme => "6", :_tint => "-0.249977111117893" },
330
+ :low => { :_theme => "6", :_tint => "-0.249977111117893" }
331
+ },
332
+ { # 16
333
+ :series => { :_theme => "7" },
334
+ :negative => { :_theme => "8" },
335
+ :markers => { :_theme => "7", :_tint => "-0.249977111117893" },
336
+ :first => { :_theme => "7", :_tint => "-0.249977111117893" },
337
+ :last => { :_theme => "7", :_tint => "-0.249977111117893" },
338
+ :high => { :_theme => "7", :_tint => "-0.249977111117893" },
339
+ :low => { :_theme => "7", :_tint => "-0.249977111117893" }
340
+ },
341
+ { # 17
342
+ :series => { :_theme => "8" },
343
+ :negative => { :_theme => "9" },
344
+ :markers => { :_theme => "8", :_tint => "-0.249977111117893" },
345
+ :first => { :_theme => "8", :_tint => "-0.249977111117893" },
346
+ :last => { :_theme => "8", :_tint => "-0.249977111117893" },
347
+ :high => { :_theme => "8", :_tint => "-0.249977111117893" },
348
+ :low => { :_theme => "8", :_tint => "-0.249977111117893" }
349
+ },
350
+ { # 18
351
+ :series => { :_theme => "9" },
352
+ :negative => { :_theme => "4" },
353
+ :markers => { :_theme => "9", :_tint => "-0.249977111117893" },
354
+ :first => { :_theme => "9", :_tint => "-0.249977111117893" },
355
+ :last => { :_theme => "9", :_tint => "-0.249977111117893" },
356
+ :high => { :_theme => "9", :_tint => "-0.249977111117893" },
357
+ :low => { :_theme => "9", :_tint => "-0.249977111117893" }
358
+ },
359
+ { # 19
360
+ :series => { :_theme => "4", :_tint => "0.39997558519241921" },
361
+ :negative => { :_theme => "0", :_tint => "-0.499984740745262" },
362
+ :markers => { :_theme => "4", :_tint => "0.79998168889431442" },
363
+ :first => { :_theme => "4", :_tint => "-0.249977111117893" },
364
+ :last => { :_theme => "4", :_tint => "-0.249977111117893" },
365
+ :high => { :_theme => "4", :_tint => "-0.499984740745262" },
366
+ :low => { :_theme => "4", :_tint => "-0.499984740745262" }
367
+ },
368
+ { # 20
369
+ :series => { :_theme => "5", :_tint => "0.39997558519241921" },
370
+ :negative => { :_theme => "0", :_tint => "-0.499984740745262" },
371
+ :markers => { :_theme => "5", :_tint => "0.79998168889431442" },
372
+ :first => { :_theme => "5", :_tint => "-0.249977111117893" },
373
+ :last => { :_theme => "5", :_tint => "-0.249977111117893" },
374
+ :high => { :_theme => "5", :_tint => "-0.499984740745262" },
375
+ :low => { :_theme => "5", :_tint => "-0.499984740745262" }
376
+ },
377
+ { # 21
378
+ :series => { :_theme => "6", :_tint => "0.39997558519241921" },
379
+ :negative => { :_theme => "0", :_tint => "-0.499984740745262" },
380
+ :markers => { :_theme => "6", :_tint => "0.79998168889431442" },
381
+ :first => { :_theme => "6", :_tint => "-0.249977111117893" },
382
+ :last => { :_theme => "6", :_tint => "-0.249977111117893" },
383
+ :high => { :_theme => "6", :_tint => "-0.499984740745262" },
384
+ :low => { :_theme => "6", :_tint => "-0.499984740745262" }
385
+ },
386
+ { # 22
387
+ :series => { :_theme => "7", :_tint => "0.39997558519241921" },
388
+ :negative => { :_theme => "0", :_tint => "-0.499984740745262" },
389
+ :markers => { :_theme => "7", :_tint => "0.79998168889431442" },
390
+ :first => { :_theme => "7", :_tint => "-0.249977111117893" },
391
+ :last => { :_theme => "7", :_tint => "-0.249977111117893" },
392
+ :high => { :_theme => "7", :_tint => "-0.499984740745262" },
393
+ :low => { :_theme => "7", :_tint => "-0.499984740745262" }
394
+ },
395
+ { # 23
396
+ :series => { :_theme => "8", :_tint => "0.39997558519241921" },
397
+ :negative => { :_theme => "0", :_tint => "-0.499984740745262" },
398
+ :markers => { :_theme => "8", :_tint => "0.79998168889431442" },
399
+ :first => { :_theme => "8", :_tint => "-0.249977111117893" },
400
+ :last => { :_theme => "8", :_tint => "-0.249977111117893" },
401
+ :high => { :_theme => "8", :_tint => "-0.499984740745262" },
402
+ :low => { :_theme => "8", :_tint => "-0.499984740745262" }
403
+ },
404
+ { # 24
405
+ :series => { :_theme => "9", :_tint => "0.39997558519241921" },
406
+ :negative => { :_theme => "0", :_tint => "-0.499984740745262" },
407
+ :markers => { :_theme => "9", :_tint => "0.79998168889431442" },
408
+ :first => { :_theme => "9", :_tint => "-0.249977111117893" },
409
+ :last => { :_theme => "9", :_tint => "-0.249977111117893" },
410
+ :high => { :_theme => "9", :_tint => "-0.499984740745262" },
411
+ :low => { :_theme => "9", :_tint => "-0.499984740745262" }
412
+ },
413
+ { # 25
414
+ :series => { :_theme => "1", :_tint => "0.499984740745262" },
415
+ :negative => { :_theme => "1", :_tint => "0.249977111117893" },
416
+ :markers => { :_theme => "1", :_tint => "0.249977111117893" },
417
+ :first => { :_theme => "1", :_tint => "0.249977111117893" },
418
+ :last => { :_theme => "1", :_tint => "0.249977111117893" },
419
+ :high => { :_theme => "1", :_tint => "0.249977111117893" },
420
+ :low => { :_theme => "1", :_tint => "0.249977111117893" }
421
+ },
422
+ { # 26
423
+ :series => { :_theme => "1", :_tint => "0.34998626667073579" },
424
+ :negative => { :_theme => "0", :_tint => "-0.249977111117893" },
425
+ :markers => { :_theme => "0", :_tint => "-0.249977111117893" },
426
+ :first => { :_theme => "0", :_tint => "-0.249977111117893" },
427
+ :last => { :_theme => "0", :_tint => "-0.249977111117893" },
428
+ :high => { :_theme => "0", :_tint => "-0.249977111117893" },
429
+ :low => { :_theme => "0", :_tint => "-0.249977111117893" }
430
+ },
431
+ { # 27
432
+ :series => { :_rgb => "FF323232" },
433
+ :negative => { :_rgb => "FFD00000" },
434
+ :markers => { :_rgb => "FFD00000" },
435
+ :first => { :_rgb => "FFD00000" },
436
+ :last => { :_rgb => "FFD00000" },
437
+ :high => { :_rgb => "FFD00000" },
438
+ :low => { :_rgb => "FFD00000" }
439
+ },
440
+ { # 28
441
+ :series => { :_rgb => "FF000000" },
442
+ :negative => { :_rgb => "FF0070C0" },
443
+ :markers => { :_rgb => "FF0070C0" },
444
+ :first => { :_rgb => "FF0070C0" },
445
+ :last => { :_rgb => "FF0070C0" },
446
+ :high => { :_rgb => "FF0070C0" },
447
+ :low => { :_rgb => "FF0070C0" }
448
+ },
449
+ { # 29
450
+ :series => { :_rgb => "FF376092" },
451
+ :negative => { :_rgb => "FFD00000" },
452
+ :markers => { :_rgb => "FFD00000" },
453
+ :first => { :_rgb => "FFD00000" },
454
+ :last => { :_rgb => "FFD00000" },
455
+ :high => { :_rgb => "FFD00000" },
456
+ :low => { :_rgb => "FFD00000" }
457
+ },
458
+ { # 30
459
+ :series => { :_rgb => "FF0070C0" },
460
+ :negative => { :_rgb => "FF000000" },
461
+ :markers => { :_rgb => "FF000000" },
462
+ :first => { :_rgb => "FF000000" },
463
+ :last => { :_rgb => "FF000000" },
464
+ :high => { :_rgb => "FF000000" },
465
+ :low => { :_rgb => "FF000000" }
466
+ },
467
+ { # 31
468
+ :series => { :_rgb => "FF5F5F5F" },
469
+ :negative => { :_rgb => "FFFFB620" },
470
+ :markers => { :_rgb => "FFD70077" },
471
+ :first => { :_rgb => "FF5687C2" },
472
+ :last => { :_rgb => "FF359CEB" },
473
+ :high => { :_rgb => "FF56BE79" },
474
+ :low => { :_rgb => "FFFF5055" }
475
+ },
476
+ { # 32
477
+ :series => { :_rgb => "FF5687C2" },
478
+ :negative => { :_rgb => "FFFFB620" },
479
+ :markers => { :_rgb => "FFD70077" },
480
+ :first => { :_rgb => "FF777777" },
481
+ :last => { :_rgb => "FF359CEB" },
482
+ :high => { :_rgb => "FF56BE79" },
483
+ :low => { :_rgb => "FFFF5055" }
484
+ },
485
+ { # 33
486
+ :series => { :_rgb => "FFC6EFCE" },
487
+ :negative => { :_rgb => "FFFFC7CE" },
488
+ :markers => { :_rgb => "FF8CADD6" },
489
+ :first => { :_rgb => "FFFFDC47" },
490
+ :last => { :_rgb => "FFFFEB9C" },
491
+ :high => { :_rgb => "FF60D276" },
492
+ :low => { :_rgb => "FFFF5367" }
493
+ },
494
+ { # 34
495
+ :series => { :_rgb => "FF00B050" },
496
+ :negative => { :_rgb => "FFFF0000" },
497
+ :markers => { :_rgb => "FF0070C0" },
498
+ :first => { :_rgb => "FFFFC000" },
499
+ :last => { :_rgb => "FFFFC000" },
500
+ :high => { :_rgb => "FF00B050" },
501
+ :low => { :_rgb => "FFFF0000" }
502
+ },
503
+ { # 35
504
+ :series => { :_theme => "3" },
505
+ :negative => { :_theme => "9" },
506
+ :markers => { :_theme => "8" },
507
+ :first => { :_theme => "4" },
508
+ :last => { :_theme => "5" },
509
+ :high => { :_theme => "6" },
510
+ :low => { :_theme => "7" }
511
+ },
512
+ { # 36
513
+ :series => { :_theme => "1" },
514
+ :negative => { :_theme => "9" },
515
+ :markers => { :_theme => "8" },
516
+ :first => { :_theme => "4" },
517
+ :last => { :_theme => "5" },
518
+ :high => { :_theme => "6" },
519
+ :low => { :_theme => "7" }
520
+ }
521
+ ]
522
+ end
523
+ end
524
+ end