a_la_chart 0.0.10 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +5 -0
- data/Manifest.txt +19 -18
- data/configs/fusion/config.yml +7 -7
- data/configs/fusion/{3.1 → v3_1}/inline.html.erb +3 -3
- data/configs/fusion/{3.1 → v3_1}/remote.html.erb +3 -3
- data/configs/fusion/{3.1 → v3_1}/stacked_column.xml.builder +1 -1
- data/configs/google/config.yml +2 -2
- data/configs/raphael/config.yml +2 -2
- data/lib/a_la_chart/a_la_chart.rb +11 -26
- data/lib/a_la_chart/a_la_chart_helper.rb +22 -12
- data/lib/a_la_chart/config.rb +67 -0
- data/lib/a_la_chart.rb +2 -1
- metadata +21 -20
- /data/configs/fusion/{3.1 → v3_1}/angular.xml.builder +0 -0
- /data/configs/fusion/{3.1 → v3_1}/bar.xml.builder +0 -0
- /data/configs/fusion/{3.1 → v3_1}/bullet.xml.builder +0 -0
- /data/configs/fusion/{3.1 → v3_1}/column.xml.builder +0 -0
- /data/configs/fusion/{3.1 → v3_1}/funnel.xml.builder +0 -0
- /data/configs/fusion/{3.1 → v3_1}/line.xml.builder +0 -0
- /data/configs/fusion/{3.1 → v3_1}/pie.xml.builder +0 -0
- /data/configs/fusion/{3.1 → v3_1}/pyramid.xml.builder +0 -0
- /data/configs/fusion/{3.1 → v3_1}/spark_column.xml.builder +0 -0
- /data/configs/fusion/{3.1 → v3_1}/spark_line.xml.builder +0 -0
- /data/configs/fusion/{3.1 → v3_1}/spark_win_loss.xml.builder +0 -0
- /data/configs/google/{1.0 → v1_0}/pie.html.erb +0 -0
- /data/configs/raphael/{1.2 → v1_2}/dot.html.erb +0 -0
- /data/configs/raphael/{1.2 → v1_2}/impact.js.erb +0 -0
- /data/configs/raphael/{1.2 → v1_2}/inline.html.erb +0 -0
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
@@ -3,31 +3,32 @@ MIT-LICENSE
|
|
3
3
|
Manifest.txt
|
4
4
|
README.rdoc
|
5
5
|
Rakefile
|
6
|
-
configs/fusion/
|
7
|
-
configs/fusion/
|
8
|
-
configs/fusion/
|
9
|
-
configs/fusion/
|
10
|
-
configs/fusion/
|
11
|
-
configs/fusion/
|
12
|
-
configs/fusion/
|
13
|
-
configs/fusion/
|
14
|
-
configs/fusion/
|
15
|
-
configs/fusion/
|
16
|
-
configs/fusion/
|
17
|
-
configs/fusion/
|
18
|
-
configs/fusion/
|
19
|
-
configs/fusion/
|
6
|
+
configs/fusion/v3_1/angular.xml.builder
|
7
|
+
configs/fusion/v3_1/bar.xml.builder
|
8
|
+
configs/fusion/v3_1/bullet.xml.builder
|
9
|
+
configs/fusion/v3_1/column.xml.builder
|
10
|
+
configs/fusion/v3_1/funnel.xml.builder
|
11
|
+
configs/fusion/v3_1/inline.html.erb
|
12
|
+
configs/fusion/v3_1/line.xml.builder
|
13
|
+
configs/fusion/v3_1/pie.xml.builder
|
14
|
+
configs/fusion/v3_1/pyramid.xml.builder
|
15
|
+
configs/fusion/v3_1/remote.html.erb
|
16
|
+
configs/fusion/v3_1/spark_column.xml.builder
|
17
|
+
configs/fusion/v3_1/spark_line.xml.builder
|
18
|
+
configs/fusion/v3_1/spark_win_loss.xml.builder
|
19
|
+
configs/fusion/v3_1/stacked_column.xml.builder
|
20
20
|
configs/fusion/config.yml
|
21
|
-
configs/google/
|
21
|
+
configs/google/v1_0/pie.html.erb
|
22
22
|
configs/google/config.yml
|
23
|
-
configs/raphael/
|
24
|
-
configs/raphael/
|
25
|
-
configs/raphael/
|
23
|
+
configs/raphael/v1_2/dot.html.erb
|
24
|
+
configs/raphael/v1_2/impact.js.erb
|
25
|
+
configs/raphael/v1_2/inline.html.erb
|
26
26
|
configs/raphael/config.yml
|
27
27
|
init.rb
|
28
28
|
lib/a_la_chart.rb
|
29
29
|
lib/a_la_chart/a_la_chart_helper.rb
|
30
30
|
lib/a_la_chart/a_la_chart.rb
|
31
|
+
lib/a_la_chart/config.rb
|
31
32
|
script/console
|
32
33
|
script/destroy
|
33
34
|
script/generate
|
data/configs/fusion/config.yml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
default:
|
2
|
-
|
1
|
+
default: v3_1
|
2
|
+
v3_1:
|
3
3
|
format: xml
|
4
4
|
angular:
|
5
5
|
data: 'angular.xml.builder'
|
@@ -9,7 +9,7 @@ default: 3.1
|
|
9
9
|
bar:
|
10
10
|
data: 'bar.xml.builder'
|
11
11
|
chart_type: Bar2D
|
12
|
-
|
12
|
+
d3: Bar3D
|
13
13
|
remote: 'remote.html.erb'
|
14
14
|
inline: 'inline.html.erb'
|
15
15
|
bullet:
|
@@ -21,25 +21,25 @@ default: 3.1
|
|
21
21
|
column:
|
22
22
|
data: 'column.xml.builder'
|
23
23
|
chart_type: Column2D
|
24
|
-
|
24
|
+
d3: Column3D
|
25
25
|
remote: 'remote.html.erb'
|
26
26
|
inline: 'inline.html.erb'
|
27
27
|
line:
|
28
28
|
data: 'line.xml.builder'
|
29
29
|
chart_type: Line2D
|
30
|
-
|
30
|
+
d3: Line3D
|
31
31
|
remote: 'remote.html.erb'
|
32
32
|
inline: 'inline.html.erb'
|
33
33
|
pie:
|
34
34
|
data: 'pie.xml.builder'
|
35
35
|
chart_type: Pie2D
|
36
|
-
|
36
|
+
d3: Pie3D
|
37
37
|
remote: 'remote.html.erb'
|
38
38
|
inline: 'inline.html.erb'
|
39
39
|
stacked_column:
|
40
40
|
data: 'stacked_column.xml.builder'
|
41
41
|
chart_type: StackedColumn2D
|
42
|
-
|
42
|
+
d3: StackedColumn3D
|
43
43
|
remote: 'remote.html.erb'
|
44
44
|
inline: 'inline.html.erb'
|
45
45
|
spark_line:
|
@@ -1,10 +1,10 @@
|
|
1
1
|
<%
|
2
2
|
require 'builder'
|
3
|
-
chart_type = chart_type_config[
|
3
|
+
chart_type = chart_type_config[:chart_type]
|
4
4
|
chart_type = chart_style.to_s if chart_type.blank?
|
5
5
|
|
6
|
-
chart_type = args[:vertical] ? chart_type_config[
|
7
|
-
chart_type = args[:dimensions] == 3 ? chart_type_config[
|
6
|
+
chart_type = args[:vertical] ? chart_type_config[:vertical] || chart_type : chart_type
|
7
|
+
chart_type = args[:dimensions] == 3 ? chart_type_config[:d3] || chart_type : chart_type
|
8
8
|
|
9
9
|
set_chart(chart_style)
|
10
10
|
|
@@ -1,9 +1,9 @@
|
|
1
1
|
<%
|
2
|
-
chart_type = chart_type_config[
|
2
|
+
chart_type = chart_type_config[:chart_type]
|
3
3
|
chart_type = chart_style.to_s if chart_type.blank?
|
4
4
|
|
5
|
-
chart_type = args[:vertical] ? chart_type_config[
|
6
|
-
chart_type = args[:dimensions] == 3 ? chart_type_config[
|
5
|
+
chart_type = args[:vertical] ? chart_type_config[:vertical] || chart_type : chart_type
|
6
|
+
chart_type = args[:dimensions] == 3 ? chart_type_config[:d3] || chart_type : chart_type
|
7
7
|
%>
|
8
8
|
<div>
|
9
9
|
<fusioncharts id="<%= div_id %>"
|
@@ -1,5 +1,5 @@
|
|
1
1
|
xml.instruct!
|
2
|
-
xml.chart(chart_options.merge(:caption => params[:title])) do
|
2
|
+
xml.chart(chart_options.merge(:caption => params[:title], :showLegend => '0')) do
|
3
3
|
the_case = params[:case]
|
4
4
|
xml.categories do
|
5
5
|
data(the_case).map{|record| value(record, :label, the_case) }.uniq.compact.each do |label|
|
data/configs/google/config.yml
CHANGED
data/configs/raphael/config.yml
CHANGED
@@ -41,21 +41,6 @@ module ALaChart
|
|
41
41
|
def set_chart(chart_type)
|
42
42
|
send "set_chart_#{chart_type}"
|
43
43
|
end
|
44
|
-
|
45
|
-
def a_la_chart_config
|
46
|
-
unless defined?(@@alachart_config)
|
47
|
-
require 'yaml'
|
48
|
-
|
49
|
-
@@alachart_config = {}
|
50
|
-
Dir.foreach(File.join(File.dirname(__FILE__), '..', '..', 'configs')) do |dir|
|
51
|
-
config_path = File.join(File.dirname(__FILE__), '..', '..', 'configs', dir, 'config.yml')
|
52
|
-
if File.exists?(config_path)
|
53
|
-
@@alachart_config[dir.to_sym] = YAML.load_file(config_path)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
@@alachart_config
|
58
|
-
end
|
59
44
|
end
|
60
45
|
|
61
46
|
module InstanceMethods
|
@@ -66,10 +51,10 @@ module ALaChart
|
|
66
51
|
chart_type = params[:ct]
|
67
52
|
|
68
53
|
chart_type_config, chart_make_version = nil, nil
|
69
|
-
if !chart_make.nil? && (chart_make_config =
|
70
|
-
chart_make_version = chart_make_version || chart_make_config[
|
71
|
-
chart_make_config = chart_make_config[chart_make_version]
|
72
|
-
chart_type_config = chart_make_config[chart_type.
|
54
|
+
if !chart_make.nil? && (chart_make_config = ALaChart::Config[chart_make])
|
55
|
+
chart_make_version = chart_make_version || chart_make_config[:default]
|
56
|
+
chart_make_config = chart_make_version.nil? ? nil : chart_make_config[chart_make_version.to_sym]
|
57
|
+
chart_type_config = chart_make_config.nil? || chart_type.nil? ? nil : chart_make_config[chart_type.to_sym]
|
73
58
|
end
|
74
59
|
|
75
60
|
return if chart_type_config.nil? || !respond_to?("set_chart_#{chart_type}")
|
@@ -85,16 +70,16 @@ module ALaChart
|
|
85
70
|
|
86
71
|
def render_style(chart_make, chart_type, chart_make_version=nil, chart_type_config=nil)
|
87
72
|
if chart_type_config.nil?
|
88
|
-
unless !chart_make.nil? && (chart_make_config =
|
89
|
-
raise "Unknown chart_make. Valid type are: #{
|
73
|
+
unless !chart_make.nil? && (chart_make_config = ALaChart::Config[chart_make])
|
74
|
+
raise "Unknown chart_make. Valid type are: #{ALaChart::Config.keys.map{|v|v.inspect}.join(', ')}"
|
90
75
|
end
|
91
76
|
|
92
|
-
chart_make_version = chart_make_version || chart_make_config[
|
93
|
-
chart_make_config = chart_make_config[chart_make_version]
|
94
|
-
chart_type_config = chart_make_config[chart_type.
|
77
|
+
chart_make_version = chart_make_version || chart_make_config[:default]
|
78
|
+
chart_make_config = chart_make_version.nil? ? nil : chart_make_config[chart_make_version.to_sym]
|
79
|
+
chart_type_config = chart_make_config.nil? || chart_type.nil? ? {} : chart_make_config[chart_type.to_sym]
|
95
80
|
end
|
96
81
|
|
97
|
-
data_template = chart_type_config[
|
82
|
+
data_template = chart_type_config[:data]
|
98
83
|
|
99
84
|
send "set_chart_#{chart_type}"
|
100
85
|
render File.join(File.dirname(__FILE__), '..', '..', 'configs', chart_make.to_s, chart_make_version.to_s, data_template)
|
@@ -116,7 +101,7 @@ module ALaChart
|
|
116
101
|
self.before_filter(:provide_chart_data, :only => [:index, :show])
|
117
102
|
|
118
103
|
# Namespace this stuff??
|
119
|
-
[:data, :fields, :meta, :value, :
|
104
|
+
[:data, :fields, :meta, :value, :set_chart].each do |method|
|
120
105
|
master_helper_module.module_eval <<-end_eval
|
121
106
|
def #{method}(*args, &block) # def current_user(*args, &block)
|
122
107
|
controller.send(%(#{method}), *args, &block) # controller.send(%(current_user), *args, &block)
|
@@ -1,6 +1,10 @@
|
|
1
1
|
module ALaChartHelper
|
2
2
|
require "erb"
|
3
3
|
|
4
|
+
def inline_chart_tag(chart_make, chart_style, args={})
|
5
|
+
chart_tag(chart_make, chart_style, args.merge(:inline => true))
|
6
|
+
end
|
7
|
+
|
4
8
|
def chart_tag(chart_make, chart_style, args={})
|
5
9
|
width = args[:width] || 400
|
6
10
|
height = args[:height] || 300
|
@@ -10,20 +14,20 @@ module ALaChartHelper
|
|
10
14
|
|
11
15
|
chart_make = chart_make.to_sym
|
12
16
|
|
13
|
-
chart_make_config =
|
14
|
-
chart_make_version = chart_make_version || chart_make_config[
|
15
|
-
chart_make_config = chart_make_config[chart_make_version]
|
17
|
+
chart_make_config = ALaChart::Config[chart_make]
|
18
|
+
chart_make_version = chart_make_version || chart_make_config[:default]
|
19
|
+
chart_make_config = chart_make_config[chart_make_version.to_sym]
|
16
20
|
|
17
|
-
chart_type_config = chart_make_config[chart_style.
|
21
|
+
chart_type_config = chart_make_config[chart_style.to_sym]
|
18
22
|
raise "#{chart_style.to_s} is an unsupported chart style" if chart_type_config.blank?
|
19
|
-
inline_template = chart_type_config[
|
20
|
-
remote_template = chart_type_config[
|
23
|
+
inline_template = chart_type_config[:inline]
|
24
|
+
remote_template = chart_type_config[:remote]
|
21
25
|
|
22
26
|
template = args[:inline] ? inline_template : remote_template || inline_template
|
23
27
|
|
24
|
-
data_format = chart_type_config[
|
28
|
+
data_format = chart_type_config[:format] || chart_make_config[:format]
|
25
29
|
|
26
|
-
append_url = chart_type_config[
|
30
|
+
append_url = chart_type_config[:url] || ".chart#{data_format}"
|
27
31
|
url += "#{append_url}?"
|
28
32
|
|
29
33
|
explicit_args = args[:args].present? ? params.merge(args[:args]) : params
|
@@ -38,11 +42,17 @@ module ALaChartHelper
|
|
38
42
|
|
39
43
|
div_id = "#{name}_#{Time.now.to_f.to_s.gsub('.','_')}"
|
40
44
|
|
41
|
-
|
42
|
-
data_template = File.join(File.dirname(__FILE__), '..', '..', 'configs', chart_make.to_s, chart_make_version.to_s,
|
45
|
+
data_template_path = chart_type_config[:data]
|
46
|
+
data_template = File.join(File.dirname(__FILE__), '..', '..', 'configs', chart_make.to_s, chart_make_version.to_s, data_template_path) if data_template_path.present?
|
47
|
+
# If we cannot find the file, try it as a relative path
|
48
|
+
data_template = File.join(RAILS_ROOT, data_template_path) if data_template_path.present? && !File.exists?(data_template) && defined?(RAILS_ROOT)
|
49
|
+
|
50
|
+
chart_template = File.join(File.dirname(__FILE__), '..', '..', 'configs', chart_make.to_s, chart_make_version.to_s, template)
|
51
|
+
# If we cannot find the file, try it as a relative path
|
52
|
+
chart_template = File.join(RAILS_ROOT, template) if !File.exists?(chart_template) && defined?(RAILS_ROOT)
|
43
53
|
|
44
|
-
|
45
|
-
|
54
|
+
chart_template_erb = ERB.new(File.read(chart_template))
|
55
|
+
chart_template_erb.result(binding)
|
46
56
|
end
|
47
57
|
|
48
58
|
# TODO: REMOVE all of this stuff... make this all external configurations
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module ALaChart
|
2
|
+
module Config
|
3
|
+
|
4
|
+
# Internally, this config is represented as:
|
5
|
+
# config = {
|
6
|
+
# :fusion => {
|
7
|
+
# :default => :v31,
|
8
|
+
# :v3_1 => {
|
9
|
+
# :format => 'xml',
|
10
|
+
# :pie => {
|
11
|
+
# :data => 'pie.xml.builder',
|
12
|
+
# :chart_type => 'Pie2D',
|
13
|
+
# :remote => 'remote.html.erb',
|
14
|
+
# :inline => 'inline.html.erb'
|
15
|
+
# }
|
16
|
+
# }
|
17
|
+
# }
|
18
|
+
# }
|
19
|
+
# Internal configs can be overridden in rails environment configs. For example,
|
20
|
+
# to use a custom :inline ERB template (paths are based on RAILS_ROOT):
|
21
|
+
#
|
22
|
+
# ALaChart::Config[:fusion][:v3_1][:pie][:data] = 'app/views/reports/a_la_chart/custom_inline.html.erb'
|
23
|
+
#
|
24
|
+
# Then just copy the original template from the gem config dir, and make the desired changes
|
25
|
+
def self.config
|
26
|
+
unless defined?(@@data)
|
27
|
+
require 'yaml'
|
28
|
+
|
29
|
+
def self.symbolize_keys!(yaml_data)
|
30
|
+
if yaml_data.is_a?(Hash)
|
31
|
+
yaml_data.each do |k,v|
|
32
|
+
unless k.is_a?(Symbol)
|
33
|
+
yaml_data[k.to_sym] ||= yaml_data.delete(k)
|
34
|
+
end
|
35
|
+
if v.is_a?(Array)
|
36
|
+
v.each {|e| self.symbolize_keys!(e) }
|
37
|
+
else
|
38
|
+
self.symbolize_keys!(v)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
@@data = {}
|
45
|
+
Dir.foreach(File.join(File.dirname(__FILE__), '..', '..', 'configs')) do |dir|
|
46
|
+
config_path = File.join(File.dirname(__FILE__), '..', '..', 'configs', dir, 'config.yml')
|
47
|
+
if File.exists?(config_path)
|
48
|
+
make = dir.to_sym
|
49
|
+
yaml_data = YAML.load_file(config_path)
|
50
|
+
# Deep clone the yaml data
|
51
|
+
@@data[make] = Marshal::load(Marshal.dump(yaml_data))
|
52
|
+
self.symbolize_keys!(@@data[make])
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
@@data
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.[](make)
|
60
|
+
self.config[make.to_sym]
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.keys
|
64
|
+
self.config.keys
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
data/lib/a_la_chart.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
module ALaChart
|
2
|
-
VERSION = '0.0.
|
2
|
+
VERSION = '0.0.11'
|
3
3
|
end
|
4
4
|
|
5
|
+
require File.join(File.dirname(__FILE__), 'a_la_chart', 'config')
|
5
6
|
require File.join(File.dirname(__FILE__), 'a_la_chart', 'a_la_chart')
|
6
7
|
require File.join(File.dirname(__FILE__), 'a_la_chart', 'a_la_chart_helper')
|
7
8
|
|
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.0.
|
4
|
+
version: 0.0.11
|
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:
|
12
|
+
date: 2010-01-11 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -38,31 +38,32 @@ files:
|
|
38
38
|
- Manifest.txt
|
39
39
|
- README.rdoc
|
40
40
|
- Rakefile
|
41
|
-
- configs/fusion/
|
42
|
-
- configs/fusion/
|
43
|
-
- configs/fusion/
|
44
|
-
- configs/fusion/
|
45
|
-
- configs/fusion/
|
46
|
-
- configs/fusion/
|
47
|
-
- configs/fusion/
|
48
|
-
- configs/fusion/
|
49
|
-
- configs/fusion/
|
50
|
-
- configs/fusion/
|
51
|
-
- configs/fusion/
|
52
|
-
- configs/fusion/
|
53
|
-
- configs/fusion/
|
54
|
-
- configs/fusion/
|
41
|
+
- configs/fusion/v3_1/angular.xml.builder
|
42
|
+
- configs/fusion/v3_1/bar.xml.builder
|
43
|
+
- configs/fusion/v3_1/bullet.xml.builder
|
44
|
+
- configs/fusion/v3_1/column.xml.builder
|
45
|
+
- configs/fusion/v3_1/funnel.xml.builder
|
46
|
+
- configs/fusion/v3_1/inline.html.erb
|
47
|
+
- configs/fusion/v3_1/line.xml.builder
|
48
|
+
- configs/fusion/v3_1/pie.xml.builder
|
49
|
+
- configs/fusion/v3_1/pyramid.xml.builder
|
50
|
+
- configs/fusion/v3_1/remote.html.erb
|
51
|
+
- configs/fusion/v3_1/spark_column.xml.builder
|
52
|
+
- configs/fusion/v3_1/spark_line.xml.builder
|
53
|
+
- configs/fusion/v3_1/spark_win_loss.xml.builder
|
54
|
+
- configs/fusion/v3_1/stacked_column.xml.builder
|
55
55
|
- configs/fusion/config.yml
|
56
|
-
- configs/google/
|
56
|
+
- configs/google/v1_0/pie.html.erb
|
57
57
|
- configs/google/config.yml
|
58
|
-
- configs/raphael/
|
59
|
-
- configs/raphael/
|
60
|
-
- configs/raphael/
|
58
|
+
- configs/raphael/v1_2/dot.html.erb
|
59
|
+
- configs/raphael/v1_2/impact.js.erb
|
60
|
+
- configs/raphael/v1_2/inline.html.erb
|
61
61
|
- configs/raphael/config.yml
|
62
62
|
- init.rb
|
63
63
|
- lib/a_la_chart.rb
|
64
64
|
- lib/a_la_chart/a_la_chart_helper.rb
|
65
65
|
- lib/a_la_chart/a_la_chart.rb
|
66
|
+
- lib/a_la_chart/config.rb
|
66
67
|
- script/console
|
67
68
|
- script/destroy
|
68
69
|
- script/generate
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|