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.

Modifying legend text / label

See original GitHub issue

I need to be able to update the legend text in order to add some formatting features for readability. Is this currently possible to do in a bar / pie chart?

Something like:

              legends={[
                   {
                       dataFrom: 'indexes',
                       anchor: 'top-right',
                       direction: 'column',
                       justify: false,
                       translateX: 450,
                       translateY: 0,
                       itemsSpacing: 12,
                       itemWidth: 380,
                       itemHeight: 20,
                       itemDirection: 'left-to-right',
                       itemOpacity: 1,
                       symbolSize: 16,
                       legendFormat: d => d.value + d.id, // attempting to format here
                       symbolShape: ({ x, y, size, fill, borderWidth, borderColor }: LegendProps) => (
                           <LegendSymbol x={x} y={y} size={size} fill={fill} borderWidth={borderWidth} borderColor={borderColor} />
                       )
                   }
               ]}

However legendFormat seems to have no effect.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:15 (1 by maintainers)

github_iconTop GitHub Comments

12reactions
wyzecommented, Dec 11, 2019

You would set the data property on the object in the legend. There you set a label property and that is what is used.

It is typed as the following shape, but I guess label needs to be added there.

        data?: Array<{
            id: string | number
            value: number
            color?: string
            fill?: string
        }>
8reactions
mboutin-qohashcommented, Mar 30, 2021

This is not legend formatting but setting a label on a data. It’s really not the same and just make another point that this lib is not mature for good chart solution

Read more comments on GitHub >

github_iconTop Results From Across the Web

Editing legend (text) labels in ggplot - Stack Overflow
When using ggplot I can't get the right text in the legend, even though it's in my dataframe. I have tried scale_colour_manual , ......
Read more >
GGPlot Legend Title, Position and Labels - Datanovia
Change the legend title and text labels · Modify the legend position. · Reverse legend order. · Remove a ggplot legend · Change...
Read more >
10.8 Changing the Labels in a Legend - R Graphics Cookbook
You want to change the text of labels in a legend. ... Modified legend label order and manually specified labels (note that the...
Read more >
How to Change Legend Labels in ggplot2 (With Examples)
You can use the following syntax to change the legend labels in ggplot2: p + scale_fill_discrete(labels=c('label1', 'label2', 'label3', .
Read more >
Legends (ggplot2) - Cookbook for R
There are two ways of changing the legend title and labels. The first way is to tell the scale to use have a...
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