GithubHelp home page GithubHelp logo

owlmafia / swiftcharts Goto Github PK

View Code? Open in Web Editor NEW
2.5K 80.0 408.0 3.98 MB

Easy to use and highly customizable charts library for iOS

License: Apache License 2.0

Swift 95.94% Ruby 0.15% HTML 3.79% Objective-C 0.13%
chart swift graph charts ios graphs plot plots swift-3

swiftcharts's Introduction

⚠️ Not maintained anymore! If you want to become a maintainer, let me know.

SwiftCharts

Version Carthage compatible License

Easy to use and highly customizable charts library for iOS

Features:

  • Bars - plain, stacked, grouped, horizontal, vertical
  • Scatter
  • Lines (straight/cubic/custom path generator)
  • Areas
  • Bubble
  • Multiple axes
  • Candlestick
  • Multiple labels per value (x axis)
  • Everything is customizable - colors, views, units, labels, animations, interactions, axes, etc.
  • Easy creation of arbitrary markers, overlays, info views, etc., using simple UIViews!
  • Modular architecture, which allows to easily create new chart types or add effects to existing types externally (without library changes).
  • Charts can be combined with each other.
  • Pie chart*
  • Legends*
  • Zooming & panning, lockable to x/y axis, max delta or both. Elastic effect. (unreleased)
  • Extensible axis values and label generators for numbers, dates, etc, with customizable zooming handling (nice numbers, divide in half, etc). (unreleased).

*These are separate repos for better focus and reusability.

iOS 7+

Video

Documentation

ScreenShot ScreenShot ScreenShot ScreenShot of Multi-chart touch tracking

ScreenShot

ScreenShot ScreenShot ScreenShot ScreenShot ScreenShot ScreenShot ScreenShot ScreenShot ScreenShot ScreenShot ScreenShot ScreenShot ScreenShot

Installation

CocoaPods

Add to your Podfile:

use_frameworks!
pod 'SwiftCharts', '~> 0.6.5'

To use master directly:

pod 'SwiftCharts', :git => 'https://github.com/i-schuetz/SwiftCharts.git'

And then:

pod install

Import the framework in your code:

import SwiftCharts

Carthage

Add to your Cartfile:

github "i-schuetz/SwiftCharts" ~> 0.6.5

Contribute

Contributions are highly appreciated! To submit one:

  1. Fork
  2. Commit changes to a branch in your fork
  3. Push your code and make a pull request

Quick start

Multiline chart:

let chartConfig = ChartConfigXY(
    xAxisConfig: ChartAxisConfig(from: 2, to: 14, by: 2),
    yAxisConfig: ChartAxisConfig(from: 0, to: 14, by: 2)
)

let frame = CGRect(x: 0, y: 70, width: 300, height: 500)

let chart = LineChart(
    frame: frame,
    chartConfig: chartConfig,
    xTitle: "X axis",
    yTitle: "Y axis",
    lines: [
        (chartPoints: [(2.0, 10.6), (4.2, 5.1), (7.3, 3.0), (8.1, 5.5), (14.0, 8.0)], color: UIColor.red),
        (chartPoints: [(2.0, 2.6), (4.2, 4.1), (7.3, 1.0), (8.1, 11.5), (14.0, 3.0)], color: UIColor.blue)
    ]
)

self.view.addSubview(chart.view)

Bars chart:

let chartConfig = BarsChartConfig(
    valsAxisConfig: ChartAxisConfig(from: 0, to: 8, by: 2)
)

let frame = CGRect(x: 0, y: 70, width: 300, height: 500)
        
let chart = BarsChart(
    frame: frame,
    chartConfig: chartConfig,
    xTitle: "X axis",
    yTitle: "Y axis",
    bars: [
        ("A", 2),
        ("B", 4.5),
        ("C", 3),
        ("D", 5.4),
        ("E", 6.8),
        ("F", 0.5)
    ],
    color: UIColor.red,
    barWidth: 20
)

self.view.addSubview(chart.view)
self.chart = chart

Concept:

  • Layer architecture, which makes it extremely easy to customize charts, create new types, combine existing ones and add interactive elements.

  • Creation of views via a generator function, which makes it easy to use custom views in any layer.

Main Components:

1. Layers:

A chart is the result of composing layers together. Everything is a layer - axis, guidelines, dividers, line, circles, etc. The idea is to have losely coupled components that can be easily changed and combined. This is for example the structure of a basic chart, which shows a line with circles:

ScreenShot

Following a more low level example, to provide an insight into the layer system. Note that most examples are written like this, in order to provider maximal flexibility.

let chartPoints: [ChartPoint] = [(2, 2), (4, 4), (6, 6), (8, 8), (8, 10), (15, 15)].map{ChartPoint(x: ChartAxisValueInt($0.0), y: ChartAxisValueInt($0.1))}

let labelSettings = ChartLabelSettings(font: ExamplesDefaults.labelFont)

let generator = ChartAxisGeneratorMultiplier(2)
let labelsGenerator = ChartAxisLabelsGeneratorFunc {scalar in
    return ChartAxisLabel(text: "\(scalar)", settings: labelSettings)
}

let xGenerator = ChartAxisGeneratorMultiplier(2)

let xModel = ChartAxisModel(firstModelValue: 0, lastModelValue: 16, axisTitleLabels: [ChartAxisLabel(text: "Axis title", settings: labelSettings)], axisValuesGenerator: xGenerator, labelsGenerator: labelsGenerator)

let yModel = ChartAxisModel(firstModelValue: 0, lastModelValue: 16, axisTitleLabels: [ChartAxisLabel(text: "Axis title", settings: labelSettings.defaultVertical())], axisValuesGenerator: generator, labelsGenerator: labelsGenerator)

let chartFrame = ExamplesDefaults.chartFrame(view.bounds)

let chartSettings = ExamplesDefaults.chartSettingsWithPanZoom

// generate axes layers and calculate chart inner frame, based on the axis models
let coordsSpace = ChartCoordsSpaceLeftBottomSingleAxis(chartSettings: chartSettings, chartFrame: chartFrame, xModel: xModel, yModel: yModel)
let (xAxisLayer, yAxisLayer, innerFrame) = (coordsSpace.xAxisLayer, coordsSpace.yAxisLayer, coordsSpace.chartInnerFrame)

