Swift Charts Agent Skills

Agent Skills for Swift Charts techniques that are easy to get almost right.
The first skill builds the TradingView-style scrub —
everything left of the finger at full strength, the rest dimmed —
and the effects made the same way:
a highlighted range, actual versus forecast on one line, a reveal up to a date.
The second skill builds a hexagonal heatmap —
many points counted into hexagonal cells, each cell colored by its count —
whose cells tile at any size.
The skills work in any AI coding tool that supports the
Agent Skills open format.
The masking technique comes from Anton Gubarenko's article
SwiftUI Charts: Dynamic Masking:
never change the data to show part of it;
plot complete copies and change only what a mask reveals and how opaque each copy is.
The heatmap technique comes from Matthaus Woolard's article
Visualising data with a hexagonal heatmap in Swift Charts:
count the points into axial hexagonal cells
and draw one hexagon symbol at each occupied cell.
This repository turns each technique into a repeatable workflow —
scan the project, check what the SDK and the deployment target allow,
propose a plan where every item cites a source, change code only after approval —
and measures the parts the article leaves to the reader.
Website: https://blog.kakoulin.com/apps/swift-charts-agent-skills
What the measurements changed
Dynamic masking
A probe in this repository renders the technique and compares pixels
(measured-behavior.md).
Four of its results change the code you would otherwise write:
- A mask from the first data point cuts the first point in half
(68 px of its symbol and line cap, in the probe),
and one that falls back to the last point cuts the last.
Masking from the edges of a padded domain leaves the chart pixel-identical.
- Mask marks and selection rules count toward an automatic x domain.
A rule that follows a raw selection past the data rescales the whole chart mid-drag.
- Nothing clamps a selection.
At the plot's padded edge it was already 6.3 hours outside the data;
30 pt outside the plot, 18 hours.
Snapping to the nearest point clamps for free.
- Gradient stops spaced by index land on the wrong points when the data is unevenly spaced.
The article's own fix — a distinct series: for each copy of the line —
is confirmed: without it, Swift Charts joins the end of one copy to the start of the other,
and a different constant color does not prevent it.
It is not only about copies:
two plots holding the solid and the dashed half of a line, without series,
drew as one solid line — the dash lost.
Hexagonal heatmap
A second probe renders hexagon grids and measures the gaps and overlaps between cells
(measured-behavior.md).
Five of its results change the code you would otherwise write:
- The article's size formula leaves 29 % of the map empty.
A symbol area sets the hexagon's height, not its width,
so (cell width)² × 0.92 draws every cell at 83 % of its slot.
symbolSize(CGSize) sets the width and the height directly
and tiled with no gap and no overlap —
even on a plot whose ratio was off, where one area covered 20 % of the plot twice.
- An automatic domain includes zero.
Longitudes around New Zealand got an x domain of 0…200,
so the map filled 6 % of the plot's width.
- Rounding q and r on their own put 16.8 % of points in the wrong cell;
cube rounding put none.
- Cells past an explicit domain draw over the axes
until the plot is
clipped().
- With axes shown, an aspect ratio on the chart is not the plot's ratio (1.5 % off);
inside
chartPlotStyle it holds.
The SDK adds two more:
ChartSymbolShape requires perceptualUnitRect,
so the article's first hexagon does not compile,
and .symmetricLog is iOS 16.4, not 16.0.
Who this is for