function render(index, scales, values, dimensions, context, next) {
if (!values.text) return next(index, scales, values, dimensions, context);
const {x, text} = values;
const pxPerChar = (this.fontSize ?? 10) * 0.6;
const monospace = (t) => d3.max(t.split("\n"), (k) => k.length) * pxPerChar;
const padding = monospace(" ");
const filtered = [];
let lastPosition = -Infinity;
for (const i of index) {
const position = x[i];
const w = d3.max(text[i].split("\n"), monospace);
if (position - lastPosition >= padding + w / 2) {
filtered.push(i);
lastPosition = position + w / 2;
}
}
return next(filtered, scales, values, dimensions, context);
}