Skip to content

Commit fe08267

Browse files
handle bar chart edge cases
1 parent f615452 commit fe08267

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

client/src/App.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const DEFAULT_SETTINGS = {
1212
sleepTime: 0,
1313
maxNewTokens: 300,
1414
k: 10,
15-
T: 1.3,
15+
T: 1,
1616
};
1717

1818
function resolveRandomSeed(input) {

client/src/components/Barplot.jsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,17 @@ export default function Barplot({ data, onTickClick, disabled }) {
8585
.style("font-size", `${tickFontSize}px`)
8686
.style("font-weight", "500");
8787

88+
yAxis
89+
.selectAll("text")
90+
.text((d) => {
91+
if (d === " ") return "[sp]";
92+
if (d === "\n") return "↵";
93+
if (d === "\t") return "→";
94+
if (typeof d === "string" && d.trim() === "" && d.length > 0)
95+
return `[${d.length}sp]`;
96+
return d;
97+
});
98+
8899
yAxis
89100
.selectAll(".tick")
90101
.style("cursor", "pointer")
@@ -95,8 +106,8 @@ export default function Barplot({ data, onTickClick, disabled }) {
95106
);
96107
return;
97108
}
98-
const tickText = d3.select(this).select("text").text();
99-
if (onTickClickRef.current) onTickClickRef.current(tickText);
109+
const token = d3.select(this).datum();
110+
if (onTickClickRef.current) onTickClickRef.current(token);
100111
});
101112

102113
svg

0 commit comments

Comments
 (0)