motion-plot 0.4.2

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.
@@ -0,0 +1,36 @@
1
+ module MotionPlot
2
+ class DataLabel
3
+
4
+ DEFAULTS = {
5
+ displacement: [0.0, 12.0]
6
+ }.merge(Style::DEFAULTS)
7
+
8
+ attr_accessor :annotation
9
+
10
+ def initialize(options={})
11
+ @attributes = DEFAULTS.merge(options)
12
+ @style = Style.new(@attributes)
13
+ end
14
+
15
+ def style
16
+ TextStyle.cpt_text_style(@style)
17
+ end
18
+
19
+ def displacement
20
+ @attributes[:displacement]
21
+ end
22
+
23
+ def annotation_for(value, atCoordinate: coordinate, plotSpace: plot_space)
24
+ @annotation = CPTPlotSpaceAnnotation.alloc.initWithPlotSpace(plot_space, anchorPlotPoint:coordinate)
25
+ @annotation.contentLayer = annotation_text_style(value)
26
+ @annotation.displacement = @attributes[:displacement]
27
+
28
+ @annotation
29
+ end
30
+
31
+ def annotation_text_style(value)
32
+ CPTTextLayer.alloc.initWithText(value.to_s, style:style)
33
+ end
34
+
35
+ end
36
+ end
@@ -0,0 +1,45 @@
1
+ module MotionPlot
2
+ class Legend
3
+
4
+ attr_accessor :swatch_size, :corner_radius, :number_of_columns, :number_of_rows, :position, :displacement, :enabled, :style, :fill_color
5
+
6
+ DEFAULTS = {
7
+ swatch_size: [25.0, 25.0],
8
+ corner_radius: 5,
9
+ position: "top",
10
+ displacement: [0.0, 0.0],
11
+ fill_color: "FFFFFF"
12
+ }
13
+
14
+ def initialize(args={})
15
+ options = DEFAULTS.merge(args)
16
+
17
+ options.each_pair {|key, value|
18
+ send("#{key}=", value) if(respond_to?("#{key}="))
19
+ }
20
+
21
+ @style = args[:style] ? Style.new(args[:style]) : Style.new
22
+ end
23
+
24
+ def enabled?
25
+ enabled
26
+ end
27
+
28
+ def position
29
+ AnchorPosition.send(@position)
30
+ end
31
+
32
+ def cpt_legend(graph)
33
+ legend = CPTLegend.legendWithGraph(graph)
34
+ legend.fill = CPTFill.fillWithColor(fill_color.to_color.to_cpt_color)
35
+ legend.cornerRadius = corner_radius
36
+ legend.swatchSize = swatch_size
37
+ legend.textStyle = TextStyle.cpt_text_style(@style) if(@style)
38
+
39
+ p @style
40
+
41
+ legend
42
+ end
43
+
44
+ end
45
+ end
@@ -0,0 +1,43 @@
1
+ module MotionPlot
2
+ class PlotArea
3
+
4
+ attr_accessor :padding, :mask_to_border, :border_line_style, :corner_radius
5
+
6
+ def self.default_border_line_style
7
+ line_style = CPTMutableLineStyle.lineStyle
8
+ line_style.lineColor = CPTColor.blackColor
9
+ line_style.lineWidth = 2.0
10
+
11
+ line_style
12
+ end
13
+
14
+ DEFAULTS = {
15
+ padding: [50.0, 10.0, 20.0, 20.0],
16
+ border_line_style: default_border_line_style,
17
+ mask_to_border: false,
18
+ corner_radius: 5.0
19
+ }
20
+
21
+ def initialize(args={})
22
+ options = DEFAULTS.merge(args)
23
+
24
+ options.each_pair {|key, value|
25
+ send("#{key}=", value) if(respond_to?("#{key}="))
26
+ }
27
+ end
28
+
29
+ def add_style(graph_plot_area)
30
+ graph_plot_area.masksToBorder = @mask_to_border
31
+ graph_plot_area.borderLineStyle = @border_line_style || nil
32
+ graph_plot_area.cornerRadius = @corner_radius unless(border_line_style.nil?)
33
+
34
+
35
+ %W(left top right bottom).each_with_index do |pos, index|
36
+ graph_plot_area.send("padding#{pos.camelize}=", @padding[index]) unless(padding[index].nil?)
37
+ end
38
+
39
+ graph_plot_area
40
+ end
41
+
42
+ end
43
+ end
@@ -0,0 +1,16 @@
1
+ module MotionPlot
2
+ class PlotOptions
3
+
4
+ attr_accessor :options
5
+
6
+ def initialize(args={})
7
+ @options = {}
8
+ args.each_pair{|k,v| @options[k] = v}
9
+ end
10
+
11
+ def method_missing(m, *args, &block)
12
+ @options[m]
13
+ end
14
+
15
+ end
16
+ end
@@ -0,0 +1,51 @@
1
+ module MotionPlot
2
+ class PlotSymbol
3
+
4
+ ALIASES = {
5
+ :rectangle => "rectanglePlotSymbol",
6
+ :plus => "plusPlotSymbol",
7
+ :star => "starPlotSymbol",
8
+ :diamond => "diamondPlotSymbol",
9
+ :triangle => "trianglePlotSymbol",
10
+ :pentagon => "pentagonPlotSymbol",
11
+ :hexagon => "hexagonPlotSymbol",
12
+ :dash => "dashPlotSymbol",
13
+ :snow => "snowPlotSymbol"
14
+ }
15
+
16
+ attr_accessor :enabled, :size
17
+
18
+ def initialize(options={})
19
+ options.each_pair {|key, value|
20
+ send("#{key}=", value) if(respond_to?("#{key}="))
21
+ }
22
+ end
23
+
24
+ def symbol_for(plot, atIndex:index)
25
+ _style = CPTMutableLineStyle.lineStyle
26
+ _style.lineColor = plot.dataLineStyle.lineColor
27
+ symbol = MotionPlot::PlotSymbol[index]
28
+ symbol.fill = CPTFill.fillWithColor(plot.dataLineStyle.lineColor, colorWithAlphaComponent:0.5)
29
+ symbol.lineStyle = _style
30
+ symbol.size = CGSizeMake(size.to_f, size.to_f)
31
+
32
+ symbol
33
+ end
34
+
35
+ class << self
36
+ def method_missing(m, *args, &block)
37
+ method_name = m == :default ? :rectangle : m
38
+
39
+ raise unless(ALIASES.keys.include?(method_name))
40
+
41
+ CPTPlotSymbol.send(ALIASES[method_name])
42
+ end
43
+
44
+ def [](index)
45
+ index = 0 if(index > 9)
46
+
47
+ send(ALIASES.keys[index])
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,34 @@
1
+ module MotionPlot
2
+ class Style
3
+ attr_accessor :font_name, :font_size, :offset, :alignment, :color, :rotation, :width, :gradient, :padding, :plot_area
4
+
5
+ DEFAULTS = {
6
+ font_name: "Helvetica",
7
+ font_size: 10,
8
+ offset: 10,
9
+ color: "000000",
10
+ padding: [5.0, 10.0, 5.0, 10.0]
11
+ }
12
+
13
+ def initialize(args={})
14
+ options = DEFAULTS.merge(args)
15
+
16
+ options.each_pair {|key, value|
17
+ send("#{key}=", value) if(respond_to?("#{key}="))
18
+ }
19
+
20
+ @plot_area = PlotArea.new(args[:plot_area] || {})
21
+ end
22
+
23
+ def paddings_for(graph)
24
+ %W(left top right bottom).each_with_index do |pos, index|
25
+ graph.send("padding#{pos.camelize}=", @padding[index]) unless(padding[index].nil?)
26
+ end
27
+ end
28
+
29
+ def color
30
+ @color.to_color.to_cpt_color
31
+ end
32
+
33
+ end
34
+ end
@@ -0,0 +1,12 @@
1
+ module MotionPlot
2
+ class TextStyle
3
+ def self.cpt_text_style(style)
4
+ text_style = CPTMutableTextStyle.textStyle
5
+ text_style.color = style.color
6
+ text_style.fontName = style.font_name
7
+ text_style.fontSize = style.font_size
8
+
9
+ text_style
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,17 @@
1
+ module MotionPlot
2
+ class Title
3
+
4
+ attr_accessor :text, :position, :style
5
+
6
+ def initialize(options={})
7
+ @text = options[:text]
8
+ @position = options[:position] || AnchorPosition.default
9
+ @style = Style.new(options)
10
+ end
11
+
12
+ def text_style
13
+ TextStyle.cpt_text_style(@style)
14
+ end
15
+
16
+ end
17
+ end
@@ -0,0 +1,3 @@
1
+ module MotionPlot
2
+ VERSION = "0.4.2"
3
+ end
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/motion-plot/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Amit Kumar"]
6
+ gem.email = ["toamitkumar@gmail.com"]
7
+ gem.description = "Build native charts as you are used with Highcharts/D3. This library is a wrapper on top of CorePlot"
8
+ gem.summary = "Build native charts as you are used with Highcharts/D3. This library is a wrapper on top of CorePlot"
9
+ gem.homepage = ""
10
+
11
+ gem.files = `git ls-files`.split("\n").delete_if {|x| x.include? "examples"}
12
+ # gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+
15
+ gem.name = "motion-plot"
16
+ gem.require_paths = ["lib"]
17
+
18
+ gem.version = MotionPlot::VERSION
19
+
20
+ gem.add_dependency "bubble-wrap"
21
+ gem.add_dependency 'motion-cocoapods', '>= 1.2.1'
22
+ gem.add_development_dependency 'rake'
23
+ end
metadata ADDED
@@ -0,0 +1,127 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: motion-plot
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Amit Kumar
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-03-11 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bubble-wrap
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '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: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: motion-cocoapods
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: 1.2.1
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 1.2.1
46
+ - !ruby/object:Gem::Dependency
47
+ name: rake
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ description: Build native charts as you are used with Highcharts/D3. This library
63
+ is a wrapper on top of CorePlot
64
+ email:
65
+ - toamitkumar@gmail.com
66
+ executables: []
67
+ extensions: []
68
+ extra_rdoc_files: []
69
+ files:
70
+ - .gitignore
71
+ - .repl_history
72
+ - Gemfile
73
+ - LICENSE
74
+ - README.md
75
+ - Rakefile
76
+ - app/app_delegate.rb
77
+ - lib/motion-plot.rb
78
+ - lib/motion-plot/chart/area_plot.rb
79
+ - lib/motion-plot/chart/bar_plot.rb
80
+ - lib/motion-plot/chart/base.rb
81
+ - lib/motion-plot/chart/delegates/bar_delegate.rb
82
+ - lib/motion-plot/chart/delegates/percent_bar_delegate.rb
83
+ - lib/motion-plot/chart/delegates/stack_bar_delegate.rb
84
+ - lib/motion-plot/chart/line_plot.rb
85
+ - lib/motion-plot/chart/pie_plot.rb
86
+ - lib/motion-plot/core_ext/ui_color.rb
87
+ - lib/motion-plot/series/series.rb
88
+ - lib/motion-plot/theme/theme.rb
89
+ - lib/motion-plot/utilities/anchor_position.rb
90
+ - lib/motion-plot/utilities/area_gradient.rb
91
+ - lib/motion-plot/utilities/axis.rb
92
+ - lib/motion-plot/utilities/data_label.rb
93
+ - lib/motion-plot/utilities/legend.rb
94
+ - lib/motion-plot/utilities/plot_area.rb
95
+ - lib/motion-plot/utilities/plot_options.rb
96
+ - lib/motion-plot/utilities/plot_symbol.rb
97
+ - lib/motion-plot/utilities/style.rb
98
+ - lib/motion-plot/utilities/text_style.rb
99
+ - lib/motion-plot/utilities/title.rb
100
+ - lib/motion-plot/version.rb
101
+ - motion-plot.gemspec
102
+ homepage: ''
103
+ licenses: []
104
+ post_install_message:
105
+ rdoc_options: []
106
+ require_paths:
107
+ - lib
108
+ required_ruby_version: !ruby/object:Gem::Requirement
109
+ none: false
110
+ requirements:
111
+ - - ! '>='
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
+ none: false
116
+ requirements:
117
+ - - ! '>='
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ requirements: []
121
+ rubyforge_project:
122
+ rubygems_version: 1.8.24
123
+ signing_key:
124
+ specification_version: 3
125
+ summary: Build native charts as you are used with Highcharts/D3. This library is a
126
+ wrapper on top of CorePlot
127
+ test_files: []