Nivo: tooltipFormat should allow fully custom formatting

Created on 10 Feb 2018  路  8Comments  路  Source: plouc/nivo

Maybe it's just me, but it seems like the tooltipFormat callback should allow formatting and returning the entire display string, not just the value.

Right now the tooltip always shows a color swatch, the data key, and then appends the formatted value.

I think the ability to format the entire string is important for a variety of reasons (custom localization, context-based messages, etc). Plus in my current usage it doesn't make sense to display a color swatch.

Is there another way to achieve this that I'm not aware of?

tooltip duplicate

Most helpful comment

I'm able to access the data with

            tooltip={(input) => {
              console.log(input.point)
              return (
              <div>
                hello
              </div>
            )}}

All 8 comments

On a related note, it also seems like users should be able to disable tooltips. From what I can tell, this isn't possible (at least in Pie or Bar which are the only components I've tried so far).

@pvjones in your settings you can disable the tooltip this way:
isInteractive: false

@stahlmanDesign Lifesaver, thanks! I was wondering what isInteractive did! My bad for speaking before investigating more.

Also it would be nice to access x and y values instead of just y

Is it possible to access x and y both in the tooltip?

@plouc Is it possible to access the x value on a tooltip? In the following example, id is y-axis and value is the value of the y-axis but how do we get the x-axis value?

tooltip={({ id, value, color }) => (
          <div style={{ color: '#fff' }}>
            {id}: {value}
          </div>
        )}

I'm able to access the data with

            tooltip={(input) => {
              console.log(input.point)
              return (
              <div>
                hello
              </div>
            )}}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

gcloeval picture gcloeval  路  3Comments

PattieC4ke picture PattieC4ke  路  3Comments

dubzzz picture dubzzz  路  3Comments

Haaziq-Uvais picture Haaziq-Uvais  路  3Comments

stahlmanDesign picture stahlmanDesign  路  3Comments