plotly / plotly/plotly.js

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

Offen
#6,492 3 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

bug P3
Vorherrschende Sprache
JavaScript
Sterne
18.3k
Forks
2k
Ø Merge
2 T. 12 Std.
Gemergte PRs (30 T.)
28

Beschreibung

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);

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginnen Sie mit der verknüpften CodePen-Reproduktion und untersuchen Sie den Pfad zur responsiven Größenänderung für die horizontale Platzierung der Legende in plotly.js. Vergleichen Sie die Größenänderung von schmal zu breit mit einer Aktualisierung und überprüfen Sie anschließend, dass sich die Legenden nach Änderungen des Viewports nicht mehr mit den x-Achsen-Markierungen oder dem Diagramm überschneiden.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
javascript
Bereich
data-visualization
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.