// create layer with guidelines
let guidelinesLayerSettings = ChartGuideLinesDottedLayerSettings(linesColor: UIColor.black, linesWidth: ExamplesDefaults.guidelinesWidth)
let guidelinesLayer = ChartGuideLinesDottedLayer(xAxisLayer: xAxisLayer, yAxisLayer: yAxisLayer, settings: guidelinesLayerSettings)

// view generator - this is a function that creates a view for each chartpoint
let viewGenerator = {(chartPointModel: ChartPointLayerModel, layer: ChartPointsViewsLayer, chart: Chart) -> UIView? in
    let viewSize: CGFloat = Env.iPad ? 30 : 20
    let center = chartPointModel.screenLoc
    let label = UILabel(frame: CGRect(x: center.x - viewSize / 2, y: center.y - viewSize / 2, width: viewSize, height: viewSize))
    label.backgroundColor = UIColor.green
    label.textAlignment = NSTextAlignment.center
    label.text = chartPointModel.chartPoint.y.description
    label.font = ExamplesDefaults.labelFont
    return label
}

// create layer that uses viewGenerator to display chartpoints
let chartPointsLayer = ChartPointsViewsLayer(xAxis: xAxisLayer.axis, yAxis: yAxisLayer.axis, chartPoints: chartPoints, viewGenerator: viewGenerator, mode: .translate)

// create chart instance with frame and layers
let chart = Chart(
    frame: chartFrame,
    innerFrame: innerFrame,
    settings: chartSettings,
    layers: [
        xAxisLayer,
        yAxisLayer,
        guidelinesLayer,
        chartPointsLayer
    ]
)

view.addSubview(chart.view)
self.chart = chart

Layers decide how to present their data - this can be done adding subviews, (CA)layers, with core graphics, etc.

2. View generators:

View based layers will use a generator function to generate chart point views. This function receives the complete state of each chartpoint (model data, screen location) and produces an UIView, allowing any type of customization.

Hello world:

There's a hello world included in the examples, similar to the above code, with a bit more explanations. Change some properties of the generated views, copy paste the chartPointsLineLayer used in the snippet above, and pass it to the chart's layers, to display a line behind the views, and you have already mastered the main concepts!

Important!

  • Don't forget to always keep a strong reference to the chart instance or it will be released, which leads to axis & labels not showing.

  • If you have a lot of axis labels in your chart it may be necessary to do the calculation of the coordinate space in the background, to avoid possible delays which are noticeable during transitions or scrolling. See ScrollExample or MultipleAxesExample example for this.

Tasks

SwiftCharts has got now some projects to plan features and improvements. Feel free to grab any of these topics even if it's just to add feedback. You can open an issue for this. Other options like opening a Slack channel are possible.

Created By:

Ivan Schütz

If you need something special or are just short of time, I'm also available for hire

Credits:

A big thank you to the awesome grafiti.io for having been sponsoring this project in the last months, and of course also to all the contributors!

License

SwiftCharts is Copyright (c) 2015 - 2019 Ivan Schütz and released as open source under the attached Apache 2.0 license.

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 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.

This is a port to Swift and (massively improved) continuation of an obj-c project which I did while working at eGym GmbH https://github.com/egymgmbh/ios-charts

swiftcharts's People

Contributors

arturolee avatar bmalbuck avatar bsqdev avatar c-st avatar casualcoder1 avatar dduugg avatar dehlen avatar fabioknoedt avatar iainbryson avatar interstateone avatar ivnsch avatar jeremygibbs avatar jobinsjohn avatar kellyroach avatar ladislavambrus avatar letko-dmitry avatar lgruen avatar loudnate avatar lsnmarcinr avatar lukecrouch avatar marcinwlodarczyk avatar nachosoto avatar najmul-csebuet avatar nwest avatar pingwinator avatar pmairoldi avatar ps2 avatar shohin avatar sonivarun avatar wlodarcm 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

swiftcharts's Issues

How to highlight cirlce in Show touch coords example?

Hi, in the Show touch coords (interactive) example, how can I make the circle highlighted (i.e. selected) when there is a selection? Right now it is showing the line and co-ord but I just want the circle highlighted instead (to keep it simple).

I noticed that in Areas,line,circles example, the circle is highlighted but I didn't want to have text inside.

So I am a little unsure what classes to use to accomplish the simple scenario. Thanks a lot for your help.

Scrolling: Using a UIScrollView makes the y-Axis disappear

Hey,

first of all, thanks for the library!

I have a question on scrolling. In the examples scrolling is enabled through a UIScrollView which contains the hole chart-view. That way the y-axis isn't visible any more when the user scrolls.

Would it be possible to implement that the axis stay visible? Could you describe which steps would be required to take (high level), then I would try :)

Linking Tap and LongPress to Bubble View

I would like to link two touch events to each point in the scatter plot as follows:

  • Tap : Display popup box with information (have this)
  • Long Press: Switch to Detail page. (want this in addition)

I am unsure how to integrate this with my extension of the Bubble Chart (gist --> https://gist.github.com/0a5191ece2b870b33658.git).

The commented code, excluding that in the header, shows my attempts to create a response to a long gesture by the user. If I put performSegueWithIdentifier in bubblesLayer, then the segue happens when the bubble layer is rendered. Putting performSegueWithIdentifier in the inner code block of bubblesLayer that creates infoView leads to a runtime error.

Tracker Layer Displays NaN for Y

Tracker view displays NaN for Y when Y values have a small delta.

Y Values = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 0, 2.008, 2.014, 1.512, 2.016, 0]

X Values can be anything.

untitled

numeric y axis and literal x axis for line chart

Is it possible to set the y axes labels all double/int values but the x axes labels all string values in LineChart?

Assume that I have arrays of values like:
line1: [1.1, 2.5, 1.3, 8.4, 2.2]
line2: [4.8, 5.1, 0.6, 7.2, 9.1]
axisX: [A,B,C,D,E]

