Convert Figma logo to code with AI

Boris-Em logoBEMSimpleLineGraph

Elegant Line Graphs for iOS. (Charting library)

2,656
383
2,656
49

Top Related Projects

27,507

Beautiful charts for iOS/tvOS/OSX! The Apple side of the crossplatform MPAndroidChart.

A powerful 🚀 Android chart view / graph view library, supporting line- bar- pie- radar- bubble- and candlestick charts as well as scaling, panning and animations.

📈📊🚀🚀🚀An elegant modern declarative data visualization chart framework for iOS, iPadOS and macOS. Extremely powerful, supports line, spline, area, areaspline, column, bar, pie, scatter, angular gauges, arearange, areasplinerange, columnrange, bubble, box plot, error bars, funnel, waterfall and polar chart types. 极其精美而又强大的现代化声明式数据可视化图表框架,支持柱状图、条形图、折线图、曲线图、折线填充图、曲线填充图、气泡图、扇形图、环形图、散点图、雷达图、混合图等各种类型的多达几十种的信息图图表,完全满足工作所需.

Android Graph Library for creating zoomable and scrollable line and bar graphs.

9,714

A simple and beautiful chart lib used in Piner and CoinsMan for iOS

Quick Overview

BEMSimpleLineGraph is an iOS library for creating elegant and customizable line graphs. It provides an easy-to-use interface for developers to create visually appealing graphs with smooth animations and interactive features. The library is written in Objective-C but can be used in Swift projects as well.

Pros

  • Simple and intuitive API for creating line graphs
  • Highly customizable with various styling options
  • Smooth animations for data updates and user interactions
  • Supports multiple lines and touch events for data points

Cons

  • Limited to line graphs only, no support for other chart types
  • Last updated in 2019, may lack support for newer iOS versions
  • Documentation could be more comprehensive
  • No built-in support for landscape orientation

Code Examples

Creating a basic line graph:

BEMSimpleLineGraphView *myGraph = [[BEMSimpleLineGraphView alloc] initWithFrame:CGRectMake(0, 0, 320, 200)];
myGraph.dataSource = self;
myGraph.delegate = self;
[self.view addSubview:myGraph];

Implementing the data source method:

- (NSInteger)numberOfPointsInLineGraph:(BEMSimpleLineGraphView *)graph {
    return 5;
}

- (CGFloat)lineGraph:(BEMSimpleLineGraphView *)graph valueForPointAtIndex:(NSInteger)index {
    return @[@10, @20, @30, @40, @50][index].floatValue;
}

Customizing graph appearance:

myGraph.colorLine = [UIColor blueColor];
myGraph.colorTop = [UIColor redColor];
myGraph.colorBottom = [UIColor greenColor];
myGraph.animationGraphEntranceTime = 1.0;
myGraph.enableTouchReport = YES;

Getting Started

  1. Install via CocoaPods by adding to your Podfile:

    pod 'BEMSimpleLineGraph'
    
  2. Import the header in your view controller:

    #import <BEMSimpleLineGraph/BEMSimpleLineGraph.h>
    
  3. Create and configure the graph:

    BEMSimpleLineGraphView *graph = [[BEMSimpleLineGraphView alloc] initWithFrame:self.view.bounds];
    graph.dataSource = self;
    graph.delegate = self;
    [self.view addSubview:graph];
    
  4. Implement the required data source methods:

    - (NSInteger)numberOfPointsInLineGraph:(BEMSimpleLineGraphView *)graph {
        return yourDataArray.count;
    }
    
    - (CGFloat)lineGraph:(BEMSimpleLineGraphView *)graph valueForPointAtIndex:(NSInteger)index {
        return [yourDataArray[index] floatValue];
    }
    
  5. Customize the graph appearance and behavior as needed using the various properties and delegate methods provided by the library.

Competitor Comparisons

27,507

Beautiful charts for iOS/tvOS/OSX! The Apple side of the crossplatform MPAndroidChart.

Pros of Charts

  • More comprehensive and feature-rich, offering a wide variety of chart types
  • Highly customizable with extensive documentation and community support
  • Regular updates and active maintenance

Cons of Charts

  • Steeper learning curve due to its complexity and extensive features
  • Larger file size and potentially higher memory footprint
  • May be overkill for simple line graph requirements

Code Comparison

BEMSimpleLineGraph:

let graph = BEMSimpleLineGraphView(frame: CGRect(x: 0, y: 0, width: 320, height: 200))
graph.dataSource = self
graph.delegate = self
view.addSubview(graph)

Charts:

