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

Message ListMessage List     Post MessagePost Message

  Is it possible not display zero-values in Pie Chart with Legend?
Posted by Alex on Mar-13-2003 17:10
I have report page for matrix survey and I'm using 3d Pie-Charts with Legend (several charts with the same number of sectors because of matrix). Everything goes fine, when values are more then 0%, but when one or more sectors have 0%, when chart looks not good (it display several times 0-legend on the same place) and I'm iteresting to make zero-sectors invisible - how could I do that?

For sure, I can simply exclude zero values from chart data - but then I will have problem with sector colors mix - e.g. if I always have

sector1 - 10% red
sector2 - 20% green
sector3 - 70% blue

but with zero value (problem with legend here)

sector1 - 10% red
sector2 - 0% green
sector3 - 90% blue

without zero have color changes

sector1 - 10% red
sector3 - 90% green <-- but I need here BLUE as usual

Thx for solution!

  Re: Is it possible not display zero-values in Pie Chart with Legend?
Posted by Peter Kwan on Mar-14-2003 04:33
Hi Alex,

I think you may try to filter out the zero values, and set the colors manually.

I am not sure which programming language you are using, so I will outline the method in ASP/VBScript.

First, prepare an array to represent the colors for the sectors. If you want to use the default colors, use the followings:

colors = Array(cd.DataColor + 0, cd.DataColor + 1, cd.DataColor + 2, .....)

Now when you remove a sector from your data array, remove the corresponding color in the colors array as well.

Finally, set the colors to be used by the sectors as follows:

Call c.setColors2(cd.DataColor, colors)

Hope this could help.

Regards
Peter Kwan

  Thx!
Posted by Alex on Mar-14-2003 17:21
it works

  Re: Thx!
Posted by TJ on Aug-26-2011 03:32
Is it also possible to do this when you have 2 values.
Currently have [Pass,Fail]
When there is 0 Fail I just want to show Pass.
When I remove Fail and have one value in the Pie Chart I get errors.
I have to show a 100% pie chart with a 0% small sliver.

  Re: Thx!
Posted by Peter Kwan on Aug-27-2011 01:36
Hi TJ,

Assuming your are using ChartDirector Ver 5, if you have one data value in a pie chart, the pie will become a complete circle, representing 100%. There should be no "0% small silver".

However, if you have two data values, one of them is 0, then there would be a "0% small silver". This accurately reflects your data, which do contain a 0 value.

If you do not want the "0% small silver", you may:

(a) Remove the 0 value from your data array. (Just use an array with one element.)

or

(b) Change the 0 value to NoValue (Note: The exact syntax of NoValue depends on your programming language. It is cd.NoValue for VBScript/VB6/VBA, Chart.NoValue for C#/Java/VB(.NET), NoValue for PHP, ....

Hope this can help.

Regards
Peter Kwan

  Re: Thx!
Posted by Alexandre on Oct-13-2011 17:15
Hi all,

Sorry to intrude on a post that is not mine, but the problem interests me.

The use of NoValue (or filter value 0) removes the value on the pie-chart, but, unfortunately, also on the legend.
Is there a way to remove the value of the graph while keeping in the legend ?

Regards,
Alexandre.

  Re: Thx!
Posted by Peter Kwan on Oct-14-2011 01:43
Hi Alexandre,

By default, there is no legend key for the removed sector because there is no color for the a sector that does not exist.

If you need a legend entry, you may add it as a custom entry using LegendBox.addKey or LegendBox.addKey2. The following is an example in VB/VBScript that automatically adds legend entry for NoValue sectors:

For i = 0 To Ubound(data)
    If data(i) = cd.NoValue Then Call c.getLegend().addKey2(10000 * (i + 1), labels(i), cd.DataColor + i)
Next

Hope this can help.

Regards
Peter Kwan

  Re: Thx!
Posted by Alexandre on Oct-15-2011 00:29
Hi Peter,

It works perfectly. Thank you.

Regards,
Alexandre.