and I'd like my chart looks this way: (sorry for the ugly presenting)

chart

The chartPoints for LineChart seems need to be in (x,y) format, which is a little trivial for combining two elements in different values array into one pair (e.g. (line1[0], axisX[0]) ), and I see no text parameter in the chartPoints class.

Do I have to use Chart class for more flexible layer settings to accomplish this or is there a simpler way within the LineChart?

Thanks for supporting!

Swift - How to install?

Hi, I am a swift newbie and I am confused by the pod file thing.
Here is what I did:

  1. In terminal, cd to my project folder, "pod init"
  2. In the newly created pod file, added the "use framework..." under "target 'project name' do section
  3. In terminal "pod install"
  4. In my viewcontroller, "import SwiftCharts" - failed and error msg is "No such module"
    Could you please help me see what went wrong here? Thanks!

Issue concerning layers (I think)

This issue is more a problem of mine I think, but after many spent time i cannot still figure it out...

Why does this code (rougthly the same as the tracker example one) doesn't display anything else than the curve?

http://imgur.com/Gca5Bxf

The datepicker bug is something else, sorry for it. but only the red plot appears. (i tryed on other circumstances before with full view on the curve)

http://imgur.com/UnmfVaO

It may be trivial but I can't find a logical explanation/solution...

Cubic lines and high slope

Using cubic lines and Data with a high slope after period of axial values causes a short decrease of the functions Graph. The following data example should not result in values below 0.0 :

data = [(name: "", quantity: 0.0), (name: "12:00", quantity: 0.0), (name: "", quantity: 0.0), (name: "", quantity: 60.0), (name: "", quantity: 57.0), (name: "", quantity: 50.0), (name: "", quantity: 150.0), (name: "18:00", quantity: 135.0), (name: "", quantity: 125.0), (name: "", quantity: 120.0), (name: "", quantity: 110.0), (name: "", quantity: 210.0), (name: "", quantity: 180.0), (name: "00:00", quantity: 165.0), (name: "", quantity: 142.0), (name: "", quantity: 120.0), (name: "", quantity: 100.0), (name: "", quantity: 80.0), (name: "", quantity: 75.0), (name: "06:00", quantity: 65.0), (name: "", quantity: 59.0), (name: "", quantity: 57.0), (name: "", quantity: 55.0), (name: "", quantity: 54.0)]

example-graph

Linking touch event on BubbleView to DetailView

It is great that the user can click on a point in the scatter plot and receive more information.

How would I enable the user to navigate to a detail page that contains further information about the point?

I envision a storyboard that begins with a tab control. One tab takes the user to the scatter plot. The other tab takes the user through a master-detail sequence. This way the user can access the further detail about the points by scrolling through a tabulation of the points or by clicking them on the screen.

I know that one would have to link DetailViewController with the viewGenerator for the scatter plot. I'm not sure where to put that linkage in the ViewController for the scatter plot.

Thanks

plotting live data 50 times a second?

Hi, first of all thanks for this fine piece of Software.

Would it be easy to plot live data that changes something like 50 times a second and gives the data in an array of doubles?

We are looking for a performant solution to present data in a live situation.

Thanks and regards, Rainer from Germany :-)

Resizing Graph

I am looking to re-size a graph, in specific your scatter plot. What is the best way to do that? I would ideally like to have a scroll view in which the graph would occupy a portion of the screen while having a few things above/below it like buttons and text fields for inputs but would like to know how to resize the graph such that it won't occupy the entire view.

Thanks!

Can not see the top half of the label of Y axis and the right half of the label of X axis

Hi,

I am using the simple code as you provided to generate the chart. But the chart seems be cut by the edge of the frame. (I can not see the top half of 200 and right half of 100). Could you help to figure out the problem? thanks

error

import UIKit
import SwiftCharts

class ChartViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        //new code
        self.view.addSubview(chart.view)

    }

    let chartConfig : ChartConfigXY!

    let chart : LineChart!

    required init(coder aDecoder: NSCoder) {
        self.chartConfig = ChartConfigXY(
            xAxisConfig: ChartAxisConfig(from: 0, to: 100, by: 20),
            yAxisConfig: ChartAxisConfig(from: 0, to: 200, by: 40)
        )

        self.chart = LineChart(
            frame: CGRectMake(10, 80, 300, 200),
            chartConfig: chartConfig,
            xTitle: "Time (s)",
            yTitle: "Pressures (cm H2O)",
            lines: [
                (chartPoints: [(12.0, 50.6), (14.2, 85.1), (17.3, 123.0), (18.1, 135.5), (94.0, 148.0)], color: UIColor.redColor()),
                (chartPoints: [(12.0, 52.6), (14.2, 59.1), (17.3, 61.0), (18.1, 90.5), (94.0, 113.0)], color: UIColor.blueColor())
            ]
        )
        super.init(coder: aDecoder)
    }
}

Updating data

Hey,

what is the recommended way to update an existing chart (delete, update or insert values)? Is there anything better than recreate the hole chart?

Many thanks!

Building the project in XCODE 7 with updated SWIFT 2.0 Carthage built framework

Hi, I tried implementing new swift 2.0 version and I have entirely removed and rebuild the framework (cart file, cart update...), got the framework in the project folder, imported it to XCODE project in the the General part under Linked Framework and libraries, put the input file "$(SRCROOT)/Carthage/Build/iOS/SwiftCharts.framework" under run scripts.

After I build I always get the error:
dyld: Library not loaded: @rpath/libswiftSecurity.dylib
Referenced from: /Users/currentuser/Library/Developer/CoreSimulator/Devices/5D1EFC15-79C5-4A91-9C38-3DF1DD8D7B06/data/Containers/Bundle/Application/DAFD269F-0E16-44D4-A237-E6D30706924A/UBS Funds.app/Frameworks/SwiftCharts.framework/SwiftCharts
Reason: image not found

I tried the online solutions without success:

  • Restart Xcode, then computer and iPhone
  • Go to project build settings and set Embedded Content Contains Swift Code flag to YES
  • Go to project build settings and add @executable_path/Frameworks to Runpath Search Paths option

