question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Question] Tooltip to use name field, not array position

See original GitHub issue

What is the current behavior?

The default tooltip is using the data point’s array index as the name instead of the object’s name field.

What is the expected behavior?

I want the tooltip to use the data point’s name as shown in the Recharts examples and API.

Which versions of Recharts, and which browser / OS are affected by this issue? Did this work in previous versions of Recharts?

Rechart version: 1.0.0-alpha.1 Browser: Chrome Not sure if it works in previous versions of Recharts.

Code

const deviceData = [ {name: 'Misfit', amount: 75, fill: '#82ca9d'}, {name: 'Samsung', amount: 96, fill: '#a4de6c'}, {name: 'Other (not listed)', amount: 36, fill: '#d0ed57'}, {name: 'Apple Watch', amount: 230, fill: '#83a6ed'}, {name: 'Jawbone', amount: 125, fill: '#8dd1e1'}, {name: 'Fitbit', amount: 200, fill: '#8884d8'}, ];

<PieChart width={800} height={400}> <Pie data={deviceData} dataKey="amount" cx={150} cy={110} innerRadius={50} outerRadius={80} label /> <Legend iconSize={10} width={120} height={140} layout='vertical' verticalAlign='middle' align="right" /> <Tooltip payload={deviceData} /> </PieChart>

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:16

github_iconTop GitHub Comments

16reactions
ZephDcommented, Jul 3, 2017

http://jsfiddle.net/sj0cfqc8/38/

<Pie nameKey="name" />

This took me WAY to f*ing long to find.

@xile611 Why is nameKey and dataKey not defaulted to “name” and “value” respectively?

10reactions
mjsevillacommented, Jul 3, 2017

@ZephD THANK YOU! Ugh, finally. I wish the docs were more details. They’re honestly pointless: formatter: the formatter function 😐

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tooltip showing Field Name without the Table Name
Hi All,. I would like to show users the field names of certain fields so they can select them, or a combination of...
Read more >
Tooltip javascript disrupts following form element when "title ...
I'm using a javascript tooltip provided by jqueryTOOLS to give tool tips within a form. ... My tooltip code: $(function() { $("#myform :input").tooltip({...
Read more >
Tooltips - Bootstrap
Documentation and examples for adding custom Bootstrap tooltips with CSS and JavaScript using CSS3 for animations and data-attributes for local title storage.
Read more >
How to add a tooltip to a Form API field? - Drupal Answers
Solution is to use #attributes attribute to provide form element with HTML title attribute, like that: 'name' => array( '#title' ...
Read more >
Visualization: Column Chart - Google Developers
The colors to use for the chart elements. An array of strings, where each element is an HTML color string, for example: colors:['red','#004411'] ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found