motion-plot 0.4.7 → 0.4.8

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -23,7 +23,12 @@ This library is a wrapper on top of [CorePlot](https://code.google.com/p/core-pl
23
23
 
24
24
  ## Usage
25
25
 
26
- Look at examples directory for usage options.
26
+ 1. Create a UIView (with frame size you wish)
27
+ 2. Build a JSON structure with details of chart (look at examples for more)
28
+ 3. Initialize the chart type with this json (it returns back an instance of CPTGraphHostingView)
29
+ 4. Add the view returned to your view
30
+
31
+ Look at examples directory for detail usage options.
27
32
 
28
33
  ## Contributing
29
34
 
@@ -116,6 +116,19 @@ module MotionPlot
116
116
 
117
117
  axis = @axes[:y]
118
118
  add_axis_title(@yaxis, axis.title)
119
+
120
+ if(axis.labels)
121
+ labels = axis.labels.each_with_index.map do |l, i|
122
+ @yaxis.labelingPolicy = CPTAxisLabelingPolicyNone
123
+ label = CPTAxisLabel.alloc.initWithText(l, textStyle: axis.text_style)
124
+ label.tickLocation = CPTDecimalFromInt(i)
125
+ label.offset = 3.0
126
+ label
127
+ end
128
+
129
+ @yaxis.axisLabels = NSSet.setWithArray(labels)
130
+ end
131
+
119
132
  @yaxis.setLabelTextStyle(axis.text_style)
120
133
  end
121
134
 
@@ -11,20 +11,35 @@ module MotionPlot
11
11
  index
12
12
  when CPTBarPlotFieldBarTip
13
13
  record_data = @delegated_to.series[plot.identifier].data[index]
14
- bar_tip_value(index, recordIndex:index, seriesData: @delegated_to.series[plot.identifier].data, startValue: record_data)
14
+ bar_tip_value(index, seriesData: @delegated_to.series[plot.identifier].data, startValue: record_data)
15
15
  when CPTBarPlotFieldBarBase
16
- bar_base_value(index, recordIndex:index, seriesData: @delegated_to.series[plot.identifier].data)
16
+ bar_base_value(index, seriesData: @delegated_to.series[plot.identifier].data)
17
17
  end
18
18
  end
19
19
 
20
+ def barPlot(plot, barWasSelectedAtRecordIndex:index)
21
+ if(@delegated_to.data_label and @delegated_to.data_label.annotation)
22
+ @delegated_to.graph.plotAreaFrame.plotArea.removeAnnotation(@delegated_to.data_label.annotation)
23
+ @delegated_to.data_label.annotation = nil
24
+ end
25
+
26
+ data_index = (index == @data_size - 1) ? (index - 1) : index
27
+ data = @delegated_to.series[plot.identifier].data
28
+ y_value = data[data_index].round(2)
29
+ y_pos = bar_tip_value(data_index, seriesData: data, startValue: y_value)
30
+ y_value = y_pos.round(2) if(index == @data_size - 1) # total bar of waterfall chart
31
+
32
+ @delegated_to.graph.plotAreaFrame.plotArea.addAnnotation(@delegated_to.data_label.annotation_for(y_value, atCoordinate: [index+CPTDecimalFloatValue(plot.barOffset), y_pos], plotSpace: @delegated_to.graph.defaultPlotSpace))
33
+ end
34
+
20
35
  protected
21
- def bar_base_value(data_index, recordIndex:index, seriesData: data)
36
+ def bar_base_value(data_index, seriesData: data)
22
37
  return 0 if(data_index == 0 || data_index == @data_size - 1)
23
38
 
24
39
  (0..data_index-1).inject(0) {|base, i| base + data[i] }
25
40
  end
26
41
 
27
- def bar_tip_value(data_index, recordIndex:index, seriesData: data, startValue: value)
42
+ def bar_tip_value(data_index, seriesData: data, startValue: value)
28
43
  data_index = data_index - 1 if(data_index == @data_size - 1)
29
44
 
30
45
  return value if(data_index == 0)
@@ -1,3 +1,3 @@
1
1
  module MotionPlot
2
- VERSION = "0.4.7"
2
+ VERSION = "0.4.8"
3
3
  end
data/motion-plot.gemspec CHANGED
@@ -4,8 +4,8 @@ require File.expand_path('../lib/motion-plot/version', __FILE__)
4
4
  Gem::Specification.new do |gem|
5
5
  gem.authors = ["Amit Kumar"]
6
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"
7
+ gem.description = "Create native iOS charts using simple JSON as you are used-to with Highcharts like JS library. This library is a wrapper on top of CorePlot"
8
+ gem.summary = "Create native iOS charts using simple JSON as you are used-to with Highcharts like JS library. This library is a wrapper on top of CorePlot"
9
9
  gem.homepage = ""
10
10
 
11
11
  gem.files = `git ls-files`.split("\n").delete_if {|x| x.include? "examples"}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motion-plot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.7
4
+ version: 0.4.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-24 00:00:00.000000000 Z
12
+ date: 2013-03-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bubble-wrap
@@ -59,8 +59,8 @@ dependencies:
59
59
  - - ! '>='
60
60
  - !ruby/object:Gem::Version
61
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
62
+ description: Create native iOS charts using simple JSON as you are used-to with Highcharts
63
+ like JS library. This library is a wrapper on top of CorePlot
64
64
  email:
65
65
  - toamitkumar@gmail.com
66
66
  executables: []
@@ -129,6 +129,6 @@ rubyforge_project:
129
129
  rubygems_version: 1.8.24
130
130
  signing_key:
131
131
  specification_version: 3
132
- summary: Build native charts as you are used with Highcharts/D3. This library is a
133
- wrapper on top of CorePlot
132
+ summary: Create native iOS charts using simple JSON as you are used-to with Highcharts
133
+ like JS library. This library is a wrapper on top of CorePlot
134
134
  test_files: []