GANTT.jsp 3.47 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 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
<%@page import="ChartDirector.*" %>
<%@page import="java.util.Date" %>
<%
//data for the gantt chart, representing the start date, end date and names for
//various activities
Date[] startDate = {new Date(102, 7, 12), new Date(102, 7, 19), new Date(102, 7,
    26), new Date(102, 8, 9), new Date(102, 8, 23), new Date(102, 8, 23),
    new Date(102, 8, 30), new Date(102, 9, 14), new Date(102, 9, 14), new Date(
    102, 9, 28), new Date(102, 9, 28), new Date(102, 10, 11)};
Date[] endDate = {new Date(102, 7, 26), new Date(102, 7, 26), new Date(102, 8, 9
    ), new Date(102, 8, 23), new Date(102, 9, 7), new Date(102, 9, 14),
    new Date(102, 9, 14), new Date(102, 9, 28), new Date(102, 10, 18), new Date(
    102, 10, 18), new Date(102, 10, 11), new Date(102, 11, 2)};
String[] labels = {"Market Research", "Brain-Storming", "Define Specifications",
    "Overall Archiecture", "Project Planning", "Assemble Team", "Detail Design",
    "Component Acquisition", "Software Development", "User Documentation",
    "Test Plan", "Testing and QA"};

//Create a XYChart object of size 620 x 280 pixels. Set background color
//0xe0e0ff, border color to 0xccccff, with 1 pixel 3D border effect.
XYChart c = new XYChart(620, 280, 0xe0e0ff, 0xccccff, 1);

//Set the plotarea at (140, 55) and of size 450 x 200 pixels. Use a white
//background. Enable both horizontal and vertical grids by setting their colors
//to grey (0xc0c0c0)
c.setPlotArea(140, 55, 450, 200, 0xffffff, -1, Chart.LineColor, 0xc0c0c0,
    0xc0c0c0);

//swap the x and y axes to create a horziontal box-whisker chart
c.swapXY();

//Add a horizontal legend box at (300, 300) using 8pt Arial Bold Italic as font
LegendBox legendBox = c.addLegend(300, 300, false, "arialbi.ttf", 8);

//Top center alignment the legend box to (300, 300)
legendBox.setAlignment(Chart.TopCenter);

//Set the width of the legend box to 500 pixels (height = automatic)
legendBox.setSize(500, 0);

//Set the legend box background and border colors to transparent
legendBox.setBackground(Chart.Transparent, Chart.Transparent);

//Add a title to the chart using 14 points Times Bold Itatic font, with a pale
//blue (0x9999ff) background
c.addTitle("Simple Gantt Chart Demo", "timesbi.ttf", 14).setBackground(0x9999ff)
    ;

//Set the y-axis scale to be date scale from Aug 12, 2002 to Dec 2, 2002, with
//ticks every 7 days (1 week)
c.yAxis().setDateScale(new Date(102, 7, 12), new Date(102, 11, 2), 86400 * 7);

//Set the label format to show month and day only.
c.yAxis().setLabelFormat("{value|mmm dd}");

//Set the y-axis to shown on the top (right + swapXY = top)
c.setYAxisOnRight();

//Set the labels on the x axis
c.xAxis().setLabels(labels);

//Reverse the x-axis scale so that it points downwards.
c.xAxis().setReverse();

//Disable ticks on x-axis by setting their length to 0.
c.xAxis().setTickLength(0);

//Add a green (0x33ff33) box-whisker layer showing the box only
c.addBoxWhiskerLayer(Chart.CTime(startDate), Chart.CTime(endDate), null, null,
    null, 0x33ff33);

//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">
    Simple Gantt Chart
</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>