It worked in XCODE 6.4 with swift 1.2, do you have any ideas?

Thanks,
Pavle

Enhancement!!!!!

Hello,
I can say....your collection is fantastic. A real tool for them they want a chart library!!!
Thanks a lot for your work.
I want to propose an enhancement for them they love objective c
Is it possible to have your tools in objective c also?

One more time thanks you very much.

George Gerardis

Tutorial does not consider auto-layout

Very nice and useful tutorials, I'm trying to learn using your library with them.
However I cannot get how to use auto layout.
Is there a simple way to solve this not programmatically?
Thanks

Issue with stride?

Hi,
When I use: stride(from: 0, through: x, by: 10) I get an error while compiling, how can I set the "through" to be a variable and not a static value?
like: stride(from: 0, through: x, by: 10) instead of stride(from: 0, through: 10, by: 10)

the compile error: cannot invoke map with an argument of type ((_) -> _)

Thanks in advance.

Adding trendlines ?

I would be interested by the automatic addition of trendlines to line charts.

Simple linear trendlines are sufficient for my intended use, however I suppose higher order trendlines are of general interest too.

Live feed

Is there a way to create a LineChart that can be updated, say every 5 seconds, with a new datapoints, and will smoothly scroll to the left as the data is added?

Issue implementing tracker

Hi
I have been unsuccessful in implementing a tracker layer using my own ChartAxisValue, it does not seem to be calling my override var text: String. Here is code replicating the issue:

//
//  MultipleAxesInteractiveExample.swift
//  SwiftCharts
//
//  Created by ischuetz on 04/05/15.
//  Copyright (c) 2015 ivanschuetz. All rights reserved.
//

import UIKit
import SwiftCharts

class MyAxisValue: ChartAxisValue {

    let myVal: Int
    let date: String
    let chartLabelSettings: ChartLabelSettings
    var labelIndexToDisplay = [0,1,2,3,4,5] // An array of valid indexes to show labels

    init(myVal: Int, date: String, chartLabelSettings: ChartLabelSettings) {
        self.myVal = myVal
        self.date = date
        self.chartLabelSettings = chartLabelSettings
        super.init(scalar: Double(myVal))
    }

    // This override doesnt get called?
    override var text: String {
        return self.date
    }

    override var labels:[ChartAxisLabel] {

        for var i = 0; i < labelIndexToDisplay.count; ++i {
            if myVal == labelIndexToDisplay[i] {
                return [ChartAxisLabel(text: date, settings: chartLabelSettings)]
            }
        }

        return []
    }
}

class MultipleAxesInteractiveExample: UIViewController {

    private var chart: Chart?

    let bgColors = [UIColor.redColor()]

    private var showGuides: Bool = false
    private var selectedLayersFlags = [true]

    private var chartPoints0: [ChartPoint] = [ChartPoint]()

    private var viewFrame: CGRect!
    private var chartInnerFrame: CGRect!

    private var yLowAxes: [ChartAxisLayer]!
    private var xLowAxes: [ChartAxisLayer]!

    private var guideLinesLayer0: ChartLayer!

    var readFormatter = NSDateFormatter()
    var displayFormatter = NSDateFormatter()

    init() {
        let labelSettings = ChartLabelSettings(font: ExamplesDefaults.labelFontSmall)

        readFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
        displayFormatter.dateFormat = "dd-MM-yy\nHH:mm:ss"

        super.init(nibName: nil, bundle: nil)

        func createChartPointWithDate(x x: Int, date: NSDate, y: Double, labelColor: UIColor) -> ChartPoint {

            let yLabelSettings = ChartLabelSettings(font: ExamplesDefaults.labelFontSmall, fontColor: labelColor)
            let xLabelSettings = ChartLabelSettings(font: ExamplesDefaults.labelFontSmall, rotation: 90, rotationKeep: .Bottom, fontColor: labelColor)

            // Calling my own axis value won't work, it does not call my text override computed variable
            return ChartPoint(x: ChartAxisValueDate(date: date, formatter: readFormatter, labelSettings: xLabelSettings), y: ChartAxisValueDouble(y, labelSettings: yLabelSettings))

            // Calling existing ChartAxisValues##### work. They call the text overrides correctly
            //return ChartPoint(x: ChartAxisValueDouble(x, labelSettings: xLabelSettings), y: ChartAxisValueDouble(y, labelSettings: yLabelSettings))
        }

        self.chartPoints0.append(createChartPointWithDate(x: 0, date: readFormatter.dateFromString("2015-10-28 22:30:17")!, y: 115.15, labelColor: bgColors[0]))
        self.chartPoints0.append(createChartPointWithDate(x: 1, date: readFormatter.dateFromString("2015-10-28 22:32:17")!, y: 115.15, labelColor: bgColors[0]))
        self.chartPoints0.append(createChartPointWithDate(x: 2, date: readFormatter.dateFromString("2015-10-28 22:34:17")!, y: 115.15, labelColor: bgColors[0]))
        self.chartPoints0.append(createChartPointWithDate(x: 3, date: readFormatter.dateFromString("2015-10-28 22:36:17")!, y: 115.15, labelColor: bgColors[0]))
        self.chartPoints0.append(createChartPointWithDate(x: 4, date: readFormatter.dateFromString("2015-10-28 22:38:17")!, y: 115.15, labelColor: bgColors[0]))
        self.chartPoints0.append(createChartPointWithDate(x: 5, date: readFormatter.dateFromString("2015-10-28 22:40:17")!, y: 115.15, labelColor: bgColors[0]))
    }

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

    override func viewDidLoad() {
        super.viewDidLoad()

        let xValues0 = self.chartPoints0.map{$0.x}

        let chartSettings = ExamplesDefaults.chartSettings

        let top: CGFloat = 80
        self.viewFrame = CGRectMake(0, top, 375, 550)

        var yValues0 = [ChartAxisValue]()
        yValues0.append(ChartAxisValueString("normal", order: 115, labelSettings: ChartLabelSettings(font: ExamplesDefaults.labelFontSmall, fontColor: self.bgColors[0])))
        yValues0.append(ChartAxisValueString("", order: 114, labelSettings: ChartLabelSettings(font: ExamplesDefaults.labelFontSmall, fontColor: self.bgColors[0])))
        yValues0.append(ChartAxisValueString("", order: 116, labelSettings: ChartLabelSettings(font: ExamplesDefaults.labelFontSmall, fontColor: self.bgColors[0])))

        let axisTitleFont = ExamplesDefaults.labelFontSmall

        let yLowModels: [ChartAxisModel] = [
            ChartAxisModel(axisValues: yValues0, lineColor: self.bgColors[0], axisTitleLabels: [ChartAxisLabel(text: "", settings: ChartLabelSettings(fontColor: self.bgColors[0], font: axisTitleFont).defaultVertical())])
        ]

        let xLowModels: [ChartAxisModel] = [
            ChartAxisModel(axisValues: xValues0, lineColor: self.bgColors[0], axisTitleLabels: [ChartAxisLabel(text: "", settings: ChartLabelSettings(fontColor: self.bgColors[0], font: axisTitleFont))])
        ]

        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) {

            let coordsSpace = ChartCoordsSpace(chartSettings: chartSettings, chartSize: self.viewFrame.size, yLowModels: yLowModels, xLowModels: xLowModels)

            dispatch_async(dispatch_get_main_queue()) {

                self.chartInnerFrame = coordsSpace.chartInnerFrame

                self.yLowAxes = coordsSpace.yLowAxes
                self.xLowAxes = coordsSpace.xLowAxes

                let guideLinesLayer0Settings = ChartGuideLinesDottedLayerSettings(linesColor: self.bgColors[0], linesWidth: ExamplesDefaults.guidelinesWidth)

                self.guideLinesLayer0 = ChartGuideLinesDottedLayer(xAxis: self.xLowAxes[0], yAxis: self.yLowAxes[0], innerFrame: self.chartInnerFrame, settings: guideLinesLayer0Settings)

                self.showChart(lineAnimDuration: 1)
            }
        }
    }

    private func createLineLayers(animDuration animDuration: Float) -> [ChartPointsLineLayer<ChartPoint>] {
        let lineModel0 = ChartLineModel(chartPoints: chartPoints0, lineColor: bgColors[0], animDuration: animDuration, animDelay: 0)

        // Controls which axis the line will use to draw the graph
        let chartPointsLineLayer0 = ChartPointsLineLayer<ChartPoint>(xAxis: xLowAxes[0], yAxis: yLowAxes[0], innerFrame: chartInnerFrame, lineModels: [lineModel0])

        return [chartPointsLineLayer0]
    }


    private func createLayers(selectedLayersFlags selectedLayersFlags: [Bool], showGuides: Bool, lineAnimDuration: Float) -> ([ChartLayer]) {

        var axisLayers: [ChartLayer] = []
        var itemsLayers: [ChartLayer] = []

        let lineLayers = self.createLineLayers(animDuration: lineAnimDuration)

        func maybeGuides(guideLayer: ChartLayer) -> [ChartLayer] {
            return (showGuides ? [guideLayer] : [])
        }

        //*************
        // Tracker
        let trackerLayerSettings = ChartPointsLineTrackerLayerSettings(thumbSize: Env.iPad ? 30 : 20, thumbCornerRadius: Env.iPad ? 16 : 10, thumbBorderWidth: Env.iPad ? 4 : 2, infoViewFont: ExamplesDefaults.fontWithSize(Env.iPad ? 26 : 16), infoViewSize: CGSizeMake(Env.iPad ? 400 : 160, Env.iPad ? 70 : 40), infoViewCornerRadius: Env.iPad ? 30 : 15)

        let chartPointsTrackerLayer = ChartPointsLineTrackerLayer(xAxis: xLowAxes[0], yAxis: yLowAxes[0], innerFrame: chartInnerFrame, chartPoints: chartPoints0, lineColor: UIColor.blackColor(), animDuration: 1, animDelay: 2, settings: trackerLayerSettings)
        //*************

        let layers: [[ChartLayer]] = [
            [yLowAxes[0], xLowAxes[0], lineLayers[0], chartPointsTrackerLayer] + maybeGuides(guideLinesLayer0)
        ]

        return selectedLayersFlags.enumerate().reduce(Array<ChartLayer>()) {selectedLayers, inTuple in

            let index = inTuple.0
            let selected = inTuple.1

            if selected {
                return selectedLayers + layers[index]
            }
            return selectedLayers
        }
    }

    private func showChart(lineAnimDuration lineAnimDuration: Float) -> () {

        self.chart?.clearView()

        let layers = self.createLayers(selectedLayersFlags: self.selectedLayersFlags, showGuides: self.showGuides, lineAnimDuration: lineAnimDuration)

        let view = ChartBaseView(frame: viewFrame)
        let chart = Chart(
            view: view,
            layers: layers
        )

        self.view.addSubview(chart.view)
        self.chart = chart
    }
}

Calling:
return ChartPoint(x: ChartAxisValueDouble(x, labelSettings: xLabelSettings), y: ChartAxisValueDouble(y, labelSettings: yLabelSettings)) works.

Calling return ChartPoint(x: ChartAxisValueDate(date: date, formatter: readFormatter, labelSettings: xLabelSettings), y: ChartAxisValueDouble(y, labelSettings: yLabelSettings)) causes an app crash because it does not call my text override.

Are you able to shed any light on this issue?

Thanks

Lines between points on Scatter Plot

I have a situation in which I wish to graph data for which the typical case sees X-values increase before decreasing again, whilst the Y-values simply decrease - picture a capital D (without the vertical line and each data point is discrete and will vary with an inputted array).

An example of the arrays may be:
x = [0, 20, 30, 35, 25, 0]
y = [100, 80, 60, 40, 20, 0]

As such, most of the typical line graph libraries available won't work as they all work for linearly increasing X-values (will only allow one y-value for each x). One solution that I had considered is rotating the graph 90 degrees and reversing the x and y values such that there is only one discrete x-value for all y-values.

