Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

actually only supporting fusion 3.1 - 3.0 working is accidental

  • Loading branch information...
commit 0beb31520dbfdd6993c2567f2aa96aa8211890cd 1 parent f5fba0b
Eric 'Puppet of master' Redmond authored
7 Manifest.txt
@@ -5,10 +5,17 @@ README.rdoc
5 5 Rakefile
6 6 configs/fusion/3.0/angular.xml.builder
7 7 configs/fusion/3.0/bar.xml.builder
  8 +configs/fusion/3.0/bullet.xml.builder
8 9 configs/fusion/3.0/column.xml.builder
  10 +configs/fusion/3.0/funnel.xml.builder
9 11 configs/fusion/3.0/inline.html.erb
10 12 configs/fusion/3.0/line.xml.builder
11 13 configs/fusion/3.0/pie.xml.builder
  14 +configs/fusion/3.0/pyramid.xml.builder
  15 +configs/fusion/3.0/remote.html.erb
  16 +configs/fusion/3.0/spark_column.xml.builder
  17 +configs/fusion/3.0/spark_line.xml.builder
  18 +configs/fusion/3.0/spark_win_loss.xml.builder
12 19 configs/fusion/3.0/stacked_column.xml.builder
13 20 configs/fusion/config.yml
14 21 configs/google/1.0/pie.html.erb
4 a_la_chart.gemspec
@@ -2,7 +2,7 @@
2 2
3 3 Gem::Specification.new do |s|
4 4 s.name = %q{a_la_chart}
5   - s.version = "0.0.8"
  5 + s.version = "0.0.9"
6 6
7 7 s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8 8 s.authors = ["Eric Redmond"]
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
10 10 s.description = %q{This is a general framework for inserting various type of charting implementations - from grabbing the data, to declaring how those values are mapped to the desired type of chart (pie, line, bar, etc).}
11 11 s.email = ["eric.redmond@gmail.com"]
12 12 s.extra_rdoc_files = ["History.txt", "Manifest.txt"]
13   - s.files = ["History.txt", "MIT-LICENSE", "Manifest.txt", "README.rdoc", "Rakefile", "configs/fusion/3.0/angular.xml.builder", "configs/fusion/3.0/bar.xml.builder", "configs/fusion/3.0/column.xml.builder", "configs/fusion/3.0/inline.html.erb", "configs/fusion/3.0/line.xml.builder", "configs/fusion/3.0/pie.xml.builder", "configs/fusion/3.0/stacked_column.xml.builder", "configs/fusion/config.yml", "configs/google/1.0/pie.html.erb", "configs/google/config.yml", "configs/raphael/1.2/dot.html.erb", "configs/raphael/1.2/impact.js.erb", "configs/raphael/1.2/inline.html.erb", "configs/raphael/config.yml", "init.rb", "lib/a_la_chart.rb", "lib/a_la_chart/a_la_chart_helper.rb", "lib/a_la_chart/a_la_chart.rb", "script/console", "script/destroy", "script/generate", "test/a_la_chart_test.rb", "test/test_a_la_chart.rb", "test/test_helper.rb"]
  13 + s.files = ["History.txt", "MIT-LICENSE", "Manifest.txt", "README.rdoc", "Rakefile", "configs/fusion/3.0/angular.xml.builder", "configs/fusion/3.0/bar.xml.builder", "configs/fusion/3.0/bullet.xml.builder", "configs/fusion/3.0/column.xml.builder", "configs/fusion/3.0/funnel.xml.builder", "configs/fusion/3.0/remote.html.erb", "configs/fusion/3.0/inline.html.erb", "configs/fusion/3.0/line.xml.builder", "configs/fusion/3.0/pie.xml.builder", "configs/fusion/3.0/pyramid.xml.builder", "configs/fusion/3.0/spark_column.xml.builder", "configs/fusion/3.0/spark_line.xml.builder", "configs/fusion/3.0/spark_win_loss.xml.builder", "configs/fusion/3.0/stacked_column.xml.builder", "configs/fusion/config.yml", "configs/google/1.0/pie.html.erb", "configs/google/config.yml", "configs/raphael/1.2/dot.html.erb", "configs/raphael/1.2/impact.js.erb", "configs/raphael/1.2/inline.html.erb", "configs/raphael/config.yml", "init.rb", "lib/a_la_chart.rb", "lib/a_la_chart/a_la_chart_helper.rb", "lib/a_la_chart/a_la_chart.rb", "script/console", "script/destroy", "script/generate", "test/a_la_chart_test.rb", "test/test_a_la_chart.rb", "test/test_helper.rb"]
