Skip to content

matthewcheok/MCGraphView

Repository files navigation

MCGraphView License MIT

Badge w/ Version Badge w/ Platform

A light-weight solution for displaying graphs.

##Screenshot Screenshot

Installation

Add the following to your CocoaPods Podfile

pod 'MCGraphView', '~> 0.1'

or clone as a git submodule,

or just copy files in the MCGraphView folder into your project.

Using MCGraphView

Add the MCGraphView class either programmatically or assign the custom class via storyboard. Then set the lineData property:

self.graphView.lineData = @[
  @[
    [NSValue valueWithCGPoint:CGPointMake(1, 20)],
    [NSValue valueWithCGPoint:CGPointMake(2, 40)],
    [NSValue valueWithCGPoint:CGPointMake(3, 20)],
    [NSValue valueWithCGPoint:CGPointMake(4, 60)],
    [NSValue valueWithCGPoint:CGPointMake(5, 40)],
    [NSValue valueWithCGPoint:CGPointMake(6, 140)],
    [NSValue valueWithCGPoint:CGPointMake(7, 80)],
  ],
  @[
    [NSValue valueWithCGPoint:CGPointMake(1, 40)],
    [NSValue valueWithCGPoint:CGPointMake(2, 20)],
    [NSValue valueWithCGPoint:CGPointMake(3, 60)],
    [NSValue valueWithCGPoint:CGPointMake(4, 100)],
    [NSValue valueWithCGPoint:CGPointMake(5, 60)],
    [NSValue valueWithCGPoint:CGPointMake(6, 20)],
    [NSValue valueWithCGPoint:CGPointMake(7, 60)],
  ]
];

Then tell the view to reload data:

[self.graphView reloadDataAnimated:YES];

The view automatically determines the ideal region to display based on the maximum and minimum values of your points.

More configuration options are available via the delegate protocol MCGraphViewDelegate. See the demo project for details.

Credits

Inspired by GraphKit and BEMSimpleLineGraph.

License

MCGraphView is under the MIT license.

About

A light-weight solution for displaying graphs.

Resources

License

Stars

Watchers

Forks

Packages

No packages published