plotly / plotly/plotly.js

Error when providing axis tickformat, but dataset is empty

Aperta
#7,169 0 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 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.

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

Riproduci la chiamata Plotly.newPlot fornita con array x e y vuoti e xaxis tickformat "%H:%M". Parti dalla chiamata newPlot e dalle voci dello stack relative alla formattazione in plotly-finance.js, quindi conferma che un set di dati vuoto non produca più l’errore bad-format.

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

Valutazione

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

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.