FONTPIE.jsp 2.49 KB
Newer Older
Thitichaipun Wutthisak committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
<%@page import="ChartDirector.*" %>
<%
//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"};

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

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

//Add a title to the pie chart using Monotype Corsiva ("mtcorsva")/20
//points/deep blue (0x000080) as font
c.addTitle("Project Cost Breakdown", "mtcorsva.ttf", 20, 128);

//Draw the pie in 3D
c.set3D();

//Add a legend box using 12 points Times New Romans Bold ("timesbd.ttf") font.
//Set background color to light grey (0xd0d0d0), with a 1 pixel 3D border.
c.addLegend(340, 80, true, "timesbd.ttf", 12).setBackground(0xd0d0d0, 0xd0d0d0,
    1);

//Set the default font for all sector labels to Impact/8 points/dark green
//(0x008000).
c.setLabelStyle("impact.ttf", 8, 0x8000);

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

//Explode the 3rd sector
c.setExplode(2, 40);

//Use Impact/12 points/red as label font for the 3rd sector
c.sector(2).setLabelStyle("impact.ttf", 12, 0xff0000);

//Use Arial/8 points/deep blue as label font for the 5th sector. Add a
//background box using the sector fill color (SameAsMainColor), with a black
//(0x000000) edge and 2 pixel 3D border.
c.sector(4).setLabelStyle("", 8, 0x80).setBackground(Chart.SameAsMainColor, 0x0,
    2);

//Use Times New Romans/8 points/light red (0xff9999) as label font for the 6th
//sector. Add a dark blue (0x000080) background box with a 2 pixel 3D border.
c.sector(0).setLabelStyle("times.ttf", 8, 0xff9999).setBackground(0x80,
    Chart.Transparent, 2);

//Use Impact/8 points/deep green (0x008000) as label font for 7th sector. Add a
//yellow (0xFFFF00) background box with a black (0x000000) edge.
c.sector(6).setLabelStyle("impact.ttf", 8, 0x8000).setBackground(0xffff00, 0x0);

//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">
    Text Style and Colors
</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>