-
Notifications
You must be signed in to change notification settings - Fork 2
/
ChartsPieChart.swift
33 lines (29 loc) · 1.03 KB
/
ChartsPieChart.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//
// ChartsPieChart.swift
// ChartsPlayground
//
// Created by Jannik Arndt on 29.08.21.
//
import Charts
import SwiftUI
struct ChartsPieChart: View {
@State private var data: [PieChartDataEntry] = [
PieChartDataEntry(value: 354, label: "Rewe", icon: NSUIImage(systemName: "cart"), data: "rewe"),
PieChartDataEntry(value: 261, label: "Lidl", icon: NSUIImage(systemName: "cart"), data: "rewe"),
PieChartDataEntry(value: 117, label: "Langer Name", icon: NSUIImage(systemName: "cart"), data: "rewe"),
PieChartDataEntry(value: 14, label: "Aldi", icon: NSUIImage(systemName: "cart"), data: "rewe")
]
var body: some View {
VStack(alignment: .center, spacing: 20) {
Form {
PieChart(entries: data).frame(height: 300)
Button("Add data") { data.append(PieChartDataEntry(value: Double.random(in: 1 ..< 500))) }
}
}
}
}
struct ChartsPieChart_Previews: PreviewProvider {
static var previews: some View {
ChartsPieChart()
}
}