Community-maintained Agent Skills for complete Swift and Apple-platform app delivery.
73
92%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Medium
Suggest reviewing before use
Extended patterns, accessibility guidance, and theming for Swift Charts on
iOS 26+. Import Charts in every file that uses these APIs.
import SwiftUI
import ChartsUse @Observable for chart data models. Pair with @State in views.
@Observable
class SalesModel {
var monthlySales: [MonthlySale] = []
func load() async {
monthlySales = await SalesService.fetchMonthlySales()
}
}
struct MonthlySale: Identifiable {
let id = UUID()
let month: Date
let revenue: Double
let category: String
}struct SalesDashboard: View {
@State private var model = SalesModel()
var body: some View {
Chart(model.monthlySales) { item in
BarMark(
x: .value("Month", item.month, unit: .month),
y: .value("Revenue", item.revenue)
)
.foregroundStyle(by: .value("Category", item.category))
}
.task { await model.load() }
}
}Chart(data) { item in
BarMark(
x: .value("Department", item.department),
y: .value("Revenue", item.revenue)
)
}When multiple bars share the same x value, they stack automatically:
Chart(data) { item in
BarMark(
x: .value("Quarter", item.quarter),
y: .value("Sales", item.sales)
)
.foregroundStyle(by: .value("Product", item.product))
}Use .position(by:) to place bars side by side instead of stacking:
Chart(data) { item in
BarMark(
x: .value("Quarter", item.quarter),
y: .value("Sales", item.sales)
)
.foregroundStyle(by: .value("Product", item.product))
.position(by: .value("Product", item.product))
}Swap the x and y axes:
Chart(data) { item in
BarMark(
x: .value("Sales", item.sales),
y: .value("Region", item.region)
)
}
.chartYAxis {
AxisMarks { _ in
AxisValueLabel()
}
}Chart(data) { item in
BarMark(
x: .value("Quarter", item.quarter),
y: .value("Sales", item.sales),
stacking: .normalized
)
.foregroundStyle(by: .value("Product", item.product))
}Chart(data) { item in
BarMark(
x: .value("Month", item.month),
y: .value("Revenue", item.revenue)
)
.annotation(position: .top, alignment: .center, spacing: 4) {
Text(item.revenue, format: .currency(code: "USD").precision(.fractionLength(0)))
.font(.caption2)
}
}Chart(tasks) { task in
BarMark(
xStart: .value("Start", task.startDate),
xEnd: .value("End", task.endDate),
y: .value("Task", task.name)
)
.foregroundStyle(by: .value("Status", task.status))
}Chart(data) { item in
LineMark(
x: .value("Date", item.date),
y: .value("Price", item.price)
)
PointMark(
x: .value("Date", item.date),
y: .value("Price", item.price)
)
.symbolSize(30)
}Chart(temperatures) { item in
LineMark(
x: .value("Date", item.date),
y: .value("Temp", item.temperature)
)
.foregroundStyle(by: .value("City", item.city))
.symbol(by: .value("City", item.city))
}Chart(data) { item in
AreaMark(
x: .value("Date", item.date),
y: .value("Value", item.value)
)
.foregroundStyle(
.linearGradient(
colors: [.blue.opacity(0.3), .blue.opacity(0.05)],
startPoint: .top,
endPoint: .bottom
)
)
LineMark(
x: .value("Date", item.date),
y: .value("Value", item.value)
)
.foregroundStyle(.blue)
}| Method | Use Case |
|---|---|
.linear | Default; straight segments between points |
.monotone | Smooth curve that preserves monotonicity |
.catmullRom | Smooth general-purpose curve |
.cardinal | Smooth with adjustable tension |
.stepStart | Step function starting at data point |
.stepCenter | Step function centered on data point |
.stepEnd | Step function ending at data point |
LineMark(x: .value("X", item.x), y: .value("Y", item.y))
.interpolationMethod(.monotone)Chart(recentData) { item in
LineMark(
x: .value("Time", item.time),
y: .value("Value", item.value)
)
.interpolationMethod(.catmullRom)
}
.chartXAxis(.hidden)
.chartYAxis(.hidden)
.chartLegend(.hidden)
.frame(width: 80, height: 30)Use strictly positive values for sectors. Filter, aggregate, or show zero and negative values outside the pie or donut so angular sizes remain meaningful.
Chart(products, id: \.name) { item in
SectorMark(angle: .value("Sales", item.sales))
.foregroundStyle(by: .value("Product", item.name))
}Chart(products, id: \.name) { item in
SectorMark(
angle: .value("Sales", item.sales),
innerRadius: .ratio(0.618),
outerRadius: .inset(10),
angularInset: 1
)
.cornerRadius(4)
.foregroundStyle(by: .value("Product", item.name))
}Chart(products, id: \.name) { item in
SectorMark(
angle: .value("Sales", item.sales),
innerRadius: .ratio(0.618),
angularInset: 1
)
.cornerRadius(4)
.foregroundStyle(by: .value("Product", item.name))
}
.chartBackground { _ in
VStack {
Text("Total")
.font(.caption)
.foregroundStyle(.secondary)
Text("\(totalSales, format: .number)")
.font(.title2.bold())
}
}struct ProductSales: Identifiable {
let id = UUID()
let name: String
let sales: Double
}
@State private var selectedAngle: Double?
var selectedProduct: ProductSales? {
guard let selectedAngle else { return nil }
var runningTotal = 0.0
return products.first { product in
let range = runningTotal..<(runningTotal + product.sales)
runningTotal += product.sales
return range.contains(selectedAngle)
}
}
Chart(products, id: \.name) { item in
SectorMark(
angle: .value("Sales", item.sales),
innerRadius: .ratio(0.618),
angularInset: 1
)
.cornerRadius(4)
.foregroundStyle(by: .value("Product", item.name))
.opacity(selectedProduct == nil || selectedProduct?.name == item.name ? 1.0 : 0.4)
}
.chartAngleSelection(value: $selectedAngle)chartAngleSelection(value:) binds the selected plottable angle value, not the
sector label. Convert that value through cumulative sector ranges before using
it to highlight or annotate a category.
Limit pie/donut charts to 5-7 positive-value sectors. Group the rest into "Other":
func groupSmallSlices(_ data: [CategorySales], topN: Int = 5) -> [CategorySales] {
let sorted = data.sorted { $0.sales > $1.sales }
let top = Array(sorted.prefix(topN))
let otherTotal = sorted.dropFirst(topN).reduce(0) { $0 + $1.sales }
guard otherTotal > 0 else { return top }
return top + [CategorySales(name: "Other", sales: otherTotal)]
}Chart(data) { item in
AreaMark(
x: .value("Date", item.date),
yStart: .value("Min", item.low),
yEnd: .value("Max", item.high)
)
.foregroundStyle(.blue.opacity(0.15))
LineMark(
x: .value("Date", item.date),
y: .value("Average", item.average)
)
.foregroundStyle(.blue)
.lineStyle(StrokeStyle(lineWidth: 2))
}Chart {
ForEach(data) { item in
BarMark(
x: .value("Month", item.month),
y: .value("Revenue", item.revenue)
)
}
RuleMark(y: .value("Target", targetRevenue))
.foregroundStyle(.red)
.lineStyle(StrokeStyle(lineWidth: 1, dash: [5, 3]))
.annotation(position: .top, alignment: .leading) {
Text("Target: \(targetRevenue, format: .number)")
.font(.caption)
.foregroundStyle(.red)
}
}Chart {
ForEach(data) { item in
PointMark(
x: .value("Experience", item.yearsExperience),
y: .value("Salary", item.salary)
)
.opacity(0.6)
}
LinePlot(x: "Experience", y: "Salary", domain: 0...20) { x in
baseSalary + x * salaryPerYear // linear trend
}
.foregroundStyle(.red)
.lineStyle(StrokeStyle(lineWidth: 1.5, dash: [4, 2]))
}.tessl-plugin
skills
accessorysetupkit
references
activitykit
adattributionkit
references
alarmkit
references
app-clips
app-intents
app-store-optimization
app-store-review
apple-on-device-ai
appmigrationkit
audioaccessorykit
references
authentication
references
avkit
background-processing
references
browserenginekit
callkit
references
carplay
cloudkit
contacts-framework
references
core-bluetooth
references
core-data
core-motion
references
core-nfc
references
coreml
references
cryptokit
cryptotokenkit
references
debugging-instruments
device-integrity
references
dockkit
energykit
references
eventkit
financekit
references
focus-engine
gamekit
healthkit
references
homekit
references
ios-accessibility
ios-app-workflow
references
ios-ettrace-performance
ios-localization
ios-memgraph-analysis
ios-networking
ios-simulator
references
metrickit
references
musickit
references
natural-language
references
paperkit
references
passkit
references
pdfkit
pencilkit
references
permissionkit
references
photokit
push-notifications
realitykit
references
relevancekit
references
scenekit
sensorkit
speech-recognition
references
spritekit
storekit
swift-api-design-guidelines
swift-architecture
references
swift-charts
swift-codable
references
swift-code-review
swift-concurrency
swift-formatstyle
references
swift-language
swift-security
references
swift-testing
swiftdata
swiftlint
swiftui-animation
swiftui-gestures
references
swiftui-layout-components
swiftui-liquid-glass
references
swiftui-patterns
swiftui-performance
swiftui-responsive-layout
swiftui-uikit-interop
swiftui-webkit
tabletopkit
tipkit
vision-framework
weatherkit
references