-
Notifications
You must be signed in to change notification settings - Fork 22
Usage guide
Francesco Leoni edited this page Apr 10, 2022
·
7 revisions
let monthsData = [MultiPlotable(name: "jan", values: [33, 43]), [...]]
let data = ChartData(title: "Consumptions",
data: monthsData,
legendKeys: [Key(key: "F1", color: .Gradient.purpleCyan),
Key(key: "F2", color: .green),
Key(key: "F3", color: .Gradient.sunset)],
unitOfMeasure: "scm")
let chart = FLChart(data: data, type: .bar(bar: FLMultipleValuesChartBar.self))
let card = FLCard(chart: chart,
style: .rounded)
card.showAverage = false
To create a custom bar create a class
that inherits from ChartBar
.
public final class CustomChartBar: UIView, ChartBar {
public var config: ChartConfig?
public var barConfig: FLBarConfig?
public func configureViews() {
[...]
}
public func configureBar(for barHeight: CGFloat, barData: BarData) {
[...]
}
}
To create a custom highlighted view create a class
that inherits from HighlightedView
.
public final class CustomHighlightedView: UIView, HighlightedView {
public var dataValue: String?
private let dataValueLabel = UILabel()
override init(frame: CGRect) {
super.init(frame: frame)
[configure views]
}
public func update(with value: String?) {
[...]
}
}
let lineChartData = FLChartData([...],
legendKeys: [
Key(key: "F1", yThresholds: [40 : .red,
56 : .blue,
84 : .green,
100 : .orange],
data: monthsData),
Key(key: "F2", xColors: [.red,
.blue,
.green,
.orange])],
[...])
let barConfig = FLBarConfig(colors: [.red, .blue, .green],
radius: .capsule,
spacing: 10)
let axesLabelConfig = FLAxisLabelConfig(color: .black,
font: .preferredFont(forTextStyle: .body))
chart.config = ChartConfig(axesLabels: axesLabelConfig)
Footer