a_la_chart 0.0.11 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,7 @@
1
1
  default: v3_1
2
+ theme: :none
3
+ themes:
4
+ none: {}
2
5
  v3_1:
3
6
  format: xml
4
7
  angular:
@@ -1,5 +1,4 @@
1
- xml.instruct!
2
- xml.chart(chart_options.merge(:upperLimit => params[:upperLimit] || 100, :caption => params[:title])) do
1
+ xml.chart(chart_options(:fusion, :angular).merge(:upperLimit => params[:upperLimit] || 100, :caption => params[:title])) do
3
2
  the_case = params[:case]
4
3
  xml.colorRange do
5
4
  xml.color :minValue => '0', :maxValue => '2', :code => 'FF654F'
@@ -1,7 +1,6 @@
1
- xml.instruct!
2
- xml.chart(chart_options.merge(:caption => params[:title])) do
1
+ xml.chart(chart_options(:fusion, :bar).merge(:caption => params[:title])) do
3
2
  the_case = params[:case]
4
3
  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
4
+ xml.set :value => value(record, :value, the_case), :label => value(record, :label, the_case), :link => value(record, :link, the_case), :color => color_palette_next(:fusion, :bar)
6
5
  end
7
6
  end
@@ -1,5 +1,4 @@
1
- xml.instruct!
2
- xml.chart(chart_options.merge(:upperLimit => params[:upperLimit] || 100, :caption => params[:title])) do
1
+ xml.chart(chart_options(:fusion, :bullet).merge(:upperLimit => params[:upperLimit] || 100, :caption => params[:title])) do
3
2
  the_case = params[:case]
4
3
  xml.colorRange do
5
4
  xml.color :minValue => '0', :maxValue => '2', :code => 'FF654F'
@@ -1,7 +1,6 @@
1
- xml.instruct!
2
- xml.chart(chart_options.merge(:caption => params[:title])) do
1
+ xml.chart(chart_options(:fusion, :bar).merge(:caption => params[:title])) do
3
2
  the_case = params[:case]
4
3
  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
4
+ xml.set :value => value(record, :value, the_case), :label => value(record, :label, the_case), :link => value(record, :link, the_case), :color => color_palette_next(:fusion, :column)
6
5
  end
7
6
  end
@@ -1,7 +1,6 @@
1
- xml.instruct!
2
- xml.chart(chart_options.merge(:caption => params[:title])) do
1
+ xml.chart(chart_options(:fusion, :funnel).merge(:caption => params[:title])) do
3
2
  the_case = params[:case]
4
3
  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
4
+ xml.set :value => value(record, :value, the_case), :label => value(record, :label, the_case), :link => value(record, :link, the_case), :color => color_palette_next(:fusion, :funnel)
6
5
  end
7
6
  end
@@ -1,5 +1,4 @@
1
- xml.instruct!
2
- xml.chart(chart_options.merge(:caption => params[:title])) do
1
+ xml.chart(chart_options(:fusion, :line).merge(:caption => params[:title])) do
3
2
  the_case = params[:case]
4
3
  xml.dataset do |dataset|
5
4
  data(the_case).each do |set|
@@ -1,7 +1,6 @@
1
- xml.instruct!
2
- xml.chart(chart_options.merge(:caption => params[:title])) do
1
+ xml.chart(chart_options(:fusion, :pie).merge(:caption => params[:title])) do
3
2
  the_case = params[:case]
4
3
  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
4
+ xml.set :value => value(record, :value, the_case), :label => value(record, :label, the_case), :link => value(record, :link, the_case), :color => color_palette_next(:fusion, :pie)
6
5
  end
7
6
  end
@@ -1,7 +1,6 @@
1
- xml.instruct!
2
- xml.chart(chart_options.merge(:caption => params[:title])) do
1
+ xml.chart(chart_options(:fusion, :pyramid).merge(:caption => params[:title])) do
3
2
  the_case = params[:case]
4
3
  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
4
+ xml.set :value => value(record, :value, the_case), :label => value(record, :label, the_case), :link => value(record, :link, the_case), :color => color_palette_next(:fusion, :pyramid)
6
5
  end
7
6
  end
@@ -1,5 +1,4 @@
1
- xml.instruct!
2
- xml.chart(chart_options.merge(:caption => params[:title])) do
1
+ xml.chart(chart_options(:fusion, :spark_column).merge(:caption => params[:title])) do
3
2
  the_case = params[:case]
4
3
  xml.dataset do
5
4
  data(the_case).each do |record|
@@ -1,5 +1,4 @@
1
- xml.instruct!
2
- xml.chart(chart_options.merge(:caption => params[:title])) do
1
+ xml.chart(chart_options(:fusion, :spark_line).merge(:caption => params[:title])) do
3
2
  the_case = params[:case]
4
3
  xml.dataset do
5
4
  data(the_case).each do |record|
@@ -1,9 +1,8 @@
1
- xml.instruct!
2
- xml.chart(chart_options.merge(:caption => params[:title])) do
1
+ xml.chart(chart_options(:fusion, :spark_win_loss).merge(:caption => params[:title])) do
3
2
  the_case = params[:case]
4
3
  xml.dataset do
5
4
  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
