Skip to content

Commit e0d4768

Browse files
committed
default to ellipsis for key/value pairs
1 parent e92bf3e commit e0d4768

3 files changed

Lines changed: 7 additions & 5 deletions

File tree

docs/marks/tip.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ Plot.plot({
9797
```
9898
:::
9999

100-
If no **title** channel is supplied, the tip mark displays all channel values. You can supply additional name-value pairs by registering extra channels using the **channels** mark option. In the scatterplot of Olympic athletes below, you can hover to see the *name* and *sport* of each athlete. This is helpful for noticing patterns — tall basketball players, giant weightlifters and judoka, diminutive gymnasts — and for seeing individuals.
100+
If no **title** channel is supplied, the tip mark displays all channel values as name-value pairs, clipping long values with an ellipsis. Set **textOverflow** to *null* to disable clipping, or use another [text overflow](../marks/text.md) mode such as *ellipsis-middle*. You can supply additional name-value pairs by registering extra channels using the **channels** mark option. In the scatterplot of Olympic athletes below, you can hover to see the *name* and *sport* of each athlete. This is helpful for noticing patterns — tall basketball players, giant weightlifters and judoka, diminutive gymnasts — and for seeing individuals.
101101

102102
:::plot defer https://observablehq.com/@observablehq/plot-tips-additional-channels
103103
```js
@@ -253,7 +253,7 @@ These [standard text options](./text.md#text-options) control the display of tex
253253
- **textAnchor** - the [text anchor](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/text-anchor) for horizontal position; *start*, *end*, or *middle*
254254
- **lineHeight** - the line height in ems; defaults to 1
255255
- **lineWidth** - the line width in ems, for wrapping; defaults to 20
256-
- **textOverflow** - how to wrap or clip lines longer than the specified line width; defaults to *ellipsis* <VersionBadge pr="2322" />
256+
- **textOverflow** - how to wrap or clip lines longer than the specified line width; defaults to *ellipsis* for name-value tips <VersionBadge pr="2322" />
257257

258258
## tip(*data*, *options*) {#tip}
259259

src/marks/text.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export class Text extends Mark {
121121

122122
export function maybeTextOverflow(textOverflow) {
123123
return textOverflow == null
124-
? null
124+
? textOverflow
125125
: keyword(textOverflow, "textOverflow", [
126126
"clip", // shorthand for clip-end
127127
"ellipsis", // … ellipsis-end

src/marks/tip.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export class Tip extends Mark {
4646
frameAnchor,
4747
format,
4848
textAnchor = "start",
49-
textOverflow = "ellipsis",
49+
textOverflow,
5050
textPadding = 8,
5151
title,
5252
pointerSize = 12,
@@ -91,7 +91,8 @@ export class Tip extends Mark {
9191
const mark = this;
9292
const {x, y, fx, fy} = scales;
9393
const {ownerSVGElement: svg, document} = context;
94-
const {anchor, monospace, lineHeight, lineWidth, textOverflow} = this;
94+
const {anchor, monospace, lineHeight, lineWidth} = this;
95+
let {textOverflow} = this;
9596
const {textPadding: r, pointerSize: m, pathFilter} = this;
9697
const {marginTop, marginLeft} = dimensions;
9798

@@ -126,6 +127,7 @@ export class Tip extends Mark {
126127
} else {
127128
sources = getSourceChannels.call(this, values.channels, scales);
128129
format = formatChannels;
130+
if (textOverflow === undefined) textOverflow = "ellipsis-end";
129131
}
130132

131133
// Format the tip text, skipping any nulls.

0 commit comments

Comments
 (0)