NOTE :: I am able to engage two different methods to display the calculated [Chart Data].
NOTE :: Both methods properly illustrate the [Chart Data].
NOTE :: As to which method would be best to engage the chart’s [Loli-pop], I do not know at this moment.
The [First Method ::
The application’s [Content View] calls the [MOCK Data] to display the [Chart] with the following code ::
struct SunElevationChartContentView: View {
// Identify the refactored [SWIFT CHARTS MOCK DATA]
@State private var overallData = Value.theSunElevationMockData()
var body: some View {
// Create the [CHART]
VStack {
Chart(overallData) {
// Display the [SOLAR ELEVATION DATA]
LineMark(
x: .value("h:m:s", $0.theRequiredTimeOfDay),
y: .value("Elevation", $0.theCalculatedElevation)
)
// A parameter for the Catmull-Rom spline. Use [0] for a [Uniform Spline].
.interpolationMethod(.catmullRom(alpha: 0))
.foregroundStyle(.yellow)
.lineStyle(StrokeStyle(lineWidth: 10))
.opacity(1.00)
} // End of [Chart(overallData)]
} // End of [VStack]
} // End of [var body: some View]
} // End of [struct SunElevationChartContentView: View]
The SwiftUI Chart displays the [Calculated Solar Elevation Values] for each [Time of Day].
The [Second Method ::
The application’s [Content View] calls the [MOCK Data] to display the [Chart] with the following code ::
struct SunElevationChartContentView: View {
// Identify the refactored [SWIFT CHARTS MOCK DATA]
@State private var overallData = Value.theSunElevationMockData()
var body: some View {
// Create the [CHART]
VStack {
Chart {
ForEach(overallData) { dataPoint in
// Display the [SOLAR ELEVATION DATA]
LineMark(
x: .value("h:m:s", dataPoint.theRequiredTimeOfDay),
y: .value("Elevation", dataPoint.theCalculatedElevation)
)
// A parameter for the Catmull-Rom spline. Use [0] for a [Uniform Spline].
.interpolationMethod(.catmullRom(alpha: 0))
.foregroundStyle(.yellow)
.lineStyle(StrokeStyle(lineWidth: 10))
.opacity(1.00)
} // End of [ForEach(overallData) { dataPoint in]
} // End of [Chart]
} // End of [VStack]
} // End of [var body: some View]
} // End of [struct SunElevationChartContentView: View]
The SwiftUI Chart displays the [Calculated Solar Elevation Values] for each [Time of Day].
As a side note, the above [Content View Code] methods do not show the incremental [Structs] to configure the [Chart] to show the [Labels], the [CGRect Vertical Lines], and the [CGRect Horizontal Lines].
For the moment, complete with my last coding issue, I am still trying to determine how to properly engage a [Chart Loli-pop] to display the individual [Solar Elevation] values. I am sure I shall discover a method to present the chart’s [Calculated Data], by employing the [Chart Loli-pop] in the future, using the [First Chart Content View Method], or the [Second Chart Content View Method]. This solution is still a mystery to me, where I did not completely resolve my question … :]
As always, thank you for your time reviewing my [Chart Data] issue … :]
Best regards,
jim_k
The resultant calculated Chart Images ::
Paris ::
Suva Fiji ::
Queenstown NZ ::
Cairo ::
Melbourne ::
London ::
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: