Skip to content

Commit 75dac00

Browse files
author
“Andras
committed
feat(new-version): add new readme
1 parent 7140b8b commit 75dac00

31 files changed

+294
-142
lines changed

README.md

Lines changed: 127 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -1,192 +1,180 @@
11
# SwiftUICharts
22

3-
Swift package for displaying charts effortlessly.
3+
### SwiftUICharts is here with a new version, giving more controll and customization over the charts and full ios 13 backwards compatibility.
44

5-
![SwiftUI Charts](./Resources/showcase1.gif "SwiftUI Charts")
5+
SwiftUICharts is an open source library for creating charts in iOS apps with SwiftUI. Built natively with SwiftUI in mind and it is fully compatible with the latest versions of iOS, also backwards **compatible up to iOS 13.**
66

7-
It supports:
8-
* Line charts
9-
* Bar charts
10-
* Pie charts
7+
With SwiftUICharts, you can easily create a variety of chart types, including line charts, bar charts, ring charts and pie charts. It also provides additional chart types and customization options, giving you the flexibility to create charts that perfectly fit your needs.
118

12-
### Installation:
9+
In addition to its native SwiftUI integration, backwards compatibility and wide range of chart types, SwiftUICharts is also easy to use, making it a great choice for creating stunning and intuitive charts in your applications.
1310

14-
It requires iOS 13 and Xcode 11!
11+
<p align="center">
12+
<img src="Resources/linevid2.gif" width="30%"/> <img src="Resources/barvid2.gif" width="30%"/> <img src="Resources/pievid2.gif" width="30%"/>
13+
</p>
1514

16-
In Xcode got to `File -> Swift Packages -> Add Package Dependency` and paste inthe repo's url: `https://github.com/AppPear/ChartView`
15+
### Composable
1716

18-
### Usage:
17+
You can now build your custom chart from prebuilt layers. Use a simple chart, add background grids, add chart labels to the axes, add tcks to the line, etc.
1918

20-
import the package in the file you would like to use it: `import SwiftUICharts`
19+
### Works great with native SwiftUI elements
2120

22-
You can display a Chart by adding a chart view to your parent view:
21+
[Example codes here]()
22+
<p align="left">
23+
<img src="Resources/linechartcard.png" width="40%"/> <img src="Resources/barchartcard.png" width="40%"/>
24+
<img src="Resources/piechartcard.png" width="40%"/>
25+
</p>
2326

24-
### Demo
27+
### Installation
2528

26-
Added an example project, with **iOS, watchOS** target: https://github.com/AppPear/ChartViewDemo
29+
It is a SPM package, in Xcode go to File -> Swift Packages -> Add Package Dependency and paste in the repo's url: https://github.com/AppPear/ChartView
2730

28-
## Line charts
31+
if you want to add previous releases you can find release tags https://github.com/AppPear/ChartView/releases
2932

30-
**LineChartView with multiple lines!**
31-
First release of this feature, interaction is disabled for now, I'll figure it out how could be the best to interact with multiple lines with a single touch.
32-
![Multiine Charts](./Resources/multiline1.gif "Multiine Charts")
33+
### Slack
3334

34-
Usage:
35-
```swift
36-
MultiLineChartView(data: [([8,32,11,23,40,28], GradientColors.green), ([90,99,78,111,70,60,77], GradientColors.purple), ([34,56,72,38,43,100,50], GradientColors.orngPink)], title: "Title")
37-
```
38-
Gradient colors are now under the `GradientColor` struct you can create your own gradient by `GradientColor(start: Color, end: Color)`
39-
40-
Available preset gradients:
41-
* orange
42-
* blue
43-
* green
44-
* blu
45-
* bluPurpl
46-
* purple
47-
* prplPink
48-
* prplNeon
49-
* orngPink
35+
Join our Slack channel for day to day conversation and more insights:
5036

51-
**Full screen view called LineView!!!**
37+
https://join.slack.com/t/swiftuichartview/shared_invite/zt-g6mxioq8-j3iUTF1YKX7D23ML3qcc4g
5238

53-
![Line Charts](./Resources/fullscreen2.gif "Line Charts")
39+
## Quick start guide:
5440

55-
```swift
56-
LineView(data: [8,23,54,32,12,37,7,23,43], title: "Line chart", legend: "Full screen") // legend is optional, use optional .padding()
57-
```
41+
**Create a simple chart:**
5842

59-
Adopts to dark mode automatically
60-
61-
![Line Charts](./Resources/showcase3.gif "Line Charts")
62-
63-
You can add your custom darkmode style by specifying:
43+
<p align="left">
44+
<img src="Resources/chartpic1.png" width="350px"/>
45+
</p>
6446

6547
```swift
66-
let myCustomStyle = ChartStyle(...)
67-
let myCutsomDarkModeStyle = ChartStyle(...)
68-
myCustomStyle.darkModeStyle = myCutsomDarkModeStyle
48+
LineChart()
49+
.data([3, 5, 4, 1, 0, 2, 4, 1, 0, 2, 8])
50+
.chartStyle(ChartStyle(backgroundColor: .white, foregroundColor: ColorGradient(.orange, .red)))
6951
```
7052

71-
**Line chart is interactive, so you can drag across to reveal the data points**
53+
**Add a background grid to the chart:**
7254

73-
You can add a line chart with the following code:
55+
<p align="left">
56+
<img src="Resources/chartpic2.png" width="350px"/>
57+
</p>
7458

7559
```swift
76-
LineChartView(data: [8,23,54,32,12,37,7,23,43], title: "Title", legend: "Legendary") // legend is optional
60+
ChartGrid {
61+
LineChart()
62+
.data([3, 5, 4, 1, 0, 2, 4, 1, 0, 2, 8])
63+
.chartStyle(ChartStyle(backgroundColor: .white, foregroundColor: ColorGradient(.orange, .red)))
64+
}
65+
.setNumberOfHorizontalLines(5)
66+
.setNumberOfVerticalLines(4)
7767
```
7868

79-
**Turn drop shadow off by adding to the Initialiser: `dropShadow: false`**
80-
81-
82-
## Bar charts
83-
![Bar Charts](./Resources/showcase2.gif "Bar Charts")
69+
**Add a axis label to the chart:**
8470

85-
**[New feature] you can display labels also along values and points for each bar to descirbe your data better!**
86-
**Bar chart is interactive, so you can drag across to reveal the data points**
87-
88-
You can add a bar chart with the following code:
89-
90-
Labels and points:
91-
92-
```swift
93-
BarChartView(data: ChartData(values: [("2018 Q4",63150), ("2019 Q1",50900), ("2019 Q2",77550), ("2019 Q3",79600), ("2019 Q4",92550)]), title: "Sales", legend: "Quarterly") // legend is optional
94-
```
95-
Only points:
71+
<p align="left">
72+
<img src="Resources/chartpic3.png" width="350px"/>
73+
</p>
9674

9775
```swift
98-
BarChartView(data: ChartData(points: [8,23,54,32,12,37,7,23,43]), title: "Title", legend: "Legendary") // legend is optional
76+
AxisLabels {
77+
ChartGrid {
78+
LineChart()
79+
.data([3, 5, 4, 1, 0, 2, 4, 1, 0, 2, 8])
80+
.chartStyle(ChartStyle(backgroundColor: .white, foregroundColor: ColorGradient(.orange, .red)))
81+
}
82+
.setNumberOfHorizontalLines(5)
83+
.setNumberOfVerticalLines(4)
84+
}
85+
.setAxisXLabels([(1, "Nov"), (2, "Dec"), (3, "Jan")], range: 1...3)
9986
```
10087

101-
**ChartData** structure
102-
Stores values in data pairs (actually tuple): `(String,Double)`
103-
* you can have duplicate values
104-
* keeps the data order
105-
106-
You can initialise ChartData multiple ways:
107-
* For integer values: `ChartData(points: [8,23,54,32,12,37,7,23,43])`
108-
* For floating point values: `ChartData(points: [2.34,3.14,4.56])`
109-
* For label,value pairs: `ChartData(values: [("2018 Q4",63150), ("2019 Q1",50900)])`
88+
**Show chart marks on the line:**
11089

111-
112-
You can add different formats:
113-
* Small `ChartForm.small`
114-
* Medium `ChartForm.medium`
115-
* Large `ChartForm.large`
90+
<p align="left">
91+
<img src="Resources/chartpic4.png" width="350px"/>
92+
</p>
11693

11794
```swift
118-
BarChartView(data: ChartData(points: [8,23,54,32,12,37,7,23,43]), title: "Title", form: ChartForm.small)
95+
AxisLabels {
96+
ChartGrid {
97+
LineChart()
98+
.showChartMarks(true)
99+
.data([3, 5, 4, 1, 0, 2, 4, 1, 0, 2, 8])
100+
.chartStyle(ChartStyle(backgroundColor: .white, foregroundColor: ColorGradient(.orange, .red)))
101+
}
102+
.setNumberOfHorizontalLines(5)
103+
.setNumberOfVerticalLines(4)
104+
}
105+
.setAxisXLabels([(1, "Nov"), (2, "Dec"), (3, "Jan")], range: 1...3)
119106
```
120107

121-
For floating point numbers, you can set a custom specifier:
108+
**Apply custom ranges on chart**
122109

123-
```swift
124-
BarChartView(data: ChartData(points:[1.23,2.43,3.37]) ,title: "A", valueSpecifier: "%.2f")
125-
```
126-
For integers you can disable by passing: `valueSpecifier: "%.0f"`
127-
128-
129-
You can set your custom image in the upper right corner by passing in the initialiser: `cornerImage:Image(systemName: "waveform.path.ecg")`
130-
131-
132-
**Turn drop shadow off by adding to the Initialiser: `dropShadow: false`**
133-
134-
### You can customize styling of the chart with a ChartStyle object:
135-
136-
Customizable:
137-
* background color
138-
* accent color
139-
* second gradient color
140-
* text color
141-
* legend text color
142-
143-
```swift
144-
let chartStyle = ChartStyle(backgroundColor: Color.black, accentColor: Colors.OrangeStart, secondGradientColor: Colors.OrangeEnd, chartFormSize: ChartForm.medium, textColor: Color.white, legendTextColor: Color.white )
145-
...
146-
BarChartView(data: [8,23,54,32,12,37,7,23,43], title: "Title", style: chartStyle)
147-
```
110+
<p align="left">
111+
<img src="Resources/chartpic5.png" width="350px"/>
112+
</p>
148113

