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

"TypeError: POt.indexOf is not a function" with mode: text and type: scattergl #7353

Open
WeisSeb opened this issue Feb 4, 2025 · 2 comments

Comments

@WeisSeb
Copy link

WeisSeb commented Feb 4, 2025

After upgrading to v3.0.0 Plotly.js throws an error when trying to plot some text in a scattergl plot e.g:

import * as Plotly from 'plotly.js-dist-min'

var element = document.getElementById('plot');

Plotly.newPlot(element, [{
    type: 'scattergl',
    x: [1],
    y: [1],
    text: 'some text',
    mode: 'text'
},], {
    margin: {t: 0}
}, {});

causes the following error to appear in the browser console and nothing is plotted. Axes do however still appear

plotly__js-dist-min.js?v=ea4ace4f:60842 Uncaught TypeError: POt.indexOf is not a function
    at Object.bqe [as parse] (plotly__js-dist-min.js?v=ea4ace4f:60842:21)
    at plotly__js-dist-min.js?v=ea4ace4f:64366:25
    at Array.forEach (<anonymous>)
    at Vu.update (plotly__js-dist-min.js?v=ea4ace4f:64362:71)
    at new Vu (plotly__js-dist-min.js?v=ea4ace4f:64264:51)
    at bOe.exports [as plot] (plotly__js-dist-min.js?v=ea4ace4f:64540:363)
    at Kve (plotly__js-dist-min.js?v=ea4ace4f:21173:93)
    at yv.plot (plotly__js-dist-min.js?v=ea4ace4f:21149:17)
    at ld.drawData (plotly__js-dist-min.js?v=ea4ace4f:16265:77)
    at li.syncOrAsync (plotly__js-dist-min.js?v=ea4ace4f:7233:63)

Other text modes, e.g. "mode:text+markers" have the same issue. This error does not occur if type is defined as "scatter"

This did work in previous versions

EDIT: The stacktrace of the non-minified version might be more useful:

Uncaught TypeError: systemFontKeywords.indexOf is not a function
    at Object.parseFont [as parse] (plotly__js-dist.js?v=0135e98b:147358:38)
    at plotly__js-dist.js?v=0135e98b:156925:36
    at Array.forEach (<anonymous>)
    at GlText2.update (plotly__js-dist.js?v=0135e98b:156920:61)
    at new GlText2 (plotly__js-dist.js?v=0135e98b:156776:20)
    at Object.plot (plotly__js-dist.js?v=0135e98b:157427:39)
    at plotOne (plotly__js-dist.js?v=0135e98b:51169:25)
    at exports2.plot (plotly__js-dist.js?v=0135e98b:51100:19)
    at exports2.drawData (plotly__js-dist.js?v=0135e98b:38240:36)
    at lib.syncOrAsync (plotly__js-dist.js?v=0135e98b:15221:23)
@secretwpn
Copy link

secretwpn commented Feb 6, 2025

Same happens here. Sadly we can't use this version until fixed.

This might be related MaartenGr/BERTopic#2279

@ayjayt
Copy link
Contributor

ayjayt commented Feb 9, 2025

Here's the detailed trace (I don't have source map, so its the bundle):

  var require_css_system_font_keywords = __commonJS({
    "node_modules/css-system-font-keywords/index.json"() {
    }

as called by "node_modules/css-font/parse.js" in

      var systemFontKeywords = require_css_system_font_keywords();

Which then uses indexOf to search systemFontKeywords.

That css-system-font-kewords/index.json is resolving as {}, not [...] like it should be, and {}.indexOf isn't a thing. It is clearly meant to resolve as [...] because it is defined that way and because its converted explicitly from [] to {} later.

So, a couple theories:

  • That json file didn't get bundled into 3.0.0 for some reason and it default as {}.
  • It hasn't been loading for a while and the default has changed from [] to {} (less likely).

Leaning towards the first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants