FLCharts: Easy to use and highly customizable charts library for iOS

Related tags

Charts FLCharts
Overview

FLCharts

CI Status Version License Platform

Requirements

  • Xcode 11 / Swift 5
  • iOS >= 11.0

Installation

FLCharts is available through CocoaPods. To install it, add the following line to your Podfile:

pod 'FLCharts'

Features

  • Dragging / Panning (with touch-gesture)
  • Customizable Axes (both x and y axis)
  • Highlighting values (with customizable popup-views)
  • Scroll through chart while highlighted to change highlighted bar
  • Animations for chart bars
  • Limit lines (providing additional information, maximums, ...)
  • Fully customizable (bar colors, axes color, background, average value, dashed lines, ...)

Docs

You can build FLCharts documentation directly in XCode. In XCode go to Product -> Build Documentation, once XCode has finished building, the documentation will appear.

Examples

  • Bar Chart

alt tag

  • Multivalue Bar Chart

alt tag

  • Highlighted Bar

alt tag

Author

francescoleoni98, [email protected]

License

FLCharts is available under the MIT license. See the LICENSE file for more info.

Comments
  • Bar chart does not use the full screen width

    Bar chart does not use the full screen width

    Discussed in https://github.com/francescoleoni98/FLCharts/discussions/37

    Originally posted by SvenMuc May 12, 2022 Hi,

    I'd like to show my results in a bar chart as shown in the top chart in the image.

    In FLCharts (bottom chart) the bars do not use the full width of the chart diagram. Is there any parameter I need to set? I only found some parameters to configure a fixed width for each bar.

    Furthermore, I miss a feature to show the values (label) for each bar.

    FLBarConfig(radius: .custom(5.0), width: 50.0, spacing: 10.0)

    Bildschirmfoto 2022-05-12 um 22 03 54

    Any ideas?

    Sven

    opened by SvenMuc 5
  • Handle empty data or 0 value

    Handle empty data or 0 value

    Describe the bug If the data is [0] the app crashes

    To Reproduce let data = FLChartData(title: "Consumptions", data: [0], legendKeys: [Key(key: "F1", color: .Gradient.purpleCyan), Key(key: "F2", color: .green), Key(key: "F3", color: .Gradient.sunset)], unitOfMeasure: "kWh")

    bug 
    opened by francescoleoni98 4
  • Localization Support

    Localization Support

    Q: Is your feature request related to a problem? Please describe.

    A: Some Strings are hardcoded ( "avg.", "No data available", ... ) with no way to change them.

    Q: Describe the solution you'd like

    A: Make them configurable or even better implement automatic localization for top n languages ( via strings file ).

    Q: Describe alternatives you've considered

    A: Forking but that would not be nice ^^

    Thanks for your time undeaD_D


    PS: Is the Darkmode not working currently ? ( It does not switch automatically, and there is no clear example -> just an image inside the readme.md )

    opened by undeaDD 2
  • Set min and max y-axis values (automatic zoom)

    Set min and max y-axis values (automatic zoom)

    Is your feature request related to a problem? Please describe. My visualized values are close together. Thus all bars looks almost the same. See also mid chart in the image below.

    Describe the solution you'd like Add an interface to set manually the min/max y-axis range.

    Describe alternatives you've considered Alternatively, an automatic zoom mode could be implemented by adding an offset to the min/max chart values.

    Additional context The chart in the middle is based on FLCharts.

    Bildschirmfoto 2022-05-26 um 22 15 23
    opened by SvenMuc 2
  • Added possibility to limit the width of bars

    Added possibility to limit the width of bars

    If a bar chart has a small amount of bars and scrolling is disabled the bars get very big. Currently the bars have to fill the total width of the chart. See this example: Screenshot BarChart

    With my adjustments in this pull request the default behaviour stays the same. But you can configure to limit the width of the bars to get a result like this: Screenshot BarChart1

    opened by iAppDeveloper88 2
  • Add possibility to FLMultipleValuesChartBar to show multiple separate bars instead of staking

    Add possibility to FLMultipleValuesChartBar to show multiple separate bars instead of staking

    It would be great if you could implement the possibility to allow FLMultipleValuesChartBar to show the provided values as separate bars instead of staking them in a single bar. In the image you can see the feature from a different chart library. 68747470733a2f2f7261772e6769746875622e636f6d2f5068696c4a61792f4d5043686172742f6d61737465722f73637265656e73686f74732f67726f7570656462617263686172742e706e67

    enhancement 
    opened by iAppDeveloper88 2
  • Double Y-axis lines in line charts

    Double Y-axis lines in line charts

    Describe the bug if you exit (button Home) the application and run it again Line Chart the y-axis lines are repeated

    To Reproduce Steps to reproduce the behavior:

    1. Launch app (example)
    2. Click on Home
    3. Launch app
    4. See Line Chart the y-axis lines are repeated
    Снимок экрана 2022-03-12 в 11 57 20

    Smartphone (please complete the following information):

    • Device: [e.g. iPhone7]
    • OS: [e.g. iOS13]
    Снимок экрана 2022-03-12 в 11 57 20
    opened by mahonya 2
  • Add pie chart

    Add pie chart

    Hi! You've made a beautiful library) I really like it. It's look like real native apple's components. But I still need to use another "the most popular" lib to represent chart, because they are support pie charts( I wish you will have possibilities and resources to do this🙏🏻 Thank you and good luck!

    opened by marshtupa 2
  • Update chart data programmatically

    Update chart data programmatically

    I try to update the chart's data programmatically, however I fail to do so.

    Initially, I build the chart showing one price fetched from UserDefaults using the function buildChart().

    From time to time, I want to update the chart's data using the function updateChartData(). I tried appending elements to chartsData, however, this fails with the error

    Cannot use mutating member on immutable value: 'chartsData' is a get-only property

    Can anyone assist? My rough code so far is:

    import UIKit
    import FLCharts
    
    class AnalysisViewController: UIViewController {
        
        @IBOutlet weak var chartView: FLChart!
        
        override func viewDidLoad() {
            super.viewDidLoad()
            
            // Listen to silent notification to reload graph when new stock price was fetched and received by this view
            NotificationCenter.default.setObserver(self, selector: #selector(updateChartData), name: NSNotification.Name(rawValue: "stockPriceFetchedForGraphUpdate"), object: nil)
            
            buildChart()
        }
        
        @objc func updateChartData() {
            print("update")
            
        }
        
        func buildChart() {
            let priceNow = UserDefaults.standard.double(forKey: "stockPriceLastFetchedAmount")
    
            var chartsData: [MultiPlotable] {
                [MultiPlotable(name: "", values: [priceNow]),]
            }
    
            let barChartData = FLChartData(title: "",
                                           data: chartsData,
                                           legendKeys: [
                                            Key(key: "", color: FLColor(UIColor(named: "Gold") ?? .label))
                                           ],
                                           unitOfMeasure: "Euro")
            barChartData.xAxisUnitOfMeasure = ""
            barChartData.yAxisFormatter = .decimal(2)
            
            //let lineChart = FLChart(data: barChartData, type: .line(config: FLLineConfig(width: 3, capStyle: .square, backgroundFill: FLColor(UIColor(named: "Gold")?.withAlphaComponent(0.2) ?? .clear), isSmooth: true)))
            let priceChart = FLChart(data: barChartData, type: .line(config: FLLineConfig(width: 3, capStyle: .butt, backgroundFill: FLColor(UIColor(named: "Gold")?.withAlphaComponent(0.2) ?? .label), showCircles: false, isSmooth: true, circleColor: UIColor(named: "Gold") ?? .label)))
            priceChart.config = FLChartConfig(granularityY: (priceNow / 5).rounded()) // to nearest 500
            priceChart.shouldScroll = false
            priceChart.showAverageLine = true
            priceChart.showTicks = false
                    
            chartView.addSubview(priceChart)
            priceChart.translatesAutoresizingMaskIntoConstraints = false
            NSLayoutConstraint.activate([
                priceChart.centerYAnchor.constraint(equalTo: self.chartView.centerYAnchor),
                priceChart.centerXAnchor.constraint(equalTo: self.chartView.centerXAnchor),
                priceChart.heightAnchor.constraint(equalToConstant: self.chartView.frame.height * 1),
                priceChart.widthAnchor.constraint(equalToConstant: UIScreen.main.bounds.width * 0.9),
            ])
        }
    }
    
    opened by d0hnj0e 1
  • Y axis rendering issue?

    Y axis rendering issue?

    Great stuff you got here mate, just thought I would flag an issue that I am experiencing from the example app. The Y axis labels appears to get rendered every time when the example app becomes enters foreground after the initial launch.

    I suspect this might have something to do with FLCartesianPlane.swift:273, as it seems to just keep on adding labels to the chart.

    opened by TheEasternInquisitor 1
  • Bar Chart Scrolling

    Bar Chart Scrolling

    I can't seem to get the bar chart to scroll. I've copied the example on the medium post and added some more data in to fill the width of the chart. Does this only work in certain configurations or is there some that needs to be enabled to get it to work?

    opened by Megatron1000 1
  • Layout Disturbed for RTL languages

    Layout Disturbed for RTL languages

    Describe the bug I am using FLMultipleValuesChartBar. Everything works fine except when I change my device language to RTL (e.g Arabic, Urdu) the layout of the chart is disturbed.

    To Reproduce Steps to reproduce the behavior:

    1. Change App layout to RTL using UIView.appearance().semanticContentAttribute = .forceRightToLeft

    Screenshots Screenshot IMG_3032

    Iphone (please complete the following information):

    • OS: 16.1.1

    Smartphone (please complete the following information):

    • Device: iPhone 13 Pro Max
    • OS:16.1.1
    • Version 1.9.0
    opened by DeveloperZainModr 0
  • View resizing

    View resizing

    I am trying to implement the library into a Mac Catalyst App. But I face some rendering issues when trying to resize the windows (see video). Thanks again for this great library !

    Best,

    Michael

    https://user-images.githubusercontent.com/9451389/180637276-194bef1a-e27a-4371-89e2-4d0f6c81b22f.mov

    opened by michael-mansour 0
  • Fixed Y granularity that caused issues when updating the chart data

    Fixed Y granularity that caused issues when updating the chart data

    Screen Shot 2022-07-22 at 5 41 30 AM

    fixed an error when updating chart data that would cause mis-sizing, causing wrong y-axis labels due to keeping the old granularity from previous data. I was going to include a check to make sure the granularity is different, but after extensive testing it seemed that there was no issues when providing no granularity, since the default is 0.

    opened by BrandonBravos 0
  • Data Labels for Line and Bar Charts

    Data Labels for Line and Bar Charts

    Discussed in https://github.com/francescoleoni98/FLCharts/discussions/36

    Originally posted by SvenMuc May 12, 2022 Hi,

    really cool library, but I still miss some basic features.

    It would be really nice if we can show data labels in the line and bar charts. Additionally the location should be configureable (e.g. above, below line marker, inside, center or outside of a bar).

    Would do you think?

    Regards Sven

    opened by SvenMuc 3
  • Is there currently a way to ignore 0 for a Line Chart?

    Is there currently a way to ignore 0 for a Line Chart?

    Describe the bug I couldn't figure out a way presently to ignore 0 on a line in a LineChart. issue that comes up is when you only have one data point with a value, it still draws a line from 0. I believe it should just show a point because the 0 should be ignored.

    Screenshot 2022-05-18 at 6 34 21 PM Screenshot 2022-05-18 at 6 37 23 PM
    func makeUIView(context: Context) -> FLChart {
        var  monthsData: [SinglePlotable] {
            [SinglePlotable(name: "M", value: 0),
             SinglePlotable(name: "T", value: 0),
             SinglePlotable(name: "W", value: 55),
             SinglePlotable(name: "T", value: 0),
             SinglePlotable(name: "F", value: 0),
             SinglePlotable(name: "S", value: 0),
             SinglePlotable(name: "S", value: 0)]
        }
        let chartData = FLChartData(title: "Consumptions",
                                    data: monthsData,
                                    legendKeys: [
                        Key(key: "F1", color: .Gradient.purpleCyan),
                        Key(key: "F2", color: .green),
                        Key(key: "F3", color: .Gradient.sunset)],
                                     unitOfMeasure: "Kg")
        chartData.xAxisUnitOfMeasure = "Days"
        //chartData.yAxisFormatter = .decimal(1)
        
        let lineChart = FLChart(data: chartData, type: .line())
       // let card = FLCard(chart: lineChart, style: .rounded)
        //card.showAverage = true
        //card.showLegend = true
        //lineChart.cartesianPlane.yAxisPosition = .right
        //lineChart.config = FLChartConfig(granularityY: 30)
        return lineChart
    }`
    

    `

    opened by 4bh1nav 2
Releases(1.9.0)
Owner
Francesco Leoni
iOS developer
Francesco Leoni
SwiftCharts - Easy to use and highly customizable charts library for iOS

SwiftCharts Easy to use and highly customizable charts library for iOS Features: Bars - plain, stacked, grouped, horizontal, vertical Scatter Lines (s

Ivan Schütz 2.4k Jan 4, 2023
Easy to use and highly customizable pie charts library for iOS

PieCharts Easy to use and highly customizable pie charts library for iOS Swift 4.2, iOS 8+ Video Features: Customizable slices Add overlays using simp

null 503 Dec 6, 2022
Easy to use and highly customizable pie charts library for iOS

PieCharts Easy to use and highly customizable pie charts library for iOS Swift 4.2, iOS 8+ Video Features: Customizable slices Add overlays using simp

null 503 Dec 6, 2022
An overview of the different types of charts you can make with Swift Charts

Swift Charts Examples This repo aims to provide sample code for lots of different chart types for you to use as inspiration for your own projects. We

Jordi Bruin 1.2k Dec 30, 2022
A powerful 🚀 Android chart view / graph view library, supporting line- bar- pie- radar- bubble- and candlestick charts as well as scaling, panning and animations.

⚡ A powerful & easy to use chart library for Android ⚡ Charts is the iOS version of this library Table of Contents Quick Start Gradle Maven Documentat

Philipp Jahoda 36k Jan 5, 2023
Core Charts | Basic Scrollable Chart Library for iOS

Core Charts | Basic Chart Library for iOS HCoreBarChart VCoreBarChart Requirements Installation Usage Appearance Customization Getting Started You nee

Çağrı ÇOLAK 71 Nov 17, 2022
SwiftUICharts - A charts / plotting library for SwiftUI.

A charts / plotting library for SwiftUI. Works on macOS, iOS, watchOS, and tvOS and has accessibility features built in.

Will Dale 632 Jan 3, 2023
Using Swift Charts and Voiceover Chart Descriptor to compose music. 🤯

Chart de lune ?? Using Swift Charts and Voiceover Chart Descriptor to compose music. ?? Image source: https://hadikarimi.com/portfolio/claude-debussy-

An Trinh 31 Nov 21, 2022
Beautiful charts for iOS/tvOS/OSX! The Apple side of the crossplatform MPAndroidChart.

One more heads up: As Swift evolves, if you are not using the latest Swift compiler, you shouldn't check out the master branch. Instead, you should go to the release page and pick up whatever suits you.

Daniel Cohen Gindi 26.3k Jan 3, 2023
🎉 SwiftUI stock charts for iOS

SwiftUI Stock Charts Display interactive stock charts easily ?? Instalation In Xcode go to File -> Swift packages -> Add package dependency Copy and p

Dennis Concepción Martín 94 Dec 26, 2022
🎉 SwiftUI stock charts for iOS

?? SwiftUI stock charts for iOS

Dennis Concepción Martín 94 Dec 26, 2022
An iOS wrapper for ChartJS. Easily build animated charts by leveraging the power of native Obj-C code.

TWRCharts TWRCharts An Obj-C wrapper for ChartJS. Easily build animated charts by leveraging the power of native code. TWRCharts is yet another charti

Michelangelo Chasseur 363 Nov 28, 2022
Light weight charts view generater for iOS. Written in Swift.

# ###Light weight charts view generater for iOS. Written in Swift. Requirements iOS 8.0+ XCode 7.3+ Installation CocoaPods $ pod init specify it in yo

Recruit Holdings. Media Technology Lab 982 Nov 16, 2022
Beautiful charts for iOS/tvOS/OSX! The Apple side of the crossplatform MPAndroidChart.

Version 4.0.0, synced to MPAndroidChart #f6a398b Just a heads up: Charts 3.0 has some breaking changes. Please read the release/migration notes. Anoth

Daniel Cohen Gindi 26.3k Jan 8, 2023
Aplikasi iOS kasus Covid-19 di U.S dengan Storyboard, Framework Charts dari danielgindi, dan API dari covidtracking.com

Aplikasi iOS kasus Covid-19 di U.S dengan Storyboard, Framework Charts dari danielgindi, dan API dari covidtracking.com

DK 7 Aug 1, 2022
This is pie chart that is very easy to use and customizable design.

CSPieChart Example To run the example project, clone the repo, and run pod install from the Example directory first. Requirements Installation CSPieCh

iOSCS 40 Nov 29, 2022
SwiftUI Charts with custom styles

SwiftUI Charts Build custom charts with SwiftUI Styles Line Chart(data: [0.1, 0.3, 0.2, 0.5, 0.4, 0.9, 0.1]) .chartStyle( LineChartStyle(.

SpaceNation 609 Jan 6, 2023
Health Sample app using Swift, RxSwift, Anchorage, Charts

HealthSample First run pod install, then build the project and run in your devices or simulators. This project has used RIBs, Swift, RxSwift, Anchorag

null 4 Feb 11, 2022