Skip to content

Uncaught TypeError when passing null to all mark titles #2274

Open
@matthewCmatt

Description

@matthewCmatt

Encountered through trying to make a Plot.geo choropleth that resembles the following:

Plot.plot({
  marks: [
    Plot.geo(countries, {
      title: (d) =>
        d.properties.user_data !=  0
          ? `Fun property: ${d.properties.user_data}`
          : null,
      tip: true
    })
  ]
})

The above snippet gives a title option that displays a geometry property when it is nonzero. Passing null to the title option works as expected, which was to not display the tooltip for that geo feature.

However, in the case that user_data is 0 for all features, Plot will throw the following error:

Uncaught TypeError: lines is null
    g tip.js:160
    each_default each.js:5
    g tip.js:146
    call_default call.js:4
    g tip.js:145
    call_default call.js:4
    render tip.js:136
    composeRender mark.js:147
    render2 pointer.js:108
    update pointer.js:99
    pointermove pointer.js:161

The plot still renders properly and no tooltips are rendered, as desired.

I believe this is because Plot does not expect there to be 0 tool tips generated from the geo title factory passed in.

Here's some more environment information:

  • Browser: Observed on both Firefox and Chromium
  • Using GeoJSON data (see countries above)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn’t working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions