Skip to content

Commit 61e1145

Browse files
committed
given data, don’t defer channels
1 parent 9c57820 commit 61e1145

File tree

4 files changed

+94
-10
lines changed

4 files changed

+94
-10
lines changed

src/marks/axis.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -545,12 +545,12 @@ function axisMark(mark, k, ariaLabel, data, options, initialize) {
545545
} else {
546546
data = scale.domain();
547547
}
548-
}
549-
if (k === "y" || k === "x") {
550-
facets = [range(data)]; // TODO allow faceted ticks?
551-
} else {
552-
channels[k] = {scale: k, value: identity};
553-
facets = undefined; // computed automatically by plot
548+
if (k === "y" || k === "x") {
549+
facets = [range(data)];
550+
} else {
551+
channels[k] = {scale: k, value: identity};
552+
facets = undefined; // computed automatically by plot
553+
}
554554
}
555555
initialize?.call(this, scale, ticks, channels);
556556
return {
@@ -562,9 +562,13 @@ function axisMark(mark, k, ariaLabel, data, options, initialize) {
562562
};
563563
})
564564
);
565-
channels = m.channels;
565+
if (data == null) {
566+
channels = m.channels;
567+
m.channels = {};
568+
} else {
569+
channels = {};
570+
}
566571
m.ariaLabel = ariaLabel;
567-
m.channels = {};
568572
return m;
569573
}
570574

test/output/aaplCloseDataTicks.svg

Lines changed: 68 additions & 0 deletions
Loading

test/plots/aapl-close.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as Plot from "@observablehq/plot";
22
import * as d3 from "d3";
33

4-
export default async function () {
4+
export async function aaplClose() {
55
const AAPL = await d3.csv("data/aapl.csv", d3.autoType);
66
return Plot.plot({
77
y: {
@@ -14,3 +14,15 @@ export default async function () {
1414
]
1515
});
1616
}
17+
18+
export async function aaplCloseDataTicks() {
19+
const AAPL = await d3.csv("data/aapl.csv", d3.autoType);
20+
return Plot.plot({
21+
marks: [
22+
Plot.axisY(d3.ticks(0, 200, 10), {anchor: "left"}),
23+
Plot.areaY(AAPL, {x: "Date", y: "Close", fillOpacity: 0.1}),
24+
Plot.lineY(AAPL, {x: "Date", y: "Close"}),
25+
Plot.ruleY([0])
26+
]
27+
});
28+
}

test/plots/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
export {default as aaplCandlestick} from "./aapl-candlestick.js";
22
export {default as aaplChangeVolume} from "./aapl-change-volume.js";
3-
export {default as aaplClose} from "./aapl-close.js";
43
export {default as aaplCloseUntyped} from "./aapl-close-untyped.js";
54
export {default as aaplMonthly} from "./aapl-monthly.js";
65
export {default as aaplVolume} from "./aapl-volume.js";
@@ -279,6 +278,7 @@ export {default as yearlyRequestsDot} from "./yearly-requests-dot.js";
279278
export {default as yearlyRequestsLine} from "./yearly-requests-line.js";
280279

281280
export * from "./aapl-bollinger.js";
281+
export * from "./aapl-close.js";
282282
export * from "./aapl-fancy-axis.js";
283283
export * from "./athletes-sample.js";
284284
export * from "./axis-labels.js";

0 commit comments

Comments
 (0)