lib/write_xlsx/chart/series.rb in write_xlsx-1.04.0 vs lib/write_xlsx/chart/series.rb in write_xlsx-1.07.0
- old
+ new
@@ -294,11 +294,111 @@
unless separator.nil? || separator.empty?
raise "unsuppoted label separator #{separator}" unless separators[separator]
labels[:separator] = separators[separator]
end
+
+ # Set the line properties for the data labels.
+ line = line_properties( labels[:line] )
+
+ # Allow 'border' as a synonym for 'line'.
+ if labels[:border]
+ line = line_properties(labels[:border])
+ end
+
+ # Set the fill properties for the labels.
+ fill = fill_properties(labels[:fill])
+
+ # Set the pattern properties for the labels.
+ pattern = pattern_properties(labels[:pattern])
+
+ # Set the gradient fill properties for the labels.
+ gradient = gradient_properties(labels[:gradient])
+
+ # Pattern fill overrides solid fill.
+ if pattern
+ fill = nil
+ end
+
+ # Gradient fill overrides solid and pattern fills.
+ if gradient
+ pattern = nil
+ fill = nil
+ end
+
+ labels[:line] = line
+ labels[:fill] = fill
+ labels[:pattern] = pattern
+ labels[:gradient] = gradient
+
if labels[:font]
labels[:font] = convert_font_args(labels[:font])
+ end
+
+ if labels[:custom]
+ # Duplicate, and modify, the custom label properties.
+ custom = []
+
+ labels[:custom].each do |label|
+ if !label
+ custom << nil
+ next
+ end
+
+ property = label.dup
+
+ # Convert formula.
+ if property[:value] && property[:value] =~ /^=[^!]+!\$/
+ property[:formula] = property[:value]
+ end
+
+ if property[:formula]
+ property[:formula] = property[:formula].sub(/^=/, '')
+
+ data_id = @chart.data_id(property[:formula], property[:data])
+ property[:data_id] = data_id
+ end
+
+ if property[:font]
+ property[:font] = convert_font_args(property[:font])
+ end
+
+ # Allow 'border' as a synonym for 'line'.
+ if property[:border]
+ line = line_properties(property[:border])
+ else
+ # Set the line properties for the data labels.
+ line = line_properties(property[:line])
+ end
+
+ # Set the fill properties for the labels.
+ fill = fill_properties(property[:fill])
+
+ # Set the pattern properties for the labels.
+ pattern = pattern_properties(property[:pattern])
+
+ # Set the gradient fill properties for the labels.
+ gradient = gradient_properties(property[:gradient])
+
+ # Pattern fill overrides solid fill.
+ if pattern
+ fill = nil
+ end
+
+ # Gradient fill overrides solid and pattern fills.
+ if gradient
+ pattern = nil
+ fill = nil
+ end
+
+ property[:line] = line
+ property[:fill] = fill
+ property[:pattern] = pattern
+ property[:gradient] = gradient
+
+ custom << property
+ end
+ labels[:custom] = custom
end
labels
end
end