Skip to content

Commit 7e178be

Browse files
committed
WIP Tests
1 parent 39ef220 commit 7e178be

File tree

2 files changed

+42
-52
lines changed

2 files changed

+42
-52
lines changed

src/plot.typ

+1
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@
400400
for plot in ptx.plots {
401401
for proj in plot.projections {
402402
if axes.all(name => proj.axes.contains(name)) {
403+
// FIXME: Broken
403404
let pt = (proj.transform)(position).first()
404405
ptx.anchors.push((name, pt))
405406
}

tests/plot/test.typ

+41-52
Original file line numberDiff line numberDiff line change
@@ -28,26 +28,26 @@
2828
x-min: -360,
2929
x-max: 360,
3030
y-tick-step: 1,
31-
x2-label: none,
32-
x2-min: -90,
33-
x2-max: 90,
34-
x2-tick-step: 45,
35-
x2-minor-tick-step: 15,
36-
y2-label: none,
37-
y2-min: -1.5,
38-
y2-max: 1.5,
39-
y2-tick-step: .5,
40-
y2-minor-tick-step: .1,
31+
u-label: none,
32+
u-min: -90,
33+
u-max: 90,
34+
u-tick-step: 45,
35+
u-minor-tick-step: 15,
36+
v-label: none,
37+
v-min: -1.5,
38+
v-max: 1.5,
39+
v-tick-step: .5,
40+
v-minor-tick-step: .1,
4141
{
4242
plot.add(data)
43-
plot.add(data, style: (stroke: blue), axes: ("x2", "y2"))
43+
plot.add(data, style: (stroke: blue), axes: ("u", "v"))
4444
})
4545
})
4646

4747
/* School-Book Style */
4848
#test-case({
4949
plot.plot(size: (5, 4),
50-
axis-style: "school-book",
50+
template: "school-book",
5151
x-tick-step: 180,
5252
y-tick-step: 1,
5353
{
@@ -58,7 +58,7 @@
5858
/* Clipping */
5959
#test-case({
6060
plot.plot(size: (5, 4),
61-
axis-style: "school-book",
61+
template: "school-book",
6262
x-min: auto,
6363
x-max: 350,
6464
x-tick-step: 180,
@@ -75,7 +75,6 @@
7575
plot.plot(size: (5, 4),
7676
x-label: [Rainbow],
7777
x-tick-step: none,
78-
axis-style: "scientific",
7978
y-label: [Color],
8079
y-max: 8,
8180
y-tick-step: none,
@@ -92,34 +91,33 @@
9291
/* Tick Step Calculation */
9392
#test-case({
9493
plot.plot(size: (12, 4),
95-
y2-decimals: 4,
94+
v-format: plot.formats.decimal.with(digits: 4),
9695
{
9796
plot.add(((0,0), (1,10)), axes: ("x", "y"))
98-
plot.add(((0,0), (.1,.01)), axes: ("x2", "y2"))
97+
plot.add(((0,0), (.1,.01)), axes: ("u", "v"))
9998
})
10099
})
101100

102101
#test-case({
103102
plot.plot(size: (12, 4),
104-
y2-decimals: 9,
105-
x2-decimals: 9,
106-
y2-format: "sci",
103+
v-format: plot.formats.sci,
104+
u-format: plot.formats.sci,
107105
{
108106
plot.add(((0,0), (30,2500)), axes: ("x", "y"))
109-
plot.add(((0,0), (.001,.0001)), axes: ("x2", "y2"))
107+
plot.add(((0,0), (.001,.0001)), axes: ("u", "v"))
110108
})
111109
})
112110

113-
/* Axis Styles */
114-
115-
111+
/* Templates */
116112
#test-case(args => {
117113
plot.plot(size: (4,4), x-tick-step: 90, y-tick-step: 1,
118-
axis-style: args, {
114+
template: args, {
119115
plot.add(domain: (0, 360), x => calc.sin(x * 1deg))
120116
})
121117
}, args: (
122-
"scientific", "scientific-auto", "left", "school-book", none
118+
// TODO
119+
//"scientific", "scientific-auto", "left", "school-book", none
120+
"scientific", "school-book"
123121
))
124122

