a_la_chart 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,9 @@
1
+ === 0.1.2 2010-1-14
2
+
3
+ * 2 major enhancement:
4
+ * Chart specific themes can now be created and configured
5
+ * Added ability to pass options through the chart
6
+
1
7
  === 0.1.0 2010-1-13
2
8
 
3
9
  * 1 major enhancement:
data/README.rdoc CHANGED
@@ -10,9 +10,10 @@
10
10
 
11
11
  Note: very much in alpha development
12
12
 
13
- * Google Charts 1.0 (partial)
14
- * Fusion Charts 3.x (partial)
15
- * gRaphaël 1.2 (partial)
13
+ * Google Charts 1.0 (partial) [http://code.google.com/apis/chart]
14
+ * Fusion Charts 3.x (partial) [http://www.fusioncharts.com]
15
+ * amCharts 1.6.4 (coming soon) [http://www.amcharts.com]
16
+ * gRaphaël 1.2 (coming soon) [http://g.raphaeljs.com]
16
17
 
17
18
  == INSTALL:
18
19
 
@@ -30,6 +30,8 @@ module ALaChartHelper
30
30
  append_url = chart_type_config[:url] || ".chart#{data_format}"
31
31
  url += "#{append_url}?"
32
32
 
33
+ options = args.delete(:options) || {}
34
+
33
35
  explicit_args = args[:args].present? ? params.merge(args[:args]) : params
34
36
  args.reject!{ |k,v| [:name,:width,:height,:base_url].include?(k) }
35
37
  args.merge!(explicit_args)
@@ -37,6 +39,8 @@ module ALaChartHelper
37
39
  args.reject!{ |k,v| ['action','controller'].include?(k) }
38
40
  args[:cm] = chart_make.to_s
39
41
  args[:ct] = chart_style.to_s
42
+ # This feels a little too hacky for my taste... try better encoding
43
+ args[:co] = encode_options(options)
40
44
 
41
45
  url += args.to_param
42
46
 
@@ -55,6 +59,16 @@ module ALaChartHelper
55
59
  chart_template_erb.result(binding)
56
60
  end
57
61
 
62
+ def encode_options(options)
63
+ options.map{|k,v| "#{CGI::escape(k.to_s)}~#{CGI::escape(v.to_s)}"}.join("|")
64
+ end
65
+
66
+ def decode_options(options_str)
67
+ hash = Hash[ *(options_str.to_s.split(/[|~]/)) ]
68
+ hash.each{|k,v| hash[CGI::unescape(k).to_sym] = CGI::unescape(hash.delete(k)) }
69
+ hash
70
+ end
71
+
58
72
  def color_palette(chart_make, chart_style=nil)
59
73
  theme(chart_make)[:color_palette] || []
60
74
  end
@@ -68,9 +82,11 @@ module ALaChartHelper
68
82
  @color_palette_ary.pop
69
83
  end
70
84
 
71
- # Merge with per-chart options
72
85
  def chart_options(chart_make, chart_style=nil)
73
- theme(chart_make)[:default_options] || {}
86
+ default_options = theme(chart_make)[:default_options] || {}
87
+ options = decode_options(params[:co])
88
+ chart_style_options = (theme(chart_make)[:options] || {})[chart_style] || {}
89
+ default_options.merge(options).merge(chart_style_options)
74
90
  end
75
91
 
76
92
  private
data/lib/a_la_chart.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module ALaChart
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
4
4
 
5
5
  require File.join(File.dirname(__FILE__), 'a_la_chart', 'config')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: a_la_chart
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Redmond
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-13 00:00:00 -05:00
12
+ date: 2010-01-14 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency