iOS library to create simple bar charts.
Given an array of NSNumber objects, the library will generate a UIImage object containing a simple graph representing them. The height of the tallest bar will correspond to the maximum value of the array.
-
Import the files located in the folder Source/ to your project.
-
Initialize an instance of MBBarGrapher with a non-empty NSArray containing only instances of NSNumbers.
NSArray *exampleValues = @[@23, @35.5, @20, @70.2, @45.5, @47.7, @13.2, @33.3, @69.999, @83.25, @90.2, @99.9, @120.0]; MBBarGrapher *barGrapher = [[MBBarGrapher alloc] initWithValues:exampleValues];
-
Adjust the background, outline and fill colors and the space between bars
barGrapher.percentageOfSpaceBetweenBars = 0.2; barGrapher.fillColor = [UIColor orangeColor]; barGrapher.strokeColor = [UIColor blackColor]; barGrapher.backgroundColor = [UIColor clearColor];
-
Generate a UIImage to display on screen, send through the Internetz or whatever.
self.imaginaryImageView.image = [barGrapher generateImageForSize:self.imaginaryImageView.bounds.size];
-
Live happily ever after.
- Currently the library handles only positive real values.
Refer to the "Issues" section in Github.
Of course! Fork this project and feel free to contribute your ideas, bug-fixes, re-factoring or suggestions through a pull-request.
Copyright (c) 2013 Hector Zarate
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.