Feature request: access to layers and subplots with stable API
Personne n'a encore pris cette issue.
- Langage dominant
- JavaScript
- Étoiles
- 18.3k
- Forks
- 2k
- Merge moyen
- 2 j 12 h
- PR mergées (30 j)
- 28
Description
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)
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par l’exemple getInteractorLayer et les points d’entrée plotly_relayout, plotly_afterplot et plotly_relayouting décrits dans l’issue. Définissez une alternative publique à l’accès privé à _fullLayout qui expose subplots, clipId et la couche supérieure de formes, ou qui crée une couche supérieure, puis vérifiez que les interacteurs peuvent être positionnés et rendus à nouveau via les callbacks présentés.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- d3js, javascript
- Domaine
- api, data-visualization, frontend
- Type d'issue
- Fonctionnalité
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 25/100