Skip to content

Commit 2dca478

Browse files
committed
render mark
``` Plot.plot({ marks: [ { render: () => svg`<text transform="translate(120,20)">Hello, function mark` } ] }) ``` closes #182
1 parent 5fa920d commit 2dca478

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/plot.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ export function plot(options = {}) {
1515
}
1616

1717
// Flatten any nested marks.
18-
const marks = options.marks === undefined ? [] : options.marks.flat(Infinity)
19-
.map(mark => typeof mark === "function" ? {
20-
initialize: () => ({ index: [], channels: [] }),
21-
render: mark
22-
} : mark);
18+
const marks = options.marks === undefined ? [] : options.marks.flat(Infinity);
19+
for (const mark of marks) {
20+
if (mark.initialize === undefined) {
21+
mark.initialize = () => ({ index: [], channels: [] });
22+
}
23+
}
2324

2425
// A Map from Mark instance to an object of named channel values.
2526
const markChannels = new Map();

0 commit comments

Comments
 (0)