Created
December 29, 2021 20:03
-
-
Save DavidPiper94/6dfc482c2191233a38da758163607ca0 to your computer and use it in GitHub Desktop.
Example code for article about Audio Graphs - Showing multiple data series
This file contains hidden or 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
| private var series: [AXDataSeriesDescriptor] { | |
| // 1 | |
| let yValuesSeries1 = [4.0, 5.0, 6.0, 3.0, 2.0, 1.0, 1.0, 3.0, 6.0, 9.0] | |
| let dataPointsSeries1 = yValuesSeries1.enumerated().map { index, yValue in | |
| AXDataPoint(x: Double(index), y: yValue) | |
| } | |
| // 2 | |
| let yValuesSeries2 = [6.0, 5.0, 4.0, 7.0, 8.0, 9.0, 9.0, 7.0, 4.0, 1.0] | |
| let dataPointsSeries2 = yValuesSeries2.enumerated().map { index, yValue in | |
| AXDataPoint(x: Double(index), y: yValue) | |
| } | |
| // 3 | |
| return [ | |
| AXDataSeriesDescriptor( | |
| name: "Data Series 1", | |
| isContinuous: true, | |
| dataPoints: dataPointsSeries1 | |
| ), | |
| AXDataSeriesDescriptor( | |
| name: "Data Series 2", | |
| isContinuous: true, | |
| dataPoints: dataPointsSeries2 | |
| ) | |
| ] | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment