anychart_xml_builder 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/anychart_xml_builder.gemspec +1 -1
- data/lib/anychart/view_helpers.rb +67 -57
- data/lib/anychart_xml_builder.rb +0 -25
- metadata +1 -1
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.
|
7
|
+
gem.version = "0.0.3"
|
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}
|
@@ -1,61 +1,71 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'
|
18
|
-
width='100%'
|
19
|
-
height='100%'
|
20
|
-
codebase='http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab'>
|
21
|
-
<param name='movie' value='#{opts[:anychart_swf_preloader]}' />
|
22
|
-
<param name='bgcolor' value='#FFFFFF' />
|
23
|
-
<param name='allowScriptAccess' value='always' />
|
24
|
-
<param name='flashvars' value='swfFile=#{opts[:anychart_swf_path]}&XMLFile=#{xml}' />
|
1
|
+
require 'action_view'
|
2
|
+
|
3
|
+
module ActionView #:nodoc:
|
4
|
+
module Helpers # :nodoc:
|
5
|
+
module AnychartHelper # :nodoc:
|
6
|
+
|
7
|
+
def self.included(base)
|
8
|
+
base.send(:include, InstanceMethods)
|
9
|
+
end
|
10
|
+
|
11
|
+
module InstanceMethods
|
12
|
+
@@default_options = {
|
13
|
+
:anychart_swf_path => '/anychart_swfs/AnyChart.swf',
|
14
|
+
:anychart_swf_preloader => '/anychart_swfs/Preloader.swf',
|
15
|
+
:div_id => 'anychart'
|
16
|
+
}
|
25
17
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
document.write('<center>');
|
41
|
-
document.write('You need to have Adobe Flash Player 9 (or above) to view the chart.<br /><br />');
|
42
|
-
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 />');
|
43
|
-
document.write('</center>');
|
44
|
-
//]]>
|
45
|
-
</script>
|
18
|
+
def anychart(xml, options={})
|
19
|
+
opts = @@default_options.merge(options)
|
20
|
+
"<div id='#{opts[:div_id]}'>
|
21
|
+
<noscript>
|
22
|
+
<object id='chart'
|
23
|
+
name='chart'
|
24
|
+
classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'
|
25
|
+
width='100%'
|
26
|
+
height='100%'
|
27
|
+
codebase='http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab'>
|
28
|
+
<param name='movie' value='#{opts[:anychart_swf_preloader]}' />
|
29
|
+
<param name='bgcolor' value='#FFFFFF' />
|
30
|
+
<param name='allowScriptAccess' value='always' />
|
31
|
+
<param name='flashvars' value='swfFile=#{opts[:anychart_swf_path]}&XMLFile=#{xml}' />
|
46
32
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
33
|
+
<embed type='application/x-shockwave-flash'
|
34
|
+
pluginspage='http://www.adobe.com/go/getflashplayer'
|
35
|
+
src='#{opts[:anychart_swf_preloader]}'
|
36
|
+
width='100%'
|
37
|
+
height='100%'
|
38
|
+
id='chart'
|
39
|
+
name='chart'
|
40
|
+
bgColor='#FFFFFF'
|
41
|
+
allowScriptAccess='always'
|
42
|
+
flashvars='swfFile=#{opts[:anychart_swf_path]}&XMLFile=#{xml}' />
|
43
|
+
</object>
|
44
|
+
</noscript>
|
45
|
+
<script type='text/javascript'>
|
46
|
+
//<![CDATA[
|
47
|
+
document.write('<center>');
|
48
|
+
document.write('You need to have Adobe Flash Player 9 (or above) to view the chart.<br /><br />');
|
49
|
+
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 />');
|
50
|
+
document.write('</center>');
|
51
|
+
//]]>
|
52
|
+
</script>
|
53
|
+
|
54
|
+
<script type='text/javascript' language='JavaScript'>
|
55
|
+
//<![CDATA[
|
56
|
+
var chartSample = new AnyChart('#{opts[:anychart_swf_path]}','#{opts[:anychart_swf_preloader]}');
|
57
|
+
chartSample.width = '100%';
|
58
|
+
chartSample.height = '100%';
|
59
|
+
chartSample.setXMLFile('#{xml}');
|
60
|
+
chartSample.write('#{opts[:div_id]}');
|
61
|
+
//init();
|
62
|
+
//]]>
|
63
|
+
</script>
|
64
|
+
</div>"
|
65
|
+
end
|
66
|
+
end
|
58
67
|
end
|
59
68
|
end
|
60
|
-
|
61
|
-
|
69
|
+
end
|
70
|
+
|
71
|
+
ActionView::Base.send(:include, ActionView::Helpers::AppletHelper)
|
data/lib/anychart_xml_builder.rb
CHANGED
@@ -1,33 +1,8 @@
|
|
1
1
|
require 'nokogiri'
|
2
2
|
require 'column_bar'
|
3
|
-
require 'activesupport'
|
4
3
|
|
5
4
|
module Anychart
|
6
|
-
|
7
|
-
class << self
|
8
|
-
def enable
|
9
|
-
enable_actionpack
|
10
|
-
end
|
11
|
-
|
12
|
-
# hooks Anychart::ViewHelpers into ActionView::Base
|
13
|
-
def enable_actionpack
|
14
|
-
def enable_actionpack
|
15
|
-
return if ActionView::Base.instance_methods.include_method? :anychart
|
16
|
-
require 'anychart/view_helpers'
|
17
|
-
ActionView::Base.send :include, ViewHelpers
|
18
|
-
|
19
|
-
if defined?(ActionController::Base) and ActionController::Base.respond_to? :rescue_responses
|
20
|
-
ActionController::Base.rescue_responses['Anychart::InvalidPage'] = :not_found
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
5
|
module XML
|
27
6
|
|
28
7
|
end
|
29
|
-
end
|
30
|
-
|
31
|
-
if defined? Rails
|
32
|
-
Anychart.enable_actionpack if defined? ActionController
|
33
8
|
end
|