Customized Click, Hover, and Selection Styles or Traces
还没有人认领这个 Issue。
- 主要语言
- JavaScript
- 星标
- 18.3k
- 派生
- 2k
- 平均合并
- 2 天 12 小时
- 30 天内合并 PR
- 28
描述
Plotly.js has default styles for hovering (tooltips) and for selection (dimmed traces).
In Dash, users want to be able to customize these styles. While they can customize these styles themselves through Dash callbacks, it's slow (roundtrip to server). And while I could write this behaviour into the Dash Graph component, it would be great if this was standard behaviour that everyone could benefit from.
Here are some examples that customized interaction styles or traces could enable.
As requested in the Dash community forum

For this example, there was some "animation fading" implemented, this is, why the line seems to be slightly behind the mouse. But I guess it's clear to see what kind of performance, I was hoping to get by Dash.
I think, it would be really nice, if there are efforts to improve these kind of animations, because I think they are used in many data visualization tools (having a moving maker I mean).
There is this built-in Plotly "Toggle Spike Lines" function in each Graph, that does nearly what I want and is pretty fast, but not customizable.
In addition to this example, users might want to:
- Make the points larger
- Make the lines that they're hovering over thicker
- Add text to the points they're hovering over
- Add shapes the points their hovering over (vertical or horizontal line shapes)
- Outline countries in maps

In this Uber Rides Dash demo created by @alishobeiri, the selected bars are replotted to be white. This persistent style informs the user which bars are selected and also matches the color palette of app itself.

While selected markers have a "dimming" effect, some users will want to customize the style of the selected points and the unselected points. For example, they might want to:
- Hide the unselected points
- Display text to the selected points (
mode: "markers+text") - Modify the colors of either selection
- Add an outline to points or countries instead of fading

In BI platforms, "clicking" is often used for drill downs. While we support click events, we don't modify the look and feel of the graph after clicking. For example, users might want to display constant text when clicking on a point.
In addition, there are a few other default style changes for clickable points (this could be a separate issue):
- Modify the hover interaction of the point to make it seem more "clickable": adding
cursor: pointerand making the point a little bit larger - Displaying an "x" over the point so that the user can "unclick" a point



I'm sure there are many more examples out there.
cc @alexcjohnson @etpinard @cpsievert @monfera @jackparmer
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先检查 Plotly.js 中 hover、选择和点击交互的入口点;该 issue 没有指定具体的文件或测试。定义支持的自定义范围,以及对 hover 中、已选择、未选择和已点击点的行为,然后验证所请求的样式无需 Dash callback 往返即可生效。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript
- 领域
- data-visualization
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 18/100