Since we don't use these now and will be switching to other charting libs (even if this just means our own fork of scruffy) when the time comes.
Revised to include edits to config/environment.rb
---
deltacloud-aggregator.spec.in | 3 -
src/app/services/graph_service.rb | 161 +------------------------------------
src/config/environment.rb | 2 -
3 files changed, 2 insertions(+), 164 deletions(-)
diff --git a/deltacloud-aggregator.spec.in b/deltacloud-aggregator.spec.in
index f05646f..841d135 100644
--- a/deltacloud-aggregator.spec.in
+++ b/deltacloud-aggregator.spec.in
@@ -22,8 +22,6 @@ Requires: rubygem(will_paginate)
Requires: rubygem(parseconfig)
Requires: rubygem(authlogic)
Requires: rubygem(deltacloud-client) >= 0.0.9.8
-Requires: rubygem(gnuplot)
-Requires: rubygem(scruffy)
Requires: rubygem(compass)
Requires: rubygem(compass-960-plugin)
Requires: rubygem(simple-navigation)
@@ -36,7 +34,6 @@ Requires: rubygem(imagebuilder-console)
Requires: postgresql
Requires: postgresql-server
Requires: ruby-postgres
-Requires: gnuplot >= 4.2.6
Requires: ruby-RMagick
Requires: classads >= 1.0
Requires: condor >= 7.5.4
diff --git a/src/app/services/graph_service.rb b/src/app/services/graph_service.rb
index 6c17743..7266434 100644
--- a/src/app/services/graph_service.rb
+++ b/src/app/services/graph_service.rb
@@ -1,7 +1,6 @@
class GraphService
- require 'gnuplot'
+
require 'nokogiri'
- require 'scruffy'
DATA_SERVICE = DataServiceActiveRecord
@@ -64,10 +63,6 @@ class GraphService
end
private
- def self.gnuplot_open( persist=false )
- cmd = Gnuplot.gnuplot( persist ) or raise 'gnuplot not found'
- output_stream = IO::popen( cmd, "r+")
- end
def self.quota_usage_graph (parent, opts = {})
x = [1,2]
@@ -175,39 +170,6 @@ class GraphService
width = 300 unless opts[:width].nil? ? nil : width = opts[:width].to_i
graph = Graph.new
-
- mytheme = Scruffy::Themes::Keynote.new
- mytheme.background = :white
- mytheme.marker = :black #sets the label text color
- mytheme.colors = %w(#00689a #00b0e0)
-
- scruffy_graph = Scruffy::Graph.new({:theme => mytheme})
- scruffy_graph.renderer = Scruffy::Renderers::Pie.new
- scruffy_graph.add :pie, '', pie_opts
-
- raw_svg = scruffy_graph.render :width => width, :height => height
-
- xml = Nokogiri::XML(raw_svg)
- svg = xml.css 'svg'
- svg.each do |node|
- node.set_attribute 'viewBox',"0 0 #{width} #{height}"
- end
-
- xml.root.traverse do |node|
- if node.name == 'text'
- if node.has_attribute? 'font-family'
- node.set_attribute 'font-family','sans-serif'
- end
- if (node.has_attribute? 'font-size') && node.get_attribute('font-size').length > 0
- size = node.get_attribute('font-size').to_f
- size = size * 1.5
- node.set_attribute 'font-size',size.to_s
- end
- end
- end
-
- graph.svg = xml.to_s
- graph
end
def self.draw_line_graph(opts, data)
@@ -217,45 +179,6 @@ class GraphService
width = 100 unless opts[:width].nil? ? nil : width = opts[:width].to_i
graph = Graph.new
- gp = gnuplot_open
-
- Gnuplot::Plot.new( gp ) do |plot|
- plot.terminal "svg size #{width},#{height}"
- plot.arbitrary_lines << "unset xtics"
- plot.arbitrary_lines << "unset x2tics"
- plot.arbitrary_lines << "unset ytics"
- plot.arbitrary_lines << "unset y2tics"
- plot.set "bmargin","0"
- plot.set "lmargin","1"
- plot.set "rmargin","0"
- plot.set "tmargin","0"
-
- #FIXME: get data from DataService for the provider.
- #For demo, plot a random walk for demo of graph display until we hook into DataService
- #First build two equal-length arrays
- #x = (0..500).collect { |v| v.to_f }
-
- #walk = 0
- #y = x.collect { |v| rand > 0.5 ? walk = walk + 1 : walk = walk - 1 }
-
- x = data[:x]
- y = data[:y]
- y_range = data[:y_range]
-
- #plot.set "yrange [-50:50]"
- plot.set "yrange " + y_range
-
- #This type of plot takes two equal length arrays of numbers as input.
- plot.data << Gnuplot::DataSet.new( [x, y] ) do |ds|
- ds.using = "1:2"
- ds.with = "lines"
- ds.notitle
- end
- end
- gp.flush
- gp.close_write
- gp.read(nil,graph.svg)
- gp.close_read
graph
end
@@ -269,87 +192,7 @@ class GraphService
height = 80 unless opts[:height].nil? ? nil : height = opts[:height].to_i
width = 150 unless opts[:width].nil? ? nil : width = opts[:width].to_i
- raw_svg = ""
- gp = gnuplot_open
- Gnuplot::Plot.new( gp ) do |plot|
- plot.terminal "svg size #{width},#{height}"
- plot.arbitrary_lines << "unset xtics"
- plot.arbitrary_lines << "unset x2tics"
- plot.arbitrary_lines << "unset ytics"
- plot.arbitrary_lines << "unset y2tics"
- plot.arbitrary_lines << "unset border"
-
- plot.set "bmargin","0"
- plot.set "lmargin","0"
- plot.set "rmargin","0"
- plot.set "tmargin","0"
- plot.set "boxwidth 0.9"
- plot.set "style fill solid 1.0"
- plot.set "xrange [.25:2.75]"
- plot.set "yrange [0:#{max_value * 1.5}]" #we want to scale maxvalue 50% larger to leave room for label
-
- x = chart_opts[:x]
- y = chart_opts[:y]
-
- #The two arrays above are three columns of data for gnuplot.
- plot.data << Gnuplot::DataSet.new( [[x[0]], [y[0]]] ) do |ds|
- ds.using = "1:2"
- ds.with = 'boxes linecolor rgb "#8cc63f"'
- ds.notitle
- end
-
- #The two arrays above are three columns of data for gnuplot.
- plot.data << Gnuplot::DataSet.new( [[x[1]], [y[1]]] ) do |ds|
- ds.using = "1:2"
- ds.with = 'boxes linecolor rgb "#cccccc"'
- ds.notitle
- end
-
-
- plot.data << Gnuplot::DataSet.new( [x, y] ) do |ds|
- ds.using = "1:2:2"
- ds.with = "labels left offset 0,.15 rotate"
- ds.notitle
- end
- end
- gp.flush
- gp.close_write
- gp.read(nil,raw_svg)
- gp.close_read
-
- #massage the svg so that the histogram's bars are oriented horizontally
- xml = Nokogiri::XML(raw_svg)
-
- nodes = xml.root.children
- wrapper = Nokogiri::XML::Node.new "g", xml.root
-
- nodes.each do |node|
- node.parent = wrapper if node.name != "desc" && node.name != "defs"
- end
-
- wrapper.parent = xml.root
- wrapper.set_attribute 'transform',"translate(#{width},0) rotate(90) scale(#{height * 1.0 / width},#{width * 1.0/ height})"
-
- text_nodes = []
- xml.root.traverse do |node|
- if node.name == 'text' && node.inner_text.strip =~ /^\d+$/
- if node.parent.name == 'g'
- pparent = node.parent
- text_nodes << pparent
- end
- end
- end
-
- text_nodes.each do |node|
- attr = node.get_attribute 'transform'
- node.remove_attribute 'transform'
- node.set_attribute 'transform',"#{attr} scale (#{height * 1.0 / width},#{width * 1.0/ height})"
- end
-
- modified_svg = xml.to_s
graph = Graph.new
- graph.svg = modified_svg
- graph
end
-end
\ No newline at end of file
+end
diff --git a/src/config/environment.rb b/src/config/environment.rb
index 423f224..7d8ba2c 100644
--- a/src/config/environment.rb
+++ b/src/config/environment.rb
@@ -47,8 +47,6 @@ Rails::Initializer.run do |config|
config.gem "haml"
config.gem "will_paginate"
config.gem "nokogiri", :version => ">= 1.4.0"
- config.gem "gnuplot"
- config.gem "scruffy"
config.gem "compass", :version => ">= 0.10.2"
config.gem "compass-960-plugin", :lib => "ninesixty"
config.gem "simple-navigation"
--
1.7.2.3