mixtli-mixtli-flex_chart 0.1.3

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/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ pkg
2
+ tmp
data/Manifest ADDED
@@ -0,0 +1,8 @@
1
+ README.rdoc
2
+ Manifest
3
+ init.rb
4
+ public/swfs/FlexChart.swf
5
+ flex/FlexChart.mxml
6
+ tasks/flex_chart.rake
7
+ lib/flex_chart.rb
8
+ Rakefile
data/README.rdoc ADDED
File without changes
data/Rakefile ADDED
@@ -0,0 +1,23 @@
1
+ # Rakefile
2
+ require 'rubygems'
3
+ require 'rake'
4
+ #require 'echoe'
5
+
6
+
7
+ Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
8
+
9
+
10
+ begin
11
+ require 'jeweler'
12
+ Jeweler::Tasks.new do |gemspec|
13
+ gemspec.name = "mixtli-flex_chart"
14
+ gemspec.summary = "Ruby interface to Flex Charting component"
15
+ gemspec.email = "mixtli@github.com"
16
+ gemspec.homepage = "http://github.com/mixtli/flex_chart"
17
+ gemspec.description = "Ruby interface to Flex Charting component"
18
+ gemspec.authors = ["Ron McClain"]
19
+ end
20
+ rescue LoadError
21
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
22
+ end
23
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.3
@@ -0,0 +1,144 @@
1
+ <?xml version="1.0"?>
2
+ <!-- charts/DateTimeAxisSample.mxml -->
3
+ <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%" creationComplete="initApp()">
4
+ <mx:Script><![CDATA[
5
+ import mx.charts.*;
6
+ import mx.charts.series.*;
7
+ import mx.charts.chartClasses.*;
8
+ import mx.controls.Alert;
9
+ import mx.charts.HitData;
10
+ import flash.net.URLVariables;
11
+ //import mx.rpc.http.HTTPService;
12
+ import mx.rpc.events.ResultEvent
13
+ import mx.utils.URLUtil;
14
+ import mx.graphics.SolidColor;
15
+ import mx.graphics.Stroke;
16
+
17
+
18
+ [Bindable]
19
+ public var data_url:String;
20
+
21
+ [Bindable]
22
+ public var graph_title:String;
23
+
24
+ [Bindable]
25
+ public var y_label:String = "Dollars";
26
+
27
+ [Bindable]
28
+ public var x_label:String = "Date";
29
+
30
+ [Bindable]
31
+ public var chart;
32
+
33
+ private function initApp():void {
34
+ trace("tracing on");
35
+ data_url = Application.application.parameters.data_url;
36
+ trace("data_url = " + data_url);
37
+ graphService.addEventListener("result", createGraph);
38
+ graphService.send();
39
+ }
40
+
41
+ private function createGraph(event:ResultEvent):void {
42
+ var result:XML = XML(event.result);
43
+ var x_axis;
44
+ var y_axis;
45
+
46
+ chart_panel.title = result.title;
47
+ trace("x_axis_type = " + result.x_axis_type);
48
+ switch(String(result.x_axis_type)) {
49
+ case "Log" :
50
+ x_axis = new LogAxis();
51
+ break;
52
+ case "DateTime" :
53
+ x_axis = new DateTimeAxis();
54
+ break;
55
+ default :
56
+ x_axis = new LinearAxis();
57
+ }
58
+
59
+ switch(String(result.y_axis_type)) {
60
+ case 'Log':
61
+ y_axis = new LogAxis();
62
+ break;
63
+ case 'DateTime':
64
+ y_axis = new DateTimeAxis();
65
+ break;
66
+ default:
67
+ y_axis = new LinearAxis();
68
+ }
69
+
70
+ y_label = result.y_label;
71
+ x_label = result.x_label;
72
+
73
+ switch(String(result.chart_type)) {
74
+ case 'Line':
75
+ chart = new LineChart();
76
+ break;
77
+ case 'Pie':
78
+ chart = new PieChart();
79
+ break;
80
+ case 'Area':
81
+ chart = new AreaChart();
82
+ break;
83
+ case 'Bar':
84
+ chart = new BarChart();
85
+ break;
86
+ default:
87
+ chart = new LineChart();
88
+ }
89
+ chart.setStyle("color", int(result.color));
90
+ chart.setStyle("fill", int(result.fill_color));
91
+ chart.setStyle("paddingLeft", 0);
92
+ chart.setStyle("paddingRight", 0);
93
+ chart.setStyle("paddingTop", 0);
94
+ chart.setStyle("paddingBottom", 0);
95
+ x_axis.title = x_label;
96
+ chart.horizontalAxis = x_axis;
97
+ y_axis.title = y_label;
98
+ chart.verticalAxis = y_axis;
99
+ chart.percentWidth = 100;
100
+ chart.percentHeight = 100;
101
+ chart.showDataTips = true;
102
+ chart.dataTipFunction = tooltipCallback;
103
+ //chart.height = "100%";
104
+ //chart.width = "100%";
105
+ chart.id = "chart";
106
+
107
+ chart_panel.addChild(chart);
108
+
109
+ var graph_items:XMLList = XMLList(result.graph_item);
110
+ var stroke:Stroke;
111
+ for each(var item:XML in graph_items) {
112
+ var ls:LineSeries = new LineSeries();
113
+ var ds:XMLList = XMLList(item.dataset.data);
114
+ ls.dataProvider = ds;
115
+ ls.yField = "y_value";
116
+ ls.xField = "x_value";
117
+ trace("color = " + int(item.color));
118
+ var s:Stroke = new Stroke(int(item.color), 1);
119
+ s.color = int(item.color);
120
+ s.alpha = 1;
121
+ ls.setStyle("lineStroke", s);
122
+ ls.displayName = item.title;
123
+ // chart.series.push(ls); # for some reason, this doesn't work. wtf?
124
+ var currentSeries:Array = chart.series;
125
+ currentSeries.push(ls);
126
+ chart.series = currentSeries;
127
+ }
128
+ }
129
+
130
+ private function tooltipCallback(hd:HitData):String {
131
+ return hd.item.x_value + "\n" + hd.item.y_value;
132
+ }
133
+ private function graphUri():String {
134
+ return URLUtil.objectToString(Application.application.parameters, '&', true);
135
+ }
136
+
137
+ ]]></mx:Script>
138
+
139
+ <mx:HTTPService id="graphService" url="{data_url}" resultFormat="e4x"/>
140
+
141
+ <mx:Panel width="100%" height="100%" id="chart_panel">
142
+ <mx:Legend dataProvider="{chart}"/>
143
+ </mx:Panel>
144
+ </mx:Application>
@@ -0,0 +1,32 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{flex_chart}
5
+ s.version = "0.1.2"
6
+
7
+
8
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
9
+ s.authors = ["Ron McClain"]
10
+ s.date = %q{2009-04-14}
11
+ s.description = %q{Interface to Flex Charting Components}
12
+ s.email = %q{mixtli@github.com}
13
+ s.extra_rdoc_files = ["README.rdoc", "tasks/flex_chart.rake", "lib/flex_chart.rb"]
14
+ s.files = ["README.rdoc", "Manifest", "init.rb", "public/swfs/FlexChart.swf", "flex/FlexChart.mxml", "tasks/flex_chart.rake", "lib/flex_chart.rb", "Rakefile", "flex_chart.gemspec"]
15
+ s.has_rdoc = true
16
+ s.homepage = %q{http://github.com/mixtli/flex_chart}
17
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Flex_chart", "--main", "README.rdoc"]
18
+ s.require_paths = ["lib"]
19
+ s.rubyforge_project = %q{flex_chart}
20
+ s.rubygems_version = %q{1.3.1}
21
+ s.summary = %q{Interface to Flex Charting Components}
22
+
23
+ if s.respond_to? :specification_version then
24
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
25
+ s.specification_version = 2
26
+
27
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
28
+ else
29
+ end
30
+ else
31
+ end
32
+ end
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ require 'flex_chart'
data/lib/flex_chart.rb ADDED
@@ -0,0 +1,60 @@
1
+ module FlexChart
2
+ class Base
3
+ attr_accessor :title, :x_label, :y_label, :series, :x_axis_type, :y_axis_type, :color, :fill_color
4
+
5
+ def initialize(options = {})
6
+ @series = []
7
+ @x_axis_type = "Linear"
8
+ @y_axis_type = "Linear"
9
+ end
10
+
11
+ def fix_color(color)
12
+ c = color.sub("#", "")
13
+ newstr = ""
14
+ c.each_char {|char| newstr << "#{char}0" }
15
+ "0x" + newstr
16
+ end
17
+
18
+ def to_xml
19
+ xml = Builder::XmlMarkup.new
20
+ xml.graph do
21
+ xml.title(@title)
22
+ xml.x_label(@x_label)
23
+ xml.y_label(@y_label)
24
+ xml.x_axis_type(@x_axis_type)
25
+ xml.y_axis_type(@y_axis_type)
26
+ xml.color(fix_color(@color))
27
+ xml.fill_color(fix_color(@fill_color))
28
+ xml.chart_type(self.class.to_s.split("::")[1])
29
+ series.each do |item|
30
+ xml.graph_item do
31
+ xml.title(item.title)
32
+ xml.color(fix_color(item.color))
33
+ xml.dataset do
34
+ item.values.each do |data|
35
+ xml.data do
36
+ xml.x_value(data[:x_value].strftime("%m/%d/%Y"))
37
+ xml.y_value(data[:y_value])
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+
47
+ class Series
48
+ attr_accessor :title, :color, :values
49
+ end
50
+
51
+ class Line < Base
52
+ end
53
+
54
+ class Pie < Base
55
+ end
56
+
57
+ class Area < Base
58
+ end
59
+
60
+ end
Binary file
@@ -0,0 +1,13 @@
1
+ namespace :flex_chart do
2
+
3
+ desc 'build flex component'
4
+ task :build do
5
+ system("mxmlc -output public/swfs/FlexChart.swf flex/FlexChart.mxml")
6
+ end
7
+
8
+ desc 'Install swf'
9
+ task :install_public => :environment do
10
+ system("cp #{File.dirname(__FILE__)}/public/swfs/FlexChart.swf #{RAILS_ROOT}/public/swfs")
11
+ end
12
+ end
13
+
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mixtli-mixtli-flex_chart
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.3
5
+ platform: ruby
6
+ authors:
7
+ - Ron McClain
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-06-06 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Ruby interface to Flex Charting component
17
+ email: mixtli@github.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README.rdoc
24
+ files:
25
+ - .gitignore
26
+ - Manifest
27
+ - README.rdoc
28
+ - Rakefile
29
+ - VERSION
30
+ - flex/FlexChart.mxml
31
+ - flex_chart.gemspec
32
+ - init.rb
33
+ - lib/flex_chart.rb
34
+ - public/swfs/FlexChart.swf
35
+ - tasks/flex_chart.rake
36
+ has_rdoc: false
37
+ homepage: http://github.com/mixtli/flex_chart
38
+ post_install_message:
39
+ rdoc_options:
40
+ - --charset=UTF-8
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: "0"
48
+ version:
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ version:
55
+ requirements: []
56
+
57
+ rubyforge_project:
58
+ rubygems_version: 1.2.0
59
+ signing_key:
60
+ specification_version: 3
61
+ summary: Ruby interface to Flex Charting component
62
+ test_files: []
63
+