Skip to content

Commit a86ddbb

Browse files
committed
allow formatter to return string
1 parent 220814c commit a86ddbb

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
)
@@ -305,11 +312,8 @@ function getSources({channels}) {
305312
return sources;
306313
}
307314

308-
function* formatTitle(i, {title}) {
309-
const text = title.value[i];
310-
for (const line of this.splitLines(formatDefault(text))) {
311-
yield {name: "", value: this.clipLine(line)};
312-
}
315+
function formatTitle(i, {title}) {
316+
return formatDefault(title.value[i]);
313317
}
314318

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

0 commit comments

Comments
 (0)