plotly / plotly/plotly.js

Multiple legends in horizontal mode overlap chart on resize from a narrow viewport to a wide one

Aperta
#6,492 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

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

Descrizione

I am having troubles when changing from portrait mode to landscape mode as the legends overlap the x axis ticks or the chart itself.

Here is the reproducible example: https://codepen.io/bleah1/full/ZEMGVpY

Please use Inspect tools and either make the viewport narrow and then pull pretty fast to make it wide again or just go to mobile view and switch from portrait to landscape.

The legends remain in the same place when resizing from a narrow viewport to a wider one.

This behavior is not as bad on PC, because you can resize again and everything falls into place, but on mobile you can't resize the viewport/window, you can only refresh and I can't use it as it is now.

The code is pretty basic:

const plotDiv = document.getElementById('plot');
const traces = [
	{x: [1,2,3], y: [2,1,4], stackgroup: 'one'},
	{x: [1,2,3], y: [1,1,2], stackgroup: 'one'},
	{x: [1,2,3], y: [3,0,2], stackgroup: 'one'},
	{x: [1,2,3], y: [4,3,2], stackgroup: 'one'},
	{x: [1,2,3], y: [5,5,2], stackgroup: 'one'},
];

const layout = {
      showlegend: true,
      legend: {
        x: 0,
        // y: 1,
        orientation: "h",
        traceorder: "normal",
        yanchor: "top",
      },
      autosize: true,
      margin: { pad: 10, b: 10, l: 40, r: 40, t: 80 },  
}

const config = {
  responsive: true 
}

Plotly.newPlot('myDiv', traces, layout, config);

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 la riproduzione collegata in CodePen e analizza il percorso di ridimensionamento responsive per il posizionamento orizzontale della legenda in plotly.js. Confronta il ridimensionamento da stretto a largo con un aggiornamento, quindi verifica che, dopo le modifiche al viewport, le legende non si sovrappongano più alle tacche dell'asse x o al grafico.

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

Valutazione

Stack tecnologico
javascript
Ambito
data-visualization
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.