Skip to content

Repository files navigation

SimpleLineChart

ReleasesVersionsPlatformLicense

SLCSLC Styled

SimpleLineChart is a lightweight UIKit line chart view for iOS with simple styling and optional time-range filters.

Features

  • UIKit chart view with minimal setup
  • Solid or gradient background
  • Line styling (stroke, points, shadow)
  • Optional period buttons for time-series data
  • Multiple datasets per chart

Requirements

  • iOS 13.0+
  • Swift 5.1+

Usage

Quick start

letvalues:[SLCData]=[SLCData(x:0, y:5),SLCData(x:1, y:7),SLCData(x:2, y:9)]letlineChart=SimpleLineChart()letdataSet=SLCDataSet(graphPoints: values)
lineChart.loadPoints(dataSet: dataSet)

Styling the chart background

letchartStyle=SLCChartStyle(
backgroundGradient:false,
solidBackgroundColor:.white
)
lineChart.setChartStyle(chartStyle: chartStyle)

Styling the chart line

letlineStyle=SLCLineStyle(
lineColor:.blue,
lineStroke:3.0,
circleDiameter:5.0,
lineShadow:true,
lineShadowgradientStart:.blue,
lineShadowgradientEnd:.white
)
dataSet.setLineStyle(lineStyle)

Time-series periods (optional)

letchartStyle=SLCChartStyle(addPeriodButtons:true)
lineChart.setChartStyle(chartStyle: chartStyle)letnow=Int(Date().timeIntervalSince1970)letvalues=[SLCData(x: now -86400, y:5),SLCData(x: now -3600, y:7),SLCData(x: now, y:9)]

When addPeriodButtons is enabled, SLCData.x must be a UNIX timestamp in seconds for filtering to work correctly.

Multiple datasets

letfirst=SLCDataSet(graphPoints: values1)letsecond=SLCDataSet(graphPoints: values2)
lineChart.loadPoints(dataSets:[first, second])

Installation

Swift Package Manager
dependencies:[.package(url:"https://github.com/augarte/SimpleLineChart.git",.exact("1.0.0"))]
CocoaPods
pod'SimpleLineChart','1.0.0'

Example

Example app can be found here: SLCExampleApp

License

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

About

Simple line charts for iOS 📈

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages