Error when providing axis tickformat, but dataset is empty
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- JavaScript
- Estrellas
- 18.3k
- Forks
- 2k
- Merge medio
- 2 d 12 h
- PR fusionados (30 d)
- 28
Descripción
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.
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Reproduce la llamada proporcionada a Plotly.newPlot con arrays x y y vacíos y xaxis tickformat "%H:%M". Comienza con la llamada newPlot y las entradas de la pila relacionadas con el formato en plotly-finance.js; después, confirma que un conjunto de datos vacío ya no produce el error bad-format.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- javascript
- Área
- data-visualization
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 45/100