gerbilcharts 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,11 +1,17 @@
1
- == 0.2.1 2009-09-15
1
+ == 0.2.2 2009-09-21
2
+ * Changes
3
+ * SVG filters specular lighting effect
4
+ * You can now specify filter => :LikeButton to all charts to buttonize
5
+ * Just a demo of the power of SVG filters applied to charting
6
+
7
+ == 0.2.1 2009-09-10
2
8
  * Changes
3
9
  * Toolip and alpha effect javascript for PIE charts
4
10
  * Accomodate wide labels on bar charts using tooltips
5
11
  * Optimize pie chart layout further
6
12
  * Fixes to stylesheet
7
13
 
8
- == 0.0.9 2009-09-10
14
+ == 0.1.9 2009-09-10
9
15
  * Changes
10
16
  * PIE Charts
11
17
  * Fixed color scheme stylesheet brushmetal.css to be more pleasing
@@ -6,16 +6,29 @@ module GerbilCharts::Charts
6
6
  #
7
7
  class PieChart < ChartBase
8
8
 
9
+
10
+
9
11
  def initialize(opt={})
10
12
  super(opt)
13
+
14
+ @gerbilfilter = opt[:filter] || ""
15
+
11
16
  end
12
17
 
13
18
  def create_chart_elements
14
19
 
15
- @thechart.create_filter(GerbilCharts::SVGDC::LinearGradientVertical.new("vertgrad","rgb(255,255,255)","rgb(224,224,224)"))
20
+ # filters if required
21
+ @thechart.create_filter(GerbilCharts::SVGDC::LinearGradientVertical.new("vertgrad",
22
+ "rgb(255,255,255)","rgb(224,224,224)"))
23
+
24
+ # additional filter by name
25
+ @thechart.create_filter(GerbilCharts::SVGDC::LikeButton.new('LikeButton')) if @gerbilfilter == 'LikeButton'
26
+
27
+
16
28
  # other elements
17
29
  @thechart.add_child(GerbilCharts::Surfaces::SurfaceBackground.new(:orient => ORIENT_OVERLAY))
18
- @thechart.add_child(GerbilCharts::Surfaces::TitlePanel.new(:orient => ORIENT_OVERLAY, :dim => 30, :just => :left))
30
+ @thechart.add_child(GerbilCharts::Surfaces::TitlePanel.new(:orient => ORIENT_OVERLAY, :dim => 30,
31
+ :just => :left))
19
32
  @thechart.add_child(GerbilCharts::Surfaces::PieSurface.new(:orient => ORIENT_OVERLAY), :anchor => true)
20
33
  end
21
34
  end
@@ -26,6 +26,12 @@ class PieSurface < Surface
26
26
  parent.modelgroup.empty_caption,{"text-anchor" => "middle"})
27
27
  return
28
28
  end
29
+
30
+
31
+ # any filters ?
32
+ if parent.get_global_option(:filter,false)
33
+ g.curr_win.add_options({:filter => "url(##{parent.get_global_option(:filter,false)})" })
34
+ end
29
35
 
30
36
  # compute totals
31
37
  y_total = 0
@@ -8,15 +8,11 @@ module GerbilCharts::SVGDC
8
8
  class Filter
9
9
 
10
10
  attr_reader :filterid
11
-
12
11
  def initialize(id,opts={})
13
12
  @filterid=id
14
13
  end
15
-
16
14
  def render(xfrag)
17
15
  end
18
-
19
-
20
16
  end
21
17
 
22
18
  # == LinearGraidentVertical
@@ -37,4 +33,36 @@ class LinearGradientVertical < Filter
37
33
 
38
34
  end
39
35
 
36
+ # == LikeButton
37
+ # uses lighting effect to create a button like effect
38
+ # * Inspired by the example in the ZVON
39
+
40
+ class LikeButton < Filter
41
+
42
+ def initialize(id,opts={})
43
+ super(id,opts)
44
+ end
45
+
46
+ def render(xfrag)
47
+ xfrag.filter(:id => 'LikeButton', :filterUnits=>'userSpaceOnUse') {
48
+ xfrag.feGaussianBlur( :in => 'SourceAlpha', :stdDeviation=> '4', :result => 'blur' )
49
+ xfrag.feSpecularLighting( :in=>"blur", :surfaceScale=>"5" , :specularConstant=>".75" ,
50
+ :specularExponent=>"20", 'lighting-color'=>"#bbbbbb", :result=>"specOut") {
51
+ xfrag.fePointLight( :x=>"-5000", :y=>"-10000", :z=>"9000")
52
+ }
53
+ xfrag.feComposite( :in=>"specOut",:in2=>"SourceAlpha",:operator=>"in",:result=>"specOut")
54
+ xfrag.feComposite( :in=>"SourceGraphic",:in2=>"specOut",:operator=>"arithmetic",
55
+ :k1=>"0",:k2=>"1",:k3=>"1", :k4=>"0", :result=>"litPaint")
56
+
57
+ xfrag.feMerge {
58
+ xfrag.feMergeNode(:in=>'litPaint')
59
+ }
60
+ }
61
+ end
62
+
63
+
64
+ end
65
+
66
+
67
+
40
68
  end
@@ -21,8 +21,8 @@ class SVGWin < SVGElement
21
21
  super()
22
22
  end
23
23
 
24
- def <<(p)
25
- @ops<<p
24
+ def << (p)
25
+ @ops << p
26
26
  end
27
27
 
28
28
  def add_transformation(t)
@@ -2,7 +2,7 @@ module GerbilCharts
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 2
5
- TINY = 1
5
+ TINY = 2
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -29,10 +29,11 @@ class TestPie < Test::Unit::TestCase
29
29
 
30
30
  mychart = GerbilCharts::Charts::PieChart.new( :width => 350, :height => 200,
31
31
  :style => 'brushmetal.css', :auto_tooltips => true ,
32
- :javascripts => {'/tmp/gerbil.js' => false, '/tmp/prototype.js' => false}
32
+ :javascripts => {'/javascripts/gerbil.js' => false, '/javascripts/prototype.js' => false},
33
+ :filter => 'LikeButton'
33
34
  )
34
35
  mychart.modelgroup=modelgroup
35
- mychart.render('/tmp/pie_monthly_sales.svg')
36
+ mychart.render('/tmp/pie_monthly_sales_lit.svg')
36
37
  end
37
38
 
38
39
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gerbilcharts
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vivek Rajagopalan
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-09-17 00:00:00 +05:30
12
+ date: 2009-09-21 00:00:00 +05:30
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency