FUIChartSummaryView
@MainActor
open class FUIChartSummaryView : FUIDrawingView, ChartObserver
Summary content view of Chart Floorplan, and related components.
Data Source
Developer should implement FUIChartSummaryDataSource to supply a summary item when user selects a category in the FUIChartFloorplan views.
Often, the Developer will want to pin an ‘aggregate’ summary item to the left of the summary view, which might sum values for each series over the range of categories in the chart, display the macro trend, etc. For this case, return an item for categoryIndex == -1.
Delegate
Developer may also optionally implement FUIChartSummaryDelegate, to handle user taps on summary items in the FUIChartSummaryView. According to the design guidelines, this should typically drill-down into the data slice for the selected category(ies).
Usage
let item = FUIChartSummaryItem()
// Category index `-1` used for 'aggregate' column. True category indexes are requested by `dataSource`.
item.categoryIndex = -1
item.isEnabled = false
let values: [Double] = {
var values: [Double] = []
let seriesCount = chartData().count
for i in 0..<seriesCount {
values.append(chartData()[i].map({ $0 * 1000 }).suffix(from: 1).reduce(0, +))
}
return values
}()
item.valuesText = values.map { formattedTitleForDouble($0)! }
item.title.text = "TTM"
// If `chartView != nil`, supply an item to the `dataSource`. Otherwise, add category index to selected set.
summaryView.addItem(at: item.category)
Attention
The delegate object with type FUIChartSummaryDelegate is declared as a weak reference. So on deallocation it will be automatically set to nil. To keep it alive as expected, developer should retain the delegate object during its whole execution scope.
-
View containing the chart and plotted points
Declaration
Swift
@MainActor public internal(set) weak var chartView: FUIChartView? { get set } -
Data source for summary items
Declaration
Swift
@MainActor public weak var dataSource: FUIChartSummaryDataSource? { get set } -
Delegate to handle user interaction with summary item views
Declaration
Swift
@MainActor public weak var delegate: FUIChartSummaryDelegate?
-
The array of title texts for each series of the chart.
Declaration
Swift
@MainActor public var seriesTitleText: [FUIText] -
Force summary view to invoke its
dataSource. You should not typically need to call this directly, as it is invoked on changes to the selected state of thechartView.Declaration
Swift
@MainActor public func reloadData() -
Get the set of current items
Remark
setmethod is obsoleted.Declaration
Swift
@MainActor public var items: [FUIChartSummaryItemType] { get set } -
Helper method, should ONLY be used, when the view’s
chartViewproperty isnil.Declaration
Swift
@MainActor public func addItem(at categoryIndex: Int)Parameters
categoryIndexThe index of the category for which a summary item should be obtained. Use
-1, to obtain a ‘fixed’ or ‘aggregate’ summary item. -
Helper method, to remove an item from the set of selected summary items. Should ONLY be used, when the view’s
chartViewproperty isnil.Declaration
Swift
@MainActor public func removeItem(at categoryIndex: Int)Parameters
categoryIndexIndex of category which should be removed from the set
-
Remove all summary items, whose
categoryIndexis> -1. Should ONLY be used, when the view’schartViewproperty isnil.Declaration
Swift
@MainActor public func removeDataCategoryItems() -
Remove all summary items. Should ONLY be used, when the view’s
chartViewproperty isnil.Declaration
Swift
@MainActor public func removeAll()