anychart_xml_builder 0.0.9 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/Rakefile CHANGED
@@ -4,7 +4,7 @@ require 'rake'
4
4
  begin
5
5
  require 'jeweler'
6
6
  Jeweler::Tasks.new do |gem|
7
- gem.version = "0.0.9"
7
+ gem.version = "0.0.11"
8
8
  gem.name = "anychart_xml_builder"
9
9
  gem.summary = %Q{AnyChart (http://anychart.com/home/) XML Builders}
10
10
  gem.description = %Q{This gem provides you the methods to easily generate the XML necessary for AnyChart}
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{anychart_xml_builder}
8
- s.version = "0.0.7"
8
+ s.version = "0.0.11"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["jduarte"]
12
- s.date = %q{2011-01-22}
12
+ s.date = %q{2011-02-26}
13
13
  s.description = %q{This gem provides you the methods to easily generate the XML necessary for AnyChart}
14
14
  s.email = %q{jose.fduarte@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -20,6 +20,7 @@ Gem::Specification.new do |s|
20
20
  ".document",
21
21
  ".gitignore",
22
22
  ".project",
23
+ "HELP_COMMIT",
23
24
  "LICENSE",
24
25
  "README.rdoc",
25
26
  "Rakefile",
@@ -27,9 +28,10 @@ Gem::Specification.new do |s|
27
28
  "lib/anychart/anychart_helpers.rb",
28
29
  "lib/anychart_xml_builder.rb",
29
30
  "lib/column_bar.rb",
30
- "lib/line_bar.rb",
31
31
  "lib/init.rb",
32
+ "lib/line_bar.rb",
32
33
  "lib/pie.rb",
34
+ "lib/xml_sections/chart_background.rb",
33
35
  "lib/xml_sections/chart_title.rb",
34
36
  "lib/xml_sections/legend.rb",
35
37
  "test/helper.rb",
@@ -10,68 +10,74 @@ module ActionView #:nodoc:
10
10
  end
11
11
 
12
12
  module InstanceMethods
13
- rand = ActiveSupport::SecureRandom.hex
14
- @@default_options = {
15
- :anychart_swf_path => '/anychart/swf/AnyChart.swf',
16
- :anychart_swf_preloader => '/anychart/swf/Preloader.swf',
17
- :wrap_id => "anychart_wrap_#{rand}",
18
- :wrap_class => "anychart_wrap",
19
- :id => "anychart_graph_#{rand}",
20
- :class => "anychart_graph",
21
- :chart_height => "100%",
22
- :chart_width => "100%"
23
- }
24
-
25
13
  def anychart(xml, options={})
26
- opts = @@default_options.merge(options)
14
+ random_hex = ActiveSupport::SecureRandom.hex
15
+
16
+ default_options = {
17
+ :anychart_swf_path => '/anychart/swf/AnyChart.swf',
18
+ :anychart_swf_preloader => '/anychart/swf/Preloader.swf',
19
+ :wrap_id => "anychart_wrap_#{random_hex}",
20
+ :wrap_class => "anychart_wrap",
21
+ :id => "anychart_graph_#{random_hex}",
22
+ :class => "anychart_graph",
23
+ :background_color => "#999999",
24
+ :wMode => "transparent",
25
+ :chart_height => "100%",
26
+ :chart_width => "100%",
27
+ :classid => "clsid:CLA_#{random_hex}",
28
+ :js_chart_name => "chart_#{random_hex}",
29
+ :show_get_flash_player_message => true
30
+ }
31
+
32
+ opts = default_options.merge(options)
27
33
 
28
34
  chart_height = opts[:chart_height].kind_of?(String) ? opts[:chart_height] : "#{opts[:chart_height]}px"
29
35
  chart_width = opts[:chart_width].kind_of?(String) ? opts[:chart_width] : "#{opts[:chart_width]}px"
30
36
 
37
+ get_flash_player_message = "<script type='text/javascript'>
38
+ //<![CDATA[
39
+ document.write(\"<center>\");
40
+ document.write(\"Precisa do Adobe Flash Player 9 (ou superior) para visualizar o gráfico.<br /><br />\");
41
+ document.write(\"<a href='http://www.adobe.com/go/getflashplayer'><img border='0' src='http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif' /></a><br />\");
42
+ document.write(\"</center>\");
43
+ //]]>
44
+ </script>".html_safe
31
45
 
32
46
  "<div class='#{opts[:wrap_class]}' id='#{opts[:wrap_id]}'>
33
47
  <div class='#{opts[:class]}' id='#{opts[:id]}'>
34
48
  <noscript>
35
49
  <object id='obj_#{opts[:id]}'
36
50
  name='obj_#{opts[:id]}'
37
- classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'
51
+ classid='clsid:#{opts[:classid]}'
38
52
  width='100%'
39
53
  height='100%'
40
54
  codebase='http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab'>
41
55
  <param name='movie' value='#{opts[:anychart_swf_preloader]}' />
42
- <param name='bgcolor' value='#FFFFFF' />
56
+ <param name='bgcolor' value='#{opts[:background_color]}' />
43
57
  <param name='allowScriptAccess' value='always' />
44
58
  <param name='flashvars' value='swfFile=#{opts[:anychart_swf_path]}&XMLFile=#{xml}' />
45
-
46
59
  <embed type='application/x-shockwave-flash'
47
- pluginspage='http://www.adobe.com/go/getflashplayer'
48
- src='#{opts[:anychart_swf_preloader]}'
49
- width='100%'
50
- height='100%'
51
- id='obj_#{opts[:id]}'
52
- name='obj_#{opts[:id]}'
53
- bgColor='#FFFFFF'
54
- allowScriptAccess='always'
55
- flashvars='swfFile=#{opts[:anychart_swf_path]}&XMLFile=#{xml}' />
60
+ pluginspage='http://www.adobe.com/go/getflashplayer'
61
+ src='#{opts[:anychart_swf_preloader]}'
62
+ id='obj_#{opts[:id]}'
63
+ name='obj_#{opts[:id]}'
64
+ bgColor='#{opts[:background_color]}'
65
+ allowScriptAccess='always'
66
+ flashvars='swfFile=#{opts[:anychart_swf_path]}&XMLFile=#{xml}'
67
+ </embed>
56
68
  </object>
57
69
  </noscript>
58
- <script type='text/javascript'>
59
- //<![CDATA[
60
- document.write('<center>');
61
- document.write('You need to have Adobe Flash Player 9 (or above) to view the chart.<br /><br />');
62
- document.write('<a href=\'http://www.adobe.com/go/getflashplayer\'><img border=\'0\' src=\'http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif\' /></a><br />');
63
- document.write('</center>');
64
- //]]>
65
- </script>
70
+ #{get_flash_player_message if opts[:show_get_flash_player_message] }
66
71
  </div>
67
72
  </div>
68
- <script type='text/javascript' language='JavaScript'>
73
+ <script type='text/javascript' language='javascript'>
69
74
  //<![CDATA[
70
- var chartSample = new AnyChart('#{opts[:anychart_swf_path]}','#{opts[:anychart_swf_preloader]}');
71
- chartSample.width = '#{chart_width}';
72
- chartSample.height = '#{chart_height}';
73
- chartSample.setXMLFile('#{xml}');
74
- chartSample.write('#{opts[:id]}');
75
+ var #{opts[:js_chart_name]} = new AnyChart('#{opts[:anychart_swf_path]}','#{opts[:anychart_swf_preloader]}');
76
+ #{opts[:js_chart_name]}.width = \"#{chart_width}\";
77
+ #{opts[:js_chart_name]}.height = \"#{chart_height}\";
78
+ #{opts[:js_chart_name]}.setXMLFile(\"#{xml}\");
79
+ #{opts[:js_chart_name]}.wMode = 'transparent';
80
+ #{opts[:js_chart_name]}.write(\"#{opts[:id]}\");
75
81
  //]]>
76
82
  </script>".html_safe
77
83
  end
data/lib/line_bar.rb CHANGED
@@ -70,7 +70,7 @@ module Anychart
70
70
  xml.charts {
71
71
  xml.chart(:plot_type => "CategorizedHorizontal") {
72
72
  xml.data_plot_settings(:default_series_type => "Bar") {
73
- xml.bar_series(:group_padding => "0.7") {
73
+ xml.bar_series(:group_padding => "0.7", :style => "AquaLight") {
74
74
  if p[:tooltip]
75
75
  xml.tooltip_settings(:enabled => "True") {
76
76
  xml.format p[:tooltip]
@@ -90,6 +90,9 @@ module Anychart
90
90
  if p[:chart][:axes].present?
91
91
  if p[:chart][:axes][:y].present?
92
92
  xml.y_axis(:position => "Opposite") {
93
+ if p[:chart][:axes][:y][:scale].present?
94
+ xml.scale(p[:chart][:axes][:y][:scale])
95
+ end
93
96
  if p[:chart][:axes][:y][:title].present?
94
97
  xml.title {
95
98
  xml.text_ p[:chart][:axes][:y][:title]
@@ -121,11 +124,13 @@ module Anychart
121
124
  xml.data {
122
125
  series = (p[:data][:series].kind_of?(Array) ? p[:data][:series] : [p[:data][:series]])
123
126
 
124
- series.each do |serie|
125
- xml.series(:name => serie[:name], :palette => "Default") {
127
+ series.each_with_index do |serie,serie_idx|
128
+ xml.series(:name => (serie[:name].blank? ? "Series #{serie_idx + 1}" : serie[:name]), :palette => "Default") {
126
129
  # Os varios pontos
127
130
  serie[:points].each do |point|
128
- xml.point(:name => point[:name].to_s, :y => point[:value].to_s)
131
+ h = {:name => point[:name].to_s, :y => point[:value].to_s}
132
+ h.merge!({:color => point[:color].to_s}) if point[:color].present?
133
+ xml.point(h)
129
134
  end
130
135
  }
131
136
  end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: anychart_xml_builder
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 9
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 0
8
- - 9
9
- version: 0.0.9
9
+ - 11
10
+ version: 0.0.11
10
11
  platform: ruby
11
12
  authors:
12
13
  - jduarte
@@ -14,7 +15,7 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2011-01-24 00:00:00 +00:00
18
+ date: 2011-02-26 00:00:00 +00:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
@@ -25,6 +26,7 @@ dependencies:
25
26
  requirements:
26
27
  - - ">="
27
28
  - !ruby/object:Gem::Version
29
+ hash: 3
28
30
  segments:
29
31
  - 0
30
32
  version: "0"
@@ -38,6 +40,7 @@ dependencies:
38
40
  requirements:
39
41
  - - ">="
40
42
  - !ruby/object:Gem::Version
43
+ hash: 5
41
44
  segments:
42
45
  - 1
43
46
  - 4
@@ -56,6 +59,7 @@ extra_rdoc_files:
56
59
  - README.rdoc
57
60
  files:
58
61
  - .document
62
+ - .gitignore
59
63
  - .project
60
64
  - HELP_COMMIT
61
65
  - LICENSE
@@ -80,8 +84,8 @@ homepage: http://github.com/jduarte/anychart_xml_builder
80
84
  licenses: []
81
85
 
82
86
  post_install_message:
83
- rdoc_options: []
84
-
87
+ rdoc_options:
88
+ - --charset=UTF-8
85
89
  require_paths:
86
90
  - lib
87
91
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -89,6 +93,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
89
93
  requirements:
90
94
  - - ">="
91
95
  - !ruby/object:Gem::Version
96
+ hash: 3
92
97
  segments:
93
98
  - 0
94
99
  version: "0"
@@ -97,6 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
102
  requirements:
98
103
  - - ">="
99
104
  - !ruby/object:Gem::Version
105
+ hash: 3
100
106
  segments:
101
107
  - 0
102
108
  version: "0"