-
Notifications
You must be signed in to change notification settings - Fork 185
Tooltips! #1304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Tooltips! #1304
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
b3f968b
tooltip
mbostock 3eff24c
show all channels
mbostock 3383a19
extra channels!
mbostock 753f50f
svg tooltip
mbostock 56cfcaa
filter: drop-shadow, overflow: visible
mbostock b183bda
fix date label
mbostock 4b9fc1d
bold labels
mbostock 72b83e1
tooltip dodge test
mbostock 7812b1b
dodge fixes
mbostock c5ac532
zwsp
mbostock b2e790c
click to stick!
mbostock 0440877
four corners
mbostock ba0c986
multi-line test
mbostock 4b65637
preferred corner
mbostock 003c162
tooltip text styles
mbostock bab44f1
listen to the window
mbostock 631f4d1
remove default overflow: visible
mbostock 7ded64c
declare maxRadius, corner
mbostock 634e51e
truncate long values
mbostock 742dc5c
one-dimensional bias
mbostock f161aa8
fixed corner option
mbostock 74fa81a
preserve corner when possible
mbostock 426b8ef
test tooltips on bin, stack
mbostock d08aaa2
avoid conflicting listeners
mbostock d2eb0b1
tidy event listeners
mbostock 32e5d22
don’t listen to window
mbostock 44a1291
tooltip for extents
mbostock 9b9e868
show y2-y1 for stack
mbostock f655983
s/corner/anchor/
mbostock f5dc9dc
fix anchor oscillation
mbostock 6bccc91
append tooltip asynchronously
mbostock 2261a39
fix lineHeight
mbostock efad9d7
simplify text layout
mbostock 36d6a37
mobile tooltip on tap (#1526)
Fil 97b93c6
simpler pointer-events
mbostock File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import type {ChannelValueSpec} from "../channel.js"; | ||
import type {Data, FrameAnchor, MarkOptions, RenderableMark} from "../mark.js"; | ||
import type {TextOptions} from "./text.js"; | ||
|
||
/** Options for styling text. TODO Move to TextOptions? */ | ||
type TextStyles = Pick<TextOptions, "lineHeight" | "lineWidth" | "monospace" | "fontFamily" | "fontSize" | "fontStyle" | "fontVariant" | "fontWeight">; // prettier-ignore | ||
|
||
/** Options for the tooltip mark. */ | ||
export interface TooltipOptions extends MarkOptions, TextStyles { | ||
/** | ||
* The horizontal position channel specifying the tooltip’s anchor, typically | ||
* bound to the *x* scale. | ||
*/ | ||
x?: ChannelValueSpec; | ||
|
||
/** | ||
* The vertical position channel specifying the tooltip’s anchor, typically | ||
* bound to the *y* scale. | ||
*/ | ||
y?: ChannelValueSpec; | ||
|
||
/** | ||
* The frame anchor specifies defaults for **x** and **y** based on the plot’s | ||
* frame; it may be one of the four sides (*top*, *right*, *bottom*, *left*), | ||
* one of the four corners (*top-left*, *top-right*, *bottom-right*, | ||
* *bottom-left*), or the *middle* of the frame. For example, for tooltips | ||
* distributed horizontally at the top of the frame: | ||
* | ||
* ```js | ||
* Plot.tooltip(data, {x: "date", frameAnchor: "top"}) | ||
* ``` | ||
*/ | ||
frameAnchor?: FrameAnchor; | ||
|
||
/** TODO */ | ||
maxRadius?: number; | ||
|
||
/** TODO */ | ||
axis?: "x" | "y" | "xy"; | ||
|
||
/** TODO */ | ||
anchor?: "top-left" | "top-right" | "bottom-right" | "bottom-left"; | ||
} | ||
|
||
/** | ||
* Returns a new tooltip mark for the given *data* and *options*. | ||
* | ||
* If either **x** or **y** is not specified, the default is determined by the | ||
* **frameAnchor** option. If none of **x**, **y**, and **frameAnchor** are | ||
* specified, *data* is assumed to be an array of pairs [[*x₀*, *y₀*], [*x₁*, | ||
* *y₁*], [*x₂*, *y₂*], …] such that **x** = [*x₀*, *x₁*, *x₂*, …] and **y** = | ||
* [*y₀*, *y₁*, *y₂*, …]. | ||
*/ | ||
export function tooltip(data?: Data, options?: TooltipOptions): Tooltip; | ||
|
||
/** The tooltip mark. */ | ||
export class Tooltip extends RenderableMark {} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’ve changed this here to allow specifying custom channels for tooltips, but we might want to make this change in more places… and we might even want to change the ChannelName type to include string so that it’s always allowed, but use the never hack to still let VS Code autocomplete known channel names. Although, that makes it less likely we will detect typos.