GithubHelp home page GithubHelp logo

philackm / scrollablegraphview Goto Github PK

View Code? Open in Web Editor NEW
5.3K 5.3K 469.0 24.88 MB

An adaptive scrollable graph view for iOS to visualise simple discrete datasets. Written in Swift.

License: MIT License

Swift 99.11% Ruby 0.55% Objective-C 0.34%

scrollablegraphview's People

Contributors

apisit avatar dhf avatar graciborski avatar kellyroach avatar philackm avatar theabstractdev avatar timbroder 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

scrollablegraphview's Issues

Simply Amazing

I just wanted to say thank you to the developer behind this. This has been the best graph option I have ever come across. It's easy to implement, very attractive, easy for the user to interact with, and highly customizable. I also appreciate that the whole thing is in a single Swift file I can just drop in my project.

Thanks for all your hard work! This is fantastic! :)

Deprecated Language Features

Multiple language features will be removed in Swift 3. The deprecated language features must be replaced with the Swift 3 equivalents.

Question: reference labels

I have a graph that shows data from 1 to 5 and i have labels that equal the date the data was submitted. On the left hand side it shows the data numbers but I want to make them strings where 1 = Good Day, 2 = Ok Day, ect. Is that possible?

I have some question , can i display data value?

i am using scrollable-graphview... so I think that is very beautiful chart
but i have to show data value... but scrollable graphview only show path...
how can i show data value each bar ... or each line datapoint ?

Feature Request: Interface Builder Designable

It would be really nice to be able to not only create the object in interface builder but to be able to design the object in interface builder as well.

To fix the first problem you need to replace the initWithCoder function with

required public init?(coder aDecoder: NSCoder) {`
    super.init(coder: aDecoder)`
}

Secondly, after // MARK: - ScrollableGraphView you need to mark the class as "designable" by adding @IBDesignable. Then for each variable which you wish to expose to interface builder you need to mark the variable with @IBInspectable. For example:

public var lineWidth: CGFloat = 2
// Will become
@IBInspectable public var lineWidth: CGFloat = 2

Finally you need to implement this function:

public override func prepareForInterfaceBuilder() {
    //Setup view
}

Horizontal Bar View

Hi all !

is it possible to display the bar layer horizontally and not vertically ?

Thanks !

Change LineColor Stroke when graph already displayed

I have my Graph already displayed. If I tap on a button, i'd like to change the strokecolor of the lineLayer. So I added this in the class:

public func changeLineColor(color : UIColor) {    
  lineLayer?.strokeColor = color.CGColor
}

But if I call it from my view like: myGraph.changeLineColor(myColor) , it will return the error:

fatal error: use of unimplemented initializer 'init(layer:)' for class 'TestGraph.ScrollableGraphViewDrawingLayer'

I can still change the background color by adding this function and it works:

public func changeBackgroundColor(color : UIColor) {
drawingView.backgroundColor = color
}

BUT do you have any idea why I can't change the linecolor ? :/ thanks !!

Detect tap Gesture on the x-axis labels

How to detect the tap gesture on the label on the x-axis?

Goal is when the graph is displayed, no "circle" on the curve is displayed but if you tap on the label, the corresponding circle will be displayed with the corresponding value somewhere

Number of labels in the x-axis

is it possible to reduce the number labels shown on the x-axis? When I have to show large number of points , label in the x-axis are overlapping. And I don't want large spacing between those points.

tvOS support

It should be possible to add tvOS support. You should just have to disable any touch based apis by wrapping them in checking for the tvOS target.

Scroll to end on initial load

Is there a way to scroll to the end of the view after the animation is complete? or even before the animation starts?

Add support for label formatter

Is there a way to format the label on y axis? Would be great to be able to format the string. It's useful to display currency and other types of data.

Prevent graph from dropping off on the right

(or stop the line from rendering after the last data point)

Scenario:
With rightmostPointPadding = 0 my last label gets cut off:

image

If I extend the padding (or the user pulls to the left more) the line drops down to 0 and looks a little odd

image

Is it possible to do any of these options?

  1. The line continues on whatever it's current trajectory is on
  2. Stop it rendering at the last data point (the vertical line being ok, the horizontal one not)
    image
  3. Prevent the user from swiping past the last data point (not ideal because then the last label gets cut in half)

Thanks!

how to chage a pointcolor?

thank you for your project. i want to change a point color. not all point but a special point. for example, i want change points which are above 30 to red and 30 less than are be white.
how and where can i do it??

Label on bar top

Hi,

For first, thanks for this awesome code.

At this time I am facing a problem with labels and my question is if there is a way to add a value on top of the bar, for example I have a bar of month January and at the bottom I want to add "January" label and on top of this bar I want to add "R$ 100,00" as a String, is this possible? If yes, please someone can explain how?

PS: Please label it as Question ;)

Thanks.

Can we use more than one lines?

I want to show more than one lines in the graph. Is it possible to show add two or more lines in the same graph? Please provide a solution.

Future Request: how to add shadow to the line ?

Hi Guys

I was wondering how to add shadow to the main line that is connecting the dots as I was inspired by a design. I have figure it out. I'm kindly asking the author of the library to expose it, so can be added easily.