125123
/* Manual Axis Bounds */
@@ -136,10 +134,10 @@
136134
yb-min: -1.5, yb-max: .5,
137135
yt-min: -.5, yt-max: 1.5,
138136
{
139-
plot.add-cartesian-axis("xl", (0, 0), (4, 0))
140-
plot.add-cartesian-axis("xr", (0, 4), (4, 4))
141-
plot.add-cartesian-axis("yt", (0, 0), (0, 4))
142-
plot.add-cartesian-axis("yb", (4, 0), (4, 4))
137+
plot.lin-axis("xl")
138+
plot.lin-axis("xr")
139+
plot.lin-axis("yt")
140+
plot.lin-axis("yb")
143141
plot.add(circle-data)
144142
plot.add(circle-data, axes: ("xl", "y"), style: (stroke: green))
145143
plot.add(circle-data, axes: ("xr", "y"), style: (stroke: red))
@@ -159,10 +157,10 @@
159157
yb-min: -1.75, yb-max: .25,
160158
yt-min: -.25, yt-max: 1.75,
161159
{
162-
plot.add-cartesian-axis("xl", (0, 0), (4, 0))
163-
plot.add-cartesian-axis("xr", (0, 4), (4, 4))
164-
plot.add-cartesian-axis("yt", (0, 0), (0, 4))
165-
plot.add-cartesian-axis("yb", (4, 0), (4, 4))
160+
plot.lin-axis("xl")
161+
plot.lin-axis("xr")
162+
plot.lin-axis("yt")
163+
plot.lin-axis("yb")
166164
plot.add(circle-data)
167165
plot.add(circle-data, axes: ("xl", "y"), style: (stroke: green))
168166
plot.add(circle-data, axes: ("xr", "y"), style: (stroke: red))
@@ -198,16 +196,6 @@
198196
mark: (start: ">", end: ">"), name: "amplitude")
199197
})
200198

201-
/* Custom sample points */
202-
#test-case({
203-
plot.plot(size: (6, 4), y-min: -2, y-max: 2,
204-
samples: 10,
205-
{
206-
plot.add(samples: 2, sample-at: (.99, 1.001, 1.99, 2.001, 2.99), domain: (0, 3),
207-
x => calc.pow(-1, int(x)))
208-
})
209-
})
210-
211199
/* Format tick values */
212200
#test-case({
213201
plot.plot(size: (6, 4),
@@ -217,19 +205,20 @@
217205
y-tick-step: none,
218206
y-ticks: (-1, 0, 1),
219207
y-format: x => $y_(#x)$,
220-
x2-tick-step: none,
221-
x2-ticks: (-1, 0, 1),
222-
x2-format: x => $x_(2,#x)$,
223-
y2-tick-step: none,
224-
y2-ticks: (-1, 0, 1),
225-
y2-format: x => $y_(2,#x)$,
208+
u-tick-step: none,
209+
u-ticks: (-1, 0, 1),
210+
u-format: x => $x_(2,#x)$,
211+
v-tick-step: none,
212+
v-ticks: (-1, 0, 1),
213+
v-format: x => $y_(2,#x)$,
226214
{
227215
plot.add(samples: 2, domain: (-1, 1), x => -x, axes: ("x", "y"))
228-
plot.add(samples: 2, domain: (-1, 1), x => x, axes: ("x2", "y2"))
216+
plot.add(samples: 2, domain: (-1, 1), x => x, axes: ("u", "v"))
229217
})
230218
})
231219

232220
// Test plot with anchors only
221+
/*
233222
#test-case({
234223
import draw: *
235224
@@ -256,13 +245,13 @@
256245
tick: (
257246
length: -.1,
258247
),
259-
left: (
248+
y: (
260249
stroke: (paint: red),
261250
tick: (
262251
stroke: auto,
263252
)
264253
),
265-
bottom: (
254+
x: (
266255
stroke: (paint: blue, thickness: 2pt),
267256
tick: (
268257
stroke: auto,

0 commit comments

Comments
 (0)