62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
# File 'lib/line_bar.rb', line 62
def self.xml(options={})
p = @@default_xml_options.merge(options)
builder = Nokogiri::XML::Builder.new do |xml|
xml.anychart {
xml.settings {
xml.animation(:enabled => "True") if p[:animation]
}
xml.charts {
xml.chart(:plot_type => "CategorizedHorizontal") {
xml.data_plot_settings(:default_series_type => "Bar") {
xml.bar_series(:group_padding => "0.7", :style => "AquaLight") {
if p[:tooltip]
xml.tooltip_settings(:enabled => "True") {
xml.format p[:tooltip]
}
else
xml.tooltip_settings(:enabled => "False") {}
end
}
}
xml.chart_settings {
Anychart::XML.chart_background(xml,p) Anychart::XML.chart_title(xml,p) Anychart::XML.legend(xml,p)
xml.axes {
if p[:chart][:axes].present?
Anychart::XML.axis(xml,p,:y,{ :y_axis_opposite => true }) Anychart::XML.axis(xml,p,:x) end
}
}
xml.data {
series = (p[:data][:series].kind_of?(Array) ? p[:data][:series] : [p[:data][:series]])
series.each_with_index do |serie,serie_idx|
xml.series(:name => (serie[:name].blank? ? "Series #{serie_idx + 1}" : serie[:name]), :palette => "Default") {
serie[:points].each do |point|
h = {:name => point[:name].to_s, :y => point[:value].to_s}
h.merge!({:color => point[:color].to_s}) if point[:color].present?
xml.point(h)
end
}
end
}
}
}
}
end
builder.to_xml.gsub(/>[ \t\r\n]+</, '><')
end
|