Chart structure
Help your agent structure charts and surrounding views to avoid updates that do not affect the chart.
SwiftFairy Scroll
Improve rendering and interaction performance by structuring charts and surrounding views to limit unnecessary updates and use Swift Charts APIs effectively.
Help your agent structure charts and surrounding views to avoid updates that do not affect the chart.
Identify API choices that introduce unnecessary rendering work and give your agent guidance to address them.
Find interaction state changes that trigger unnecessary chart updates, helping your agent keep interactions responsive.
These examples show the patterns SwiftFairy flags and the guidance your agent can use to address them. Highlighted lines mark the code to review; each finding indicates whether the guidance is a requirement, recommendation, or consideration.
Consider
When a measurement is missing, substituting zero changes what the chart communicates. The appropriate representation depends on whether the chart draws independent marks or connects neighboring observations.
BarMark(
x: .value("Date", reading.date),
y: .value(
"Temperature",
reading.temperature ?? 0
)
)
AreaMark(
x: .value("Date", reading.date),
y: .value(
"Temperature",
reading.temperature ?? 0
)
)
if let temperature = reading.temperature {
BarMark(
x: .value("Date", reading.date),
y: .value(
"Temperature",
temperature
)
)
}
AreaMark(
x: .value("Date", reading.date),
y: .value(
"Temperature",
reading.temperature ?? Double.nan
)
)
For independent bars, omit the mark when its measurement is missing. For an area chart, retain the observation and use Double.nan for the missing value to break the area across the gap. Removing the observation would connect its neighbors.
Consider
When observations represent the same variable, their semantic label should remain consistent. Each observation's value belongs in the second argument to .value, rather than being interpolated into its label.
BarMark(
x: .value("Date", reading.date),
y: .value("Temperature", reading.temperature)
)
.foregroundStyle(by:
.value(
"Status \(reading.status)",
reading.status
)
)
.foregroundStyle(
by: .value("Status", reading.status)
)
Use a consistent dimension label and pass the observation's status as the value. Whether a dynamic label is appropriate depends on the intended semantics.
Ask your agent to review a code change or a complete codebase with SwiftFairy. Your agent uses the findings and their accompanying code examples to resolve issues in your code.
How to use SwiftFairyActivate your trial in the SwiftFairy app. No card or payment information is required.
Choose lifetime access, a fixed term, or a subscription for this Scroll, or get all three together in a bundle.
Correct subtle bugs and performance issues in data flow, state ownership, and view updates by using SwiftUI as it was designed to be used.
Refine code for clarity, maintainability, and performance through idiomatic use of modern Swift APIs, including modern Swift concurrency and collection processing.