However I was also wondering if it was possible to draw lines between the data points on your scatter plot and how one might go about doing this?
I understand that there might be some difficulty with ordering of values and perhaps the library isn't built for scatter plots to include any line drawing capability.

Any help would be much appreciated!

Use of unresolved identifier 'ExamplesDefaults'

Hi,
i installed this framework but i get same 6 errors on different lines with ExamplesDefaults:
ex.: LineChart.swift:23:54: Use of unresolved identifier 'ExamplesDefaults'
Im using xCode 7 Beta 4

Where can be the problem?

Need to update your Examples

Hello
I'm trying out your library for the first time and noticing that none of your example works with it's current build. Would be nice to have this updated so that I can understand what things do instead of trying to debug it.

Display text next to Bubbles similar to AreasExample.swift

I am trying to have a text box appear next to each bubble in the bubble plot when the user touches that bubble. Similar to the dialog box in AreasExample.swift, I want the dialog box next to the bubble to display a string stored in a field of ChartPointBubble.

My understanding is that I need to pass a modification of circleViewGenerator as the viewGenerator for chartPointsBubbleLayer. I am unsure of how to mesh AreasExample.swift and BubbleExample.swift to achieve this. BubbleExample.swift has a local version of BubbleView. BubbleExample.swift seems to not need a viewGenerator, which makes me all the more uncertain of how to insert it.

Unable to satisfy the requirements Following

Hi, newbie cocoapods help please.
I'm having trouble installing the pod.
I am getting the following error:
[!] Unable to satisfy the requirements Following:

  • SwiftCharts (from https: // github.com / i-Schuetz / SwiftCharts.git, branchswift2.0) required by Podfile

I followed the following steps:

  • Sudo gem install cocoapods
  • Pod install

And I used the Podfile seguite:
use_frameworks!
pod 'SwiftCharts': git => 'https://github.com/i-schuetz/SwiftCharts.git': branch => 'swift2.0'

How I do I solve this problem?

Thanks,

Geraldo Roberson

Number of Compiler Errors

Hi Ivan,

I'm trying to import the framework into a project (via pods) but am having a few issues I thought you might be able to shed some light on.

First of all, I'm getting 6 compiler errors from the pods and an additional error "No Such Module" when I attempt to import the framework (images attached).

The steps I've followed are merely setup and installed the podfile with the Swift 2.0 branch, opened the workspace in xCode 6.3.1, inputted the import statement and built the project.

Thanks for your help!

P.S. in reference to my previous question involving getting the touch point to move between two different points on the y-axis, I managed to develop a method, although I am sure it could be done more elegantly - happy to upload if you are interested.

default

screen shot 2015-07-27 at 8 31 15 pm

redraw on rotation question

New to iOS dev and really like what you've done here. Just wondering - what is the best way to deal with a screen rotation and redrawing a chart with different bounds. Thanks!

Charts do not rotate properly

Great Library! The examples look great. When I rotate, the landscape doesn't fill the frame. When I rotate back to prostrate, part of the graph is cut off. This happens with and without using auto layout.

Here's the ViewController I'm using:

// Copyright © 2015 us.rickstreet. All rights reserved.
//

import UIKit
import SwiftCharts

class ViewController: UIViewController {

private var chart: Chart? // arc

@IBOutlet weak var chartView: ChartBaseView!

private var didLayout: Bool = false

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
NSNotificationCenter.defaultCenter().addObserver(self, selector: "rotated", name: UIDeviceOrientationDidChangeNotification, object: nil)
}

override func viewDidLayoutSubviews() {
    super.viewDidLayoutSubviews()

    if !self.didLayout {
        self.didLayout = true
        self.initChart()
    }
}

private func initChart() {

    for index in 5.stride(through: 1, by: -1) {
        print(index)
    }

    // map model data to chart points
    let chartPoints: [ChartPoint] = [(2, 2), (4, 4), (6, 6), (8, 10), (12, 14)].map{ChartPoint(x: ChartAxisValueInt($0.0), y: ChartAxisValueInt($0.1))}

    let labelSettings = ChartLabelSettings(font: ExamplesDefaults.labelFont)

    // define x and y axis values (quick-demo way, see other examples for generation based on chartpoints)
    let xValues = 0.stride(through: 16, by: 2).map {ChartAxisValueInt($0, labelSettings: labelSettings)}

    let yValues = 0.stride(through: 16, by: 2).map {ChartAxisValueInt($0, labelSettings: labelSettings)}

    // create axis models with axis values and axis title
    let xModel = ChartAxisModel(axisValues: xValues, axisTitleLabel: ChartAxisLabel(text: "Axis title", settings: labelSettings))
    let yModel = ChartAxisModel(axisValues: yValues, axisTitleLabel: ChartAxisLabel(text: "Axis title", settings: labelSettings.defaultVertical()))

    let chartFrame = self.chartView.frame

    // generate axes layers and calculate chart inner frame, based on the axis models
    let coordsSpace = ChartCoordsSpaceLeftBottomSingleAxis(chartSettings: ExamplesDefaults.chartSettings, chartFrame: chartFrame, xModel: xModel, yModel: yModel)
    let (xAxis, yAxis, innerFrame) = (coordsSpace.xAxis, coordsSpace.yAxis, coordsSpace.chartInnerFrame)

    // create layer with guidelines
    let guidelinesLayerSettings = ChartGuideLinesDottedLayerSettings(linesColor: UIColor.blackColor(), linesWidth: ExamplesDefaults.guidelinesWidth)
    let guidelinesLayer = ChartGuideLinesDottedLayer(xAxis: xAxis, yAxis: yAxis, innerFrame: innerFrame, settings: guidelinesLayerSettings)

    // view generator - this is a function that creates a view for each chartpoint
    let viewGenerator = {(chartPointModel: ChartPointLayerModel, layer: ChartPointsViewsLayer, chart: Chart) -> UIView? in
        let viewSize: CGFloat = Env.iPad ? 30 : 20
        let center = chartPointModel.screenLoc
        let label = UILabel(frame: CGRectMake(center.x - viewSize / 2, center.y - viewSize / 2, viewSize, viewSize))
        label.backgroundColor = UIColor.greenColor()
        label.textAlignment = NSTextAlignment.Center
        label.text = "\(chartPointModel.chartPoint.y.text)"
        label.font = ExamplesDefaults.labelFont
        return label
    }

    // create layer that uses viewGenerator to display chartpoints
    let chartPointsLayer = ChartPointsViewsLayer(xAxis: xAxis, yAxis: yAxis, innerFrame: innerFrame, chartPoints: chartPoints, viewGenerator: viewGenerator)

    // create chart instance with frame and layers
    let chart = Chart(
        view: self.chartView!,
        layers: [
            coordsSpace.xAxis,
            coordsSpace.yAxis,
            guidelinesLayer,
            chartPointsLayer
        ]
    )
    self.chart = chart
}

func rotated() {
    for view in self.chartView.subviews {
        view.removeFromSuperview()
    }
    self.initChart()
}

}

