Last active
June 14, 2022 13:26
-
-
Save swiftui-lab/e317fbe4e7bb911c073c845e57cb318b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Author: The SwiftUI-Lab | |
// The charts in this code are used in the article: https://swiftui-lab.com/swiftui-22-in-numbers | |
// | |
import SwiftUI | |
import Charts | |
@main | |
struct ChartGistApp: App { | |
var body: some Scene { | |
WindowGroup { | |
MainView() | |
.navigationTitle("SwiftUI Evolution Charts") | |
} | |
} | |
} | |
enum HistoryPlatform: String { | |
case macOS = "macOS" | |
case iOS = "iOS" | |
case tvOS = "tvOS" | |
case watchOS = "watchOS" | |
case anyOS = "anyOS" | |
} | |
enum HistoryDataType: String, Plottable { | |
case view = "Views" | |
case `protocol` = "Protocols" | |
case scene = "Scenes" | |
case shape = "Shapes" | |
case env = "Environment Values" | |
case style_protocol = "Style Protocols" | |
case style = "Styles" | |
case wrapper = "Property Wrappers" | |
case static_method = "Type Methods" | |
case method = "Methods" | |
case static_property = "Type Properties" | |
case property = "Properties" | |
case initializer = "Initializers" | |
var weight: Int { | |
switch self { | |
case .view: | |
return 1 | |
case .protocol: | |
return 2 | |
case .shape: | |
return 3 | |
case .style_protocol: | |
return 4 | |
case .style: | |
return 5 | |
case .wrapper: | |
return 6 | |
case .scene: | |
return 7 | |
case .env: | |
return 8 | |
case .initializer: | |
return 9 | |
case .static_method: | |
return 10 | |
case .method: | |
return 11 | |
case .static_property: | |
return 12 | |
case .property: | |
return 13 | |
} | |
} | |
} | |
enum HistoryOperation: Equatable { | |
case introduced | |
case deprecated | |
case extended(HistoryPlatform) | |
} | |
struct HistoryDataPoint { | |
let year: Int | |
let dataType: HistoryDataType | |
let operation: HistoryOperation | |
let count: Int | |
} | |
struct DataPoint: Identifiable { | |
let id: String | |
let value: Int | |
let dataType: HistoryDataType | |
} | |
struct DataSeries: Identifiable { | |
let id: String | |
let data: [DataPoint] | |
} | |
let rawData: [HistoryDataPoint] = [ | |
HistoryDataPoint(year: 2019, dataType: .initializer, operation: .introduced, count: 221), | |
HistoryDataPoint(year: 2019, dataType: .protocol, operation: .introduced, count: 24), | |
HistoryDataPoint(year: 2019, dataType: .shape, operation: .introduced, count: 11), | |
HistoryDataPoint(year: 2019, dataType: .env, operation: .introduced, count: 37), | |
HistoryDataPoint(year: 2019, dataType: .static_property, operation: .introduced, count: 61), | |
HistoryDataPoint(year: 2019, dataType: .wrapper, operation: .introduced, count: 8), | |
HistoryDataPoint(year: 2019, dataType: .static_method, operation: .introduced, count: 21), | |
HistoryDataPoint(year: 2019, dataType: .property, operation: .introduced, count: 77), | |
HistoryDataPoint(year: 2019, dataType: .method, operation: .introduced, count: 306), | |
HistoryDataPoint(year: 2019, dataType: .style, operation: .introduced, count: 46), | |
HistoryDataPoint(year: 2019, dataType: .view, operation: .introduced, count: 45), | |
HistoryDataPoint(year: 2019, dataType: .style_protocol, operation: .introduced, count: 13), | |
HistoryDataPoint(year: 2019, dataType: .scene, operation: .introduced, count: 0), | |
HistoryDataPoint(year: 2019, dataType: .initializer, operation: .deprecated, count: 0), | |
HistoryDataPoint(year: 2019, dataType: .protocol, operation: .deprecated, count: 0), | |
HistoryDataPoint(year: 2019, dataType: .shape, operation: .deprecated, count: 0), | |
HistoryDataPoint(year: 2019, dataType: .env, operation: .deprecated, count: 0), | |
HistoryDataPoint(year: 2019, dataType: .static_property, operation: .deprecated, count: 1), | |
HistoryDataPoint(year: 2019, dataType: .wrapper, operation: .deprecated, count: 0), | |
HistoryDataPoint(year: 2019, dataType: .static_method, operation: .deprecated, count: 0), | |
HistoryDataPoint(year: 2019, dataType: .property, operation: .deprecated, count: 0), | |
HistoryDataPoint(year: 2019, dataType: .method, operation: .deprecated, count: 0), | |
HistoryDataPoint(year: 2019, dataType: .style, operation: .deprecated, count: 0), | |
HistoryDataPoint(year: 2019, dataType: .view, operation: .deprecated, count: 0), | |
HistoryDataPoint(year: 2019, dataType: .style_protocol, operation: .deprecated, count: 2), | |
HistoryDataPoint(year: 2019, dataType: .scene, operation: .deprecated, count: 0), | |
HistoryDataPoint(year: 2019, dataType: .initializer, operation: .extended(.anyOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .protocol, operation: .extended(.anyOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .shape, operation: .extended(.anyOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .env, operation: .extended(.anyOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .static_property, operation: .extended(.anyOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .wrapper, operation: .extended(.anyOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .static_method, operation: .extended(.anyOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .property, operation: .extended(.anyOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .method, operation: .extended(.anyOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .style, operation: .extended(.anyOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .view, operation: .extended(.anyOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .style_protocol, operation: .extended(.anyOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .scene, operation: .extended(.anyOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .initializer, operation: .extended(.macOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .protocol, operation: .extended(.macOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .shape, operation: .extended(.macOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .env, operation: .extended(.macOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .static_property, operation: .extended(.macOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .wrapper, operation: .extended(.macOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .static_method, operation: .extended(.macOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .property, operation: .extended(.macOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .method, operation: .extended(.macOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .style, operation: .extended(.macOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .view, operation: .extended(.macOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .style_protocol, operation: .extended(.macOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .scene, operation: .extended(.macOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .initializer, operation: .extended(.iOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .protocol, operation: .extended(.iOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .shape, operation: .extended(.iOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .env, operation: .extended(.iOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .static_property, operation: .extended(.iOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .wrapper, operation: .extended(.iOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .static_method, operation: .extended(.iOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .property, operation: .extended(.iOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .method, operation: .extended(.iOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .style, operation: .extended(.iOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .view, operation: .extended(.iOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .style_protocol, operation: .extended(.iOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .scene, operation: .extended(.iOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .initializer, operation: .extended(.tvOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .protocol, operation: .extended(.tvOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .shape, operation: .extended(.tvOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .env, operation: .extended(.tvOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .static_property, operation: .extended(.tvOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .wrapper, operation: .extended(.tvOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .static_method, operation: .extended(.tvOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .property, operation: .extended(.tvOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .method, operation: .extended(.tvOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .style, operation: .extended(.tvOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .view, operation: .extended(.tvOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .style_protocol, operation: .extended(.tvOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .scene, operation: .extended(.tvOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .initializer, operation: .extended(.watchOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .protocol, operation: .extended(.watchOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .shape, operation: .extended(.watchOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .env, operation: .extended(.watchOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .static_property, operation: .extended(.watchOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .wrapper, operation: .extended(.watchOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .static_method, operation: .extended(.watchOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .property, operation: .extended(.watchOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .method, operation: .extended(.watchOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .style, operation: .extended(.watchOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .view, operation: .extended(.watchOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .style_protocol, operation: .extended(.watchOS), count: 0), | |
HistoryDataPoint(year: 2019, dataType: .scene, operation: .extended(.watchOS), count: 0), | |
HistoryDataPoint(year: 2020, dataType: .initializer, operation: .introduced, count: 114), | |
HistoryDataPoint(year: 2020, dataType: .protocol, operation: .introduced, count: 15), | |
HistoryDataPoint(year: 2020, dataType: .shape, operation: .introduced, count: 1), | |
HistoryDataPoint(year: 2020, dataType: .env, operation: .introduced, count: 9), | |
HistoryDataPoint(year: 2020, dataType: .static_property, operation: .introduced, count: 35), | |
HistoryDataPoint(year: 2020, dataType: .wrapper, operation: .introduced, count: 11), | |
HistoryDataPoint(year: 2020, dataType: .static_method, operation: .introduced, count: 7), | |
HistoryDataPoint(year: 2020, dataType: .property, operation: .introduced, count: 34), | |
HistoryDataPoint(year: 2020, dataType: .method, operation: .introduced, count: 142), | |
HistoryDataPoint(year: 2020, dataType: .style, operation: .introduced, count: 31), | |
HistoryDataPoint(year: 2020, dataType: .view, operation: .introduced, count: 22), | |
HistoryDataPoint(year: 2020, dataType: .style_protocol, operation: .introduced, count: 8), | |
HistoryDataPoint(year: 2020, dataType: .scene, operation: .introduced, count: 5), | |
HistoryDataPoint(year: 2020, dataType: .initializer, operation: .deprecated, count: 5), | |
HistoryDataPoint(year: 2020, dataType: .protocol, operation: .deprecated, count: 3), | |
HistoryDataPoint(year: 2020, dataType: .shape, operation: .deprecated, count: 0), | |
HistoryDataPoint(year: 2020, dataType: .env, operation: .deprecated, count: 0), | |
HistoryDataPoint(year: 2020, dataType: .static_property, operation: .deprecated, count: 0), | |
HistoryDataPoint(year: 2020, dataType: .wrapper, operation: .deprecated, count: 0), | |
HistoryDataPoint(year: 2020, dataType: .static_method, operation: .deprecated, count: 0), | |
HistoryDataPoint(year: 2020, dataType: .property, operation: .deprecated, count: 0), | |
HistoryDataPoint(year: 2020, dataType: .method, operation: .deprecated, count: 45), | |
HistoryDataPoint(year: 2020, dataType: .style, operation: .deprecated, count: 5), | |
HistoryDataPoint(year: 2020, dataType: .view, operation: .deprecated, count: 4), | |
HistoryDataPoint(year: 2020, dataType: .style_protocol, operation: .deprecated, count: 2), | |
HistoryDataPoint(year: 2020, dataType: .scene, operation: .deprecated, count: 0), | |
HistoryDataPoint(year: 2020, dataType: .initializer, operation: .extended(.anyOS), count: 8), | |
HistoryDataPoint(year: 2020, dataType: .protocol, operation: .extended(.anyOS), count: 1), | |
HistoryDataPoint(year: 2020, dataType: .shape, operation: .extended(.anyOS), count: 0), | |
HistoryDataPoint(year: 2020, dataType: .env, operation: .extended(.anyOS), count: 1), | |
HistoryDataPoint(year: 2020, dataType: .static_property, operation: .extended(.anyOS), count: 7), | |
HistoryDataPoint(year: 2020, dataType: .wrapper, operation: .extended(.anyOS), count: 0), | |
HistoryDataPoint(year: 2020, dataType: .static_method, operation: .extended(.anyOS), count: 0), | |
HistoryDataPoint(year: 2020, dataType: .property, operation: .extended(.anyOS), count: 1), | |
HistoryDataPoint(year: 2020, dataType: .method, operation: .extended(.anyOS), count: 5), | |
HistoryDataPoint(year: 2020, dataType: .style, operation: .extended(.anyOS), count: 7), | |
HistoryDataPoint(year: 2020, dataType: .view, operation: .extended(.anyOS), count: 3), | |
HistoryDataPoint(year: 2020, dataType: .style_protocol, operation: .extended(.anyOS), count: 2), | |
HistoryDataPoint(year: 2020, dataType: .scene, operation: .extended(.anyOS), count: 0), | |
HistoryDataPoint(year: 2020, dataType: .initializer, operation: .extended(.macOS), count: 1), | |
HistoryDataPoint(year: 2020, dataType: .protocol, operation: .extended(.macOS), count: 1), | |
HistoryDataPoint(year: 2020, dataType: .shape, operation: .extended(.macOS), count: 0), | |
HistoryDataPoint(year: 2020, dataType: .env, operation: .extended(.macOS), count: 1), | |
HistoryDataPoint(year: 2020, dataType: .static_property, operation: .extended(.macOS), count: 0), | |
HistoryDataPoint(year: 2020, dataType: .wrapper, operation: .extended(.macOS), count: 0), | |
HistoryDataPoint(year: 2020, dataType: .static_method, operation: .extended(.macOS), count: 0), | |
HistoryDataPoint(year: 2020, dataType: .property, operation: .extended(.macOS), count: 1), | |
HistoryDataPoint(year: 2020, dataType: .method, operation: .extended(.macOS), count: 2), | |
HistoryDataPoint(year: 2020, dataType: .style, operation: .extended(.macOS), count: 0), | |
HistoryDataPoint(year: 2020, dataType: .view, operation: .extended(.macOS), count: 0), | |
HistoryDataPoint(year: 2020, dataType: .style_protocol, operation: .extended(.macOS), count: 0), | |
HistoryDataPoint(year: 2020, dataType: .scene, operation: .extended(.macOS), count: 0), | |
HistoryDataPoint(year: 2020, dataType: .initializer, operation: .extended(.iOS), count: 4), | |
HistoryDataPoint(year: 2020, dataType: .protocol, operation: .extended(.iOS), count: 0), | |
HistoryDataPoint(year: 2020, dataType: .shape, operation: .extended(.iOS), count: 0), | |
HistoryDataPoint(year: 2020, dataType: .env, operation: .extended(.iOS), count: 0), | |
HistoryDataPoint(year: 2020, dataType: .static_property, operation: .extended(.iOS), count: 3), | |
HistoryDataPoint(year: 2020, dataType: .wrapper, operation: .extended(.iOS), count: 0), | |
HistoryDataPoint(year: 2020, dataType: .static_method, operation: .extended(.iOS), count: 0), | |
HistoryDataPoint(year: 2020, dataType: .property, operation: .extended(.iOS), count: 0), | |
HistoryDataPoint(year: 2020, dataType: .method, operation: .extended(.iOS), count: 0), | |
HistoryDataPoint(year: 2020, dataType: .style, operation: .extended(.iOS), count: 3), | |
HistoryDataPoint(year: 2020, dataType: .view, operation: .extended(.iOS), count: 1), | |
HistoryDataPoint(year: 2020, dataType: .style_protocol, operation: .extended(.iOS), count: 0), | |
HistoryDataPoint(year: 2020, dataType: .scene, operation: .extended(.iOS), count: 0), | |
HistoryDataPoint(year: 2020, dataType: .initializer, operation: .extended(.tvOS), count: 0), | |
HistoryDataPoint(year: 2020, dataType: .protocol, operation: .extended(.tvOS), count: 0), | |
HistoryDataPoint(year: 2020, dataType: .shape, operation: .extended(.tvOS), count: 0), | |
HistoryDataPoint(year: 2020, dataType: .env, operation: .extended(.tvOS), count: 0), | |
HistoryDataPoint(year: 2020, dataType: .static_property, operation: .extended(.tvOS), count: 0), | |
HistoryDataPoint(year: 2020, dataType: .wrapper, operation: .extended(.tvOS), count: 0), | |
HistoryDataPoint(year: 2020, dataType: .static_method, operation: .extended(.tvOS), count: 0), | |
HistoryDataPoint(year: 2020, dataType: .property, operation: .extended(.tvOS), count: 0), | |
HistoryDataPoint(year: 2020, dataType: .method, operation: .extended(.tvOS), count: 1), | |
HistoryDataPoint(year: 2020, dataType: .style, operation: .extended(.tvOS), count: 0), | |
HistoryDataPoint(year: 2020, dataType: .view, operation: .extended(.tvOS), count: 0), | |
HistoryDataPoint(year: 2020, dataType: .style_protocol, operation: .extended(.tvOS), count: 0), | |
HistoryDataPoint(year: 2020, dataType: .scene, operation: .extended(.tvOS), count: 0), | |
HistoryDataPoint(year: 2020, dataType: .initializer, operation: .extended(.watchOS), count: 3), | |
HistoryDataPoint(year: 2020, dataType: .protocol, operation: .extended(.watchOS), count: 0), | |
HistoryDataPoint(year: 2020, dataType: .shape, operation: .extended(.watchOS), count: 0), | |
HistoryDataPoint(year: 2020, dataType: .env, operation: .extended(.watchOS), count: 0), | |
HistoryDataPoint(year: 2020, dataType: .static_property, operation: .extended(.watchOS), count: 4), | |
HistoryDataPoint(year: 2020, dataType: .wrapper, operation: .extended(.watchOS), count: 0), | |
HistoryDataPoint(year: 2020, dataType: .static_method, operation: .extended(.watchOS), count: 0), | |
HistoryDataPoint(year: 2020, dataType: .property, operation: .extended(.watchOS), count: 0), | |
HistoryDataPoint(year: 2020, dataType: .method, operation: .extended(.watchOS), count: 2), | |
HistoryDataPoint(year: 2020, dataType: .style, operation: .extended(.watchOS), count: 4), | |
HistoryDataPoint(year: 2020, dataType: .view, operation: .extended(.watchOS), count: 2), | |
HistoryDataPoint(year: 2020, dataType: .style_protocol, operation: .extended(.watchOS), count: 2), | |
HistoryDataPoint(year: 2020, dataType: .scene, operation: .extended(.watchOS), count: 0), | |
HistoryDataPoint(year: 2021, dataType: .initializer, operation: .introduced, count: 86), | |
HistoryDataPoint(year: 2021, dataType: .protocol, operation: .introduced, count: 7), | |
HistoryDataPoint(year: 2021, dataType: .shape, operation: .introduced, count: 0), | |
HistoryDataPoint(year: 2021, dataType: .env, operation: .introduced, count: 16), | |
HistoryDataPoint(year: 2021, dataType: .static_property, operation: .introduced, count: 43), | |
HistoryDataPoint(year: 2021, dataType: .wrapper, operation: .introduced, count: 3), | |
HistoryDataPoint(year: 2021, dataType: .static_method, operation: .introduced, count: 10), | |
HistoryDataPoint(year: 2021, dataType: .property, operation: .introduced, count: 34), | |
HistoryDataPoint(year: 2021, dataType: .method, operation: .introduced, count: 173), | |
HistoryDataPoint(year: 2021, dataType: .style, operation: .introduced, count: 14), | |
HistoryDataPoint(year: 2021, dataType: .view, operation: .introduced, count: 8), | |
HistoryDataPoint(year: 2021, dataType: .style_protocol, operation: .introduced, count: 2), | |
HistoryDataPoint(year: 2021, dataType: .scene, operation: .introduced, count: 0), | |
HistoryDataPoint(year: 2021, dataType: .initializer, operation: .deprecated, count: 38), | |
HistoryDataPoint(year: 2021, dataType: .protocol, operation: .deprecated, count: 0), | |
HistoryDataPoint(year: 2021, dataType: .shape, operation: .deprecated, count: 0), | |
HistoryDataPoint(year: 2021, dataType: .env, operation: .deprecated, count: 2), | |
HistoryDataPoint(year: 2021, dataType: .static_property, operation: .deprecated, count: 0), | |
HistoryDataPoint(year: 2021, dataType: .wrapper, operation: .deprecated, count: 0), | |
HistoryDataPoint(year: 2021, dataType: .static_method, operation: .deprecated, count: 0), | |
HistoryDataPoint(year: 2021, dataType: .property, operation: .deprecated, count: 2), | |
HistoryDataPoint(year: 2021, dataType: .method, operation: .deprecated, count: 11), | |
HistoryDataPoint(year: 2021, dataType: .style, operation: .deprecated, count: 1), | |
HistoryDataPoint(year: 2021, dataType: .view, operation: .deprecated, count: 9), | |
HistoryDataPoint(year: 2021, dataType: .style_protocol, operation: .deprecated, count: 0), | |
HistoryDataPoint(year: 2021, dataType: .scene, operation: .deprecated, count: 0), | |
HistoryDataPoint(year: 2021, dataType: .initializer, operation: .extended(.anyOS), count: 0), | |
HistoryDataPoint(year: 2021, dataType: .protocol, operation: .extended(.anyOS), count: 0), | |
HistoryDataPoint(year: 2021, dataType: .shape, operation: .extended(.anyOS), count: 0), | |
HistoryDataPoint(year: 2021, dataType: .env, operation: .extended(.anyOS), count: 4), | |
HistoryDataPoint(year: 2021, dataType: .static_property, operation: .extended(.anyOS), count: 3), | |
HistoryDataPoint(year: 2021, dataType: .wrapper, operation: .extended(.anyOS), count: 0), | |
HistoryDataPoint(year: 2021, dataType: .static_method, operation: .extended(.anyOS), count: 1), | |
HistoryDataPoint(year: 2021, dataType: .property, operation: .extended(.anyOS), count: 4), | |
HistoryDataPoint(year: 2021, dataType: .method, operation: .extended(.anyOS), count: 7), | |
HistoryDataPoint(year: 2021, dataType: .style, operation: .extended(.anyOS), count: 4), | |
HistoryDataPoint(year: 2021, dataType: .view, operation: .extended(.anyOS), count: 0), | |
HistoryDataPoint(year: 2021, dataType: .style_protocol, operation: .extended(.anyOS), count: 1), | |
HistoryDataPoint(year: 2021, dataType: .scene, operation: .extended(.anyOS), count: 0), | |
HistoryDataPoint(year: 2021, dataType: .initializer, operation: .extended(.macOS), count: 0), | |
HistoryDataPoint(year: 2021, dataType: .protocol, operation: .extended(.macOS), count: 0), | |
HistoryDataPoint(year: 2021, dataType: .shape, operation: .extended(.macOS), count: 0), | |
HistoryDataPoint(year: 2021, dataType: .env, operation: .extended(.macOS), count: 1), | |
HistoryDataPoint(year: 2021, dataType: .static_property, operation: .extended(.macOS), count: 0), | |
HistoryDataPoint(year: 2021, dataType: .wrapper, operation: .extended(.macOS), count: 0), | |
HistoryDataPoint(year: 2021, dataType: .static_method, operation: .extended(.macOS), count: 0), | |
HistoryDataPoint(year: 2021, dataType: .property, operation: .extended(.macOS), count: 1), | |
HistoryDataPoint(year: 2021, dataType: .method, operation: .extended(.macOS), count: 2), | |
HistoryDataPoint(year: 2021, dataType: .style, operation: .extended(.macOS), count: 0), | |
HistoryDataPoint(year: 2021, dataType: .view, operation: .extended(.macOS), count: 0), | |
HistoryDataPoint(year: 2021, dataType: .style_protocol, operation: .extended(.macOS), count: 0), | |
HistoryDataPoint(year: 2021, dataType: .scene, operation: .extended(.macOS), count: 0), | |
HistoryDataPoint(year: 2021, dataType: .initializer, operation: .extended(.iOS), count: 0), | |
HistoryDataPoint(year: 2021, dataType: .protocol, operation: .extended(.iOS), count: 0), | |
HistoryDataPoint(year: 2021, dataType: .shape, operation: .extended(.iOS), count: 0), | |
HistoryDataPoint(year: 2021, dataType: .env, operation: .extended(.iOS), count: 1), | |
HistoryDataPoint(year: 2021, dataType: .static_property, operation: .extended(.iOS), count: 1), | |
HistoryDataPoint(year: 2021, dataType: .wrapper, operation: .extended(.iOS), count: 0), | |
HistoryDataPoint(year: 2021, dataType: .static_method, operation: .extended(.iOS), count: 0), | |
HistoryDataPoint(year: 2021, dataType: .property, operation: .extended(.iOS), count: 1), | |
HistoryDataPoint(year: 2021, dataType: .method, operation: .extended(.iOS), count: 1), | |
HistoryDataPoint(year: 2021, dataType: .style, operation: .extended(.iOS), count: 2), | |
HistoryDataPoint(year: 2021, dataType: .view, operation: .extended(.iOS), count: 0), | |
HistoryDataPoint(year: 2021, dataType: .style_protocol, operation: .extended(.iOS), count: 0), | |
HistoryDataPoint(year: 2021, dataType: .scene, operation: .extended(.iOS), count: 0), | |
HistoryDataPoint(year: 2021, dataType: .initializer, operation: .extended(.tvOS), count: 0), | |
HistoryDataPoint(year: 2021, dataType: .protocol, operation: .extended(.tvOS), count: 0), | |
HistoryDataPoint(year: 2021, dataType: .shape, operation: .extended(.tvOS), count: 0), | |
HistoryDataPoint(year: 2021, dataType: .env, operation: .extended(.tvOS), count: 0), | |
HistoryDataPoint(year: 2021, dataType: .static_property, operation: .extended(.tvOS), count: 0), | |
HistoryDataPoint(year: 2021, dataType: .wrapper, operation: .extended(.tvOS), count: 0), | |
HistoryDataPoint(year: 2021, dataType: .static_method, operation: .extended(.tvOS), count: 0), | |
HistoryDataPoint(year: 2021, dataType: .property, operation: .extended(.tvOS), count: 0), | |
HistoryDataPoint(year: 2021, dataType: .method, operation: .extended(.tvOS), count: 0), | |
HistoryDataPoint(year: 2021, dataType: .style, operation: .extended(.tvOS), count: 0), | |
HistoryDataPoint(year: 2021, dataType: .view, operation: .extended(.tvOS), count: 0), | |
HistoryDataPoint(year: 2021, dataType: .style_protocol, operation: .extended(.tvOS), count: 0), | |
HistoryDataPoint(year: 2021, dataType: .scene, operation: .extended(.tvOS), count: 0), | |
HistoryDataPoint(year: 2021, dataType: .initializer, operation: .extended(.watchOS), count: 0), | |
HistoryDataPoint(year: 2021, dataType: .protocol, operation: .extended(.watchOS), count: 0), | |
HistoryDataPoint(year: 2021, dataType: .shape, operation: .extended(.watchOS), count: 0), | |
HistoryDataPoint(year: 2021, dataType: .env, operation: .extended(.watchOS), count: 2), | |
HistoryDataPoint(year: 2021, dataType: .static_property, operation: .extended(.watchOS), count: 2), | |
HistoryDataPoint(year: 2021, dataType: .wrapper, operation: .extended(.watchOS), count: 0), | |
HistoryDataPoint(year: 2021, dataType: .static_method, operation: .extended(.watchOS), count: 1), | |
HistoryDataPoint(year: 2021, dataType: .property, operation: .extended(.watchOS), count: 2), | |
HistoryDataPoint(year: 2021, dataType: .method, operation: .extended(.watchOS), count: 4), | |
HistoryDataPoint(year: 2021, dataType: .style, operation: .extended(.watchOS), count: 2), | |
HistoryDataPoint(year: 2021, dataType: .view, operation: .extended(.watchOS), count: 0), | |
HistoryDataPoint(year: 2021, dataType: .style_protocol, operation: .extended(.watchOS), count: 1), | |
HistoryDataPoint(year: 2021, dataType: .scene, operation: .extended(.watchOS), count: 0), | |
HistoryDataPoint(year: 2022, dataType: .initializer, operation: .introduced, count: 193), | |
HistoryDataPoint(year: 2022, dataType: .protocol, operation: .introduced, count: 5), | |
HistoryDataPoint(year: 2022, dataType: .shape, operation: .introduced, count: 1), | |
HistoryDataPoint(year: 2022, dataType: .env, operation: .introduced, count: 20), | |
HistoryDataPoint(year: 2022, dataType: .static_property, operation: .introduced, count: 21), | |
HistoryDataPoint(year: 2022, dataType: .wrapper, operation: .introduced, count: 0), | |
HistoryDataPoint(year: 2022, dataType: .static_method, operation: .introduced, count: 6), | |
HistoryDataPoint(year: 2022, dataType: .property, operation: .introduced, count: 25), | |
HistoryDataPoint(year: 2022, dataType: .method, operation: .introduced, count: 156), | |
HistoryDataPoint(year: 2022, dataType: .style, operation: .introduced, count: 19), | |
HistoryDataPoint(year: 2022, dataType: .view, operation: .introduced, count: 20), | |
HistoryDataPoint(year: 2022, dataType: .style_protocol, operation: .introduced, count: 5), | |
HistoryDataPoint(year: 2022, dataType: .scene, operation: .introduced, count: 2), | |
HistoryDataPoint(year: 2022, dataType: .initializer, operation: .deprecated, count: 15), | |
HistoryDataPoint(year: 2022, dataType: .protocol, operation: .deprecated, count: 0), | |
HistoryDataPoint(year: 2022, dataType: .shape, operation: .deprecated, count: 0), | |
HistoryDataPoint(year: 2022, dataType: .env, operation: .deprecated, count: 1), | |
HistoryDataPoint(year: 2022, dataType: .static_property, operation: .deprecated, count: 4), | |
HistoryDataPoint(year: 2022, dataType: .wrapper, operation: .deprecated, count: 0), | |
HistoryDataPoint(year: 2022, dataType: .static_method, operation: .deprecated, count: 0), | |
HistoryDataPoint(year: 2022, dataType: .property, operation: .deprecated, count: 1), | |
HistoryDataPoint(year: 2022, dataType: .method, operation: .deprecated, count: 6), | |
HistoryDataPoint(year: 2022, dataType: .style, operation: .deprecated, count: 5), | |
HistoryDataPoint(year: 2022, dataType: .view, operation: .deprecated, count: 2), | |
HistoryDataPoint(year: 2022, dataType: .style_protocol, operation: .deprecated, count: 1), | |
HistoryDataPoint(year: 2022, dataType: .scene, operation: .deprecated, count: 0), | |
HistoryDataPoint(year: 2022, dataType: .initializer, operation: .extended(.anyOS), count: 38), | |
HistoryDataPoint(year: 2022, dataType: .protocol, operation: .extended(.anyOS), count: 9), | |
HistoryDataPoint(year: 2022, dataType: .shape, operation: .extended(.anyOS), count: 0), | |
HistoryDataPoint(year: 2022, dataType: .env, operation: .extended(.anyOS), count: 2), | |
HistoryDataPoint(year: 2022, dataType: .static_property, operation: .extended(.anyOS), count: 4), | |
HistoryDataPoint(year: 2022, dataType: .wrapper, operation: .extended(.anyOS), count: 0), | |
HistoryDataPoint(year: 2022, dataType: .static_method, operation: .extended(.anyOS), count: 2), | |
HistoryDataPoint(year: 2022, dataType: .property, operation: .extended(.anyOS), count: 8), | |
HistoryDataPoint(year: 2022, dataType: .method, operation: .extended(.anyOS), count: 30), | |
HistoryDataPoint(year: 2022, dataType: .style, operation: .extended(.anyOS), count: 4), | |
HistoryDataPoint(year: 2022, dataType: .view, operation: .extended(.anyOS), count: 4), | |
HistoryDataPoint(year: 2022, dataType: .style_protocol, operation: .extended(.anyOS), count: 2), | |
HistoryDataPoint(year: 2022, dataType: .scene, operation: .extended(.anyOS), count: 0), | |
HistoryDataPoint(year: 2022, dataType: .initializer, operation: .extended(.macOS), count: 5), | |
HistoryDataPoint(year: 2022, dataType: .protocol, operation: .extended(.macOS), count: 0), | |
HistoryDataPoint(year: 2022, dataType: .shape, operation: .extended(.macOS), count: 0), | |
HistoryDataPoint(year: 2022, dataType: .env, operation: .extended(.macOS), count: 0), | |
HistoryDataPoint(year: 2022, dataType: .static_property, operation: .extended(.macOS), count: 1), | |
HistoryDataPoint(year: 2022, dataType: .wrapper, operation: .extended(.macOS), count: 0), | |
HistoryDataPoint(year: 2022, dataType: .static_method, operation: .extended(.macOS), count: 0), | |
HistoryDataPoint(year: 2022, dataType: .property, operation: .extended(.macOS), count: 0), | |
HistoryDataPoint(year: 2022, dataType: .method, operation: .extended(.macOS), count: 7), | |
HistoryDataPoint(year: 2022, dataType: .style, operation: .extended(.macOS), count: 1), | |
HistoryDataPoint(year: 2022, dataType: .view, operation: .extended(.macOS), count: 1), | |
HistoryDataPoint(year: 2022, dataType: .style_protocol, operation: .extended(.macOS), count: 1), | |
HistoryDataPoint(year: 2022, dataType: .scene, operation: .extended(.macOS), count: 0), | |
HistoryDataPoint(year: 2022, dataType: .initializer, operation: .extended(.iOS), count: 24), | |
HistoryDataPoint(year: 2022, dataType: .protocol, operation: .extended(.iOS), count: 3), | |
HistoryDataPoint(year: 2022, dataType: .shape, operation: .extended(.iOS), count: 0), | |
HistoryDataPoint(year: 2022, dataType: .env, operation: .extended(.iOS), count: 0), | |
HistoryDataPoint(year: 2022, dataType: .static_property, operation: .extended(.iOS), count: 3), | |
HistoryDataPoint(year: 2022, dataType: .wrapper, operation: .extended(.iOS), count: 0), | |
HistoryDataPoint(year: 2022, dataType: .static_method, operation: .extended(.iOS), count: 0), | |
HistoryDataPoint(year: 2022, dataType: .property, operation: .extended(.iOS), count: 2), | |
HistoryDataPoint(year: 2022, dataType: .method, operation: .extended(.iOS), count: 6), | |
HistoryDataPoint(year: 2022, dataType: .style, operation: .extended(.iOS), count: 3), | |
HistoryDataPoint(year: 2022, dataType: .view, operation: .extended(.iOS), count: 3), | |
HistoryDataPoint(year: 2022, dataType: .style_protocol, operation: .extended(.iOS), count: 2), | |
HistoryDataPoint(year: 2022, dataType: .scene, operation: .extended(.iOS), count: 0), | |
HistoryDataPoint(year: 2022, dataType: .initializer, operation: .extended(.tvOS), count: 0), | |
HistoryDataPoint(year: 2022, dataType: .protocol, operation: .extended(.tvOS), count: 0), | |
HistoryDataPoint(year: 2022, dataType: .shape, operation: .extended(.tvOS), count: 0), | |
HistoryDataPoint(year: 2022, dataType: .env, operation: .extended(.tvOS), count: 0), | |
HistoryDataPoint(year: 2022, dataType: .static_property, operation: .extended(.tvOS), count: 0), | |
HistoryDataPoint(year: 2022, dataType: .wrapper, operation: .extended(.tvOS), count: 0), | |
HistoryDataPoint(year: 2022, dataType: .static_method, operation: .extended(.tvOS), count: 0), | |
HistoryDataPoint(year: 2022, dataType: .property, operation: .extended(.tvOS), count: 0), | |
HistoryDataPoint(year: 2022, dataType: .method, operation: .extended(.tvOS), count: 2), | |
HistoryDataPoint(year: 2022, dataType: .style, operation: .extended(.tvOS), count: 0), | |
HistoryDataPoint(year: 2022, dataType: .view, operation: .extended(.tvOS), count: 0), | |
HistoryDataPoint(year: 2022, dataType: .style_protocol, operation: .extended(.tvOS), count: 0), | |
HistoryDataPoint(year: 2022, dataType: .scene, operation: .extended(.tvOS), count: 0), | |
HistoryDataPoint(year: 2022, dataType: .initializer, operation: .extended(.watchOS), count: 14), | |
HistoryDataPoint(year: 2022, dataType: .protocol, operation: .extended(.watchOS), count: 6), | |
HistoryDataPoint(year: 2022, dataType: .shape, operation: .extended(.watchOS), count: 0), | |
HistoryDataPoint(year: 2022, dataType: .env, operation: .extended(.watchOS), count: 2), | |
HistoryDataPoint(year: 2022, dataType: .static_property, operation: .extended(.watchOS), count: 1), | |
HistoryDataPoint(year: 2022, dataType: .wrapper, operation: .extended(.watchOS), count: 0), | |
HistoryDataPoint(year: 2022, dataType: .static_method, operation: .extended(.watchOS), count: 2), | |
HistoryDataPoint(year: 2022, dataType: .property, operation: .extended(.watchOS), count: 6), | |
HistoryDataPoint(year: 2022, dataType: .method, operation: .extended(.watchOS), count: 17), | |
HistoryDataPoint(year: 2022, dataType: .style, operation: .extended(.watchOS), count: 1), | |
HistoryDataPoint(year: 2022, dataType: .view, operation: .extended(.watchOS), count: 1), | |
HistoryDataPoint(year: 2022, dataType: .style_protocol, operation: .extended(.watchOS), count: 0), | |
HistoryDataPoint(year: 2022, dataType: .scene, operation: .extended(.watchOS), count: 0), | |
] | |
struct MainView: View { | |
let chart1: [HistoryDataType] = [.view, .protocol, .shape, .style_protocol, .style, .env, .scene] | |
let chart2: [HistoryDataType] = [.initializer, .static_method, .method, .static_property, .property] | |
let smallChartsHeight: CGFloat = 180 | |
var body: some View { | |
ScrollView { | |
VStack { | |
Text("WWDC 2022 SwiftUI Components").font(.largeTitle) | |
NewStuffChart(domain: 0...30, height: 350, strideBy: 10, series: seriesForNewStuff(include: chart1)) | |
} | |
.padding(20) | |
Divider() | |
VStack { | |
Text("WWDC 2022: Initializers, Methods and Properties").font(.largeTitle) | |
NewStuffChart(domain: 0...300, height: 150, strideBy: 50, series: seriesForNewStuff(include: chart2, mergeStatic: true)) | |
} | |
.padding(20) | |
Divider() | |
VStack { | |
Text("Over the Years (additions)").font(.title) | |
HStack { | |
DataPerYearChart(title: "Protocols", height: smallChartsHeight, data: yearlyAdditions(dataType: [.protocol]), color: .green) | |
DataPerYearChart(title: "Views", height: smallChartsHeight, data: yearlyAdditions(dataType: [.view]), color: .green) | |
DataPerYearChart(title: "Shapes", height: smallChartsHeight, data: yearlyAdditions(dataType: [.shape]), color: .green) | |
DataPerYearChart(title: "Style Protocols", height: smallChartsHeight, data: yearlyAdditions(dataType: [.style_protocol]), color: .green) | |
} | |
HStack { | |
DataPerYearChart(title: "Styles", height: smallChartsHeight, data: yearlyAdditions(dataType: [.style]), color: .green) | |
DataPerYearChart(title: "Property Wrappers", height: smallChartsHeight, data: yearlyAdditions(dataType: [.wrapper]), color: .green) | |
DataPerYearChart(title: "Scenes", height: smallChartsHeight, data: yearlyAdditions(dataType: [.scene]), color: .green) | |
DataPerYearChart(title: "Environment Values", height: smallChartsHeight, data: yearlyAdditions(dataType: [.env]), color: .green) | |
} | |
} | |
VStack { | |
HStack { | |
DataPerYearChart(title: "Initializers", height: smallChartsHeight, data: yearlyAdditions(dataType: [.initializer]), color: .purple) | |
DataPerYearChart(title: "Methods", height: smallChartsHeight, data: yearlyAdditions(dataType: [.method, .static_method]), color: .purple) | |
DataPerYearChart(title: "Properties", height: smallChartsHeight, data: yearlyAdditions(dataType: [.property, .static_property]), color: .purple) | |
} | |
} | |
Divider() | |
VStack { | |
Text("Over the Years (totals)").font(.title) | |
HStack { | |
DataPerYearChart(title: "Protocols", height: smallChartsHeight, data: yearlyTotals(dataType: [.protocol]), color: .pink) | |
DataPerYearChart(title: "Views", height: smallChartsHeight, data: yearlyTotals(dataType: [.view]), color: .pink) | |
DataPerYearChart(title: "Shapes", height: smallChartsHeight, data: yearlyTotals(dataType: [.shape]), color: .pink) | |
DataPerYearChart(title: "Style Protocols", height: smallChartsHeight, data: yearlyTotals(dataType: [.style_protocol]), color: .pink) | |
} | |
HStack { | |
DataPerYearChart(title: "Styles", height: smallChartsHeight, data: yearlyTotals(dataType: [.style]), color: .pink) | |
DataPerYearChart(title: "Property Wrappers", height: smallChartsHeight, data: yearlyTotals(dataType: [.wrapper]), color: .pink) | |
DataPerYearChart(title: "Scenes", height: smallChartsHeight, data: yearlyTotals(dataType: [.scene]), color: .pink) | |
DataPerYearChart(title: "Environment Values", height: smallChartsHeight, data: yearlyTotals(dataType: [.env]), color: .pink) | |
} | |
} | |
VStack { | |
HStack { | |
DataPerYearChart(title: "Initializers", height: smallChartsHeight, data: yearlyTotals(dataType: [.initializer]), color: .mint) | |
DataPerYearChart(title: "Methods", height: smallChartsHeight, data: yearlyTotals(dataType: [.method, .static_method]), color: .mint) | |
DataPerYearChart(title: "Properties", height: smallChartsHeight, data: yearlyTotals(dataType: [.property, .static_property]), color: .mint) | |
} | |
} | |
} | |
.preferredColorScheme(.light) | |
} | |
} | |
struct NewStuffChart: View { | |
let domain: ClosedRange<Int> | |
let height: CGFloat | |
let strideBy: CGFloat | |
let series: [DataSeries] | |
var body: some View { | |
Chart { | |
ForEach(series) { s in | |
chart(series: series, s: s) | |
} | |
} | |
.chartYAxis(.hidden) | |
.chartXScale(domain: domain) | |
.chartXAxis { | |
AxisMarks(values: .stride(by: strideBy)) | |
} | |
.chartForegroundStyleScale(["New": .green, "Deprecated": .orange, "Extended": .yellow]) | |
.chartPlotStyle { proxy in | |
proxy.frame(height: height) | |
} | |
} | |
func chart(series: [DataSeries], s: DataSeries) -> some ChartContent { | |
ForEach(s.data) { dataValue in | |
BarMark(x: .value("Desc", dataValue.value), | |
y: .value("Value", dataValue.id), width: 25) | |
.foregroundStyle(by: .value("Desc", s.id)) | |
.annotation(position: .trailing, alignment: .leading, spacing: 10) { | |
if series.last?.id == s.id { | |
Text("\(dataValue.id)") | |
} else { | |
Text("") | |
} | |
} | |
} | |
} | |
} | |
struct DataPerYearChart: View { | |
let title: String | |
let height: CGFloat | |
let data: [DataPoint] | |
let color: Color | |
var body: some View { | |
VStack { | |
Text(title).font(.headline) | |
Chart { | |
ForEach(data) { dt in | |
BarMark(x: .value("Year", dt.id), y: .value("Count", dt.value)) | |
.foregroundStyle(color) | |
} | |
} | |
} | |
.chartPlotStyle { proxy in | |
proxy.frame(height: height) | |
} | |
.padding(.horizontal, 20) | |
.padding(.vertical, 10) | |
} | |
} | |
func seriesForNewStuff(include: [HistoryDataType], mergeStatic: Bool = true) -> [DataSeries] { | |
let introduced = rawData.filter { $0.operation == .introduced && $0.year == 2022 && include.contains($0.dataType) }.map { | |
DataPoint(id: $0.dataType.rawValue, value: $0.count, dataType: $0.dataType) | |
}.mergeStatic(merge: mergeStatic, groupById: false).sorted { $0.dataType.weight < $1.dataType.weight } | |
let deprecated = rawData.filter { $0.operation == .deprecated && $0.year == 2022 && include.contains($0.dataType)}.map { | |
DataPoint(id: $0.dataType.rawValue, value: $0.count, dataType: $0.dataType) | |
}.mergeStatic(merge: mergeStatic, groupById: false).sorted { $0.dataType.weight < $1.dataType.weight } | |
let extended = rawData.filter { $0.operation == .extended(.anyOS) && $0.year == 2022 && include.contains($0.dataType)}.map { | |
DataPoint(id: $0.dataType.rawValue, value: $0.count, dataType: $0.dataType) | |
}.mergeStatic(merge: mergeStatic, groupById: false).sorted { $0.dataType.weight < $1.dataType.weight } | |
let series = [ | |
DataSeries(id: "New", data: introduced), | |
DataSeries(id: "Deprecated", data: deprecated), | |
DataSeries(id: "Extended", data: extended) | |
] | |
return series | |
} | |
func yearlyAdditions(dataType: Set<HistoryDataType>) -> [DataPoint] { | |
return rawData.filter { dataType.contains($0.dataType) && $0.operation == .introduced }.map { | |
DataPoint(id: "\($0.year)", value: $0.count, dataType: $0.dataType) | |
}.mergeStatic(merge: false).sorted { $0.id < $1.id } | |
} | |
func yearlyTotals(dataType: Set<HistoryDataType>) -> [DataPoint] { | |
let values = yearlyAdditions(dataType: dataType).mergeStatic(merge: true, groupById: true) | |
let totals = values.enumerated().map { (idx, v) in | |
print("\(v.id) - \(v.value) - \(v.dataType)") | |
return DataPoint(id: v.id, value: values[0...idx].reduce(0) { $0 + $1.value }, dataType: v.dataType) | |
} | |
totals.forEach { | |
print("_to: \($0.id) -> \($0.value) -> \($0.dataType)") | |
} | |
return totals | |
} | |
extension Array where Element == DataPoint { | |
func mergeStatic(merge: Bool = true, groupById: Bool = true) -> [DataPoint] { | |
guard merge else { return self } | |
return self.map { dpoint in | |
if dpoint.dataType == .method { | |
if let st = self.first { $0.dataType == .static_method && (!groupById || $0.id == dpoint.id) } { | |
return DataPoint(id: dpoint.id, value: (dpoint.value + st.value), dataType: dpoint.dataType) | |
} | |
} | |
else if dpoint.dataType == .property { | |
if let st = self.first { $0.dataType == .static_property && (!groupById || $0.id == dpoint.id)} { | |
return DataPoint(id: dpoint.id, value: (dpoint.value + st.value), dataType: dpoint.dataType) | |
} | |
} | |
return dpoint | |
} | |
.filter { $0.dataType != .static_method && $0.dataType != .static_property } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment