Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

Error when providing axis tickformat, but dataset is empty

Offen
#7,169 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
45/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Veraltet
Tech-Stack
javascript

Rechercherichtung

Reproduziere den bereitgestellten Plotly.newPlot-Aufruf mit leeren x- und y-Arrays und xaxis tickformat "%H:%M". Beginne mit dem newPlot-Aufruf und den formatbezogenen Stack-Einträgen in plotly-finance.js und bestätige anschließend, dass ein leerer Datensatz nicht mehr den bad-format-Fehler erzeugt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

bug P3

I could not find this anywhere in reported/open/closed problems, so here goes.
I'm dynamically fetching my dataset for plotly - and sometimes there is no data - a normal condition for my app.
When providing a timestamp-like xaxis tickformat, an error will occur when the dataset is empty.

  Plotly.newPlot(this.chartTarget.id, {
    data: [
      { name: "Spot", type: "scatter", mode: 'lines', x: [], y: [], line: {color: 'black'} },
    ],
    layout: {
      title: "Blah",
      hovermode: "closest",
      hoverlabel: { bgcolor: "#FFF" },
      legend: { orientation: 'h', y: -0.3 },
      xaxis: { tickformat: "%H:%M", title: {text: "Time", automargin: true, standoff: 0}, zeroline: false },
      yaxis: { title: "YAxis" }
    },
    config: { responsive: true }
  });

When the dataset is empty alike above (and only when empty), a JS error will be thrown with a trace that looks like:

console.trace() WARN: encountered bad format: "%H:%M" plotly-finance.js:27425:18
warn plotly-finance.js:27425
warnBadFormat plotly-finance.js:25902
numberFormat plotly-finance.js:50110
numFormat plotly-finance.js:40235
formatLinear plotly-finance.js:40138
tickText plotly-finance.js:39918
setTickLabel plotly-finance.js:39477
calcTicks plotly-finance.js:39509
drawOne plotly-finance.js:40613
draw plotly-finance.js:40541
syncOrAsync plotly-finance.js:26272
draw plotly-finance.js:40534
drawAxes plotly-finance.js:31315
syncOrAsync plotly-finance.js:26272
_doPlot plotly-finance.js:31340
newPlot plotly-finance.js:31501

It seems like the format handler should be able to detect this situation and avoid the error when there's actually nothing to format in the first place.

Thanks for consideration and hopeful for a resolution within plotly itself for this potentially-expected condition.

Vorherrschende Sprache
JavaScript
Sterne
18.3k
Forks
2k
Ø Merge
2 T. 10 Std.
Gemergte PRs (30 T.)
30

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus plotly/plotly.js

Alle Issues in plotly/plotly.js

Ähnliche Issues

Weitere Issues zu JavaScript

Neue Issues direkt in Ihr Postfach

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