Thanks,
Rick

Clarify usage of protocols and classes in implementation

I've been working on doing this myself, but I've come to a point where I think it would be helpful for you to provide some input as to where this should go.

An example of what I mean: There is a ChartLayer protocol for conforming types to be able to draw in a chart's context. There is then a single ChartLayerBase base class that implements this protocol with empty methods for subclasses to override if necessary. This seems like a mixture of two different concepts that ends up negating any potential benefits of either. I.e. Anything that would implement the protocol probably will end up just subclassing the base class, and any of the benefits of using protocols instead of inheritance is lost. The situation with ChartAxisLayer is similar.

In investigating alternatives, I found that when mixing protocols with default implementations and class inheritance, the rulers for which method implementation gets called is a little different than what one might think, and so a simple change ends up not working.

Instead I'd propose using protocols strictly for describing a defined set of behaviour of a type instead of a particular component of a chart. For example: the ChartLayer protocol could be renamed to DrawableLayer, have empty default implementations of its methods, and the different kinds of components of a chart (ChartAxisLayer, ChartCoordsSpaceLayer, etc. and their subclasses) would each implement this protocol. This would also involve removing the ChartAxisLayer protocol in favour of the existing ChartAxisLayerDefault base class.

I've gotten this far on a branch of SwiftCharts, and then I noticed that there is also a ChartContextDrawer base class that looks a lot like my new DrawableLayer protocol. So I think this is where I need input from you! Although there might be a difference between the kinds of chart components that conform to/subclass ChartLayer and ChartContextDrawer, the two interfaces are almost exactly the same and I think they should be one and the same or at least more closely related. Is there a reason that these were separate before?

Example, where these could also be a single protocol:

protocol Drawable {
    func initialize(chart: Chart)
    func draw(context: CGContextRef, chart: Chart)
}

protocol Hideable: Drawable {
    var hidden: Bool { get, set }
}

extension Hideable {
    func drawIfVisible(context: CGContextRef, chart: Chart) {
        if !hidden {
            draw(context: context, chart: chart)
        }
    }
}

Documentation is nonexistent

How soon is "coming soon" for the documentation? Just in line comments in the examples would help. Having a terrible time getting the views sized correctly. In the examples you're moving the view down by 70px why? Using almost identical code my bar chart is squished into about 100px height. Its hard to figure out why without some documentation

Define xValues without .map method?

I was trying to define the xAxis and yAxis values using Double values.
I tried using ChartAxisValue but with no luck the numbers do not appear while the chart is presented.
Any idea how to define xValues without using .map, or giving a more detailed explanation?

how to combine chart as follows

Top: CombinedChartDrawOrder.Candle + CombinedChartDrawOrder.Line
Bottom: BarChartData

Their leftAxis and xAxis are different.
How to combine them in a chartView?

thank you.

1070cd76-99d3-11e5-842a-6a1d24cdfe91

15 Swift Compiler Errors

I am trying to include SwiftCharts in a small graphing app targeted at iOS 8 or later.

Swift Chart is the only library beyond UIKit in my app. I am programming in Swift.

I installed CocoaPods, and linked to the SwiftCharts pod without trouble. The same issues arise on versions 0.1 and 0.2.

Console output:
(Thanks in advance for your help)
screen shot 2015-05-22 at 5 42 10 pm

How do I make the max width the same as the container with autolayouts?

screen shot 2015-09-17 at 6 31 15 am

I'm using SwiftCharts with AutoLayouts where I want the chart to the same width as the container UIView. I'm having problems where the chart is being clipped off the bounds.
I set the bounds to the same as the UIView which adds the chart. Any ideas?

        func calcChartFrame(containerBounds: CGRect) -> CGRect {
            return CGRectMake(0, 70, containerBounds.size.width, containerBounds.size.height - 70)
        }
        let chartFrame = calcChartFrame(self.chartView.bounds)