let lineChartView = LineChartView(frame: CGRect(x: 0, y: 0, width: 320, height: 200))
let dataSet = LineChartDataSet(entries: entries, label: "Line Chart")
let data = LineChartData(dataSet: dataSet)
lineChartView.data = data
view.addSubview(lineChartView)

BEMSimpleLineGraph is more straightforward for simple line graphs, while Charts offers more flexibility and customization options but requires more setup code.

A powerful 🚀 Android chart view / graph view library, supporting line- bar- pie- radar- bubble- and candlestick charts as well as scaling, panning and animations.

Pros of MPAndroidChart

  • More comprehensive and feature-rich, offering a wide variety of chart types
  • Highly customizable with extensive documentation and community support
  • Regular updates and active maintenance

Cons of MPAndroidChart

  • Steeper learning curve due to its complexity and extensive features
  • Larger library size, which may impact app size and performance
  • Potentially overkill for simple line graph requirements

Code Comparison

BEMSimpleLineGraph:

BEMSimpleLineGraphView *myGraph = [[BEMSimpleLineGraphView alloc] initWithFrame:CGRectMake(0, 0, 320, 200)];
myGraph.dataSource = self;
[self.view addSubview:myGraph];

MPAndroidChart:

LineChart chart = findViewById(R.id.chart);
LineData data = new LineData(dataSets);
chart.setData(data);
chart.invalidate();

BEMSimpleLineGraph is specifically designed for iOS and uses Objective-C, while MPAndroidChart is for Android and uses Java. BEMSimpleLineGraph focuses solely on line graphs, making it simpler to implement for basic use cases. MPAndroidChart offers more chart types and customization options but requires more setup and configuration.

📈📊🚀🚀🚀An elegant modern declarative data visualization chart framework for iOS, iPadOS and macOS. Extremely powerful, supports line, spline, area, areaspline, column, bar, pie, scatter, angular gauges, arearange, areasplinerange, columnrange, bubble, box plot, error bars, funnel, waterfall and polar chart types. 极其精美而又强大的现代化声明式数据可视化图表框架,支持柱状图、条形图、折线图、曲线图、折线填充图、曲线填充图、气泡图、扇形图、环形图、散点图、雷达图、混合图等各种类型的多达几十种的信息图图表,完全满足工作所需.

Pros of AAChartKit

  • More comprehensive charting options, including 3D charts and various chart types
  • Extensive customization capabilities for chart appearance and behavior
  • Active development and frequent updates

Cons of AAChartKit

  • Steeper learning curve due to more complex API
  • Larger library size, potentially impacting app performance
  • May be overkill for simple line graph requirements

Code Comparison

BEMSimpleLineGraph:

BEMSimpleLineGraphView *myGraph = [[BEMSimpleLineGraphView alloc] initWithFrame:CGRectMake(0, 0, 320, 200)];
myGraph.dataSource = self;
[self.view addSubview:myGraph];

AAChartKit:

let chartView = AAChartView()
chartView.frame = CGRect(x: 0, y: 0, width: 320, height: 200)
let chartModel = AAChartModel()
    .chartType(.line)
    .title("Line Chart")
    .series([
        AASeriesElement()
            .name("Data")
            .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])
    ])
chartView.aa_drawChartWithChartModel(chartModel)

BEMSimpleLineGraph is more straightforward for simple line graphs, while AAChartKit offers more flexibility and options but requires more setup code.

Android Graph Library for creating zoomable and scrollable line and bar graphs.

Pros of GraphView

  • More feature-rich, offering various graph types (line, bar, point)
  • Supports real-time data updates and scrolling graphs
  • Extensive customization options for labels, colors, and styles

Cons of GraphView

  • Steeper learning curve due to more complex API
  • Larger library size, potentially impacting app performance
  • May be overkill for simple line graph needs

Code Comparison

BEMSimpleLineGraph:

BEMSimpleLineGraphView *myGraph = [[BEMSimpleLineGraphView alloc] initWithFrame:CGRectMake(0, 0, 320, 200)];
myGraph.dataSource = self;
[self.view addSubview:myGraph];

GraphView:

GraphView graph = new LineGraphView(this, null);
graph.addSeries(new GraphViewSeries(new GraphViewData[] {
    new GraphViewData(1, 2.0d),
    new GraphViewData(2, 1.5d),
    new GraphViewData(3, 2.5d),
    new GraphViewData(4, 1.0d)
}));

BEMSimpleLineGraph is simpler to implement for basic line graphs, while GraphView offers more flexibility but requires more setup code. GraphView is better suited for complex graphing needs, while BEMSimpleLineGraph excels in creating clean, minimalist line graphs with less overhead.

9,714

A simple and beautiful chart lib used in Piner and CoinsMan for iOS

Pros of PNChart

  • Offers a wider variety of chart types (line, bar, circle, pie, radar)
  • Provides more customization options for chart appearance
  • Includes animations for chart rendering and updates

Cons of PNChart

  • More complex to implement due to its extensive feature set
  • Larger codebase, potentially impacting app size and performance
  • Less frequently updated compared to BEMSimpleLineGraph

Code Comparison

BEMSimpleLineGraph:

BEMSimpleLineGraphView *myGraph = [[BEMSimpleLineGraphView alloc] initWithFrame:CGRectMake(0, 0, 320, 200)];
myGraph.dataSource = self;
[self.view addSubview:myGraph];

PNChart:

PNLineChart *lineChart = [[PNLineChart alloc] initWithFrame:CGRectMake(0, 0, 320, 200)];
[lineChart setXLabels:@[@"SEP 1",@"SEP 2",@"SEP 3",@"SEP 4",@"SEP 5"]];
[lineChart setYValues:@[@60.1, @25.0, @75.4, @30.2, @98.3]];
[lineChart strokeChart];
[self.view addSubview:lineChart];

BEMSimpleLineGraph focuses on simplicity and ease of use for line graphs, while PNChart offers more chart types and customization options at the cost of increased complexity. BEMSimpleLineGraph may be preferable for projects requiring only line graphs, while PNChart is better suited for applications needing diverse chart types and advanced customization.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

BEMSimpleLineGraph

Build Status Version License Platform

BEMSimpleLineGraph makes it easy to create and customize line graphs for iOS.

BEMSimpleLineGraph is a charting library that makes it easy to create beautiful line graphs for iOS. It is easy to set-up and to use in any iOS Project. It's focused on highly customizable and interactive line graphs. Plus, it is lightweight and can be integrated in minutes (maybe even seconds).

BEMSimpleLineGraph's implementation, data source, and delegate are all modeled off of UITableView and UICollectionView. If you're familiar with using a UITableView, UITableViewController, or UICollectionView, using BEMSimpleLineGraph should be a breeze!

The full documentation of the project is available on its wiki.

Table of Contents

Project Details

Learn more about the BEMSimpleLineGraph project requirements, licensing, and contributions.

Requirements

See the full article on the wiki here.

  • Requires iOS 7 or later. The sample project is optimized for iOS 8.
  • Requires Automatic Reference Counting (ARC).
  • Optimized for ARM64 Architecture

Requires Xcode 6 for use in any iOS Project. Requires a minimum of iOS 7.0 as the deployment target.

Current Build TargetEarliest Supported Build TargetEarliest Compatible Build Target
iOS 8.0iOS 7.0iOS 6.1
Xcode 6.3Xcode 6.1.1Xcode 6.0
LLVM 6.1LLVM 6.1LLVM 5.0