the final goal is to get line which will have shadow as the example below created by Sam Thibault in one of his prototypes.

report_full

Because this line chart is using CALayer it can have shadow very easy. You just need to find it where exactly is and add the code.

In file ScrollableraphView.swift locate the function shown bellow i.e. "addDrawingLayers" and add the code to add your shadow(of course you can change the values to change the type of the shadow):
bear in mind that I have switched off the property graphView.shouldFill = false because I wanted the shadow to be below the line.

        lineLayer?.shadowOffset = CGSize(width: 4,height: 4)
        lineLayer?.shadowColor = UIColor.darkGrayColor().CGColor
        lineLayer?.shadowRadius = 2.0
        lineLayer?.shadowOpacity = 1.0

After adding the code the line chart was like this

screen shot 2016-06-10 at 20 28 05

And this is how looks like the function after i added the code.

screen shot 2016-06-10 at 20 22 50

If someone have idea how to create the gradient for the line itself, it would be great.

Cheers.

How can I Give the values to X-Axis and Y-Axis?

Hello, I'm using Scrollable-GraphView of DarkGraph. But I don't know to add the x-axis and y-axis values from my end I have dates in x-axis and float values in Y-axis in different arrays.
How can I give the 2 arrays to X-axis and Y-axis. Thanks!

CocoaPods doesn't work

Hi, I'm trying to use your Lib, but when I add " pod 'ScrollableGraphView' " to my Podfile, the following error occurs.. " Unable to find a specification for 'ScrollableGraphView' ". How can I solve this problem?

init(coder:) not implemented

Consider this a feature request rather than a bug. :)

It would be much more convenient to be able to connect directly to the GraphView from Interface Builder. Unfortunately, I have to create a container right now, because when I hook it up in IB, it tries to call the method that is not implemented yet:

required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") }

Fatal issue with assert

: Error: this application, or a library it uses, has passed an invalid numeric value (NaN, or not-a-number) to CoreGraphics API and this value is being ignored. Please fix this problem.

This line of code is crashing the app.
assert (layer.zeroYPosition > 0);

How to add GraphView in tableViewCell?

Hi guys,

Do you have any idea how to put GraphView in tableViewCell?
I'm getting lots of crash and can't list two or three different graphs in a tableview

Thanks.

A Possible enhancement...

Hi,

Nice work indeed.
Can we have 2 line scrollable graph?
This will be a nice enhancement!

Thank you very much

George Gerardis

OS X support

We’d love to use this library in our Mac appβ€”it looks fantastic!

Scroll after create Graph

Hello!

First of all I want to thank you about this awesome library! I'm using it in a new project and It's really smooth. I only have one question. Is it posible to automatically scroll to the end of the graph after it appears on the view?

Best regards!

Animation resets if multiple calls are made

Hi,

First of all thanks for this awesome library!

I've been using it and sometimes the graph gets updated twice (usually with the same data), before the animation of the first calls finishes. And this causes the animation to abort and restart for the 2nd call. Which looks odd.

To test this include the following code in the viewDidLoad method of the example project:

  dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(graphView.animationDuration * 0.5 * Double(NSEC_PER_SEC))), dispatch_get_main_queue()){
       self.graphView.setData(self.data, withLabels: self.labels)
 }

I think possible solutions would be:

  1. Always start the 2nd animation at the current point each point is
  2. If the 2nd call has the exact same data as the currently animating call, don't animate it.

More flexibility when shouldAutomaticallyDetectRange = true

First of all, great library, I really like it :)

I'm wondering if we could add more flexiblity to shouldAutomaticallyDetectRange = true. Right now, it will resize the graph depending on what is the max-y value and min-y value. I m wondering if we can add some vertical margin in there?

Example: if max-y value is 115, and y-margin is 15, then highest value in graph would be 130 and not 115 like it is now.

I know that I can just find out what is my max y value and then compute the new rangeMax and rangeMin, but I think it would be nice to have it in the library. I can also help with that if need be, it should not be hard by looking at the code :)

Support negative numbers below zero for BarLayer

Hi,
first of all thank you very much for this great framework!

But currently it is not possible to draw negative bars below zero. E.g. try to draw data = [-10.0, 10.0] with minRange = -20.0: Both bars will start to draw from -20 instead of the baseline 0.

screen shot 2016-09-21 at 22 20 07

How do I disable vertical scrolling on the graph?

I wanna keep just the horizontal scrolling and disable vertical. How do I do this?

This is the default behavior
screen shot 2016-08-18 at 7 20 48 pm

I want the graph t position itself like this.

screen shot 2016-08-18 at 7 21 10 pm

Or even disable the vertical scroll. Please help me.

Feature Request: Comments on variables

It would be really nice to have some /// comments before each variable so we know what each one is doing without having to reverse engineer your code πŸ˜„

Segmentation fault 11 when inherit from ScrollableGraphView

Hi,
I have Command failed due to signal: Segmentation fault: 11 when trying to inherit from ScrollableGraphView:

@IBDesignable
@objc open class ProductivityGraphView: ScrollableGraphView {

}
  1. While loading conformances for 'ProductivityGraphView' at

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.