14 14 s.homepage = %q{http://github.com/coderoshi/a_la_chart}
15 15 s.rdoc_options = ["--main", "README.rdoc"]
16 16 s.require_paths = ["lib"]
0  configs/fusion/3.0/angular.xml.builder → configs/fusion/3.1/angular.xml.builder
File renamed without changes
0  configs/fusion/3.0/bar.xml.builder → configs/fusion/3.1/bar.xml.builder
File renamed without changes
15 configs/fusion/3.1/bullet.xml.builder
... ... @@ -0,0 +1,15 @@
  1 +xml.instruct!
  2 +xml.chart(chart_options.merge(:upperLimit => params[:upperLimit] || 100, :caption => params[:title])) do
  3 + the_case = params[:case]
  4 + xml.colorRange do
  5 + xml.color :minValue => '0', :maxValue => '2', :code => 'FF654F'
  6 + xml.color :minValue => '2', :maxValue => '4', :code => 'F6BD0F'
  7 + xml.color :minValue => '4', :maxValue => '5', :code => '8BBA00'
  8 + end
  9 + xml.value do
  10 + value(data, :value, the_case)
  11 + end
  12 + xml.target do
  13 + value(data, :target, the_case)
  14 + end
  15 +end
0  configs/fusion/3.0/column.xml.builder → configs/fusion/3.1/column.xml.builder
File renamed without changes
0  configs/fusion/3.0/pie.xml.builder → configs/fusion/3.1/funnel.xml.builder
File renamed without changes
28 configs/fusion/3.1/inline.html.erb
... ... @@ -0,0 +1,28 @@
  1 +<%
  2 + require 'builder'
  3 + chart_type = chart_type_config['chart_type']
  4 + chart_type = chart_style.to_s if chart_type.blank?
  5 +
  6 + chart_type = args[:vertical] ? chart_type_config['vertical'] || chart_type : chart_type
  7 + chart_type = args[:dimensions] == 3 ? chart_type_config['3d'] || chart_type : chart_type
  8 +
  9 + set_chart(chart_style)
  10 +
  11 + xml = Builder::XmlMarkup.new(:target=>$stdout, :indent=>2) #Builder::XmlMarkup.new() #File.join(File.dirname(__FILE__), data_template))
  12 +
  13 + params[:title] = args[:title]
  14 +%>
  15 +<div>
  16 + <fusioncharts id="<%= div_id %>"
  17 + chartType="<%= chart_type %>"
  18 + swfPath="/FusionCharts/"
  19 + width="<%= width %>"
  20 + height="<%= height %>"
  21 + registerWithJS="1"
  22 + debugMode="0">
  23 + <data><!--[CDATA[
  24 + <%# load data_template, true %>
  25 + <% eval(File.read(data_template), binding) %>
  26 + ]]--></data>
  27 + </fusioncharts>
  28 +</div>
0  configs/fusion/3.0/line.xml.builder → configs/fusion/3.1/line.xml.builder
File renamed without changes
7 configs/fusion/3.1/pie.xml.builder
... ... @@ -0,0 +1,7 @@
  1 +xml.instruct!
  2 +xml.chart(chart_options.merge(:caption => params[:title])) do
  3 + the_case = params[:case]
  4 + data(the_case).each do |record|
  5 + xml.set :value => value(record, :value, the_case), :label => value(record, :label, the_case), :link => value(record, :link, the_case), :color => next_color
  6 + end
  7 +end
7 configs/fusion/3.1/pyramid.xml.builder
... ... @@ -0,0 +1,7 @@
  1 +xml.instruct!
  2 +xml.chart(chart_options.merge(:caption => params[:title])) do
  3 + the_case = params[:case]
  4 + data(the_case).each do |record|
  5 + xml.set :value => value(record, :value, the_case), :label => value(record, :label, the_case), :link => value(record, :link, the_case), :color => next_color
  6 + end
  7 +end
7 configs/fusion/3.0/inline.html.erb → configs/fusion/3.1/remote.html.erb
... ... @@ -1,3 +1,10 @@
  1 +<%
  2 + chart_type = chart_type_config['chart_type']
  3 + chart_type = chart_style.to_s if chart_type.blank?
  4 +
  5 + chart_type = args[:vertical] ? chart_type_config['vertical'] || chart_type : chart_type
  6 + chart_type = args[:dimensions] == 3 ? chart_type_config['3d'] || chart_type : chart_type
  7 +-%>
1 8 <div>
2 9 <fusioncharts id="<%= div_id %>"
3 10 chartType="<%= chart_type %>"
9 configs/fusion/3.1/spark_column.xml.builder
... ... @@ -0,0 +1,9 @@
  1 +xml.instruct!
  2 +xml.chart(chart_options.merge(:caption => params[:title])) do
  3 + the_case = params[:case]
  4 + xml.dataset do
  5 + data(the_case).each do |record|
  6 + xml.set :value => value(record, :value, the_case)
  7 + end
  8 + end
  9 +end
9 configs/fusion/3.1/spark_line.xml.builder
... ... @@ -0,0 +1,9 @@
  1 +xml.instruct!
  2 +xml.chart(chart_options.merge(:caption => params[:title])) do
  3 + the_case = params[:case]
  4 + xml.dataset do
  5 + data(the_case).each do |record|
  6 + xml.set :value => value(record, :value, the_case)
  7 + end
  8 + end
  9 +end
9 configs/fusion/3.1/spark_win_loss.xml.builder
... ... @@ -0,0 +1,9 @@
  1 +xml.instruct!
  2 +xml.chart(chart_options.merge(:caption => params[:title])) do
  3 + the_case = params[:case]
  4 + xml.dataset do
  5 + data(the_case).each do |record|
  6 + xml.set :value => value(record, :value, the_case), :label => value(record, :label, the_case), :scoreless => value(record, :scoreless, the_case), :color => next_color
  7 + end
  8 + end
  9 +end
0  configs/fusion/3.0/stacked_column.xml.builder → configs/fusion/3.1/stacked_column.xml.builder
File renamed without changes
46 configs/fusion/config.yml
... ... @@ -1,27 +1,69 @@
1   -default: 3.0
2   -3.0:
  1 +default: 3.1
  2 +3.1:
3 3 format: xml
4 4 angular:
5 5 data: 'angular.xml.builder'
6 6 chart_type: AngularGauge
  7 + remote: 'remote.html.erb'
7 8 inline: 'inline.html.erb'
8 9 bar:
9 10 data: 'bar.xml.builder'
10 11 chart_type: Bar2D
  12 + 3d: Bar3D
  13 + remote: 'remote.html.erb'
  14 + inline: 'inline.html.erb'
  15 + bullet:
  16 + data: 'bullet.xml.builder'
  17 + chart_type: HBullet
  18 + vertical: VBullet
  19 + remote: 'remote.html.erb'
11 20 inline: 'inline.html.erb'
12 21 column:
13 22 data: 'column.xml.builder'
14 23 chart_type: Column2D
  24 + 3d: Column3D
  25 + remote: 'remote.html.erb'
15 26 inline: 'inline.html.erb'
16 27 line:
17 28 data: 'line.xml.builder'
18 29 chart_type: Line2D
  30 + 3d: Line3D
  31 + remote: 'remote.html.erb'
19 32 inline: 'inline.html.erb'
20 33 pie:
21 34 data: 'pie.xml.builder'
22 35 chart_type: Pie2D
  36 + 3d: Pie3D
  37 + remote: 'remote.html.erb'
23 38 inline: 'inline.html.erb'
24 39 stacked_column:
25 40 data: 'stacked_column.xml.builder'
26 41 chart_type: StackedColumn2D
  42 + 3d: StackedColumn3D
  43 + remote: 'remote.html.erb'
  44 + inline: 'inline.html.erb'
  45 + spark_line:
  46 + data: 'spark_line.xml.builder'
  47 + chart_type: SparkLine
  48 + remote: 'remote.html.erb'
  49 + inline: 'inline.html.erb'
  50 + spark_column:
  51 + data: 'spark_column.xml.builder'
  52 + chart_type: SparkColumn
  53 + remote: 'remote.html.erb'
  54 + inline: 'inline.html.erb'
  55 + spark_win_loss:
  56 + data: 'spark_win_loss.xml.builder'
  57 + chart_type: SparkWL
  58 + remote: 'remote.html.erb'
  59 + inline: 'inline.html.erb'
  60 + pyramid:
  61 + data: 'pyramid.xml.builder'
  62 + chart_type: Pyramid
  63 + remote: 'remote.html.erb'
  64 + inline: 'inline.html.erb'
  65 + funnel:
  66 + data: 'funnel.xml.builder'
  67 + chart_type: Funnel
  68 + remote: 'remote.html.erb'
27 69 inline: 'inline.html.erb'
10 lib/a_la_chart/a_la_chart_helper.rb
@@ -16,9 +16,10 @@ def chart_tag(chart_make, chart_style, args={})
16 16
17 17 chart_type_config = chart_make_config[chart_style.to_s]
18 18 raise "#{chart_style.to_s} is an unsupported chart style" if chart_type_config.blank?
19   - chart_type = chart_type_config['chart_type']
20   - chart_type = chart_style.to_s if chart_type.blank?
21 19 inline_template = chart_type_config['inline']
  20 + remote_template = chart_type_config['remote']
  21 +
  22 + template = args[:inline] ? inline_template : remote_template || inline_template
22 23
23 24 data_format = chart_type_config['format'] || chart_make_config['format']
24 25
@@ -37,7 +38,10 @@ def chart_tag(chart_make, chart_style, args={})
37 38
38 39 div_id = "#{name}_#{Time.now.to_f.to_s.gsub('.','_')}"
39 40
40   - inline = ERB.new(File.read(File.join(File.dirname(__FILE__), '..', '..', 'configs', chart_make.to_s, chart_make_version.to_s, inline_template)))
  41 + data_template = chart_type_config['data']
  42 + data_template = File.join(File.dirname(__FILE__), '..', '..', 'configs', chart_make.to_s, chart_make_version.to_s, data_template) if data_template.present?
  43 +
  44 + inline = ERB.new(File.read(File.join(File.dirname(__FILE__), '..', '..', 'configs', chart_make.to_s, chart_make_version.to_s, template)))
41 45 inline.result(binding)
42 46 end
43 47

0 comments on commit 0beb315

Please sign in to comment.
Something went wrong with that request. Please try again.