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

Message ListMessage List     Post MessagePost Message

  How to disable the 0% data related label in the chart
Posted by basamp on Aug-31-2011 19:13
Hi,
We are using Chart Directory5.0 based on my requirement; Pie diagram is working fine
based on my input data.  But we are passing the data 0% for particular label(ex: Labor is
0%).  our requirement 0% data label is not displaying in the chart.  But our below code
0% data related label also appearing.
Can you please help me how to disable the 0% data related label in the chart.


<%@page import="ChartDirector.*" %>
<%
// The data for the pie chart
double[] data = {0, 0, 20, 20, 20, 20, 20};

// The labels for the pie chart
String[] labels = {"Labor", "Licenses", "Taxes", "Legal", "Insurance", "Facilities",
    "Production"};

// Create a PieChart object of size 360 x 300 pixels
PieChart c = new PieChart(360, 300);

// Set the center of the pie at (180, 140) and the radius to 100 pixels
c.setPieSize(180, 140, 100);

// Set the pie data and the pie labels
c.setData(data, labels);

// Output the chart
String chart1URL = c.makeSession(request, "chart1");

// Include tool tip for the chart
String imageMap1 = c.getHTMLImageMap("", "",
    "title='{label}: US${value}K ({percent}%)'");
%>
<html>
<body style="margin:5px 0px 0px 5px">
<div style="font-size:18pt; font-family:verdana; font-weight:bold">
    Simple Pie Chart
</div>
<hr color="#000080">
<div style="font-size:9pt; font-family:verdana; margin-bottom:1.5em">
    <a href="viewsource.jsp?file=<%=request.getServletPath()%>">View Source
Code</a>
</div>
<img src='<%=response.encodeURL("getchart.jsp?"+chart1URL)%>'
    usemap="#map1" border="0">
<map name="map1"><%=imageMap1%></map>
</body>
</html>

  Re: How to disable the 0% data related label in the chart
Posted by Peter Kwan on Sep-01-2011 03:20
Hi basamp,

You may use one of the following method:

(a) Instead of 0, please use Chart.NoValue. In ChartDirector, the value of 0 will be displayed as 0, while Chart.NoValue will not be displayed.

For example:

double[] data = {Chart.NoValue, Chart.NoValue, 20, 20, 20, 20, 20};

or

//change 0 into Chart.NoValue
for (int i = 0; i < data.lenght; ++i)
    if (data[i] == 0) data[i] =Chart.NoValue;

(b) Alternatively, you may consider not to pass the 0 values to ChartDirector (eg. remove them from the data arrays before passing the data to ChartDirector).

Hope this can help.

Regards
Peter Kwan

  Re: How to disable the 0% data related label in the chart
Posted by basamp on Sep-05-2011 14:56
Hi,

This is just i Show you static data only. I want to pass on data in dynamically.

can you help me how disable 0% data related label in dynamically.

Regards
basam

  Re: How to disable the 0% data related label in the chart
Posted by Peter Kwan on Sep-06-2011 01:13
Hi basamp,

I think the following code in my previous post is already disabling the 0% label dynamically, because it dynamically replaces zero values with Chart.NoValue;

//change 0 into Chart.NoValue
for (int i = 0; i < data.lenght; ++i)
    if (data[i] == 0) data[i] =Chart.NoValue;

Hope this can help.

Regards
Peter Kwan