Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when providing axis tickformat, but dataset is empty #7169

Open
jmaino opened this issue Sep 22, 2024 · 0 comments
Open

Error when providing axis tickformat, but dataset is empty #7169

jmaino opened this issue Sep 22, 2024 · 0 comments
Labels
bug something broken P3 not needed for current cycle

Comments

@jmaino
Copy link

jmaino commented Sep 22, 2024

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.

@gvwilson gvwilson added bug something broken P3 not needed for current cycle labels Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken P3 not needed for current cycle
Projects
None yet
Development

No branches or pull requests

2 participants