---
src/app/controllers/dashboard_controller.rb | 11 +++++++++++
src/app/services/graph_service.rb | 14 +++++++++-----
src/app/views/dashboard/summary.haml | 2 +-
src/config/initializers/mime_types.rb | 1 +
src/public/stylesheets/components.css | 1 -
5 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/src/app/controllers/dashboard_controller.rb
b/src/app/controllers/dashboard_controller.rb
index adc83d2..114673f 100644
--- a/src/app/controllers/dashboard_controller.rb
+++ b/src/app/controllers/dashboard_controller.rb
@@ -31,6 +31,17 @@ class DashboardController < ApplicationController
return params[:ajax] == "true"
end
+ def graph(opts = {})
+ entity = nil
+ entity = Provider.find(params[:id]) if params[:entity_type] == 'Provider'
+ gparams = [entity]
+ gparams << params[:width] << params[:height] if params.has_key?(:width)
&& params.has_key?(:height)
+ graph =
GraphService.dashboard_qos(*gparams)[('Graph::'+params[:type]).constantize]
+ respond_to do |format|
+ format.svg { render :xml => graph.svg}
+ end
+ end
+
def index
@providers = Provider.find(:all)
diff --git a/src/app/services/graph_service.rb b/src/app/services/graph_service.rb
index 8fc5bad..e858cfd 100644
--- a/src/app/services/graph_service.rb
+++ b/src/app/services/graph_service.rb
@@ -1,13 +1,13 @@
class GraphService
require 'gnuplot'
- def gnuplot_open( persist=false )
+ def self.gnuplot_open( persist=false )
cmd = Gnuplot.gnuplot( persist ) or raise 'gnuplot not found'
output_stream = IO::popen( cmd, "r+")
end
- def qos_avg_time_to_submit_graph ( provider=nil, width=200, height=100 )
+ def self.qos_avg_time_to_submit_graph ( provider=nil, width=200, height=100 )
graph = Graph.new
gp = gnuplot_open
@@ -18,6 +18,10 @@ class GraphService
plot.arbitrary_lines << "unset x2tics"
plot.arbitrary_lines << "unset ytics"
plot.arbitrary_lines << "unset y2tics"
+ plot.set "bmargin","0"
+ plot.set "lmargin","0"
+ plot.set "tmargin","0"
+ plot.set "rmargin","0"
#FIXME: get data from DataService for the provider.
#First build three equal-length arrays
@@ -30,7 +34,7 @@ class GraphService
#'lc variable' usage.
plot.data << Gnuplot::DataSet.new( [x, y, c] ) do |ds|
ds.using = "1:2:3"
- ds.with = "lines lc variable"
+ ds.with = "lines"
ds.notitle
end
end
@@ -41,9 +45,9 @@ class GraphService
graph
end
- def dashboard_qos (provider = nil)
+ def self.dashboard_qos (provider = nil, width = 200, height = 100)
graphs = Hash.new
- graphs[Graph::QOS_AVG_TIME_TO_SUBMIT] = qos_avg_time_to_submit_graph(provider)
+ graphs[Graph::QOS_AVG_TIME_TO_SUBMIT] = qos_avg_time_to_submit_graph(provider, width,
height)
graphs
end
diff --git a/src/app/views/dashboard/summary.haml b/src/app/views/dashboard/summary.haml
index 633fb84..5a8eed6 100644
--- a/src/app/views/dashboard/summary.haml
+++ b/src/app/views/dashboard/summary.haml
@@ -79,7 +79,7 @@
<img src="images/dashboard_summary_prev.png" /><img
src="images/dashboard_summary_next.png" />
- @providers.each do |provider|
.provider_service_quality_graph
- <!-- FIXME include graph -->
+ = "<object data='" + url_for(:action => :graph, :type =>
'QOS_AVG_TIME_TO_SUBMIT', :entity_type => 'Provider', :id =>
provider.id, :width => 100, :height => 50) + "'
type='image/svg+xml' />"
.provider_service_quality_graph_summary
= provider.name
<!-- FIXME 'good/poor/average service... -->
diff --git a/src/config/initializers/mime_types.rb
b/src/config/initializers/mime_types.rb
index 72aca7e..c0feb58 100644
--- a/src/config/initializers/mime_types.rb
+++ b/src/config/initializers/mime_types.rb
@@ -3,3 +3,4 @@
# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf
# Mime::Type.register_alias "text/html", :iphone
+Mime::Type.register "image/svg+xml", :svg
diff --git a/src/public/stylesheets/components.css
b/src/public/stylesheets/components.css
index 1391fc5..abbf0bd 100644
--- a/src/public/stylesheets/components.css
+++ b/src/public/stylesheets/components.css
@@ -164,7 +164,6 @@ ul.nav li.selected {
.provider_service_quality_graph {
width: 100px;
height: 50px;
- border: 1px solid black;
float: left;
margin: 0px 5px 0px 5px;
}
--
1.6.2.5
Show replies by date