Question: Access chart data inside legend
See original GitHub issueHi,
is it possible to access the chart data inside the legend? For example I want to show the individual value next to the legend text in a doughnut chart.
labels: ['A', 'B', 'C']
series: [100, 20, 55]
And the legend should display:
🔴 A - 100
🔵 B - 20
⚫️ C - 55
However inside the legend.formatter
I have only access to the label itself.
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Legend labels not displaying in chart with dynamic row source
The chart has a legend that shows the name of each agency with a color ... I get an error "The Microsoft Access...
Read more >AmCharts: How to access values showing in legend
To access the legend values, you have to create a valueFunction inside the legend object: "legend": { // .
Read more >How To Add and Remove Legends In Excel Chart? - eduCBA
Guide to Legends in Chart. Tutorials on how to add, remove and change the position of legends in excel chart with examples and...
Read more >Chart Elements
A chart's legend shows what kind of data is represented in the chart. By default, the text that appears in the legend is...
Read more >How To Add a Legend to a Chart in Excel (2 Methods, FAQs)
You can use a legend to show the same data differently, or it can clarify what the various axes, colors or labels on...
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
Very good point and I have already taken that into consideration. You can do it like this
Will add in the docs.
Not directly, but there is another way you can style your legend text elements.
If you return an array in the
legend.formatter
function, your texts are split into different tspan elements inside the parent <text> element. So, you can then target them with CSS and apply styles.Here is how you would format the
legend.formatter
functionand then you can apply CSS like
which will result in legend like these