Adding Interactivity to Your iOS Charts with SwiftCharts

Swift Charts

Easy to use and highly customisable Swift Charts library for iOS.

A Powerful framework that enables developers to create stunning and interactive data visualisations with ease. Whether you’re an experienced iOS developer or just getting started, this blog is your go-to resource for mastering the art of data representation in your iOS applications.

Explore the diverse range of chart types supported by the iOS Charts library, including bar charts, line charts, pie charts, scatter plots, and more.

We break down each chart type, explaining their unique features and use cases, while offering practical examples and code snippets to facilitate your learning and implementation process.

Additionally, we explore the interactive features of the iOS Charts library, such as zooming, scrolling, and tapping, enabling users to interact with and explore your data visualizations. We also delve into advanced features like adding annotations, tooltips, and legends to enhance the user experience and make your charts more informative and engaging.

  • language: Swift 
  • platform: ios
  • device: iphone/ipad
  • license: Apache Licence Version 2.0

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

github "i-schuetz/SwiftCharts" ~> 0.6.5

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).
charts in swift
swift chart
line chart in swift
multiple chart in swift
candlestick chart in swift
line chart in swift
multiple axes chart in swift
multiple axes chart
bubble chart in swift
scatter chart
stacked bar
track touch interactive in swift
rotated label
line chart
dynamic charts in swift
pie chart doughnut
multi chart in swift

Quick start

Multiline charts:

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 charts:

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

Download

SwiftCharts

Related Posts

One thought on “Adding Interactivity to Your iOS Charts with SwiftCharts

  1. This is excellent information about charts and reports. This information is meaningful and magnificent for us to increase our knowledge about it. Keep sharing this kind of information. Thank you.

Leave a Reply

Your email address will not be published. Required fields are marked *