-
Notifications
You must be signed in to change notification settings - Fork 8
/
VennDiagramViewController.swift
48 lines (36 loc) · 2.1 KB
/
VennDiagramViewController.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import UIKit
import AnyChart_iOS
class VennDiagramViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let anyChartView = AnyChartView()
view.addSubview(anyChartView)
anyChartView.translatesAutoresizingMaskIntoConstraints = false
anyChartView.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
anyChartView.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true
anyChartView.widthAnchor.constraint(equalTo: view.widthAnchor).isActive = true
anyChartView.heightAnchor.constraint(equalTo: view.heightAnchor).isActive = true
let chart = AnyChart.venn()
let data: Array<DataEntry> = [
NameValueDataEntry(x: "A", name: "Data Science", value: 100),
NameValueDataEntry(x: "B", name: "Computer Science", value: 25),
NameValueDataEntry(x: "C", name: "Math and Statistics", value: 25),
NameValueDataEntry(x: "D", name: "Subject Matter Expertise", value: 25),
NameValueDataEntry(x: "A&B", name: "Computer Science", value: 50),
NameValueDataEntry(x: "A&C", name: "Math and Statistics", value: 50),
NameValueDataEntry(x: "A&D", name: "Subject Matter Expertise", value: 50),
NameValueDataEntry(x: "B&C", name: "Machine\\nLearning", value: 5),
NameValueDataEntry(x: "C&D", name: "Traditional\\nResearch", value: 5),
NameValueDataEntry(x: "D&B", name: "Traditional\\nSoftware", value: 5),
NameValueDataEntry(x: "B&C&D", name: "Unicorn", value: 5)
]
chart.data(data: data)
chart.stroke(settings: "2 #FFFFFF")
chart.labels().format(token: "{%Name}")
chart.intersections().hovered().fill(color: "black", opacity: 0.25)
chart.intersections().labels().fontWeight(weight: "bold")
chart.intersections().labels().format(token: "{%Name}")
chart.tooltip().titleFormat(format: "{%Name}")
anyChartView.setChart(chart: chart)
}
}