|
Color displaying for charts |
Posted by PBasam on Sep-10-2011 15:02 |
|
Hi,
Hi,
We are using Chart Directory as per our requirement; I want a small confirmation for Pie chart.
As per below example all colors is displaying anonymously. I want to display user defined colors.
Could you help me how to set user defined colors for PIE chart or other charts also?
Please find the below example and attachment.
<%@page import="ChartDirector.*" %>
<%
double[] data = {Chart.NoValue, 30, 15, 12, 8, Chart.NoValue, 35,10,20,30,40};
String[] labels = {"Labor", "Licenses", "Taxes", "Legal", "Insurance", "Facilities",
"Production","aaaa","bbbb","ccccc","ddddddd"};
PieChart c = new PieChart(360, 300);
c.setPieSize(180, 140, 100);
c.setData(data, labels);
String chart1URL = c.makeSession(request, "chart1");
String imageMap1 = c.getHTMLImageMap("", "",
"title='{label}: US${value}K ({percent}%)'");
%>
<html>
<body style="margin:5px 0px 0px 5px">
<img src='<%=response.encodeURL("getchart.jsp?"+chart1URL)%>'
usemap="#map1" border="0">
<map name="map1"><%=imageMap1%></map>
</body>
</html>
Regards,
PBasam.
|
Re: Color displaying for charts |
Posted by Peter Kwan on Sep-13-2011 00:17 |
|
Hi PBasam,
There are a number of examples included in ChartDirector that demonstrates how to use custom colors for the sectors. For example, see the sample code "Pie Chart with Legend (2)". The code is basically like:
// The colors to use for the sectors
int[] colors = {0x66aaee, 0xeebb22, 0xbbbbbb, 0x8844ff, 0xdd2222, 0x009900, .....};
// Use the above color arrays as the sector colors
c.setColors2(Chart.DataColor, colors);
Hope this can help.
Regards
Peter Kwan |
|