<%@page import="ChartDirector.*" %> <%! //Utility function to get the real path given a relative URL String MapPath(HttpServletRequest request, String path) { 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()); return new java.io.File(realPath).getParent() + "/" + path; } %> <%! void createChart(HttpServletRequest request, String img) { //The data for the pie chart double[] data = {25, 18, 15, 12, 8, 30, 35}; //The labels for the pie chart String[] labels = {"Labor", "Licenses", "Taxes", "Legal", "Insurance", "Facilities", "Production"}; //Colors of the sectors if custom coloring is used int[] colors = {0xb8bc9c, 0xecf0b9, 0x999966, 0x333366, 0xc3c3e6, 0x594330, 0xa0bdc4}; //Create a PieChart object of size 280 x 240 pixels PieChart c = new PieChart(280, 240); //Set the center of the pie at (140, 120) and the radius to 80 pixels c.setPieSize(140, 120, 80); //Draw the pie in 3D c.set3D(); //Set the coloring schema if (img.equals("0")) { c.addTitle("Custom Colors"); //set the LineColor to light gray c.setColor(Chart.LineColor, 0xc0c0c0); //use given color array as the data colors (sector colors) c.setColors2(Chart.DataColor, colors); } else if (img.equals("1")) { c.addTitle("Dark Background Colors"); //use the standard white on black palette c.setColors(Chart.whiteOnBlackPalette); } else if (img.equals("2")) { c.addTitle("Wallpaper As Background"); c.setWallpaper(MapPath(request, "bg.png")); } else { c.addTitle("Transparent Colors"); c.setWallpaper(MapPath(request, "bg.png")); //use semi-transparent colors to allow the background to be seen c.setColors(Chart.transparentPalette); } //Set the pie data and the pie labels c.setData(data, labels); //Explode the 1st sector (index = 0) c.setExplode(0); //output the chart request.getSession().setAttribute("chart" + img, c.makeChart2(Chart.PNG)); } %> <% createChart(request, "0"); createChart(request, "1"); createChart(request, "2"); createChart(request, "3"); %> <html> <body topmargin=0 leftmargin=5 rightmargin=0 marginwidth=5 marginheight=0> <div style="font-size:18pt; font-family:verdana; font-weight:bold"> Coloring and Wallpaper </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="chart0.chart?no_cache=<%=Chart.getUniqueId()%>"> <img src="chart1.chart?no_cache=<%=Chart.getUniqueId()%>"> <img src="chart2.chart?no_cache=<%=Chart.getUniqueId()%>"> <img src="chart3.chart?no_cache=<%=Chart.getUniqueId()%>"> </body> </html>