Unspecified number appearing at the end of (Plot) tooltips

I have an unwanted number (in red rectangle below) appearing in tooltips in Plot:

These are ‘native’ tooltips created with the title attribute:

Plot.plot({
  color: {
    scheme: "blues",
    reverse: true,
  },
  y: { 
    label: "↑ Population",
    tickFormat: "s",
    grid: true
  },
  marks: [
    Plot.barY(
      data_sortable,
      Plot.groupX(
        { y: "sum" },
        { x: "state",
         y: "population", 
         fill: "ageGroup",
         sort: {x: 'y', reverse: true},
         title: d => 
`Age group: ${d.ageGroup}
State: ${d.state}
Population: ${d.population}
`
        }
      )
    )
  ]
})

I tried truncating the title using slice() after the title content to no avail:

    title: d => 
`Age group: ${d.ageGroup}
State: ${d.state}
Population: ${d.population}
`.slice(...)

Obviously the (1) part is added afterwards, hence no effect of the slice().

The problem persists when using Mike Freeman’s tooltips.

I isolated the issue in the following notebook:

Anyone perhaps faced this issue and solved it? I’d very much appreciate any ideas. Thanks a lot in advance!

That label is happening because of grouping, telling you that there is (1) item in the group. But it appears that the grouping+sum is not necessary here, since there is only one item for each (x, y z) = (state, population, ageGroup).

So maybe the answer is to simplify:

    Plot.barY(
      data_sortable,
      
        { x: "state",
         y: "population", 
         fill: "ageGroup",
         sort: {x: 'y', reverse: true},
         title: d => 
`Age group: ${d.ageGroup}
State: ${d.state}
Population: ${d.population}`
        }
      )

However, maybe we should avoid this numbering if the number is 1 (issue #876).

1 Like

Ah, so that was the issue. Explains why grouping them never quite made sense to begin with. Thanks a lot for the solution and the more minimalistic code!

However, maybe we should avoid this numbering if the number is 1.

Maybe it could also be desirable not to add the group number automatically and implicitly to the title attribute, even if the number of groups is greater than 1.