Here's a more full snippet:

    @IBOutlet weak var chartView: UIView!

    override func viewDidLoad() {
        super.viewDidLoad()
        self.addChart()
    }

    func addChart() {
        self.chartView.backgroundColor = UIColor.whiteColor()

        let labelFont = UIFont.systemFontOfSize(14)

        let labelSettings = ChartLabelSettings(font: labelFont)

        let chartSettings: ChartSettings = {
            let chartSettings = ChartSettings()
            chartSettings.leading = 10
            chartSettings.top = 10
            chartSettings.trailing = 10
            chartSettings.bottom = 10
            chartSettings.labelsToAxisSpacingX = 5
            chartSettings.labelsToAxisSpacingY = 5
            chartSettings.axisTitleLabelsToLabelsSpacing = 4
            chartSettings.axisStrokeWidth = 0.2
            chartSettings.spacingBetweenAxesX = 8
            chartSettings.spacingBetweenAxesY = 8
            return chartSettings
        }()

        let guidelinesWidth = CGFloat(0.1)
        func calcChartFrame(containerBounds: CGRect) -> CGRect {
            return CGRectMake(0, 70, containerBounds.size.width, containerBounds.size.height - 70)
        }

        let chartPoints = [(1, 10), (3, 20), (4, 5), (5, 25), (8, 10)].map{ChartPoint(x: ChartAxisValueInt($0.0), y: ChartAxisValueInt($0.1))}

        let xValues = ChartAxisValuesGenerator.generateXAxisValuesWithChartPoints(chartPoints, minSegmentCount: 7, maxSegmentCount: 7, multiple: 2, axisValueGenerator: {ChartAxisValueFloat($0, labelSettings: labelSettings)}, addPaddingSegmentIfEdge: false)
        let yValues = ChartAxisValuesGenerator.generateYAxisValuesWithChartPoints(chartPoints, minSegmentCount: 2, maxSegmentCount: 5, multiple: 2, axisValueGenerator: {ChartAxisValueFloat($0, labelSettings: labelSettings)}, addPaddingSegmentIfEdge: true)

        let xModel = ChartAxisModel(axisValues: xValues, axisTitleLabel: ChartAxisLabel(text: "Days", settings: labelSettings))
        let yModel = ChartAxisModel(axisValues: yValues, axisTitleLabel: ChartAxisLabel(text: "Duration", settings: labelSettings.defaultVertical()))
        let chartFrame = calcChartFrame(self.chartView.bounds)

        let coordsSpace = ChartCoordsSpaceLeftBottomSingleAxis(chartSettings: chartSettings, chartFrame: chartFrame, xModel: xModel, yModel: yModel)
        let (xAxis, yAxis, innerFrame) = (coordsSpace.xAxis, coordsSpace.yAxis, coordsSpace.chartInnerFrame)

        let showCoordsTextViewsGenerator = {(chartPointModel: ChartPointLayerModel, layer: ChartPointsLayer, chart: Chart) -> UIView? in
            let (chartPoint, screenLoc) = (chartPointModel.chartPoint, chartPointModel.screenLoc)
            let w: CGFloat = 70
            let h: CGFloat = 30

            let text = "(\(chartPoint.x.text), \(chartPoint.y.text))"
            let font = labelFont
            let textSize = ChartUtils.textSize(text, font: font)
            let x = min(screenLoc.x + 5, chart.bounds.width - textSize.width - 5)
            let view = UIView(frame: CGRectMake(x, screenLoc.y - h, w, h))
            let label = UILabel(frame: view.bounds)
            label.text = "\(chartPoint.y.text) mins"
            label.font = labelFont
            view.addSubview(label)
            view.alpha = 0
            UIView.animateWithDuration(0.2, delay: 0, options: UIViewAnimationOptions.CurveEaseOut, animations: { () -> Void in
                view.alpha = 1
                }, completion: nil)
            return view
        }

        let showCoordsLinesLayer = ChartShowCoordsLinesLayer<ChartPoint>(xAxis: xAxis, yAxis: yAxis, innerFrame: innerFrame, chartPoints: chartPoints)
        let showCoordsTextLayer = ChartPointsSingleViewLayer<ChartPoint, UIView>(xAxis: xAxis, yAxis: yAxis, innerFrame: innerFrame, chartPoints: chartPoints, viewGenerator: showCoordsTextViewsGenerator)

        let touchViewsGenerator = {(chartPointModel: ChartPointLayerModel, layer: ChartPointsLayer, chart: Chart) -> UIView? in
            let (chartPoint, screenLoc) = (chartPointModel.chartPoint, chartPointModel.screenLoc)
            let s: CGFloat = 30
            let view = HandlingView(frame: CGRectMake(screenLoc.x - s/2, screenLoc.y - s/2, s, s))
            view.touchHandler = {
                showCoordsLinesLayer.showChartPointLines(chartPoint, chart: chart)
                showCoordsTextLayer.showView(chartPoint: chartPoint, chart: chart)
            }
            return view
        }

        let touchLayer = ChartPointsViewsLayer(xAxis: xAxis, yAxis: yAxis, innerFrame: innerFrame, chartPoints: chartPoints, viewGenerator: touchViewsGenerator)

        let lineModel = ChartLineModel(chartPoints: chartPoints, lineColor: UIColor(red: 0.4, green: 0.4, blue: 1, alpha: 0.2), lineWidth: 3, animDuration: 0.7, animDelay: 0)
        let chartPointsLineLayer = ChartPointsLineLayer(xAxis: xAxis, yAxis: yAxis, innerFrame: innerFrame, lineModels: [lineModel])

        let circleViewGenerator = {(chartPointModel: ChartPointLayerModel, layer: ChartPointsLayer, chart: Chart) -> UIView? in
            let circleView = ChartPointEllipseView(center: chartPointModel.screenLoc, diameter: 18)
            circleView.animDuration = 1.5
            circleView.fillColor = UIColor.whiteColor()
            circleView.borderWidth = 5
            circleView.borderColor = UIColor.blueColor()
            return circleView
        }
        let chartPointsCircleLayer = ChartPointsViewsLayer(xAxis: xAxis, yAxis: yAxis, innerFrame: innerFrame, chartPoints: chartPoints, viewGenerator: circleViewGenerator, displayDelay: 0, delayBetweenItems: 0.05)

        var settings = ChartGuideLinesDottedLayerSettings(linesColor: UIColor.blackColor(), linesWidth: guidelinesWidth)
        let guidelinesLayer = ChartGuideLinesDottedLayer(xAxis: xAxis, yAxis: yAxis, innerFrame: innerFrame, settings: settings)


        let chart = Chart(
            frame: chartFrame,
            layers: [
                xAxis,
                yAxis,
                guidelinesLayer,
                showCoordsLinesLayer,
                chartPointsLineLayer,
                chartPointsCircleLayer,
                showCoordsTextLayer,
                touchLayer,

            ]
        )

        self.chartView.addSubview(chart.view)
    }

Build Failed

I tried to run the code on both xcode 6.4 and 7 beta 4 gave compilation error. I tried to convert the code to the latest version of swift, and keeps giving error. I wonder if a specific configuration is required to run the code?

thanks

Deployment target 8.4

Please change deployment target from 8.4 to lower (8.0). Downloaded using Carthage and when added to project and on import SwiftCharts, compiler gives an error:
module file's minimum deployment target is ios 8.4 v8.4
I worked around like this: changed it manually and carthage build and then droped the library
Thx in advance.

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.