5
+ xml.set :value => value(record, :value, the_case), :label => value(record, :label, the_case), :scoreless => value(record, :scoreless, the_case), :color => color_palette_next(:fusion, :spark_win_loss)
7
6
  end
8
7
  end
9
8
  end
@@ -1,5 +1,4 @@
1
- xml.instruct!
2
- xml.chart(chart_options.merge(:caption => params[:title], :showLegend => '0')) do
1
+ xml.chart(chart_options(:fusion, :stacked_column).merge(:caption => params[:title], :showLegend => '0')) do
3
2
  the_case = params[:case]
4
3
  xml.categories do
5
4
  data(the_case).map{|record| value(record, :label, the_case) }.uniq.compact.each do |label|
@@ -11,7 +10,7 @@ xml.chart(chart_options.merge(:caption => params[:title], :showLegend => '0')) d
11
10
  (data_by_category[value(record, :category, the_case)] ||= []) << record
12
11
  end
13
12
  data_by_category.each do |category, records|
14
- xml.dataset(:seriesName => category, :color => value(records.first, :color, the_case) || next_color) do
13
+ xml.dataset(:seriesName => category, :color => value(records.first, :color, the_case) || color_palette_next(:fusion, :stacked_column)) do
15
14
  records.each do |record|
16
15
  xml.set :value => value(record, :value, the_case)
17
16
  end
@@ -1,4 +1,7 @@
1
1
  default: v1_0
2
+ theme: :none
3
+ themes:
4
+ none: {}
2
5
  v1_0:
3
6
  pie:
4
7
  inline: 'pie.html.erb'
@@ -1,4 +1,7 @@
1
1
  default: v1_2
2
+ theme: :none
3
+ themes:
4
+ none: {}
2
5
  v1_2:
3
6
  format: js
4
7
  impact:
@@ -40,7 +40,7 @@ module ALaChartHelper
40
40
 
41
41
  url += args.to_param
42
42
 
43
- div_id = "#{name}_#{Time.now.to_f.to_s.gsub('.','_')}"
43
+ div_id = "#{name}#{Time.now.to_f.to_s.gsub('.','')}"
44
44
 
45
45
  data_template_path = chart_type_config[:data]
46
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?
@@ -55,46 +55,32 @@ module ALaChartHelper
55
55
  chart_template_erb.result(binding)
56
56
  end
57
57
 
58
- # TODO: REMOVE all of this stuff... make this all external configurations
59
- def color_palette
60
- ["7BB465","B2B4B6","FEC35A","65A4B5","9E65B5","B57765","F7DF65","8F866C","B6A65F","C99D60","C1727A","8AABB9","65B584"]
58
+ def color_palette(chart_make, chart_style=nil)
59
+ theme(chart_make)[:color_palette] || []
61
60
  end
62
-
63
- def next_color
64
- @colors ||= color_palette
65
- @colors.pop
61
+
62
+ def color_palette_clear(chart_make, chart_style=nil)
63
+ @color_palette_ary = color_palette(chart_make, chart_style).clone
64
+ end
65
+
66
+ def color_palette_next(chart_make, chart_style=nil)
67
+ @color_palette_ary ||= color_palette(chart_make, chart_style).clone
68
+ @color_palette_ary.pop
69
+ end
70
+
71
+ # Merge with per-chart options
72
+ def chart_options(chart_make, chart_style=nil)
73
+ theme(chart_make)[:default_options] || {}
66
74
  end
67
-
68
- def chart_options
69
- {
70
- :animation => '1',
71
- :showBorder => '0',
72
- :canvasBorderThickness => '1',
73
- :canvasBorderColor => 'eeeeee',
74
- :divLineThickness => '1',
75
- :bgAlpha => '0',
76
- :useRoundEdges => '0',
77
- :alpha => '100',
78
- :bgColor => 'ffffff',
79
- :shadowXShift=>"1",
80
- :shadowYShift=>"1",
81
- :shadowAlpha=>"75",
82
- # :numberprefix => '$',
83
- :showValues => '0',
84
- :showSum => '1',
85
- :enableSmartLabels => '1',
86
- :skipOverlapLabels => '1',
87
- :decimalPrecision => "2",
88
- :captionPadding => '3',
89
- :chartLeftMargin => '0',
90
- :formatNumber => '1',
91
- :formatNumberScale => '0',
92
- :baseFont => 'Helvetica, Arial, sans-serif',
93
- :baseFontSize => '11',
94
- :baseFontColor => '515151',
95
- :showToolTip => '1',
96
- :toolTipBgColor => 'ffffff'
97
- }
75
+
76
+ private
77
+
78
+ def theme_name(chart_make)
79
+ ALaChart::Config[chart_make][:theme]
80
+ end
81
+
82
+ def theme(chart_make)
83
+ ALaChart::Config[chart_make][:themes][theme_name(chart_make)] || {}
98
84
  end
99
85
 
100
86
  end
data/lib/a_la_chart.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module ALaChart
2
- VERSION = '0.0.11'
2
+ VERSION = '0.1.0'
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.0.11
4
+ version: 0.1.0
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-11 00:00:00 -05:00
12
+ date: 2010-01-13 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency