Feature request: access to layers and subplots with stable API
还没有人认领这个 Issue。
- 主要语言
- JavaScript
- 星标
- 18.3k
- 派生
- 2k
- 平均合并
- 2 天 12 小时
- 30 天内合并 PR
- 28
描述
Context
We want to display interactive SVG elements on a plotly plot in data coordinates. In order to do this, we currently use the _fullLayout "private" API in order to get a handle to
- subplots
clipId- top shape layer.
We then add a new layer for positioning interactive elements right above _fullLayout._shapeUpperLayer, as seen here:
import { select as d3_select } from 'd3-selection';
export function getInteractorLayer(plotlyPlot, plot='xy') {
// plotlyPlot is a plotly plot object, e.g. from Plotly.newPlot() or Plotly.react()
// plot is the subplot name, e.g. 'xy', 'x2y2'
const subplot = plotlyPlot._fullLayout._plots[plot];
const shapelayer = plotlyPlot._fullLayout._shapeUpperLayer;
const layer_above = d3_select(shapelayer.node().parentNode);
// create interactor layer, if not exists:
layer_above.selectAll("g.interactorlayer")
.data(["interactors"])
.enter().append("g")
.classed("interactorlayer", true);
const interactorlayer = layer_above.selectAll("g.interactorlayer");
const clipid = subplot.clipId.replace(/plot$/, '');
return { interactorlayer, subplot, clipid };
}
Request
A public interface for getting handles to subplots, the clipId, and the top shape layer (or a simple API function for creating a new top layer!)
Once we have the items above, we can create interactors on top of a plotly plot and re-render them as needed with e.g.
plotlyPlot.on('plotly_relayout', relayout);
plotlyPlot.on('plotly_afterplot', relayout);
plotlyPlot.on('plotly_relayouting', relayout);
as seen in this demo: https://bmaranville.github.io/plotly-interactors/demo.html (drag the interactors around and look at the console to see the callbacks being called with the updated state of the interactor)
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 issue 中描述的 getInteractorLayer 示例以及 plotly_relayout、plotly_afterplot 和 plotly_relayouting 入口点开始。定义一种公开替代方案,以取代对私有 _fullLayout 的访问,使其暴露 subplots、clipId 和顶层 shape 图层,或创建一个顶层图层,然后验证是否可以通过演示的回调来定位并重新渲染 interactors。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- d3js, javascript
- 领域
- api, data-visualization, frontend
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 25/100