<%@page import="ChartDirector.*" %>
<%
//The data for the pie chart
double[] data = {28, 45, 5, 1, 12};

//The labels for the pie chart
String[] labels = {"Excellent", "Good", "Bad", "Very Bad", "Neutral"};

//The icons for the sectors
String[] icons = {"laugh.png", "smile.png", "sad.png", "angry.png",
    "nocomment.png"};

//Create a PieChart object of size 560 x 300 pixels, using 0xe0e0ff as the
//background color, 0xccccff as the border color, with 1 pixel 3D border effect
PieChart c = new PieChart(560, 300, 0xe0e0ff, 0xccccff, 1);

//Set default directory for loading images from current script directory
String realPath = request.getRealPath(request.getServletPath());
if (realPath == null)
    //some web servers have bugs and real path must be obtained as follows
    realPath = request.getRealPath(request.getRequestURI());
c.setSearchPath(new java.io.File(realPath).getParent());

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

//Add a title box with title written in CDML
c.addTitle(
    "<*block,valign=absmiddle*><*img=doc.png*><*font=timesbi.ttf,size=15*> " +
    "Customer Survey : <*font=timesi.ttf*>Do you like our " +
    "<*block,valign=top*><*font=mtcorsva.ttf,color=dd0000,size=17*>Hyper" +
    "<*block*><*font=arial.ttf,size=8*> TM<*/*><*/*> molecules?<*/*>"
    ).setBackground(0xccccff);

//Add a logo to the chart written in CDML as the bottom title aligned to the
//bottom right
c.addTitle2(Chart.BottomRight,
    "<*block,valign=absmiddle*><*img=molecule.png*> <*block*><*color=FF*>" +
    "<*font=mtcorsva.ttf,size=15*>Molecular Engineering\n" +
    "<*font=verdana.ttf,size=9*>Creating better molecules<*/*>");

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

//Set 3D style
c.set3D();

//Use the side label layout method
c.setLabelLayout(Chart.SideLayout);

//Set the label background color to transparent
c.setLabelStyle().setBackground(Chart.Transparent);

//Set the join line color to black
c.setJoinLine(0);

//Add icons to the chart as a custom field
c.addExtraField(icons);

//Configure the sector labels using CDML to include the icon images
c.setLabelFormat(
    "<*block,valign=absmiddle*><*img={field0}*> {label} ({percent|0}%)");

//Explode the 3rd and 4th sectors as a group (index = 2 and 3)
c.setExplodeGroup(2, 3);

//Set the start angle to 135 degrees may improve layout when there are many
//small sectors at the end of the data array (that is, data sorted in descending
//order). It is because this makes the small sectors position near the
//horizontal axis, where the text label has the least tendency to overlap. For
//data sorted in ascending order, a start angle of 45 degrees can be used
//instead.
c.setStartAngle(135);

//output the chart
request.getSession().setAttribute("chart1", c.makeChart2(Chart.PNG));
%>
<html>
<body topmargin=0 leftmargin=5 rightmargin=0 marginwidth=5 marginheight=0>
<div style="font-size:18pt; font-family:verdana; font-weight:bold">
    Icon Pie Chart (2)
</div>
<hr color="#000080">
<div style="font-size:10pt; font-family:verdana">
    <a href="VIEWSOURCE.jsp?file=<%=request.getServletPath()%>">
        View Chart Source Code
    </a>
</div>
<br>
<img src="chart1.chart?no_cache=<%=Chart.getUniqueId()%>">
</body>
</html>