Hi - I have been trying to figure out how to hide the zero value and label in my legend of the pie chart. I found the below code in the am chart documentation. Isn’t working for me. Does anyone have any ideas?
That’s correct. The reason why is because your Data Model most certainly doesn’t contain the record fields test1 until test5.
Please note that the shared JavaScript code is just an example. You will have to expand your own Bar Script to a Standard Script and change the JavaScript code, as applied to the Standard Script, so that the code will first check if the data value is greater than 0 before creating a graph for it.
Attached you will find a simple example. Please note that this is just an example and that you will to change the JavaScript code differently to get it work in your situation.
Thank you. I should have also said that I received the same errors when I used my data. I haven’t been updated to the newest version of OL yet. Any change of getting the sample in in 2022.2? Sorry.
Thank you for your sample. I really appreciate it. I can get the zero’s to hide in the chart. My issue is getting the zero’s to hide in the actual legend. The zero’s are not showing in the pie chart but are in the legend. Any ideas?
It is possible to hide both bars and the corresponding information in the legend by expanding the Chart Script to a Standard Script and by applying changes to the JavaScript code applied to the expanded Chart Script.
Caution: I would not recommend to expand a Chart Script to a Standard Script and make any changes to the JavaScript code of the expanded Chart Script unless you understand what the applied JavaScript code (better).
Thank you for this. I will definitely save this and learn from this! For now I will accept the zero’s in the legend. One last question, I use percentPrecision = 1 to display the percents to one decimal point in the pie chart but can’t figure out how to show the percents to one decimal point. I have tried using the percentPrecision in a few different places. The legends are giving me trouble!! UGH.
Yes - I saw that. I look at the code. But as you indicated if you don’t understand the scripting better to be careful. I am learning but wasn’t sure how to use it with the data i have. I saved it and am using it to learn what it’s doing so I can do that in the future. Currently, I am hiding the value’s below 2% by using the ‘hideLabelsPercent = 3’. Now I just need to get the below to one decimal point. I tried 'percentPrecision = 1 for the legend, it doesn’t work. Works for the chart but not the legend. For example:
2.14 to 2
.053 to .5