Skip to content

Commit 586a672

Browse files
committed
allow formatter to return string
1 parent b2d0ebd commit 586a672

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

src/marks/tip.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,18 @@ export class Tip extends Mark {
146146
this.setAttribute("stroke", "none");
147147
// iteratively render each channel value
148148
const names = new Set();
149-
for (const line of format.call(mark, i, sources, scales, values)) {
150-
const {name = ""} = line;
151-
if (name && names.has(name)) continue;
152-
else names.add(name);
153-
renderLine(that, line);
149+
const lines = format.call(mark, i, sources, scales, values);
150+
if (typeof lines === "string") {
151+
for (const line of mark.splitLines(lines)) {
152+
renderLine(that, {value: mark.clipLine(line)});
153+
}
154+
} else {
155+
for (const line of lines) {
156+
const {name = ""} = line;
157+
if (name && names.has(name)) continue;
158+
else names.add(name);
159+
renderLine(that, line);
160+
}
154161
}
155162
})
156163
)
@@ -301,11 +308,8 @@ function getSources({channels}) {
301308
return sources;
302309
}
303310

304-
function* formatTitle(i, {title}) {
305-
const text = title.value[i];
306-
for (const line of this.splitLines(formatDefault(text))) {
307-
yield {name: "", value: this.clipLine(line)};
308-
}
311+
function formatTitle(i, {title}) {
312+
return formatDefault(title.value[i]);
309313
}
310314

311315
function* formatChannels(i, channels, scales, values) {

0 commit comments

Comments
 (0)