plot_simple 0.1.3 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/app/views/plot_simple/_barchartxml.xml.erb +22 -0
- data/app/views/plot_simple/_piechartxml.xml.erb +13 -0
- data/app/views/plot_simple/_stackedcolumnxml.xml.erb +14 -0
- data/lib/plot_simple.rb +80 -50
- data/plot_simple.gemspec +5 -3
- metadata +22 -4
- data/app/views/plot_simple/_chartxml.xml.erb +0 -22
@@ -0,0 +1,22 @@
|
|
1
|
+
<chart>
|
2
|
+
<grid>
|
3
|
+
<title><%= chart.title.to_s%></title>
|
4
|
+
<background>transparent</background>
|
5
|
+
<borderColor><%=chart.borderColor.to_s%></borderColor>
|
6
|
+
<lineColor><%=chart.lineColor.to_s%></lineColor>
|
7
|
+
<width><%= chart.width.to_s %></width>
|
8
|
+
<height><%= chart.height.to_s%></height>
|
9
|
+
<% if !chart.seriesColors.blank? %>
|
10
|
+
<% chart.seriesColors.each do |color|%>
|
11
|
+
<seriesColor><%=color.to_s%></seriesColor>
|
12
|
+
<%end%>
|
13
|
+
<%end%>
|
14
|
+
</grid>
|
15
|
+
<backgroundImage><%= chart.backgroundImage.to_s%></backgroundImage>
|
16
|
+
<% chart.categories.each do |cat| %>
|
17
|
+
<category>
|
18
|
+
<tick text="<%= cat[:tick].to_s %>" />
|
19
|
+
<bar size="<%= cat[:bar_size].to_s %>" link="<%= cat[:link].to_s%>" />
|
20
|
+
</category>
|
21
|
+
<%end%>
|
22
|
+
</chart>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<?xml version="1.0" ?>
|
2
|
+
<chart>
|
3
|
+
<grid>
|
4
|
+
<width><%= chart.width.to_s%></width>
|
5
|
+
<height><%= chart.height.to_s %></height>
|
6
|
+
<backgroundImage><%= chart.backgroundImage.to_s%></backgroundImage>
|
7
|
+
</grid>
|
8
|
+
<category>
|
9
|
+
<% chart.categories.each do |cat|%>
|
10
|
+
<slice name="<%= cat[:tick] %>" size="<%= cat[:bar_size] %>" link="<%= cat[:link ]%>" />
|
11
|
+
<%end%>
|
12
|
+
</category>
|
13
|
+
</chart>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<chart>
|
2
|
+
<grid>
|
3
|
+
<title><%= chart.title.to_s%></title>
|
4
|
+
<width><%= chart.width.to_s%></width>
|
5
|
+
<height><%= chart.height.to_s%></height>
|
6
|
+
</grid>
|
7
|
+
<% chart.series.each_with_index do |serie,i|%>
|
8
|
+
<series link="<%= chart.links[i] %>">
|
9
|
+
<%serie.each do |part|%>
|
10
|
+
<partion size="<%=part%>"></partion>
|
11
|
+
<%end%>
|
12
|
+
</series>
|
13
|
+
<%end%>
|
14
|
+
</chart>
|
data/lib/plot_simple.rb
CHANGED
@@ -1,65 +1,95 @@
|
|
1
1
|
module PlotSimple
|
2
2
|
require 'engine' if defined?(Rails)
|
3
3
|
module Charts
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
4
|
+
#This will be a bump to 1.0.0...inserting objects
|
5
|
+
class BarChart
|
6
|
+
attr_accessor :type, :title, :backgroundImage, :background_color, :borderColor, :lineColor, :width, :height, :categories, :pointLabels, :seriesColors
|
7
|
+
def initialize
|
8
|
+
@type = "bar"
|
9
|
+
#just so that this can be an object
|
10
|
+
end
|
11
|
+
|
12
|
+
def setTitle(title)
|
13
|
+
@title = title;
|
14
|
+
end
|
15
|
+
|
16
|
+
def setBackgroundImage(image)
|
17
|
+
@backgroundImage = image
|
18
|
+
end
|
19
|
+
|
20
|
+
def setBackgroundColor(color)
|
21
|
+
@bgcolor = color
|
22
|
+
end
|
23
|
+
|
24
|
+
def setBorderColor(color)
|
25
|
+
@borderColor = color
|
26
|
+
end
|
27
|
+
|
28
|
+
def setLineColor(color)
|
29
|
+
@lineColor = color
|
30
|
+
end
|
31
|
+
|
32
|
+
def setWidth(width)
|
33
|
+
@width = width
|
34
|
+
end
|
35
|
+
|
36
|
+
def setHeight(height)
|
37
|
+
@height = height
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
def addCategory(name,size,link)
|
42
|
+
@categories ||= []
|
43
|
+
@pointLabels ||= []
|
44
|
+
@categories << Hash[:tick=>name,:bar_size=>size,:link=>link]
|
45
|
+
@pointLabels << size
|
46
|
+
end
|
47
|
+
|
48
|
+
def addSeriesColor(color)
|
49
|
+
@seriesColors ||= []
|
50
|
+
@seriesColors << color
|
51
|
+
end
|
52
|
+
|
53
|
+
def seriesColors
|
54
|
+
@seriesColors
|
55
|
+
end
|
56
|
+
|
40
57
|
end
|
41
58
|
|
42
|
-
|
43
|
-
|
59
|
+
class PieChart < BarChart
|
60
|
+
#Pretty much exactly the same as barchart as of 7/30/2012, so inherit from it...
|
61
|
+
#override initialize so we can use a method to get at XML later
|
62
|
+
def initialize
|
63
|
+
@type = "pie"
|
64
|
+
end
|
44
65
|
end
|
45
66
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
67
|
+
class StackedColumn < BarChart
|
68
|
+
attr_accessor :series, :links
|
69
|
+
def initialize
|
70
|
+
@type = "stacked"
|
71
|
+
end
|
72
|
+
|
73
|
+
def addSeries(series)
|
74
|
+
@series ||= []
|
75
|
+
@series << series
|
76
|
+
end
|
77
|
+
|
78
|
+
def addLinks(links)
|
79
|
+
@links = links
|
80
|
+
end
|
81
|
+
|
50
82
|
end
|
51
83
|
|
52
|
-
def addSeriesColor(color)
|
53
|
-
color = Hash[:color=>color]
|
54
|
-
@chart[:series_colors] << color
|
55
|
-
end
|
56
84
|
|
57
|
-
def
|
85
|
+
def chartToXML(chart = nil)
|
58
86
|
chart ||= @chart
|
59
|
-
if
|
60
|
-
render :partial=>"plot_simple/
|
61
|
-
|
87
|
+
if chart.type == "bar"
|
88
|
+
render :partial=>"plot_simple/barchartxml",:locals=>{:chart=>chart}
|
89
|
+
elsif chart.type == "pie"
|
62
90
|
render :partial=>"plot_simple/piechartxml",:locals=>{:chart=>chart}
|
91
|
+
elsif chart.type == "stacked"
|
92
|
+
render :partial=>"plot_simple/stackedcolumnxml",:locals=>{:chart=>chart}
|
63
93
|
end
|
64
94
|
end
|
65
95
|
|
data/plot_simple.gemspec
CHANGED
@@ -1,20 +1,22 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = %q{plot_simple}
|
3
|
-
s.version = "0.1
|
3
|
+
s.version = "1.0.1"
|
4
4
|
|
5
5
|
s.required_ruby_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
6
6
|
s.authors = %q{Travis Pessetto}
|
7
|
-
s.date =
|
7
|
+
s.date = Date.today
|
8
8
|
s.description = %q{A graphing engine for jqplot}
|
9
9
|
s.email = %q{travis.pessetto@es3inc.com}
|
10
10
|
s.extra_rdoc_files = [%q{README.md}, %q{lib/plot_simple.rb}]
|
11
|
-
s.files = [%q{README.md}, %q{lib/plot_simple.rb},%q{lib/engine.rb}, %q{plot_simple.gemspec},%q{app/views/plot_simple/
|
11
|
+
s.files = [%q{README.md}, %q{lib/plot_simple.rb},%q{lib/engine.rb}, %q{plot_simple.gemspec}, %q{app/views/plot_simple/_barchartxml.xml.erb},%q{app/views/plot_simple/_piechartxml.xml.erb},
|
12
|
+
%q{app/views/plot_simple/_stackedcolumnxml.xml.erb}]
|
12
13
|
s.homepage = %q{http://www.es3inc.com}
|
13
14
|
s.rdoc_options = [%q{--line-numbers}, %q{--inline-source}, %q{--title}, %q{plot_simple}, %q{--main}, %q{readme.rdoc}]
|
14
15
|
s.require_paths = [%q{lib}]
|
15
16
|
s.rubyforge_project = %q{plot_simple}
|
16
17
|
s.rubygems_version = %q{1.8.6}
|
17
18
|
s.summary = %q{A gem to simplify the creation of charts from the controller}
|
19
|
+
s.add_dependency('jquery_cheats', '>= 4.2.0')
|
18
20
|
|
19
21
|
if s.respond_to? :specification_version then
|
20
22
|
s.specification_version = 3
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: plot_simple
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 1.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,8 +9,24 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
13
|
-
dependencies:
|
12
|
+
date: 2012-07-31 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: jquery_cheats
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 4.2.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 4.2.0
|
14
30
|
description: A graphing engine for jqplot
|
15
31
|
email: travis.pessetto@es3inc.com
|
16
32
|
executables: []
|
@@ -23,7 +39,9 @@ files:
|
|
23
39
|
- lib/plot_simple.rb
|
24
40
|
- lib/engine.rb
|
25
41
|
- plot_simple.gemspec
|
26
|
-
- app/views/plot_simple/
|
42
|
+
- app/views/plot_simple/_barchartxml.xml.erb
|
43
|
+
- app/views/plot_simple/_piechartxml.xml.erb
|
44
|
+
- app/views/plot_simple/_stackedcolumnxml.xml.erb
|
27
45
|
homepage: http://www.es3inc.com
|
28
46
|
licenses: []
|
29
47
|
post_install_message:
|
@@ -1,22 +0,0 @@
|
|
1
|
-
<chart>
|
2
|
-
<grid>
|
3
|
-
<title><%=chart[:title]%></title>
|
4
|
-
<background>transparent</background>
|
5
|
-
<borderColor><%=chart[:background_color]%></borderColor>
|
6
|
-
<lineColor><%=chart[:line_color]%></lineColor>
|
7
|
-
<width><%= chart[:chart_width] %></width>
|
8
|
-
<height><%= chart[:chart_height]%></height>
|
9
|
-
<% if !chart[:series_colors].blank? %>
|
10
|
-
<% chart[:series_colors].each do |col|%>
|
11
|
-
<seriesColor><%=col[:color]%></seriesColor>
|
12
|
-
<%end%>
|
13
|
-
<%end%>
|
14
|
-
</grid>
|
15
|
-
<backgroundImage><%= chart[:background_image]%></backgroundImage>
|
16
|
-
<% chart[:categories].each do |cat| %>
|
17
|
-
<category>
|
18
|
-
<tick text="<%= cat[:tick] %>" />
|
19
|
-
<bar size="<%= cat[:bar_size] %>" link="<%= cat[:link]%>" />
|
20
|
-
</category>
|
21
|
-
<%end%>
|
22
|
-
</chart>
|