149-
You can access built-in styles:
150114
```swift
151-
BarChartView(data: [8,23,54,32,12,37,7,23,43], title: "Title", style: Styles.barChartMidnightGreen)
115+
AxisLabels {
116+
ChartGrid {
117+
LineChart()
118+
.showChartMarks(true)
119+
.data([3, 5, 4, 1, 0, 2, 4, 1, 0, 2, 8])
120+
.rangeY(0...10)
121+
.rangeX(0...5)
122+
.chartStyle(ChartStyle(backgroundColor: .white, foregroundColor: ColorGradient(.orange, .red)))
123+
}
124+
.setNumberOfHorizontalLines(5)
125+
.setNumberOfVerticalLines(4)
126+
}
127+
.setAxisXLabels([(1, "Nov"), (2, "Dec"), (3, "Jan")], range: 1...3)
152128
```
153-
#### All styles available as a preset:
154-
* barChartStyleOrangeLight
155-
* barChartStyleOrangeDark
156-
* barChartStyleNeonBlueLight
157-
* barChartStyleNeonBlueDark
158-
* barChartMidnightGreenLight
159-
* barChartMidnightGreenDark
160-
161-
![Midnightgreen](./Resources/midnightgreen.gif "Midnightgreen")
162-
163-
![Custom Charts](./Resources/showcase5.png "Custom Charts")
164129

130+
**Add multiple charts in the same frame**
165131

166-
### You can customize the size of the chart with a ChartForm object:
167-
168-
**ChartForm**
169-
* `.small`
170-
* `.medium`
171-
* `.large`
172-
* `.detail`
132+
<p align="left">
133+
<img src="Resources/chartpic6.png" width="350px"/>
134+
</p>
173135

174136
```swift
175-
BarChartView(data: [8,23,54,32,12,37,7,23,43], title: "Title", form: ChartForm.small)
137+
AxisLabels {
138+
ChartGrid {
139+
LineChart()
140+
.showChartMarks(true)
141+
.data([3, 5, 4, 1, 0, 2, 4, 1, 0, 2, 8])
142+
.rangeY(0...12)
143+
.rangeX(0...5)
144+
.chartStyle(ChartStyle(backgroundColor: .white, foregroundColor: ColorGradient(.orange, .red)))
145+
LineChart()
146+
.showChartMarks(true)
147+
.data([4, 1, 0, 2, 8, 3, 6, 1, 4])
148+
.rangeY(0...12)
149+
.rangeX(0...5)
150+
.chartStyle(ChartStyle(backgroundColor: .white, foregroundColor: ColorGradient(.blue, .purple)))
151+
}
152+
.setNumberOfHorizontalLines(5)
153+
.setNumberOfVerticalLines(4)
154+
}
155+
.setAxisXLabels([(1, "Nov"), (2, "Dec"), (3, "Jan")], range: 1...3)
176156
```
177157

178-
### WatchOS support for Bar charts:
179-
180-
![Pie Charts](./Resources/watchos1.png "Pie Charts")
158+
**Combine chart types in the same frame**
181159

182-
## Pie charts
183-
![Pie Charts](./Resources/showcase4.png "Pie Charts")
184-
185-
You can add a pie chart with the following code:
160+
<p align="left">
161+
<img src="Resources/chartpic7.png" width="350px"/>
162+
</p>
186163

187164
```swift
188-
PieChartView(data: [8,23,54,32], title: "Title", legend: "Legendary") // legend is optional
165+
AxisLabels {
166+
ChartGrid {
167+
BarChart()
168+
.data([2, 4, 1, 3])
169+
.chartStyle(ChartStyle(backgroundColor: .white, foregroundColor: ColorGradient(.orange, .red)))
170+
LineChart()
171+
.showChartMarks(true)
172+
.data([2, 4, 1, 3])
173+
.chartStyle(ChartStyle(backgroundColor: .white, foregroundColor: ColorGradient(.blue, .purple)))
174+
}
175+
.setNumberOfHorizontalLines(5)
176+
.setNumberOfVerticalLines(4)
177+
}
178+
.setAxisXLabels([(1, "Nov"), (2, "Dec"), (3, "Jan")], range: 1...3)
189179
```
190180

191-
**Turn drop shadow off by adding to the Initialiser: `dropShadow: false`**
192-

Resources/barchartcard.png

64 KB
Loading

Resources/barvid2.gif

125 KB
Loading

Resources/chartpic1.png

96.4 KB
Loading

Resources/chartpic2.png

103 KB
Loading

Resources/chartpic3.png

109 KB
Loading

Resources/chartpic4.png

117 KB
Loading

Resources/chartpic5.png

76.4 KB
Loading

Resources/chartpic6.png

112 KB
Loading

Resources/chartpic7.png

153 KB
Loading

0 commit comments

Comments
 (0)