Skip to content

Commit

Permalink
rescale monospace base width to 63
Browse files Browse the repository at this point in the history
closes #1879
  • Loading branch information
Fil committed Sep 28, 2023
1 parent ebe85f2 commit c3d047d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion src/marks/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ export function defaultWidth(text, start = 0, end = text.length) {
export function monospaceWidth(text, start = 0, end = text.length) {
let sum = 0;
for (let i = start; i < end; i = readCharacter(text, i)) {
sum += isPictographic(text, i) ? 200 : 100;
sum += isPictographic(text, i) ? 126 : 63;
}
return sum;
}
Expand Down
54 changes: 27 additions & 27 deletions test/output/textOverflow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions test/plots/text-overflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export async function textOverflow() {
fx: () => "monospace",
monospace: true,
textOverflow: "ellipsis-end",
lineWidth: 13,
lineWidth: 8,
dx: -4,
frameAnchor: "right"
}),
Expand Down Expand Up @@ -117,7 +117,7 @@ async function textOverflowPlot(textOverflow, {monospace = false} = {}) {
color: {domain: opinions, scheme: "rdylbu"},
marks: [
Plot.axisX({monospace}),
Plot.axisY({lineWidth: monospace ? 9 : 6, textOverflow, monospace}),
Plot.axisY({lineWidth: 6, textOverflow, monospace}),
Plot.axisY({
anchor: "right",
tickFormat: (name) => `${dates.get(name).getUTCFullYear()}`,
Expand Down

0 comments on commit c3d047d

Please sign in to comment.