amcharts / amcharts4

The most advanced amCharts charting library for JavaScript and TypeScript apps.
https://www.amcharts.com/
1.16k stars 322 forks source link

Need to add custom percentages in Tooltip instead of default CalculatePercentage in amcharts 4 #4401

Closed meghanaNanuvala closed 5 months ago

meghanaNanuvala commented 6 months ago

Hi

I need to display percentage along with actual value, which is calculated by us in Stacked bar chart. refernce

I referred this document: https://www.amcharts.com/docs/v4/tutorials/using-percent-values-in-series/

I have written below snippet:

series.dataFields.valueY = field;
 series.dataFields.categoryX = 'y';           
 series.dataFields.valueYShow = 'originated_percent';
 series.columns.template.tooltipText = '[bold]{name}[/]\n[font-size:12px]{categoryX}: {valueY}[/]' +  '({valueYShow}%[/])';

In the above originated_percent, I have given. This is how data looks like:

chart.data = [{
  "Originated": 13,   
  "Received": 19
   "originated_percent": 33.36
   "total": 32
}]

Can you help us to add a custom percentage? Please reach out to me asap, i need your help.

martynasma commented 6 months ago

You can refer to any value in data using curly brackets, e.g.: {originated_percent}.

meghanaNanuvala commented 6 months ago

is this : series.dataFields.valueYShow = '{originated_percent}';

Can you please provide exact one, because i have tried above one. It's not as expected.

martynasma commented 6 months ago

No, you can refer it in a tooltip:

series.columns.template.tooltipText = '[bold]{name}[/]\n[font-size:12px]{categoryX}: {valueY}[/]' +  '({originated_percent}%[/])';
github-actions[bot] commented 5 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.