custom legend text in BarChart
See original GitHub issueHi there,
Nivo is amazing! Thanks for all the great work.
Is there a way to set custom legend text in BarChart?
In https://github.com/plouc/nivo/blob/master/packages/nivo-bar/src/Bar.js it seems like text either comes directly from keys or indexes.
What we really need is a way to pass in some function i.e.
legends={
[
{
"dataFrom": () => {
// returns array of { label: xxx, fill: yyy } objects
}
"anchor": "bottom-right",
"direction": "column",
}
]
}
Any ideas really appreciated!
Issue Analytics
- State:
- Created 5 years ago
- Reactions:30
- Comments:31
Top Results From Across the Web
Google Bar Chart - custom Legend text with total values ...
Google Bar Chart - custom Legend text with total values & column wise total for Table chart · Ask Question. Asked 2 years,...
Read more >Add a legend to a chart - Microsoft Support
Edit legend texts · Click the chart. · Click Chart Filters Filters next to the chart, and click Select Data. · Select an...
Read more >Legends in graphs and charts. Statistics for Ecologists ...
The barplot() command allows use of a legend parameter, which calls legend() with its basic settings. You can pass parameters to the legend() ......
Read more >Customise the legend titles in a bar chart - Qlik Community
Then to make absolutely certain your text box colors don't get out of sync with your chart colors, you could define the colors...
Read more >Custom Legend Item in Bar Chart - APEX - Oracle Communities
I am on APEX 4.2 and have a bar chart with 2 series. The series are 'Last Week' and 'This Week'. I am...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Is there an example of how to set custom legend text? I can’t find anything for it. Thanks!
It looks like it requires a custom layer to replicate the legend. Which is apparently what I have been doing in my project. See an example here: https://codesandbox.io/s/nivo-bar-example-nf86t
We could add a check for a label property where it computes the legend data (https://github.com/plouc/nivo/blob/441383999dad1c9697ef6f4bc89b1c19b4505153/packages/bar/src/compute/legends.js) and use that if it is present, that way you don’t need a custom layer component.