Skip to content

Instantly share code, notes, and snippets.

@DavidPiper94
Created December 29, 2021 20:03
Show Gist options
  • Select an option

  • Save DavidPiper94/6dfc482c2191233a38da758163607ca0 to your computer and use it in GitHub Desktop.

Select an option

Save DavidPiper94/6dfc482c2191233a38da758163607ca0 to your computer and use it in GitHub Desktop.
Example code for article about Audio Graphs - Showing multiple data series
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