https://github.com/augarte/simplelinechart
Simple line charts for iOS 📈
https://github.com/augarte/simplelinechart
chart ios linechart swift swiftpackagemanager
Last synced: 4 months ago
JSON representation
Simple line charts for iOS 📈
- Host: GitHub
- URL: https://github.com/augarte/simplelinechart
- Owner: augarte
- License: mit
- Created: 2023-01-06T22:38:27.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-09-16T15:52:08.000Z (almost 3 years ago)
- Last Synced: 2026-01-19T21:24:55.417Z (5 months ago)
- Topics: chart, ios, linechart, swift, swiftpackagemanager
- Language: Swift
- Homepage:
- Size: 129 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SimpleLineChart





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
```swift
let values: [SLCData] = [
SLCData(x: 0, y: 5),
SLCData(x: 1, y: 7),
SLCData(x: 2, y: 9)
]
let lineChart = SimpleLineChart()
let dataSet = SLCDataSet(graphPoints: values)
lineChart.loadPoints(dataSet: dataSet)
```
Styling the chart background
```swift
let chartStyle = SLCChartStyle(
backgroundGradient: false,
solidBackgroundColor: .white
)
lineChart.setChartStyle(chartStyle: chartStyle)
```
Styling the chart line
```swift
let lineStyle = SLCLineStyle(
lineColor: .blue,
lineStroke: 3.0,
circleDiameter: 5.0,
lineShadow: true,
lineShadowgradientStart: .blue,
lineShadowgradientEnd: .white
)
dataSet.setLineStyle(lineStyle)
```
Time-series periods (optional)
```swift
let chartStyle = SLCChartStyle(addPeriodButtons: true)
lineChart.setChartStyle(chartStyle: chartStyle)
let now = Int(Date().timeIntervalSince1970)
let values = [
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
```swift
let first = SLCDataSet(graphPoints: values1)
let second = SLCDataSet(graphPoints: values2)
lineChart.loadPoints(dataSets: [first, second])
```
## Installation
##### Swift Package Manager
```swift
dependencies: [
.package(url: "https://github.com/augarte/SimpleLineChart.git", .exact("1.0.0"))
]
```
##### CocoaPods
```ruby
pod 'SimpleLineChart', '1.0.0'
```
## Example
Example app can be found here: [SLCExampleApp](https://github.com/augarte/SLCExampleApp)
## License
SimpleLineChart is available under the MIT license.
See the [LICENSE](https://github.com/augarte/SimpleLineChart/blob/main/LICENSE) for more info.