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.

custom legend text in BarChart

See original GitHub issue

Hi 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:closed
  • Created 5 years ago
  • Reactions:30
  • Comments:31

github_iconTop GitHub Comments

16reactions
rascaticommented, May 14, 2019

Is there an example of how to set custom legend text? I can’t find anything for it. Thanks!

5reactions
wyzecommented, Dec 20, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

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