Skip to content

[Bug] String templates unable to display datasource values within tooltip formatter #18138

@Blakey

Description

@Blakey

Version

5.4.1

Link to Minimal Reproduction

https://codepen.io/blake11235/pen/Expgqzo

Steps to Reproduce

  • Provide data to chart using datasource.source rather than data within the series
  • show tooltip on item hover
  • add custom formatter for tooltip using string templates (cannot use function here as we have limited what users can do on the frontend as we save this in the database as JSON)
  • attempt to access value hovered over using template {c}, {c0} or @2012

Current Behavior

When using datasource rather than data provided within series itself, I am unable to access the value information when applying a custom tooltip formatter using any of the in-built string templates ({a}, {b}, {c} , {d}, ...)

In the codepen you will see the label formatter works fine with formatter: '{b}: {@2012} ({d}%)' . However when trying to use this same formatter on the tooltip it does not access the @2012 value.

Have also tried '{b}: {c} ({d}%)' but this gives [object Object] when datasource is an array of objects. And it gives a string of all values in the object when the datasource is provided as an array of arrays.

Have also tried '{b}: {c0} ({d}%)' but nothing provides access to the actual specific values needed within the object.

Expected Behavior

Expected that tooltip formatter can access the value of the highlighted segment of the pie chart using string template {c}, or with specific dimension names @2012 in my example.

Original goal: tooltip of pie chart shows both the value and the % of the total when you hover over the item. Was hoping this might be possible even without any customization of the tooltip, as with these string templates you lost the nice formatting that the in-built tooltip has with colored bullets for each series, etc.

Environment

- OS: Windows 10
- Browser: Chrome 108.0.5359.125 (Official Build) (64-bit)

Any additional comments?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugenThis issue is in EnglishpendingWe are not sure about whether this is a bug/new feature.staleInactive for a long time. Will be closed in 7 days.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions