Giter Club home page Giter Club logo

bemsimplelinegraph's Introduction

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 Target Earliest Supported Build Target Earliest Compatible Build Target
iOS 8.0 iOS 7.0 iOS 6.1
Xcode 6.3 Xcode 6.1.1 Xcode 6.0
LLVM 6.1 LLVM 6.1 LLVM 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.

bemsimplelinegraph's People

Contributors

ben181231 avatar boris-em avatar bryant1410 avatar danielbuechele avatar davidql avatar dkk avatar jeffreyjackson avatar joeblau avatar kattrali avatar patters avatar readmecritic avatar rpassis avatar sam-spencer avatar sbhhbs avatar skywinder avatar vernsu avatar zrcoder avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bemsimplelinegraph's Issues

Use NSDate Objects for X-Axis

I'm wondering if it's possible to use NSDate objects for the X-axis labels, rather than text? This could be quite a large feature to implement, but I'm curious - have you considered adding it? Why would I want to do this?

  • it would allow axis labels to have timestamps relative to an NSDate object (e.g. 1 minute ago, 5 days ago...)
  • You could scale up/down the date resolution when zooming in/out. So at largest zoom level the dates read annually (2010, 2011), and when you zoom in the dates read at each zoom level (2010, Feb 2010, 3rd Feb 2010, 7pm 3rd Feb 2010...).

What do you think?

Displaying multiple lines by using two graphs

I want to show two lines in my graph, so I'm using a work-around where I add two graphs to my view, and make the top graph's background color clear. It works great.

My only problem is only the top graph will recognize the pan gesture that displays the values. Is there any way to pass the pan gesture along to bottom graph, so I can have both values displayed on the pan gesture?

Or maybe just add a feature for showing two lines in the same graph object?

Thanks!

labelXaxisOffset flipped

The labelXaxisOffset is flipped to that instead of it being offset from the bottom, the offset comes from the top. I entered the value 20, and all the labels are at the top of the graph.
screen shot 2014-05-06 at 11 42 48 am

Absolute Y Axis

I like having the option to auto-scale the Y axis for the graph, but I'd also like to be able to simply show absolute values. I'm currently hacking around this by auto-appending a value at the upper & lower range of my scale (40 & 180), so the graph auto scales between these values.

It would be great to have an option to set the scale to a range of values, on init (perhaps allowing for this to be set again later), rather than constantly autoscaling the graph.

Display pop-up label values all the time, not only on touch

I love this chart but since I want to place this on a horizontal scrolling UIScrollView I can't use the touch feature to display the labels, since that disables the scrolling. I would like an option to display the points and value labels all the time instead on only on touch.

Closest point not calculated correctly

currentlyCloser = pow((self.frame.size.width/(numberOfPoints-1))/2, 2);

currentlyCloser is declared as NSInteger:

NSInteger currentlyCloser;

- (BEMCircle *)closestDotFromtouchInputLine:(UIView *)touchInputLine 

method returns nil if there are more points, change it to CGFloat to fix this:

CGFloat currentlyCloser = pow((self.frame.size.width/(numberOfPoints-1))/2, 2);

Add option to draw an "average" line

First, a big thanks for this great lib... helps a lot!!

I would be nice to have the option to draw a "average" line (average value from all data values) in a different color.

index beyond bounds when touch graph

I am getting below error when touch graph, both numberOfPointsInLineGraph and valueForPointAtIndex return exactly two objects. So, I am wondering where 4294967196 comes from?
* Terminating app due to uncaught exception 'NSRangeException', reason: '* -[__NSArrayM objectAtIndex:]: index 4294967196 beyond bounds [0 .. 1]'

On Device

When run into device show error on -[BEMSimpleLineGraphView drawLines] at BEMSimpleLineGraphView.m:318:

