blob: 3f4bf289e17f960f1e4cd155c14de1384fc398dd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# encoding: UTF-8
module Axlsx
# A ScatterSeries defines the x and y position of data in the chart
# @note The recommended way to manage series is to use Chart#add_series
# @see Worksheet#add_chart
# @see Chart#add_series
# @see examples/example.rb
class ScatterSeries < Series
# The x data for this series.
# @return [NamedAxisData]
attr_reader :xData
# The y data for this series.
# @return [NamedAxisData]
attr_reader :yData
# The fill color for this series.
# Red, green, and blue is expressed as sequence of hex digits, RRGGBB. A perceptual gamma of 2.2 is used.
# @return [String]
attr_reader :color
# Creates a new ScatterSeries
def initialize(chart, options={})
@xData, @yData = nil
super(chart, options)
@xData = NamedAxisData.new("xVal", options[:xData]) unless options[:xData].nil?
@yData = NamedAxisData.new("yVal", options[:yData]) unless options[:yData].nil?
end
# @see color
def color=(v)
@color = v
end
# Serializes the object
# @param [String] str
# @return [String]
def to_xml_string(str = '')
super(str) do |inner_str|
# needs to override the super color here to push in ln/and something else!
if color
str << '<c:spPr><a:solidFill>'
str << '<a:srgbClr val="' << color << '"/>'
str << '</a:solidFill>'
str << '<a:ln><a:solidFill>'
str << '<a:srgbClr val="' << color << '"/></a:solidFill></a:ln>'
str << '</c:spPr>'
str << '<c:marker>'
str << '<c:spPr><a:solidFill>'
str << '<a:srgbClr val="' << color << '"/>'
str << '</a:solidFill>'
str << '<a:ln><a:solidFill>'
str << '<a:srgbClr val="' << color << '"/></a:solidFill></a:ln>'
str << '</c:spPr>'
str << '</c:marker>'
end
@xData.to_xml_string(inner_str) unless @xData.nil?
@yData.to_xml_string(inner_str) unless @yData.nil?
end
str
end
end
end
|