Charts Swift Example: Line Graphs, Pie – Candlestick Charts

Discover the simplicity and power of integrating charts into your iOS apps with Swift.

This tutorial provides step-by-step guidance on creating and customizing various chart types, including line graphs, bar charts, pie charts, Candlestick Charts, Bubble Charts, and Radar Charts

Whether you’re a beginner or experienced developer, learn how to present your data visually, making it engaging and informative for users. Enhance your app’s data visualization capabilities and unlock new possibilities with charts in Swift.

Learn how to effortlessly integrate click here : charts in SwiftUI


Beautiful charts for iOS/tvOS/OSX! The Apple side of the cross platform MPAndroidChart.

BarChart (with legend, simple design)

  • language: Swift 5
  • platform: ios | tvos | osx
  • device: iphone/ipad | Mac
  • license: Apache




pod 'Charts'

For Realm support, please add pod 'ChartsRealm' too.

Note: pod 'ios-charts' is not the correct library, and refers to a different project by someone else.

Carthage Install

Charts now include Carthage prebuilt binaries.

github "danielgindi/Charts" == 3.5.0
github "danielgindi/Charts" ~> 3.5.0

In order to build the binaries for a new release, use carthage build --no-skip-current && carthage archive Charts.

3rd party bindings

Xamarin (by @Flash3001): iOS – GitHub/NuGetAndroid – GitHub/NuGet.

Chart types:

Screenshots are currently taken from the original repository, as they render exactly the same 🙂

LineChart (with legend, simple design)

Line charts in swift

LineChart (with legend, simple design)

Linecharts in swift

LineChart (cubic lines)

chart in swift

LineChart (gradient fill)

chart in swift

Combined-Chart (bar- and linechart in this case)

combined charts in swift

BarChart (grouped DataSets)

Barchart in swift


horizontal barchart in swift

PieChart (with selection, …)

pie chart in swift

ScatterChart (with squares, triangles, circles, … and more)

scatter chart in swift

CandleStickChart (for financial data)

candlestick charts

BubbleChart (area covered by bubbles indicates the value)


RadarChart (spider web chart)



In order to correctly compile:

  1. 1. Drag the Charts.xcodeproj to your project
  2. 2. Go to your target’s settings, hit the “+” under the “Embedded Binaries” section, and select the Charts.framework
  3. 3. When using Swift in an ObjC project:
  4. 4. You need to import your Bridging Header. Usually it is “YourProject-Swift.h”, so in ChartsDemo it’s “ChartsDemo-Swift.h”. Do not try to actually include “ChartsDemo-Swift.h” in your project 🙂
  5. 5. (Xcode 8.1 and earlier) Under “Build Options”, mark “Embedded Content Contains Swift Code”
  6. 6. (Xcode 8.2+) Under “Build Options”, mark “Always Embed Swift Standard Libraries”

When using

  • Note that the Realm framework is not linked with Charts – it is only there for optional bindings. Which means that you need to have the framework in your project, and in a compatible version to whatever is compiled with Charts. We will do our best to always compile against the latest version.
  • You’ll need to add ChartsRealm as a dependency too.
  • @import Charts


Core features:

  • 8 different chart types
  • Scaling on both axes (with touch-gesture, axes separately or pinch-zoom)
  • Dragging / Panning (with touch-gesture)
  • Combined-Charts (line-, bar-, scatter-, candle-stick-, bubble-)
  • Dual (separate) Axes
  • Customizable Axes (both x- and y-axis)
  • Highlighting values (with customizable popup-views)
  • Save chart to camera-roll / export to PNG/JPEG
  • Predefined color templates
  • Legends (generated automatically, customizable)
  • Animations (build up animations, on both x- and y-axis)
  • Limit lines (providing additional information, maximums, …)
  • Fully customizable (paints, typefaces, legends, colors, background, gestures, dashed lines, …)
  • Plotting data directly from mobile database



Related Posts

Leave a Reply

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