FLCharts

repository·main·Indexed 43 days ago

https://github.com/francescoleoni98/flcharts

A customizable Swift library for building bar, line, pie, radar, and scatter charts for iOS. Features include animations, custom highlighting views, embedded chart cards, and support for various data protocols such as SinglePlotable, MultiPlotable, ScatterPlotable, and FLPiePlotable.

Tokens
768
Snippets
4
Records
7
Agent score
5%

What's inside FLCharts

  1. Install FLCharts via Swift Package Manager

    main

    To install FLCharts using Swift Package Manager (SPM):

    1. In Xcode, go to File -> Add Packages....
    2. Search for https://github.com/francescoleoni98/FLCharts and click Add Package.
    3. Select the target you want to add the package to and click Add Package again.
  2. Install FLCharts via Carthage

    main

    To install FLCharts using Carthage:

    1. Add the following to your Cartfile:
      github "francescoleoni98/FLCharts"
    2. Run `carthage update`.
    3. In Xcode, go to **Build Phases** and click the plus button to create a **New Run Script Phase**.
    4. In the **Run Script > Shell script** window, add: `/usr/local/bin/carthage copy-frameworks`.
    5. In the **Run Script > Input file** window, add: `$(SRCROOT)/Carthage/Build/iOS/FLCharts.framework`.
    6. Go to `$project_dir/Carthage/Build/iOS` and drag the `FLCharts.framework` folder into your **Xcode Project > Your Target > Frameworks, Libraries and Embedded Content**.
    
  3. Use Prebuilt Bar Cells in FLChart

    main

    When initializing an FLChart of type .bar, you can specify which prebuilt bar cell class to use.

    Available classes:

    • FLPlainChartBar
    • FLMultipleValuesChartBar
    • FLHorizontalMultipleValuesChartBar
    // Example of initializing a bar chart with a specific bar class
    FLChart(data: ..., type: .bar(bar: FLMultipleValuesChartBar.self))
  4. Configure FLCharts using ChartConfig

    main

    FLCharts is highly customizable via the .config property. You can modify properties such as axes labels using FLAxisLabelConfig and assigning it to a ChartConfig object.

    let axisLabelConfig = FLAxisLabelConfig(color: .black,
                                            font: .preferredFont(forTextStyle: .body))
                             
    chart.config = ChartConfig(axesLabels: axisLabelConfig)
  5. Supported Chart Types and Data Protocols

    main

    FLCharts supports various chart types, each requiring specific data protocols:

    Chart TypeBar/Cell ClassData Protocol
    Plain Bar ChartFLPlainChartBarSinglePlotable
    Multi Value Bar ChartFLMultipleValuesChartBarMultiPlotable
    Horizontal Multi Value Bar ChartFLHorizontalMultipleValuesChartBarMultiPlotable
    Line ChartN/ASinglePlotable
    Multi Value Line ChartN/AMultiPlotable
    Scatter ChartN/AScatterPlotable
    Radar ChartN/AFLDataSet
    Pie ChartN/AFLPiePlotable