Skip to content

Commit 5fa920d

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

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/plot.js

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

1717
// Flatten any nested marks.
18-
const marks = options.marks === undefined ? [] : options.marks.flat(Infinity);
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);
1923

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

0 commit comments

Comments
 (0)