Browse files

Some addition to readme and cleanup

  • Loading branch information...
1 parent dfe83d4 commit 5094f14d9430fd65400f8ec50387d409e80620e5 @toamitkumar committed Mar 18, 2013
View
6 README.md
@@ -1,12 +1,12 @@
# Motion::Plot
-Build native charts as you are used with Highcharts/D3. This library is a wrapper on top of CorePlot
+Build native charts as you are used with Highcharts/D3. This library is a wrapper on top of [CorePlot](https://code.google.com/p/core-plot/), the iOS plotting framework to build native chart using CoreAnimation, Core Data and Cocoa Bindings
## Installation
Add this line to your application's Gemfile:
- gem 'motion-plot'
+ `gem 'motion-plot'`
And then execute:
@@ -16,6 +16,8 @@ Or install it yourself as:
$ gem install motion-plot
+And add `require 'motion-plot'` to your `Gemfile`
+
## Usage
Look at examples directory for usage options.
View
38 examples/LineChart/app/home_view_controller.rb
@@ -66,46 +66,16 @@ def add_chart
},
series: [{
name: 'Tokyo',
- data: [
- [7.0, 'Jan'],
- [6.9, 'Feb'],
- [9.5, 'Mar'],
- [14.5, 'Apr'],
- [18.2, 'May'],
- [21.5, 'Jun'],
- [25.2, 'Jul'],
- [26.5, 'Aug'],
- [23.3, 'Sep'],
- [18.3, 'Oct'],
- [13.9, 'Nov'],
- [9.6, 'Dec']
- ],
- style: {
- color: "173B0B",
- width: 8.0
- }
+ data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]
}, {
name: 'New York',
- data: [
- [0.2, 'Jan'],
- [0.8, 'Feb'],
- [5.7, 'Mar'],
- [11.3, 'Apr'],
- [17.0, 'May'],
- [22.0, 'Jun'],
- [24.8, 'Jul'],
- [24.1, 'Aug'],
- [20.1, 'Sep'],
- [14.1, 'Oct'],
- [8.6, 'Nov'],
- [2.5, 'Dec']
- ]
+ data: [0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8, 24.1, 20.1, 14.1, 8.6, 2.5]
}, {
name: 'Berlin',
- data: [[-0.9, 'Jan'], [0.6, 'Feb'], [3.5, 'Mar'], [8.4, 'Apr'], [13.5, 'May'], [17.0, 'Jun'], [18.6, 'Jul'], [17.9, 'Aug'], [14.3, 'Sep'], [9.0, 'Oct'], [3.9, 'Nov'], [1.0, 'Dec']]
+ data: [-0.9, 0.6, 3.5, 8.4, 13.5, 17.0, 18.6, 17.9, 14.3, 9.0, 3.9, 1.0]
}, {
name: 'London',
- data: [[3.9, 'Jan'], [4.2, 'Feb'], [5.7, 'Mar'], [8.5, 'Apr'], [11.9, 'May'], [15.2, 'Jun'], [17.0, 'Jul'], [16.6, 'Aug'], [14.2, 'Sep'], [10.3, 'Oct']]
+ data: [3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3]
}]
}
View
BIN examples/LineChart/vendor/Pods/.build/libPods.a
Binary file not shown.
View
4,884 examples/LineChart/vendor/Pods/Pods.bridgesupport
2,442 additions, 2,442 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
4,262 examples/LineChart/vendor/Pods/Pods.xcodeproj/project.pbxproj
2,131 additions, 2,131 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
BIN examples/LineChart/vendor/Pods/build-iPhoneSimulator/libPods.a
Binary file not shown.
View
6 lib/motion-plot/chart/base.rb
@@ -134,9 +134,9 @@ def add_plot_space
@plot_space.allowsUserInteraction = true
end
- def add_plot_symbol(line, index)
- line.plotSymbol = @plot_symbol.symbol_for(line, atIndex: index)
- line.plotSymbolMarginForHitDetection = 5.0
+ def add_plot_symbol(plot, index)
+ plot.plotSymbol = @plot_symbol.symbol_for(plot, atIndex: index)
+ plot.plotSymbolMarginForHitDetection = 5.0
end
def add_xy_range
View
4 lib/motion-plot/chart/line_plot.rb
@@ -36,7 +36,7 @@ def scatterPlot(plot, plotSymbolWasSelectedAtRecordIndex:index)
@data_label.annotation = nil
end
- y_value = @series[plot.identifier].data[index][0].round(2)
+ y_value = @series[plot.identifier].data[index].round(2)
@graph.plotAreaFrame.plotArea.addAnnotation(@data_label.annotation_for(y_value, atCoordinate: [index, y_value], plotSpace: @graph.defaultPlotSpace))
end
@@ -47,7 +47,7 @@ def numberOfRecordsForPlot(plot)
def numberForPlot(plot, field:field_enum, recordIndex:index)
data = @series[plot.identifier].data
- (field_enum == CPTScatterPlotFieldY) ? data[index][0] : index
+ (field_enum == CPTScatterPlotFieldY) ? data[index] : index
end
protected
View
6 lib/motion-plot/utilities/plot_symbol.rb
@@ -21,11 +21,11 @@ def initialize(options={})
}
end
- def symbol_for(line, atIndex:index)
+ def symbol_for(plot, atIndex:index)
_style = CPTMutableLineStyle.lineStyle
- _style.lineColor = line.dataLineStyle.lineColor
+ _style.lineColor = plot.dataLineStyle.lineColor
symbol = MotionPlot::PlotSymbol[index]
- symbol.fill = CPTFill.fillWithColor(line.dataLineStyle.lineColor, colorWithAlphaComponent:0.5)
+ symbol.fill = CPTFill.fillWithColor(plot.dataLineStyle.lineColor, colorWithAlphaComponent:0.5)
symbol.lineStyle = _style
symbol.size = CGSizeMake(size.to_f, size.to_f)
View
2 lib/motion-plot/version.rb
@@ -1,3 +1,3 @@
module MotionPlot
- VERSION = "0.4.2"
+ VERSION = "0.4.3"
end

0 comments on commit 5094f14

Please sign in to comment.