Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

remove sparklines dependency, replace with staticly generated pie charts, added script/pie.rb to easily regenerate them if necessary

Erik Hatchera8353ff8e4f8
diff --git a/client/ruby/flare/app/controllers/sparklines_controller.rb b/client/ruby/flare/app/controllers/sparklines_controller.rb
deleted file mode 100644
index 1c69f290525..00000000000
--- a/client/ruby/flare/app/controllers/sparklines_controller.rb
+++ /dev/null
@@ -1,40 +0,0 @@
-class SparklinesController < ApplicationController
-
- # Handles requests for sparkline graphs from views.
- #
- # Params are generated by the sparkline_tag helper method.
- #
- def index
- # Make array from comma-delimited list of data values
- ary = []
- if params.has_key?('results') && !params['results'].nil?
- params['results'].split(',').each do |s|
- ary << s.to_i
- end
- end
-
- send_data( Sparklines.plot( ary, params ),
- :disposition => 'inline',
- :type => 'image/png',
- :filename => "spark_#{params[:type]}.png" )
- end
-
-
- # Use this type of method for sparklines that can be cached. (Doesn't work with the helper.)
- #
- # To make caching easier, add a line like this to config/routes.rb:
- # map.sparklines "sparklines/:action/:id/image.png", :controller => "sparklines"
- #
- # Then reference it with the named route:
- # image_tag sparklines_url(:action => 'show', :id => 42)
- def show
- send_data(Sparklines.plot(
- [42, 37, 89, 74, 70, 50, 40, 30, 40, 50],
- :type => 'bar', :above_color => 'orange'
- ),
- :disposition => 'inline',
- :type => 'image/png',
- :filename => "sparkline.png")
- end
-
-end
diff --git a/client/ruby/flare/app/views/browse/index.rhtml b/client/ruby/flare/app/views/browse/index.rhtml
index 0fb08a1d534..f7ccd438306 100644
--- a/client/ruby/flare/app/views/browse/index.rhtml
+++ b/client/ruby/flare/app/views/browse/index.rhtml
@@ -11,7 +11,7 @@
<ul>
<% @response.field_facets(field).each do |f| %>
<li>
- <%= sparkline_tag [(f.value * 100.0 / @response.total_hits).ceil], :type => 'pie', :diameter => 20, :share_color => 'blue'%>
+ <%= image_tag "pie_#{(f.value * 100.0 / @response.total_hits).ceil}.png"%>
<%= link_to "#{f.name} (#{f.value})", :action => 'add_filter', :field_name=>field, :value=>f.name%>
</li>
<% end %>
diff --git a/client/ruby/flare/public/images/pie_0.png b/client/ruby/flare/public/images/pie_0.png
new file mode 100644
index 00000000000..90b277ebdc6
Binary files /dev/null and b/client/ruby/flare/public/images/pie_0.png differ
diff --git a/client/ruby/flare/public/images/pie_1.png b/client/ruby/flare/public/images/pie_1.png
new file mode 100644
index 00000000000..5da25606650
Binary files /dev/null and b/client/ruby/flare/public/images/pie_1.png differ
diff --git a/client/ruby/flare/public/images/pie_10.png b/client/ruby/flare/public/images/pie_10.png
new file mode 100644
index 00000000000..904f7122f9b
Binary files /dev/null and b/client/ruby/flare/public/images/pie_10.png differ
diff --git a/client/ruby/flare/public/images/pie_100.png b/client/ruby/flare/public/images/pie_100.png
new file mode 100644
index 00000000000..dc310a3623a
Binary files /dev/null and b/client/ruby/flare/public/images/pie_100.png differ
diff --git a/client/ruby/flare/public/images/pie_11.png b/client/ruby/flare/public/images/pie_11.png
new file mode 100644
index 00000000000..0ce81416b65
Binary files /dev/null and b/client/ruby/flare/public/images/pie_11.png differ
diff --git a/client/ruby/flare/public/images/pie_12.png b/client/ruby/flare/public/images/pie_12.png
new file mode 100644
index 00000000000..e0241e23125
Binary files /dev/null and b/client/ruby/flare/public/images/pie_12.png differ
diff --git a/client/ruby/flare/public/images/pie_13.png b/client/ruby/flare/public/images/pie_13.png
new file mode 100644
index 00000000000..0a57c3a4c09
Binary files /dev/null and b/client/ruby/flare/public/images/pie_13.png differ
diff --git a/client/ruby/flare/public/images/pie_14.png b/client/ruby/flare/public/images/pie_14.png
new file mode 100644
index 00000000000..4ca1e8fe69e
Binary files /dev/null and b/client/ruby/flare/public/images/pie_14.png differ
diff --git a/client/ruby/flare/public/images/pie_15.png b/client/ruby/flare/public/images/pie_15.png
new file mode 100644
index 00000000000..22e1ad981eb
Binary files /dev/null and b/client/ruby/flare/public/images/pie_15.png differ
diff --git a/client/ruby/flare/public/images/pie_16.png b/client/ruby/flare/public/images/pie_16.png
new file mode 100644
index 00000000000..c893a780c35
Binary files /dev/null and b/client/ruby/flare/public/images/pie_16.png differ
diff --git a/client/ruby/flare/public/images/pie_17.png b/client/ruby/flare/public/images/pie_17.png
new file mode 100644
index 00000000000..fe1bac3b986
Binary files /dev/null and b/client/ruby/flare/public/images/pie_17.png differ
diff --git a/client/ruby/flare/public/images/pie_18.png b/client/ruby/flare/public/images/pie_18.png
new file mode 100644
index 00000000000..fbef06a80af
Binary files /dev/null and b/client/ruby/flare/public/images/pie_18.png differ
diff --git a/client/ruby/flare/public/images/pie_19.png b/client/ruby/flare/public/images/pie_19.png
new file mode 100644
index 00000000000..fe7feb61cf3
Binary files /dev/null and b/client/ruby/flare/public/images/pie_19.png differ
diff --git a/client/ruby/flare/public/images/pie_2.png b/client/ruby/flare/public/images/pie_2.png
new file mode 100644
index 00000000000..f3f1f242746
Binary files /dev/null and b/client/ruby/flare/public/images/pie_2.png differ
diff --git a/client/ruby/flare/public/images/pie_20.png b/client/ruby/flare/public/images/pie_20.png
new file mode 100644
index 00000000000..b1e8653e286
Binary files /dev/null and b/client/ruby/flare/public/images/pie_20.png differ
diff --git a/client/ruby/flare/public/images/pie_21.png b/client/ruby/flare/public/images/pie_21.png
new file mode 100644
index 00000000000..709e152d31e
Binary files /dev/null and b/client/ruby/flare/public/images/pie_21.png differ
diff --git a/client/ruby/flare/public/images/pie_22.png b/client/ruby/flare/public/images/pie_22.png
new file mode 100644
index 00000000000..98453ba6b86
Binary files /dev/null and b/client/ruby/flare/public/images/pie_22.png differ
diff --git a/client/ruby/flare/public/images/pie_23.png b/client/ruby/flare/public/images/pie_23.png
new file mode 100644
index 00000000000..239fec72bce
Binary files /dev/null and b/client/ruby/flare/public/images/pie_23.png differ
diff --git a/client/ruby/flare/public/images/pie_24.png b/client/ruby/flare/public/images/pie_24.png
new file mode 100644
index 00000000000..28e3b1164b2
Binary files /dev/null and b/client/ruby/flare/public/images/pie_24.png differ
diff --git a/client/ruby/flare/public/images/pie_25.png b/client/ruby/flare/public/images/pie_25.png
new file mode 100644
index 00000000000..7066071b926
Binary files /dev/null and b/client/ruby/flare/public/images/pie_25.png differ
diff --git a/client/ruby/flare/public/images/pie_26.png b/client/ruby/flare/public/images/pie_26.png
new file mode 100644
index 00000000000..a63f5b25cfe
Binary files /dev/null and b/client/ruby/flare/public/images/pie_26.png differ
diff --git a/client/ruby/flare/public/images/pie_27.png b/client/ruby/flare/public/images/pie_27.png
new file mode 100644
index 00000000000..801079b042b
Binary files /dev/null and b/client/ruby/flare/public/images/pie_27.png differ
diff --git a/client/ruby/flare/public/images/pie_28.png b/client/ruby/flare/public/images/pie_28.png
new file mode 100644
index 00000000000..f885436c9d3
Binary files /dev/null and b/client/ruby/flare/public/images/pie_28.png differ
diff --git a/client/ruby/flare/public/images/pie_29.png b/client/ruby/flare/public/images/pie_29.png
new file mode 100644
index 00000000000..ecaa1e903b5
Binary files /dev/null and b/client/ruby/flare/public/images/pie_29.png differ
diff --git a/client/ruby/flare/public/images/pie_3.png b/client/ruby/flare/public/images/pie_3.png
new file mode 100644
index 00000000000..60e7c143d92
Binary files /dev/null and b/client/ruby/flare/public/images/pie_3.png differ
diff --git a/client/ruby/flare/public/images/pie_30.png b/client/ruby/flare/public/images/pie_30.png
new file mode 100644
index 00000000000..5a14e72a639
Binary files /dev/null and b/client/ruby/flare/public/images/pie_30.png differ
diff --git a/client/ruby/flare/public/images/pie_31.png b/client/ruby/flare/public/images/pie_31.png
new file mode 100644
index 00000000000..ccab4b6fd96
Binary files /dev/null and b/client/ruby/flare/public/images/pie_31.png differ
diff --git a/client/ruby/flare/public/images/pie_32.png b/client/ruby/flare/public/images/pie_32.png
new file mode 100644
index 00000000000..36492fb9d6a
Binary files /dev/null and b/client/ruby/flare/public/images/pie_32.png differ
diff --git a/client/ruby/flare/public/images/pie_33.png b/client/ruby/flare/public/images/pie_33.png
new file mode 100644
index 00000000000..370e87110bc
Binary files /dev/null and b/client/ruby/flare/public/images/pie_33.png differ
diff --git a/client/ruby/flare/public/images/pie_34.png b/client/ruby/flare/public/images/pie_34.png
new file mode 100644
index 00000000000..045aafb4459
Binary files /dev/null and b/client/ruby/flare/public/images/pie_34.png differ
diff --git a/client/ruby/flare/public/images/pie_35.png b/client/ruby/flare/public/images/pie_35.png
new file mode 100644
index 00000000000..3af7145f047
Binary files /dev/null and b/client/ruby/flare/public/images/pie_35.png differ
diff --git a/client/ruby/flare/public/images/pie_36.png b/client/ruby/flare/public/images/pie_36.png
new file mode 100644
index 00000000000..a8c7a8d3eeb
Binary files /dev/null and b/client/ruby/flare/public/images/pie_36.png differ
diff --git a/client/ruby/flare/public/images/pie_37.png b/client/ruby/flare/public/images/pie_37.png
new file mode 100644
index 00000000000..23c0f457584
Binary files /dev/null and b/client/ruby/flare/public/images/pie_37.png differ
diff --git a/client/ruby/flare/public/images/pie_38.png b/client/ruby/flare/public/images/pie_38.png
new file mode 100644
index 00000000000..13274cdaeb7
Binary files /dev/null and b/client/ruby/flare/public/images/pie_38.png differ
diff --git a/client/ruby/flare/public/images/pie_39.png b/client/ruby/flare/public/images/pie_39.png
new file mode 100644
index 00000000000..a52537277c9
Binary files /dev/null and b/client/ruby/flare/public/images/pie_39.png differ
diff --git a/client/ruby/flare/public/images/pie_4.png b/client/ruby/flare/public/images/pie_4.png
new file mode 100644
index 00000000000..2f9d398c548
Binary files /dev/null and b/client/ruby/flare/public/images/pie_4.png differ
diff --git a/client/ruby/flare/public/images/pie_40.png b/client/ruby/flare/public/images/pie_40.png
new file mode 100644
index 00000000000..383fa6e3fc4
Binary files /dev/null and b/client/ruby/flare/public/images/pie_40.png differ
diff --git a/client/ruby/flare/public/images/pie_41.png b/client/ruby/flare/public/images/pie_41.png
new file mode 100644
index 00000000000..80efdf8883e
Binary files /dev/null and b/client/ruby/flare/public/images/pie_41.png differ
diff --git a/client/ruby/flare/public/images/pie_42.png b/client/ruby/flare/public/images/pie_42.png
new file mode 100644
index 00000000000..cc3620de730
Binary files /dev/null and b/client/ruby/flare/public/images/pie_42.png differ
diff --git a/client/ruby/flare/public/images/pie_43.png b/client/ruby/flare/public/images/pie_43.png
new file mode 100644
index 00000000000..fa332e96ead
Binary files /dev/null and b/client/ruby/flare/public/images/pie_43.png differ
diff --git a/client/ruby/flare/public/images/pie_44.png b/client/ruby/flare/public/images/pie_44.png
new file mode 100644
index 00000000000..eaec4076297
Binary files /dev/null and b/client/ruby/flare/public/images/pie_44.png differ
diff --git a/client/ruby/flare/public/images/pie_45.png b/client/ruby/flare/public/images/pie_45.png
new file mode 100644
index 00000000000..fcf240f75d6
Binary files /dev/null and b/client/ruby/flare/public/images/pie_45.png differ
diff --git a/client/ruby/flare/public/images/pie_46.png b/client/ruby/flare/public/images/pie_46.png
new file mode 100644
index 00000000000..53c40dafc7f
Binary files /dev/null and b/client/ruby/flare/public/images/pie_46.png differ
diff --git a/client/ruby/flare/public/images/pie_47.png b/client/ruby/flare/public/images/pie_47.png
new file mode 100644
index 00000000000..20ef29f3a46
Binary files /dev/null and b/client/ruby/flare/public/images/pie_47.png differ
diff --git a/client/ruby/flare/public/images/pie_48.png b/client/ruby/flare/public/images/pie_48.png
new file mode 100644
index 00000000000..b1bdd5dfd55
Binary files /dev/null and b/client/ruby/flare/public/images/pie_48.png differ
diff --git a/client/ruby/flare/public/images/pie_49.png b/client/ruby/flare/public/images/pie_49.png
new file mode 100644
index 00000000000..c3ab8d17565
Binary files /dev/null and b/client/ruby/flare/public/images/pie_49.png differ
diff --git a/client/ruby/flare/public/images/pie_5.png b/client/ruby/flare/public/images/pie_5.png
new file mode 100644
index 00000000000..9a2eb7caa86
Binary files /dev/null and b/client/ruby/flare/public/images/pie_5.png differ
diff --git a/client/ruby/flare/public/images/pie_50.png b/client/ruby/flare/public/images/pie_50.png
new file mode 100644
index 00000000000..58e9e8067a9
Binary files /dev/null and b/client/ruby/flare/public/images/pie_50.png differ
diff --git a/client/ruby/flare/public/images/pie_51.png b/client/ruby/flare/public/images/pie_51.png
new file mode 100644
index 00000000000..cc693d6f140
Binary files /dev/null and b/client/ruby/flare/public/images/pie_51.png differ
diff --git a/client/ruby/flare/public/images/pie_52.png b/client/ruby/flare/public/images/pie_52.png
new file mode 100644
index 00000000000..88141ab827e
Binary files /dev/null and b/client/ruby/flare/public/images/pie_52.png differ
diff --git a/client/ruby/flare/public/images/pie_53.png b/client/ruby/flare/public/images/pie_53.png
new file mode 100644
index 00000000000..36c3d6dc4e2
Binary files /dev/null and b/client/ruby/flare/public/images/pie_53.png differ
diff --git a/client/ruby/flare/public/images/pie_54.png b/client/ruby/flare/public/images/pie_54.png
new file mode 100644
index 00000000000..9b44cef8c4e
Binary files /dev/null and b/client/ruby/flare/public/images/pie_54.png differ
diff --git a/client/ruby/flare/public/images/pie_55.png b/client/ruby/flare/public/images/pie_55.png
new file mode 100644
index 00000000000..23cb1cbc424
Binary files /dev/null and b/client/ruby/flare/public/images/pie_55.png differ
diff --git a/client/ruby/flare/public/images/pie_56.png b/client/ruby/flare/public/images/pie_56.png
new file mode 100644
index 00000000000..f264f08091d
Binary files /dev/null and b/client/ruby/flare/public/images/pie_56.png differ
diff --git a/client/ruby/flare/public/images/pie_57.png b/client/ruby/flare/public/images/pie_57.png
new file mode 100644
index 00000000000..389c20b9d59
Binary files /dev/null and b/client/ruby/flare/public/images/pie_57.png differ
diff --git a/client/ruby/flare/public/images/pie_58.png b/client/ruby/flare/public/images/pie_58.png
new file mode 100644
index 00000000000..2d7a6de9971
Binary files /dev/null and b/client/ruby/flare/public/images/pie_58.png differ
diff --git a/client/ruby/flare/public/images/pie_59.png b/client/ruby/flare/public/images/pie_59.png
new file mode 100644
index 00000000000..3d8f64eda81
Binary files /dev/null and b/client/ruby/flare/public/images/pie_59.png differ
diff --git a/client/ruby/flare/public/images/pie_6.png b/client/ruby/flare/public/images/pie_6.png
new file mode 100644
index 00000000000..58a682f18bf
Binary files /dev/null and b/client/ruby/flare/public/images/pie_6.png differ
diff --git a/client/ruby/flare/public/images/pie_60.png b/client/ruby/flare/public/images/pie_60.png
new file mode 100644
index 00000000000..b81032302e9
Binary files /dev/null and b/client/ruby/flare/public/images/pie_60.png differ
diff --git a/client/ruby/flare/public/images/pie_61.png b/client/ruby/flare/public/images/pie_61.png
new file mode 100644
index 00000000000..ef3e61a2fb4
Binary files /dev/null and b/client/ruby/flare/public/images/pie_61.png differ
diff --git a/client/ruby/flare/public/images/pie_62.png b/client/ruby/flare/public/images/pie_62.png
new file mode 100644
index 00000000000..93e5e2e324b
Binary files /dev/null and b/client/ruby/flare/public/images/pie_62.png differ
diff --git a/client/ruby/flare/public/images/pie_63.png b/client/ruby/flare/public/images/pie_63.png
new file mode 100644
index 00000000000..94e981df777
Binary files /dev/null and b/client/ruby/flare/public/images/pie_63.png differ
diff --git a/client/ruby/flare/public/images/pie_64.png b/client/ruby/flare/public/images/pie_64.png
new file mode 100644
index 00000000000..6b745163566
Binary files /dev/null and b/client/ruby/flare/public/images/pie_64.png differ
diff --git a/client/ruby/flare/public/images/pie_65.png b/client/ruby/flare/public/images/pie_65.png
new file mode 100644
index 00000000000..2d2ff885e7c
Binary files /dev/null and b/client/ruby/flare/public/images/pie_65.png differ
diff --git a/client/ruby/flare/public/images/pie_66.png b/client/ruby/flare/public/images/pie_66.png
new file mode 100644
index 00000000000..8180fb7373c
Binary files /dev/null and b/client/ruby/flare/public/images/pie_66.png differ
diff --git a/client/ruby/flare/public/images/pie_67.png b/client/ruby/flare/public/images/pie_67.png
new file mode 100644
index 00000000000..36224239f98
Binary files /dev/null and b/client/ruby/flare/public/images/pie_67.png differ
diff --git a/client/ruby/flare/public/images/pie_68.png b/client/ruby/flare/public/images/pie_68.png
new file mode 100644
index 00000000000..d377737a0b1
Binary files /dev/null and b/client/ruby/flare/public/images/pie_68.png differ
diff --git a/client/ruby/flare/public/images/pie_69.png b/client/ruby/flare/public/images/pie_69.png
new file mode 100644
index 00000000000..626f6bc228a
Binary files /dev/null and b/client/ruby/flare/public/images/pie_69.png differ
diff --git a/client/ruby/flare/public/images/pie_7.png b/client/ruby/flare/public/images/pie_7.png
new file mode 100644
index 00000000000..08a3918748a
Binary files /dev/null and b/client/ruby/flare/public/images/pie_7.png differ
diff --git a/client/ruby/flare/public/images/pie_70.png b/client/ruby/flare/public/images/pie_70.png
new file mode 100644
index 00000000000..972350e1dce
Binary files /dev/null and b/client/ruby/flare/public/images/pie_70.png differ
diff --git a/client/ruby/flare/public/images/pie_71.png b/client/ruby/flare/public/images/pie_71.png
new file mode 100644
index 00000000000..6066ef6199f
Binary files /dev/null and b/client/ruby/flare/public/images/pie_71.png differ
diff --git a/client/ruby/flare/public/images/pie_72.png b/client/ruby/flare/public/images/pie_72.png
new file mode 100644
index 00000000000..d351a43e2de
Binary files /dev/null and b/client/ruby/flare/public/images/pie_72.png differ
diff --git a/client/ruby/flare/public/images/pie_73.png b/client/ruby/flare/public/images/pie_73.png
new file mode 100644
index 00000000000..f32c7715347
Binary files /dev/null and b/client/ruby/flare/public/images/pie_73.png differ
diff --git a/client/ruby/flare/public/images/pie_74.png b/client/ruby/flare/public/images/pie_74.png
new file mode 100644
index 00000000000..6e5ebc60bb4
Binary files /dev/null and b/client/ruby/flare/public/images/pie_74.png differ
diff --git a/client/ruby/flare/public/images/pie_75.png b/client/ruby/flare/public/images/pie_75.png
new file mode 100644
index 00000000000..a1e5134254f
Binary files /dev/null and b/client/ruby/flare/public/images/pie_75.png differ
diff --git a/client/ruby/flare/public/images/pie_76.png b/client/ruby/flare/public/images/pie_76.png
new file mode 100644
index 00000000000..59ba9b8915d
Binary files /dev/null and b/client/ruby/flare/public/images/pie_76.png differ
diff --git a/client/ruby/flare/public/images/pie_77.png b/client/ruby/flare/public/images/pie_77.png
new file mode 100644
index 00000000000..158773252b2
Binary files /dev/null and b/client/ruby/flare/public/images/pie_77.png differ
diff --git a/client/ruby/flare/public/images/pie_78.png b/client/ruby/flare/public/images/pie_78.png
new file mode 100644
index 00000000000..b5dcb9f68a6
Binary files /dev/null and b/client/ruby/flare/public/images/pie_78.png differ
diff --git a/client/ruby/flare/public/images/pie_79.png b/client/ruby/flare/public/images/pie_79.png
new file mode 100644
index 00000000000..dee07a1227e
Binary files /dev/null and b/client/ruby/flare/public/images/pie_79.png differ
diff --git a/client/ruby/flare/public/images/pie_8.png b/client/ruby/flare/public/images/pie_8.png
new file mode 100644
index 00000000000..a3cd65d59b3
Binary files /dev/null and b/client/ruby/flare/public/images/pie_8.png differ
diff --git a/client/ruby/flare/public/images/pie_80.png b/client/ruby/flare/public/images/pie_80.png
new file mode 100644
index 00000000000..bc3936e5c04
Binary files /dev/null and b/client/ruby/flare/public/images/pie_80.png differ
diff --git a/client/ruby/flare/public/images/pie_81.png b/client/ruby/flare/public/images/pie_81.png
new file mode 100644
index 00000000000..ddd79f44dfc
Binary files /dev/null and b/client/ruby/flare/public/images/pie_81.png differ
diff --git a/client/ruby/flare/public/images/pie_82.png b/client/ruby/flare/public/images/pie_82.png
new file mode 100644
index 00000000000..b00752cc338
Binary files /dev/null and b/client/ruby/flare/public/images/pie_82.png differ
diff --git a/client/ruby/flare/public/images/pie_83.png b/client/ruby/flare/public/images/pie_83.png
new file mode 100644
index 00000000000..c8eb31d5206
Binary files /dev/null and b/client/ruby/flare/public/images/pie_83.png differ
diff --git a/client/ruby/flare/public/images/pie_84.png b/client/ruby/flare/public/images/pie_84.png
new file mode 100644
index 00000000000..0e55462bf32
Binary files /dev/null and b/client/ruby/flare/public/images/pie_84.png differ
diff --git a/client/ruby/flare/public/images/pie_85.png b/client/ruby/flare/public/images/pie_85.png
new file mode 100644
index 00000000000..f770bdfe9f2
Binary files /dev/null and b/client/ruby/flare/public/images/pie_85.png differ
diff --git a/client/ruby/flare/public/images/pie_86.png b/client/ruby/flare/public/images/pie_86.png
new file mode 100644
index 00000000000..f2d9635fbd5
Binary files /dev/null and b/client/ruby/flare/public/images/pie_86.png differ
diff --git a/client/ruby/flare/public/images/pie_87.png b/client/ruby/flare/public/images/pie_87.png
new file mode 100644
index 00000000000..5a9a47c94d8
Binary files /dev/null and b/client/ruby/flare/public/images/pie_87.png differ
diff --git a/client/ruby/flare/public/images/pie_88.png b/client/ruby/flare/public/images/pie_88.png
new file mode 100644
index 00000000000..df05c249f4d
Binary files /dev/null and b/client/ruby/flare/public/images/pie_88.png differ
diff --git a/client/ruby/flare/public/images/pie_89.png b/client/ruby/flare/public/images/pie_89.png
new file mode 100644
index 00000000000..75ee881f226
Binary files /dev/null and b/client/ruby/flare/public/images/pie_89.png differ
diff --git a/client/ruby/flare/public/images/pie_9.png b/client/ruby/flare/public/images/pie_9.png
new file mode 100644
index 00000000000..d181bd26b03
Binary files /dev/null and b/client/ruby/flare/public/images/pie_9.png differ
diff --git a/client/ruby/flare/public/images/pie_90.png b/client/ruby/flare/public/images/pie_90.png
new file mode 100644
index 00000000000..b5db8c33b39
Binary files /dev/null and b/client/ruby/flare/public/images/pie_90.png differ
diff --git a/client/ruby/flare/public/images/pie_91.png b/client/ruby/flare/public/images/pie_91.png
new file mode 100644
index 00000000000..6c3a86d7ac0
Binary files /dev/null and b/client/ruby/flare/public/images/pie_91.png differ
diff --git a/client/ruby/flare/public/images/pie_92.png b/client/ruby/flare/public/images/pie_92.png
new file mode 100644
index 00000000000..12f4695a56d
Binary files /dev/null and b/client/ruby/flare/public/images/pie_92.png differ
diff --git a/client/ruby/flare/public/images/pie_93.png b/client/ruby/flare/public/images/pie_93.png
new file mode 100644
index 00000000000..9f3f11769d6
Binary files /dev/null and b/client/ruby/flare/public/images/pie_93.png differ
diff --git a/client/ruby/flare/public/images/pie_94.png b/client/ruby/flare/public/images/pie_94.png
new file mode 100644
index 00000000000..229cbc88001
Binary files /dev/null and b/client/ruby/flare/public/images/pie_94.png differ
diff --git a/client/ruby/flare/public/images/pie_95.png b/client/ruby/flare/public/images/pie_95.png
new file mode 100644
index 00000000000..3efb986e309
Binary files /dev/null and b/client/ruby/flare/public/images/pie_95.png differ
diff --git a/client/ruby/flare/public/images/pie_96.png b/client/ruby/flare/public/images/pie_96.png
new file mode 100644
index 00000000000..11405007ed3
Binary files /dev/null and b/client/ruby/flare/public/images/pie_96.png differ
diff --git a/client/ruby/flare/public/images/pie_97.png b/client/ruby/flare/public/images/pie_97.png
new file mode 100644
index 00000000000..31e79c47675
Binary files /dev/null and b/client/ruby/flare/public/images/pie_97.png differ
diff --git a/client/ruby/flare/public/images/pie_98.png b/client/ruby/flare/public/images/pie_98.png
new file mode 100644
index 00000000000..bd15f032475
Binary files /dev/null and b/client/ruby/flare/public/images/pie_98.png differ
diff --git a/client/ruby/flare/public/images/pie_99.png b/client/ruby/flare/public/images/pie_99.png
new file mode 100644
index 00000000000..3410c820909
Binary files /dev/null and b/client/ruby/flare/public/images/pie_99.png differ
diff --git a/client/ruby/flare/script/pie.rb b/client/ruby/flare/script/pie.rb
new file mode 100755
index 00000000000..44991459873
--- /dev/null
+++ b/client/ruby/flare/script/pie.rb
@@ -0,0 +1,25 @@
+#!/usr/bin/env ruby
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+require 'rubygems'
+require 'sparklines'
+
+0.upto(100) do |i|
+ Sparklines.plot_to_file("public/images/pie_#{i}.png",
+ [i], :type => 'pie',
+ :share_color => "blue"
+ # :remain_color => "#dcdcdc", :background_color => "#ededed"
+ )
+end
+
+
diff --git a/client/ruby/flare/vendor/plugins/sparklines/MIT-LICENSE b/client/ruby/flare/vendor/plugins/sparklines/MIT-LICENSE
deleted file mode 100644
index 8d1b480afff..00000000000
--- a/client/ruby/flare/vendor/plugins/sparklines/MIT-LICENSE
+++ /dev/null
@@ -1,20 +0,0 @@
-Copyright (c) 2006 Geoffrey Grosenbach
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/client/ruby/flare/vendor/plugins/sparklines/README b/client/ruby/flare/vendor/plugins/sparklines/README
deleted file mode 100644
index 800b508beff..00000000000
--- a/client/ruby/flare/vendor/plugins/sparklines/README
+++ /dev/null
@@ -1,15 +0,0 @@
-== Sparklines Plugin
-
-Make tiny graphs.
-
-Also has a "sparklines" generator for copying a controller and functional test to your app.
-
- ./script/generate sparklines
-
-See examples at http://nubyonrails.com/pages/sparklines
-
-== Author
-
-Geoffrey Grosenbach [email protected] http://nubyonrails.com
-
-
diff --git a/client/ruby/flare/vendor/plugins/sparklines/Rakefile b/client/ruby/flare/vendor/plugins/sparklines/Rakefile
deleted file mode 100644
index d3456e4d602..00000000000
--- a/client/ruby/flare/vendor/plugins/sparklines/Rakefile
+++ /dev/null
@@ -1,23 +0,0 @@
-require 'rake'
-require 'rake/testtask'
-require 'rake/rdoctask'
-
-desc 'Default: run unit tests.'
-task :default => :test
-
-desc 'Test the plugin.'
-Rake::TestTask.new(:test) do |t|
- t.libs << 'lib'
- t.pattern = 'test/**/test_*.rb'
- t.verbose = true
-end
-
-desc 'Generate documentation for the plugin.'
-Rake::RDocTask.new(:rdoc) do |rdoc|
- rdoc.rdoc_dir = 'rdoc'
- rdoc.title = 'CalendarHelper'
- rdoc.options << '--line-numbers' << '--inline-source'
- rdoc.rdoc_files.include('README')
- rdoc.rdoc_files.include('lib/**/*.rb')
-end
-
diff --git a/client/ruby/flare/vendor/plugins/sparklines/about.yml b/client/ruby/flare/vendor/plugins/sparklines/about.yml
deleted file mode 100644
index f018110da10..00000000000
--- a/client/ruby/flare/vendor/plugins/sparklines/about.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-author: topfunky
-summary: A library for making small graphs, a la Edward Tufte. A generator and helper are also included.
-homepage: http://nubyonrails.com/pages/sparklines
-plugin: http://topfunky.net/svn/plugins/sparklines
-license: MIT
-version: 0.4.0
-rails_version: 1.1+
diff --git a/client/ruby/flare/vendor/plugins/sparklines/generators/sparklines/sparklines_generator.rb b/client/ruby/flare/vendor/plugins/sparklines/generators/sparklines/sparklines_generator.rb
deleted file mode 100644
index 40e8daedafe..00000000000
--- a/client/ruby/flare/vendor/plugins/sparklines/generators/sparklines/sparklines_generator.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-class SparklinesGenerator < Rails::Generator::Base
-
- def manifest
- record do |m|
- m.directory File.join("app/controllers")
- m.directory File.join("test/functional")
-
- m.file "controller.rb", File.join("app/controllers/sparklines_controller.rb")
- m.file "functional_test.rb", File.join("test/functional/sparklines_controller_test.rb")
- end
- end
-
-end
diff --git a/client/ruby/flare/vendor/plugins/sparklines/generators/sparklines/templates/controller.rb b/client/ruby/flare/vendor/plugins/sparklines/generators/sparklines/templates/controller.rb
deleted file mode 100644
index 1c69f290525..00000000000
--- a/client/ruby/flare/vendor/plugins/sparklines/generators/sparklines/templates/controller.rb
+++ /dev/null
@@ -1,40 +0,0 @@
-class SparklinesController < ApplicationController
-
- # Handles requests for sparkline graphs from views.
- #
- # Params are generated by the sparkline_tag helper method.
- #
- def index
- # Make array from comma-delimited list of data values
- ary = []
- if params.has_key?('results') && !params['results'].nil?
- params['results'].split(',').each do |s|
- ary << s.to_i
- end
- end
-
- send_data( Sparklines.plot( ary, params ),
- :disposition => 'inline',
- :type => 'image/png',
- :filename => "spark_#{params[:type]}.png" )
- end
-
-
- # Use this type of method for sparklines that can be cached. (Doesn't work with the helper.)
- #
- # To make caching easier, add a line like this to config/routes.rb:
- # map.sparklines "sparklines/:action/:id/image.png", :controller => "sparklines"
- #
- # Then reference it with the named route:
- # image_tag sparklines_url(:action => 'show', :id => 42)
- def show
- send_data(Sparklines.plot(
- [42, 37, 89, 74, 70, 50, 40, 30, 40, 50],
- :type => 'bar', :above_color => 'orange'
- ),
- :disposition => 'inline',
- :type => 'image/png',
- :filename => "sparkline.png")
- end
-
-end
diff --git a/client/ruby/flare/vendor/plugins/sparklines/generators/sparklines/templates/functional_test.rb b/client/ruby/flare/vendor/plugins/sparklines/generators/sparklines/templates/functional_test.rb
deleted file mode 100644
index 7d58be406d8..00000000000
--- a/client/ruby/flare/vendor/plugins/sparklines/generators/sparklines/templates/functional_test.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-require File.dirname(__FILE__) + '/../test_helper'
-require 'sparklines_controller'
-
-# Re-raise errors caught by the controller.
-class SparklinesController; def rescue_action(e) raise e end; end
-
-class SparklinesControllerTest < Test::Unit::TestCase
-
- #fixtures :data
-
- def setup
- @controller = SparklinesController.new
- @request = ActionController::TestRequest.new
- @response = ActionController::TestResponse.new
- end
-
- def test_index
- get :index, :results => "1,2,3,4,5", :type => 'bar', :line_color => 'black'
- assert_response :success
- assert_equal 'image/png', @response.headers['Content-Type']
- end
-
- # TODO Replace this with your actual tests
- def test_show
- get :show
- assert_response :success
- assert_equal 'image/png', @response.headers['Content-Type']
- end
-
-end
diff --git a/client/ruby/flare/vendor/plugins/sparklines/init.rb b/client/ruby/flare/vendor/plugins/sparklines/init.rb
deleted file mode 100644
index c9c2349628b..00000000000
--- a/client/ruby/flare/vendor/plugins/sparklines/init.rb
+++ /dev/null
@@ -1 +0,0 @@
-ActionView::Base.send :include, SparklinesHelper
diff --git a/client/ruby/flare/vendor/plugins/sparklines/lib/sparklines.rb b/client/ruby/flare/vendor/plugins/sparklines/lib/sparklines.rb
deleted file mode 100644
index 4c4e2de094e..00000000000
--- a/client/ruby/flare/vendor/plugins/sparklines/lib/sparklines.rb
+++ /dev/null
@@ -1,582 +0,0 @@
-
-require 'rubygems'
-require 'RMagick'
-
-=begin rdoc
-
-A library for generating small unmarked graphs (sparklines).
-
-Can be used to write an image to a file or make a web service with Rails or other Ruby CGI apps.
-
-Idea and much of the outline for the source lifted directly from {Joe Gregorio's Python Sparklines web service script}[http://bitworking.org/projects/sparklines].
-
-Requires the RMagick image library.
-
-==Authors
-
-{Dan Nugent}[mailto:[email protected]] Original port from Python Sparklines library.
-
-{Geoffrey Grosenbach}[mailto:[email protected]] -- http://nubyonrails.topfunky.com
--- Conversion to module and further maintenance.
-
-==General Usage and Defaults
-
-To use in a script:
-
- require 'rubygems'
- require 'sparklines'
- Sparklines.plot([1,25,33,46,89,90,85,77,42],
- :type => 'discrete',
- :height => 20)
-
-An image blob will be returned which you can print, write to STDOUT, etc.
-
-For use with Ruby on Rails, see the sparklines plugin:
-
- http://nubyonrails.com/pages/sparklines
-
-In your view, call it like this:
-
- <%= sparkline_tag [1,2,3,4,5,6] %>
-
-Or specify details:
-
- <%= sparkline_tag [1,2,3,4,5,6],
- :type => 'discrete',
- :height => 10,
- :upper => 80,
- :above_color => 'green',
- :below_color => 'blue' %>
-
-Graph types:
-
- area
- discrete
- pie
- smooth
- bar
- whisker
-
-General Defaults:
-
- :type => 'smooth'
- :height => 14px
- :upper => 50
- :above_color => 'red'
- :below_color => 'grey'
- :background_color => 'white'
- :line_color => 'lightgrey'
-
-==License
-
-Licensed under the MIT license.
-
-=end
-class Sparklines
-
- VERSION = '0.4.1'
-
- @@label_margin = 5.0
- @@pointsize = 10.0
-
- class << self
-
- # Does the actual plotting of the graph.
- # Calls the appropriate subclass based on the :type argument.
- # Defaults to 'smooth'
- def plot(data=[], options={})
- defaults = {
- :type => 'smooth',
- :height => 14,
- :upper => 50,
- :diameter => 20,
- :step => 2,
- :line_color => 'lightgrey',
-
- :above_color => 'red',
- :below_color => 'grey',
- :background_color => 'white',
- :share_color => 'red',
- :remain_color => 'lightgrey',
- :min_color => 'blue',
- :max_color => 'green',
- :last_color => 'red',
-
- :has_min => false,
- :has_max => false,
- :has_last => false,
-
- :label => nil
- }
-
- # HACK for HashWithIndifferentAccess
- options_sym = Hash.new
- options.keys.each do |key|
- options_sym[key.to_sym] = options[key]
- end
-
- options_sym = defaults.merge(options_sym)
-
- # Call the appropriate method for actual plotting.
- sparkline = self.new(data, options_sym)
- if %w(area bar pie smooth discrete whisker).include? options_sym[:type]
- sparkline.send options_sym[:type]
- else
- sparkline.plot_error options_sym
- end
- end
-
- # Writes a graph to disk with the specified filename, or "sparklines.png"
- def plot_to_file(filename="sparklines.png", data=[], options={})
- File.open( filename, 'wb' ) do |png|
- png << self.plot( data, options)
- end
- end
-
- end # class methods
-
- def initialize(data=[], options={})
- @data = Array(data)
- @options = options
- normalize_data
- end
-
- ##
- # Creates a continuous area sparkline. Relevant options.
- #
- # :step - An integer that determines the distance between each point on the sparkline. Defaults to 2.
- #
- # :height - An integer that determines what the height of the sparkline will be. Defaults to 14
- #
- # :upper - An integer that determines the threshold for colorization purposes. Any value less than upper will be colored using below_color, anything above and equal to upper will use above_color. Defaults to 50.
- #
- # :has_min - Determines whether a dot will be drawn at the lowest value or not. Defaults to false.
- #
- # :has_max - Determines whether a dot will be drawn at the highest value or not. Defaults to false.
- #
- # :has_last - Determines whether a dot will be drawn at the last value or not. Defaults to false.
- #
- # :min_color - A string or color code representing the color that the dot drawn at the smallest value will be displayed as. Defaults to blue.
- #
- # :max_color - A string or color code representing the color that the dot drawn at the largest value will be displayed as. Defaults to green.
- #
- # :last_color - A string or color code representing the color that the dot drawn at the last value will be displayed as. Defaults to red.
- #
- # :above_color - A string or color code representing the color to draw values above or equal the upper value. Defaults to red.
- #
- # :below_color - A string or color code representing the color to draw values below the upper value. Defaults to gray.
-
- def area
-
- step = @options[:step].to_i
- height = @options[:height].to_i
- background_color = @options[:background_color]
-
- create_canvas((@norm_data.size - 1) * step + 4, height, background_color)
-
- upper = @options[:upper].to_i
-
- has_min = @options[:has_min]
- has_max = @options[:has_max]
- has_last = @options[:has_last]
-
- min_color = @options[:min_color]
- max_color = @options[:max_color]
- last_color = @options[:last_color]
- below_color = @options[:below_color]
- above_color = @options[:above_color]
-
-
- coords = [[0,(height - 3 - upper/(101.0/(height-4)))]]
- i=0
- @norm_data.each do |r|
- coords.push [(2 + i), (height - 3 - r/(101.0/(height-4)))]
- i += step
- end
- coords.push [(@norm_data.size - 1) * step + 4, (height - 3 - upper/(101.0/(height-4)))]
-
- # TODO Refactor! Should take a block and do both.
- #
- # Block off the bottom half of the image and draw the sparkline
- @draw.fill(above_color)
- @draw.define_clip_path('top') do
- @draw.rectangle(0,0,(@norm_data.size - 1) * step + 4,(height - 3 - upper/(101.0/(height-4))))
- end
- @draw.clip_path('top')
- @draw.polygon *coords.flatten
-
- # Block off the top half of the image and draw the sparkline
- @draw.fill(below_color)
- @draw.define_clip_path('bottom') do
- @draw.rectangle(0,(height - 3 - upper/(101.0/(height-4))),(@norm_data.size - 1) * step + 4,height)
- end
- @draw.clip_path('bottom')
- @draw.polygon *coords.flatten
-
- # The sparkline looks kinda nasty if either the above_color or below_color gets the center line
- @draw.fill('black')
- @draw.line(0,(height - 3 - upper/(101.0/(height-4))),(@norm_data.size - 1) * step + 4,(height - 3 - upper/(101.0/(height-4))))
-
- # After the parts have been masked, we need to let the whole canvas be drawable again
- # so a max dot can be displayed
- @draw.define_clip_path('all') do
- @draw.rectangle(0,0,@canvas.columns,@canvas.rows)
- end
- @draw.clip_path('all')
-
- drawbox(coords[@norm_data.index(@norm_data.min)+1], 1, min_color) if has_min == true
- drawbox(coords[@norm_data.index(@norm_data.max)+1], 1, max_color) if has_max == true
-
- drawbox(coords[-2], 1, last_color) if has_last == true
-
- @draw.draw(@canvas)
- @canvas.to_blob
- end
-
- ##
- # A bar graph.
-
- def bar
- step = @options[:step].to_i
- height = @options[:height].to_f
- background_color = @options[:background_color]
-
- create_canvas(@norm_data.length * step + 2, height, background_color)
-
- upper = @options[:upper].to_i
- below_color = @options[:below_color]
- above_color = @options[:above_color]
-
- i = 1
- @norm_data.each_with_index do |r, index|
- color = (r >= upper) ? above_color : below_color
- @draw.stroke('transparent')
- @draw.fill(color)
- @draw.rectangle( i, @canvas.rows,
- i + step - 2, @canvas.rows - ( (r / @maximum_value) * @canvas.rows) )
- i += step
- end
-
- @draw.draw(@canvas)
- @canvas.to_blob
- end
-
-
- ##
- # Creates a discretized sparkline
- #
- # :height - An integer that determines what the height of the sparkline will be. Defaults to 14
- #
- # :upper - An integer that determines the threshold for colorization purposes. Any value less than upper will be colored using below_color, anything above and equal to upper will use above_color. Defaults to 50.
- #
- # :above_color - A string or color code representing the color to draw values above or equal the upper value. Defaults to red.
- #
- # :below_color - A string or color code representing the color to draw values below the upper value. Defaults to gray.
-
- def discrete
-
- height = @options[:height].to_i
- upper = @options[:upper].to_i
- background_color = @options[:background_color]
- step = @options[:step].to_i
-
- create_canvas(@norm_data.size * step - 1, height, background_color)
-
- below_color = @options[:below_color]
- above_color = @options[:above_color]
-
- i = 0
- @norm_data.each do |r|
- color = (r >= upper) ? above_color : below_color
- @draw.stroke(color)
- @draw.line(i, (@canvas.rows - r/(101.0/(height-4))-4).to_i,
- i, (@canvas.rows - r/(101.0/(height-4))).to_i)
- i += step
- end
-
- @draw.draw(@canvas)
- @canvas.to_blob
- end
-
-
- ##
- # Creates a pie-chart sparkline
- #
- # :diameter - An integer that determines what the size of the sparkline will be. Defaults to 20
- #
- # :share_color - A string or color code representing the color to draw the share of the pie represented by percent. Defaults to red.
- #
- # :remain_color - A string or color code representing the color to draw the pie not taken by the share color. Defaults to lightgrey.
-
- def pie
- diameter = @options[:diameter].to_i
- background_color = @options[:background_color]
-
- create_canvas(diameter, diameter, background_color)
-
- share_color = @options[:share_color]
- remain_color = @options[:remain_color]
- percent = @norm_data[0]
-
- # Adjust the radius so there's some edge left in the pie
- r = diameter/2.0 - 2
- @draw.fill(remain_color)
- @draw.ellipse(r + 2, r + 2, r , r , 0, 360)
- @draw.fill(share_color)
-
- # Special exceptions
- if percent == 0
- # For 0% return blank
- @draw.draw(@canvas)
- return @canvas.to_blob
- elsif percent == 100
- # For 100% just draw a full circle
- @draw.ellipse(r + 2, r + 2, r , r , 0, 360)
- @draw.draw(@canvas)
- return @canvas.to_blob
- end
-
- # Okay, this part is as confusing as hell, so pay attention:
- # This line determines the horizontal portion of the point on the circle where the X-Axis
- # should end. It's caculated by taking the center of the on-image circle and adding that
- # to the radius multiplied by the formula for determinig the point on a unit circle that a
- # angle corresponds to. 3.6 * percent gives us that angle, but it's in degrees, so we need to
- # convert, hence the muliplication by Pi over 180
- arc_end_x = r + 2 + (r * Math.cos((3.6 * percent)*(Math::PI/180)))
-
- # The same goes for here, except it's the vertical point instead of the horizontal one
- arc_end_y = r + 2 + (r * Math.sin((3.6 * percent)*(Math::PI/180)))
-
- # Because the SVG path format is seriously screwy, we need to set the large-arc-flag to 1
- # if the angle of an arc is greater than 180 degrees. I have no idea why this is, but it is.
- percent > 50? large_arc_flag = 1: large_arc_flag = 0
-
- # This is also confusing
- # M tells us to move to an absolute point on the image. We're moving to the center of the pie
- # h tells us to move to a relative point. We're moving to the right edge of the circle.
- # A tells us to start an absolute elliptical arc. The first two values are the radii of the ellipse
- # the third value is the x-axis-rotation (how to rotate the ellipse if we wanted to [could have some fun
- # with randomizing that maybe), the fourth value is our large-arc-flag, the fifth is the sweep-flag,
- # (again, confusing), the sixth and seventh values are the end point of the arc which we calculated previously
- # More info on the SVG path string format at: http://www.w3.org/TR/SVG/paths.html
- path = "M#{r + 2},#{r + 2} h#{r} A#{r},#{r} 0 #{large_arc_flag},1 #{arc_end_x},#{arc_end_y} z"
- @draw.path(path)
-
- @draw.draw(@canvas)
- @canvas.to_blob
- end
-
-
- ##
- # Creates a smooth sparkline.
- #
- # :step - An integer that determines the distance between each point on the sparkline. Defaults to 2.
- #
- # :height - An integer that determines what the height of the sparkline will be. Defaults to 14
- #
- # :has_min - Determines whether a dot will be drawn at the lowest value or not. Defaults to false.
- #
- # :has_max - Determines whether a dot will be drawn at the highest value or not. Defaults to false.
- #
- # :has_last - Determines whether a dot will be drawn at the last value or not. Defaults to false.
- #
- # :min_color - A string or color code representing the color that the dot drawn at the smallest value will be displayed as. Defaults to blue.
- #
- # :max_color - A string or color code representing the color that the dot drawn at the largest value will be displayed as. Defaults to green.
- #
- # :last_color - A string or color code representing the color that the dot drawn at the last value will be displayed as. Defaults to red.
-
- def smooth
-
- step = @options[:step].to_i
- height = @options[:height].to_i
- background_color = @options[:background_color]
-
- create_canvas((@norm_data.size - 1) * step + 4, height, background_color)
-
- min_color = @options[:min_color]
- max_color = @options[:max_color]
- last_color = @options[:last_color]
- has_min = @options[:has_min]
- has_max = @options[:has_max]
- has_last = @options[:has_last]
- line_color = @options[:line_color]
-
- @draw.stroke(line_color)
- coords = []
- i=0
- @norm_data.each do |r|
- coords.push [ 2 + i, (height - 3 - r/(101.0/(height-4))) ]
- i += step
- end
-
- open_ended_polyline(coords)
-
- drawbox(coords[@norm_data.index(@norm_data.min)], 2, min_color) if has_min == true
-
- drawbox(coords[@norm_data.index(@norm_data.max)], 2, max_color) if has_max == true
-
- drawbox(coords[-1], 2, last_color) if has_last == true
-
- @draw.draw(@canvas)
- @canvas.to_blob
- end
-
-
- ##
- # Creates a whisker sparkline to track on/off type data. There are five states:
- # on, off, no value, exceptional on, exceptional off. On values create an up
- # whisker and off values create a down whisker. Exceptional values may be
- # colored differently than regular values to indicate, for example, a shut out.
- # No value produces an empty row to indicate a tie.
- #
- # * results - an array of integer values between -2 and 2. -2 is exceptional
- # down, 1 is regular down, 0 is no value, 1 is up, and 2 is exceptional up.
- # * options - a hash that takes parameters
- #
- # :height - height of the sparkline
- #
- # :whisker_color - the color of regular whiskers; defaults to black
- #
- # :exception_color - the color of exceptional whiskers; defaults to red
-
- def whisker
-
- # step = @options[:step].to_i
- height = @options[:height].to_i
- background_color = @options[:background_color]
-
- create_canvas((@data.size - 1) * 2, height, background_color)
-
- whisker_color = @options[:whisker_color] || 'black'
- exception_color = @options[:exception_color] || 'red'
-
- i = 0
- @data.each do |r|
- color = whisker_color
-
- if ( (r == 2 || r == -2) && exception_color )
- color = exception_color
- end
-
- y_mid_point = (r >= 1) ? (@canvas.rows/2.0 - 1).ceil : (@canvas.rows/2.0).floor
-
- y_end_point = y_mid_point
- if ( r > 0)
- y_end_point = 0
- end
-
- if ( r < 0 )
- y_end_point = @canvas.rows
- end
-
- @draw.stroke( color )
- @draw.line( i, y_mid_point, i, y_end_point )
- i += 2
- end
-
- @draw.draw(@canvas)
- @canvas.to_blob
- end
-
- ##
- # Draw the error Sparkline.
-
- def plot_error(options={})
- create_canvas(40, 15, 'white')
-
- @draw.fill('red')
- @draw.line(0,0,40,15)
- @draw.line(0,15,40,0)
-
- @draw.draw(@canvas)
- @canvas.to_blob
- end
-
-private
-
- def normalize_data
- @maximum_value = @data.max
- if @options[:type].to_s == 'pie'
- @norm_data = @data
- else
- @norm_data = @data.map { |value| value = (value.to_f / @maximum_value) * 100.0 }
- end
- end
-
- ##
- # * :arr - an array of points (represented as two element arrays)
-
- def open_ended_polyline(arr)
- 0.upto(arr.length - 2) { |i|
- @draw.line(arr[i][0], arr[i][1], arr[i+1][0], arr[i+1][1])
- }
- end
-
- ##
- # Create an image to draw on and a drawable to do the drawing with.
- #
- # TODO Refactor into smaller methods
-
- def create_canvas(w, h, bkg_col)
- @draw = Magick::Draw.new
- @draw.pointsize = @@pointsize # TODO Use height
- @canvas = Magick::Image.new(w , h) { self.background_color = bkg_col }
-
- # Make room for label and last value
- unless @options[:label].nil?
- @options[:has_last] = true
- @label_width = calculate_width(@options[:label])
- @data_last_width = calculate_width(@data.last)
- # HACK The 7.0 is a severe hack. Must figure out correct spacing
- @label_and_data_last_width = @label_width + @data_last_width + @@label_margin * 7.0
- w += @label_and_data_last_width
- end
-
- @canvas = Magick::Image.new(w , h) { self.background_color = bkg_col }
- @canvas.format = "PNG"
-
- # Draw label and last value
- unless @options[:label].nil?
- if ENV.has_key?('MAGICK_FONT_PATH')
- vera_font_path = File.expand_path('Vera.ttf', ENV['MAGICK_FONT_PATH'])
- @font = File.exists?(vera_font_path) ? vera_font_path : nil
- else
- @font = nil
- end
-
- @draw.fill = 'black'
- @draw.font = @font if @font
- @draw.gravity = Magick::WestGravity
- @draw.annotate( @canvas,
- @label_width, 1.0,
- w - @label_and_data_last_width + @@label_margin, h - calculate_caps_height/2.0,
- @options[:label])
-
- @draw.fill = 'red'
- @draw.annotate( @canvas,
- @data_last_width, 1.0,
- w - @data_last_width - @@label_margin * 2.0, h - calculate_caps_height/2.0,
- @data.last.to_s)
- end
- end
-
- ##
- # Utility to draw a coloured box
- # Centred on pt, offset off in each direction, fill color is col
-
- def drawbox(pt, offset, color)
- @draw.stroke 'transparent'
- @draw.fill(color)
- @draw.rectangle(pt[0]-offset, pt[1]-offset, pt[0]+offset, pt[1]+offset)
- end
-
- def calculate_width(text)
- @draw.get_type_metrics(@canvas, text.to_s).width
- end
-
- def calculate_caps_height
- @draw.get_type_metrics(@canvas, 'X').height
- end
-
-end
diff --git a/client/ruby/flare/vendor/plugins/sparklines/lib/sparklines_helper.rb b/client/ruby/flare/vendor/plugins/sparklines/lib/sparklines_helper.rb
deleted file mode 100644
index c8958d33995..00000000000
--- a/client/ruby/flare/vendor/plugins/sparklines/lib/sparklines_helper.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-# Provides a tag for embedding sparklines graphs into your Rails app.
-#
-module SparklinesHelper
-
- # Call with an array of data and a hash of params for the Sparklines module.
- #
- # sparkline_tag [42, 37, 43, 182], :type => 'bar', :line_color => 'black'
- #
- # You can also pass :class => 'some_css_class' ('sparkline' by default).
- def sparkline_tag(results=[], options={})
- url = { :controller => 'sparklines',
- :results => results.join(',') }
- options = url.merge(options)
-
- %(<img src="#{ url_for options }" class="#{options[:class] || 'sparkline'}" alt="Sparkline Graph" />)
- end
-
-end