REQUIREMENTS NOTE
Supported means that the library has been tested with this version. Compatible means that the library should work on this OS version (i.e. it doesn't rely on any unavailable SDK features) but is no longer being tested for compatibility and may require tweaking or bug fixes to run correctly.

License

See the License. You are free to make changes and use this in either personal or commercial projects. Attribution is not required, but it is appreciated. A little Thanks! (or something to that affect) would be much appreciated. If you use BEMSimpleLineGraph in your app, let us know.

Support

Gitter chat
Join us on Gitter if you need any help or want to talk about the project.

Ask questions and get answers from a massive community or programmers on StackOverflow when you use the BEMSimpleLineGraph tag.

Sample App

The iOS Sample App included with this project demonstrates how to correctly setup and use BEMSimpleLineGraph. You can refer to the sample app for an understanding of how to use and setup BEMSimpleLineGraph.

Apps Using This Project

Dozens of production apps available on the iOS App Store use BEMSimpleLineGraph. You can view a full list of the known App Store apps using this project on the wiki, read their descriptions, get links, pricing, featured status, and screenshots of graph usage.

Add your BEMSimpleLineGraph app to the wiki page for a chance to get showcased in the Readme and / or the wiki. We can't wait to see what you create with BEMSimpleLineGraph.

Getting Started

See the full article on the wiki here.

BEMSimpleLineGraph can be added to any project (big or small) in a matter of minutes (maybe even seconds if you're super speedy). CocoaPods is fully supported, and so are all the latest technologies (eg. ARC, Storyboards, Interface Builder Attributes, Modules, and more).

Installation

The easiest way to install BEMSimpleLineGraph is to use CocoaPods. To do so, simply add the following line to your Podfile:

pod 'BEMSimpleLineGraph'

The other way to install BEMSimpleLineGraph, is to drag and drop the Classes folder into your Xcode project. When you do so, check the "Copy items into destination group's folder" box.

Swift Projects

To use BEMSimpleLineGraph in a Swift project add the following to your bridging header:

#import "BEMSimpleLineGraphView.h"

Setup

Setting up BEMSimpleLineGraph in your project is simple. If you're familiar with UITableView, then **BEMSimpleLineGraph **should be a breeze. Follow the steps below to get everything up and running.

  1. Import "BEMSimpleLineGraphView.h" to the header of your view controller:

     #import "BEMSimpleLineGraphView.h"
    
  2. Implement the BEMSimpleLineGraphDelegate and BEMSimpleLineGraphDataSource in the same view controller:

     @interface YourViewController : UIViewController <BEMSimpleLineGraphDataSource, BEMSimpleLineGraphDelegate>
    
  3. BEMSimpleLineGraphView can be initialized in one of two ways. You can either add it directly to your interface (storyboard file) OR through code. Both ways provide the same initialization, just different ways to do the same thing. Use the method that makes sense for your app or project.

    Interface Initialization
    1 - Add a UIView to your UIViewController
    2 - Change the class type of the UIView to BEMSimpleLineGraphView
    3 - Link the view to your code using an IBOutlet. You can set the property to weak and nonatomic.
    4 - Select the BEMSimpleLineGraphView in your interface. Connect the dataSource property and then the delegate property to your ViewController.
    5 - Select the BEMSimpleLineGraphView and open the Attributes Inspector. Most of the line graph's customizable properties can easily be set from the Attributes Inspector. The Sample App demonstrates this capability. Note that graph data will not be loaded in Interface Builder.

    Code Initialization
    Just add the following code to your implementation (usually the viewDidLoad method).

    BEMSimpleLineGraphView *myGraph = [[BEMSimpleLineGraphView alloc] initWithFrame:CGRectMake(0, 0, 320, 200)];
    myGraph.dataSource = self;
    myGraph.delegate = self;
    [self.view addSubview:myGraph];
    
  4. Implement the two required data source methods: numberOfPointsInLineGraph: and lineGraph:valueForPointAtIndex:. See documentation below for more information

Documentation

The essential parts of BEMSimpleLineGraph are documented below. For full documentation, see the wiki. Documentation is available directly within Xcode (just Option-Click any method for Quick Help).

Required Delegate / Data Source Methods

Number of Points in Graph
Returns the number of points in the line graph. The line graph gets the value returned by this method from its data source and caches it.

- (NSInteger)numberOfPointsInLineGraph:(BEMSimpleLineGraphView *)graph {
		return X; // Number of points in the graph.
}

Value for Point at Index
Informs the position of each point on the Y-Axis at a given index. This method is called for every point specified in the numberOfPointsInLineGraph: method. The parameter index is the position from left to right of the point on the X-Axis:

- (CGFloat)lineGraph:(BEMSimpleLineGraphView *)graph valueForPointAtIndex:(NSInteger)index {
		return …; // The value of the point on the Y-Axis for the index.
}

Reloading the Data Source

Similar to a UITableView's reloadData method, BEMSimpleLineGraph has a reloadGraph method. Call this method to reload all the data that is used to construct the graph, including points, axis, index arrays, colors, alphas, and so on. Calling this method will cause the line graph to call layoutSubviews on itself. The line graph will also call all of its data source and delegate methods again (to get the updated data).

- (void)anyMethodInYourOwnController {
    // Change graph properties
    // Update data source / arrays
    
    // Reload the graph
    [self.myGraph reloadGraph];
}

Interactive Graph

BEMSimpleLineGraph can react to the user touching the graph by two different ways: Popup Reporting and Touch Reporting.

On this example, both Popup Reporting and Touch Reporting are activated.

Bezier Curves

BEMSimpleLineGraph can be drawn with curved lines instead of directly connecting the dots with straight lines.
To do so, set the property enableBezierCurve to YES.

self.myGraph.enableBezierCurve = YES;

Properties

BEMSimpleLineGraphs can be customized by using various properties. A multitude of properties let you control the animation, colors, and alpha of the graph. Many of these properties can be set from Interface Build and the Attributes Inspector, others must be set in code.

Contributing

To contribute to BEMSimpleLineGraph please see the CONTRIBUTING.md file, which lays out exactly how you can contribute to this project.