Skip to content

Commit 9fd222e

Browse files
committed
plot: Implement anchors
1 parent 10bf4b4 commit 9fd222e

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/plot.typ

+11-2
Original file line numberDiff line numberDiff line change
@@ -417,8 +417,17 @@
417417
fn: ptx => {
418418
for plot in ptx.plots {
419419
for proj in plot.projections {
420-
if axes.all(name => proj.axes.contains(name)) {
421-
// FIXME: Broken
420+
let axis-names = proj.axes.map(ax => ax.name)
421+
if axes.all(name => axis-names.contains(name)) {
422+
let position = position.enumerate().map(((i, v)) => {
423+
return if v == "min" {
424+
proj.axes.at(i).min
425+
} else if v == "max" {
426+
proj.axes.at(i).max
427+
} else {
428+
v
429+
}
430+
})
422431
let pt = (proj.transform)(position).first()
423432
ptx.anchors.push((name, pt))
424433
}

tests/plot/test.typ

+1-2
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@
167167
plot.add(circle-data, axes: ("x", "yt"), style: (stroke: blue))
168168
plot.add(circle-data, axes: ("x", "yb"), style: (stroke: yellow))
169169
})
170-
}),))
170+
})
171171

172172
/* Anchors */
173173
#test-case({
@@ -218,7 +218,6 @@
218218
})
219219

220220
// Test plot with anchors only
221-
/*
222221
#test-case({
223222
import draw: *
224223

0 commit comments

Comments
 (0)