ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Legend
Posted by Sean L on Feb-28-2023 09:32
Hi,

  I have a unique need for a Doughnut chart. If the sector(s) in a given dataset constitutes < .1% , I want to exclude them from the chart BUT list ALL the sectors in the legend.
So the question is 'Is it possible to format a legendbox that does not match the Doughnut chart? Can they be made independent assuming I can create an array for data and Labels based on the specific logic I need"

Thx
GIVEN:
data {99.5, .1, .1, .1,.1,.1}
labels {"l1" , "l2" , "l3" , "l4", "l5 , "l6"}

EXPECTED:
However my chart should ONLY have the 99.5 data value as rest of them are <=.1%, I can have a white sliver (break in the ring) for the remaining data points
BUT My legend should list all 6 values with the right %

Thx

  Re: Legend
Posted by Peter Kwan on Feb-28-2023 21:14
Hi Sean L,

From your previous posts, I assume you are using ChartDirector for Java.

For the donut chart, your code can move the values so that the invisible values (those less than 0.1% of the total) is at the end of the array. Then plot the pie chart as usual. For the sectors less than 0.1%, set their fill, edge and label colors to Chart.Transparent. Those less than 0.1% sectors will then be invisible and become a gap in the pie. The API to use are:

https://www.advsofteng.com/doc/cdjava.htm#PieChart.getSector.htm
https://www.advsofteng.com/doc/cdjava.htm#Sector.setColor.htm
https://www.advsofteng.com/doc/cdjava.htm#Sector.setLabelStyle.htm

You can add the legend box as usual, and it will contain the entries for the invisible sectors as well. It is also possible to add an an independent legend box. See:

https://www.chartdir.com/forum/download_thread.php?bn=chartdir_support&thread=1662365691#N1662462624

Best Regards
Peter Kwan