Im replace my last version for the new one, in the simulator run perfect. BTW: its fabulous your charts great job, THANKS A LOT.

  • (void)drawLines {
    for (UIView subview in [self subviews]) {
    if ([subview isKindOfClass:[BEMLine class]])
    [subview removeFromSuperview];
    }
    BEMLine *line = [[BEMLine alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
    line.opaque = NO;
    line.alpha = 1;
    line.backgroundColor = [UIColor clearColor];
    line.topColor = self.colorTop;
    line.bottomColor = self.colorBottom;
    line.topAlpha = self.alphaTop;
    line.bottomAlpha = self.alphaBottom;
    line.lineWidth = self.widthLine;
    line.lineAlpha = self.alphaLine;
    line.bezierCurveIsEnabled = self.enableBezierCurve;
    line.arrayOfPoints = yAxisValues; // <-- this line
    /
    Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[BEMLine setArrayOfPoints:]: unrecognized selector sent to instance 0x135528cc0' */

    line.color = self.colorLine;
    line.animationTime = self.animationGraphEntranceTime;
    [self addSubview:line];
    [self sendSubviewToBack:line];

}

screen shot 2014-05-25 at 1 20 42 pm

Exception thrown when number of X-Axis label is not good

When labelOnXAxisForIndex returns a different amount of strings than numberOfPointsInLineGraph, the app crashes.
In this scenario, the labels shouldn't be displayed on the X-axis, but the app shouldn't return an exception.

Demo Project Not Working

The demo app included in the project crashes at launch. I guess it's something related to the Storyboard. Here's the crash log:

*** First throw call stack:
(
    0   CoreFoundation                      0x0180a1e4 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x015898e5 objc_exception_throw + 44
    2   UIKit                               0x007ad400 -[UIStoryboard name] + 0
    3   UIKit                               0x00249692 -[UIApplication _loadMainStoryboardFileNamed:bundle:] + 53
    4   UIKit                               0x00249949 -[UIApplication _loadMainInterfaceFile] + 245
    5   UIKit                               0x0024854e -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 543
    6   UIKit                               0x0025cf92 -[UIApplication handleEvent:withNewEvent:] + 3517
    7   UIKit                               0x0025d555 -[UIApplication sendEvent:] + 85
    8   UIKit                               0x0024a250 _UIApplicationHandleEvent + 683
    9   GraphicsServices                    0x037fff02 _PurpleEventCallback + 776
    10  GraphicsServices                    0x037ffa0d PurpleEventCallback + 46
    11  CoreFoundation                      0x01785ca5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
    12  CoreFoundation                      0x017859db __CFRunLoopDoSource1 + 523
    13  CoreFoundation                      0x017b068c __CFRunLoopRun + 2156
    14  CoreFoundation                      0x017af9d3 CFRunLoopRunSpecific + 467
    15  CoreFoundation                      0x017af7eb CFRunLoopRunInMode + 123
    16  UIKit                               0x00247d9c -[UIApplication _run] + 840
    17  UIKit                               0x00249f9b UIApplicationMain + 1225
    18  SimpleLineChart                     0x000115dd main + 141
    19  libdyld.dylib                       0x01e51701 start + 1
    20  ???                                 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

Y-axis label issues

The x-axis labels currently show up below the frame and the background is the color/alphaBottom. This is not the same for the y-axis. The background is the backgroundColor. This can be avoided by making the background a solid color, but any other styling will get you in trouble. The example looks fine, but a white backgroundColor with different alpha top/bottom has issues (that i'm currently experiencing).

Additionally, some y-axis labels are cutoff and only display "...". Personally, I would like to see this as just a smaller font if it cannot fit.

A way to avoid the above issues all together would to have the y-axis labels appear inside the graph's frame (with the y-axis). This would be the best solution to me.

Partial X-Axis, Partially Filled Graph

If you are looking for new features to implement, a feature I would like is the ability to set a static value for the x-axis maximum and x-axis label, so if there is not enough entries to fill the graph, you will see a partially filled graph.

Touch interaction on touch-down, not just start-pan?

Hola,

What do you think about an option to start registering user touch as soon as a touch event occurs, like a user touching the screen, versus the way it is now where a user has to begin panning on the graph before touch events are registered? I could see this improving discoverability a bit by any touch resulting in some action. Clearly this would need to be an option though, because that amount of responsiveness might be too heavy for some applications.

Just a thought. Curious what you think.

Thanks,

  • Conrad

Bug: If all the values are the same

Hi and thanks for this awesome tool.

When I wanna draw a chart with 6 numbers and all of them are 30.0 the app crashes and seems Line graph can not find the YAxis there. Would you mind please fix it ? Thanks

alwaysDisplayDots=YES is not having effect when animationGraphEntranceTime=0.0

When animationGraphEntranceTime=0.0, alwaysDisplayDots=YES is not showing dots. However the dots will appear ( and stays) once i pan through the graph.

The background reference line thickness is varying when animationGraphEntranceTime=0.0 and when it is having some value greater than 0.

animationGraphEntranceTime=0.5
screen shot 2014-08-19 at 7 47 15 pm

animationGraphEntranceTime=0.0
screen shot 2014-08-19 at 7 47 36 pm

Reference line is taking colorLine of graph but usually not the case. Can we set it explicitly?

Several Graphs in the same View Controller

Hi Boris,
Thank you for writing this control, I have found it great to work with. My only issue (and it's not one that I can't work around) is that when I have several graphs in the same view-controller, the data source and delegate methods lack a sender id, making it a bit hack-ish to present different datasets for the graphs. Do you think it could be a good idea to add it?

Something like this:

- (int)numberOfPointsInGraph:(id)sender {
   if ([sender isEqual:@"FirstGraph"]) {
      return (int)[self.ArrayOfFirstValues count];
   } else {
      return (int)[self.ArrayOfOtherValues count];
   }
}

Cheers,
Nils

Reference Lines & Frame

Follow-up of the conversation on issue #30. See specifically point4.

This feature would allow the user to draw reference lines according to the axis labels. See the red arrows on the picture above.

The work has been started by @Sam-Spencer (see commit 2b16d64). Only vertical reference lines (X-axis) and an X-axis frame are supported for now.

Outside the Graph

If I drag my finger off a graph that is only partially filling a view, I can keep dragging my finger outside the graph and the indicator line will follow. Also the indicator circle will appear on the edge of the graph, overlapping into the parent view.

img_0054

How to draw two relative graphs?

I wanted to draw two graphs overlapping each other to show the relative statistics of two different variables. I created two different instances of the graph and overlapped them like in the figure. the problem is, the max value of y for green graph is 7000 and for purple its 8000 but they are at the same height. I understand that it is because the maxValue is considered to mark the highest point and the two graphs have their respective maxValue as the highest points. Is there any way to relate both the graphs and represent values accordingly?
screen shot 2014-07-15 at 5 00 27 pm

Option to set Maximum Point on Y-Axis for the Line Graph

I'm trying to implement BEMSimpleLineGraph in my Project and so far everything is good, but there doesn't seem to be a method to set a Maximum Point for Y-Axis. The valueForPointAtIndex for my Graph would usually be between 3-7 but I'd like the graph's Y-Axis to be up to 10.

How would I make this happen?

Multiline Implementation - Padding & Min / Max

This post is after testing the lowerGraph implementation in one of the fork.

Showing two graphs is working fine for me. But the same is not making sense when the scale for two graphs are different. The maxValue and minValue of two graphs need not be same (I believe the y axis scale is divided based on minValue and maxValue for each graph)

Problem : In my project where I am showing total sale on each day on main graph ( Y = sale in $ X= days in month) and sale of particular product 'A' on lower graph. 25000 in lower graph is plotted much higher than the 45000 in main graph. ( total sale always greater than sale of a particular product hence the maxValue and minValue for each graph is different)

Parallel line for min/max values

I'd like to have an interface like shown on this mockup:

screenshot 2014-04-12 10 56 06

But I really have difficulties to find the correct y values for my min and max point.
Any suggestions?

Y-Axis zero value not aligned at graph origin

When drawing a graph the Y-Axis zero value appears above the origin of the graph. The coordinate (0, 0) should be in the lower left corner of the graph. However, it appears above the X-Axis at a seemingly arbitrary value such as (0, 10).

ios simulator screen shot jul 2 2014 10 33 37 pm

My guess is that this is a padding / calculation issue.

Glitches appearing on bezier corners

ios simulator screen shot 1 may 2014 12 28 35

If you use bezier corners, you sometimes get glitches at the data points. I dont really know how to describe this, but hopefully this makes it clearer:
glitch

Just Dots; No Line

Hello @Boris-Em, Thanks for sharing this excellent control.

Another great feature for this which would be easy to implement, is to allow the user to show/hide the bezier completely and just show the dots. What do you think?

Y-Axis labels

Follow-up of the conversation on issue #30. See specifically point2.

The feature branch now supports Y-axis labels thanks to @japanconman (see commit b5f21a2 & PR #32).

This feature is still being tested but so far seems to be working pretty well.

@Diaonic pointed out on a conversation on Gitter that the labels show too many numbers after the decimals point.

BEMSimpleLineGraph uses delegate for dataSource

Perhaps I'm wrong (as I've only just started implementing this control in an app) but it seems at first glance (without running the code) that the delegate receiver is also used as a datasource?

I cannot find a dataSource property to set on the line graph itself either? If I am incorrect, ignore this; if I am correct, I will submit a PR so that the datasource and delegate can have different receivers (more flexible design).

Gradient fill

I would like to have linear gradient fill for chart, instead of just single color bottomColor.

Scatter Plot

Another good idea would be the ability to create a scatter chart.

I managed to fiddle with the code and get the scatter effect in place but the x labels are messed up. There is nothing wrong with the project, rather than my code.

The idea behind the scatter chart is that I hide the bezier curves and show only the dots without the x labels showing up. Since the scatter dots are way more than the x labels I must find a way to show predefined labels for the x-axis that should span across all the width of the chart.

scatter

Just wanted to say thanks again for the chart and if you have time we could discuss the possibility of a scatter plot if you are interested.

BezierCurve issue

self.myGraph = [[BEMSimpleLineGraphView alloc] initWithFrame:CGRectMake(10, 0, 300, 130)];
self.myGraph.backgroundColor = [UIColor clearColor];
self.myGraph.dataSource = self;
self.myGraph.delegate = self;
self.myGraph.enableTouchReport = YES;
self.myGraph.enablePopUpReport = YES;
self.myGraph.enableBezierCurve = YES;
self.myGraph.enableYAxisLabel = YES;
self.myGraph.alwaysDisplayDots = YES;
self.myGraph.colorYaxisLabel = [UIColor whiteColor];
self.myGraph.colorXaxisLabel = [UIColor whiteColor];
self.myGraph.colorTop = [UIColor clearColor];
self.myGraph.colorBottom = [UIColor clearColor];

I set enableBezierCurve = YES . Sometimes effective and sometimes ineffective

Graph refresh rate

I really like this lib, it produces very lovely graphs with very little effort.

I'm trying to use it to create live graphs, which update in real-time (every second) and I'm seeing big spikes in memory and GPU usage. Could you give me any suggestions on how I could streamline the library to speed up this performance? I've dropped alpha to zero and turned off beziers - scratching the surface to be sure - are there any other low hanging fruit that I could tackle?
thanks again
Jason

Graph Displaying Opposite Direction

My graph is showing 100 at the bottom and then as numbers get lower, the line actually goes up. Here is the data and a screenshot:

screen shot 2014-04-23 at 12 14 16 pm

The data in the array passed to the graph is actually drops during that period, not rises.

Here is my code:

#pragma mark GraphView
- (NSInteger)numberOfPointsInLineGraph:(BEMSimpleLineGraphView *)graph {
    //ArrayOfValues = [NSMutableArray arrayWithObjects:@"44", @"42", @"30", @"100", @"0", nil];
    return (int)[ArrayOfValues count]; // Number of points in the graph.
}

- (CGFloat)lineGraph:(BEMSimpleLineGraphView *)graph valueForPointAtIndex:(NSInteger)index {

    //ArrayOfValues = [NSMutableArray arrayWithObjects:@"44", @"42", @"30", @"100", @"0", nil];

    return [[ArrayOfValues objectAtIndex:index] floatValue]; // The value of the point on the Y-Axis for the index.
}

- (NSInteger)numberOfGapsBetweenLabelsOnLineGraph:(BEMSimpleLineGraphView *)graph {
    return 9; // The number of hidden labels between each displayed label.
}
- (NSString *)lineGraph:(BEMSimpleLineGraphView *)graph labelOnXAxisForIndex:(NSInteger)index {


    return [NSString stringWithFormat:@"%i", index];
}

- (void)lineGraph:(BEMSimpleLineGraphView *)graph didTouchGraphWithClosestIndex:(NSInteger)index {
    self.graphTouch.text = [NSString stringWithFormat:@"%@%% Chance", [ArrayOfValues objectAtIndex:index]];

}

- (void)lineGraph:(BEMSimpleLineGraphView *)graph didReleaseTouchFromGraphWithClosestIndex:(CGFloat)index {
    [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{
        self.graphTouch.alpha = 0.0;
    } completion:^(BOOL finished){

        self.graphTouch.text = [NSString stringWithFormat:@" "];

        [UIView animateWithDuration:0.5 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{
            self.graphTouch.alpha = 1.0;
        } completion:nil];
    }];
}

Graph ScrollView

I'm using this lib to graph data in realtime, appending new data as it arrives (Right To Left).

After a while, all the data gets bunched up and hard to read. Currently I'm trimming the earlier data, so the graph only shows the last 30 seconds or so.

It'd be nice if the user could 'scroll' left-right to see their graph history.

How to use lowerGraph

How do you use the lower graph property in the feature branch?

I've tried declaring firstGraph and secondGraph as a property and doing the following:

self.firstGraph.lowerGraph = self.secondGraph;

but to no avail. Can someone give me an example of how to use lowerGraph?

Thanks

Height of graph

Hello! Do not tell me how to make a height chart in the entire height UIView?

change difference of min/max points

With your help, I was able to add the marks for min and max. Thanks again for that.

Now I want to make the difference between the two lines bigger.
The chart should start at about the middle of the screenshot - the max line should stay.
Can you give me a hint, what and how to change the code to get this result?

screenshot 2014-04-21 22 25 14

Two points with the same dates are not located in a vertical line.

I'used BEMSimpleLineGraphView to draw my measurements that may have points with the same X-value (date).
The expected result should be draw the two values on a vertical line cause they have the same X value which is date, but they are drawn with a slope.

for example two points"
Point 1 : X -> 28-11-2013 , Y -> 50
Point 2 : X -> 28-11-2013 , Y -> 80

They should be drawn at the same vertical line, but they are drawn with slope.

Straight lines appear with extra curves

Due to the bezier curving, straight lines (constant values or linear slopes) will appear like this:

ios simulator screen shot apr 25 2014 3 45 50 pm

Initial dip there is also part of the bug.

Created line simply by removing the random number and replacing with the index of the loop.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.