Skip to content

Commit 0c58cf0

Browse files
committed
test ordinal difference
1 parent 30db89c commit 0c58cf0

File tree

3 files changed

+170
-7
lines changed

3 files changed

+170
-7
lines changed

test/output/differenceYOrdinal.svg

Lines changed: 66 additions & 0 deletions
Loading
Lines changed: 66 additions & 0 deletions
Loading

test/plots/difference.ts

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@ export async function differenceYVariable() {
7373
});
7474
}
7575

76+
export async function differenceYClip() {
77+
const gistemp = await d3.csv<any>("data/gistemp.csv", d3.autoType);
78+
return Plot.differenceY(gistemp, Plot.windowY(28, {x: "Date", y: "Anomaly", clip: "frame"})).plot({
79+
x: {insetLeft: -50}
80+
});
81+
}
82+
7683
export async function differenceYClipVariable() {
7784
const stocks = await readStocks();
7885
return Plot.plot({
@@ -90,18 +97,42 @@ export async function differenceYClipVariable() {
9097
});
9198
}
9299

93-
export async function differenceYClip() {
94-
const gistemp = await d3.csv<any>("data/gistemp.csv", d3.autoType);
95-
return Plot.differenceY(gistemp, Plot.windowY(28, {x: "Date", y: "Anomaly", clip: "frame"})).plot({
96-
x: {insetLeft: -50}
97-
});
98-
}
99-
100100
export async function differenceYConstant() {
101101
const aapl = await d3.csv<any>("data/aapl.csv", d3.autoType);
102102
return Plot.differenceY(aapl, {x: "Date", y1: 115, y2: "Close"}).plot();
103103
}
104104

105+
export async function differenceYOrdinal() {
106+
const random = d3.randomLcg(42);
107+
return Plot.plot({
108+
marks: [
109+
Plot.differenceY(
110+
{length: 30},
111+
{
112+
y1: () => "ABCDE"[(random() * 5) | 0],
113+
y2: () => "ABCDE"[(random() * 5) | 0]
114+
}
115+
)
116+
]
117+
});
118+
}
119+
120+
export async function differenceYOrdinalFlip() {
121+
const random = d3.randomLcg(42);
122+
return Plot.plot({
123+
y: {reverse: true},
124+
marks: [
125+
Plot.differenceY(
126+
{length: 30},
127+
{
128+
y1: () => "ABCDE"[(random() * 5) | 0],
129+
y2: () => "ABCDE"[(random() * 5) | 0]
130+
}
131+
)
132+
]
133+
});
134+
}
135+
105136
export async function differenceYReverse() {
106137
const gistemp = await d3.csv<any>("data/gistemp.csv", d3.autoType);
107138
return Plot.differenceY(gistemp, Plot.windowY(28, {x: "Date", y: "Anomaly"})).plot({y: {reverse: true}});

0 commit comments

Comments
 (0)