plotly / plotly/plotly.js

Feature request: access to layers and subplots with stable API

Aperta
#7,488 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
JavaScript
Stelle
18.3k
Fork
2k
Merge medio
2g 12h
PR unite (30g)
28

Descrizione

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)

Image

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia con l’esempio getInteractorLayer e con gli entry point plotly_relayout, plotly_afterplot e plotly_relayouting descritti nell’issue. Definisci un’alternativa pubblica all’accesso privato a _fullLayout che esponga subplots, clipId e il livello superiore delle shape, oppure che crei un livello superiore, quindi verifica che gli interactor possano essere posizionati e sottoposti nuovamente al rendering tramite i callback mostrati.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
d3js, javascript
Ambito
api, data-visualization, frontend
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.