MARKZONE2.jsp 2.8 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 90 91 92
<%@page import="ChartDirector.*" %>
<%
//The data for the chart
double[] data = {50, 55, 47, 34, 42, 49, 63, 62, 73, 59, 56, 50, 64, 60, 67, 67,
    58, 59, 73, 77, 84, 82, 80, 84, 89};

//The labels for the chart. Note the "-" means a minor tick.
String[] labels = {"0\nJun 4", "-", "-", "3", "-", "-", "6", "-", "-", "9", "-",
    "-", "12", "-", "-", "15", "-", "-", "18", "-", "-", "21", "-", "-",
    "0\nJun 5"};

//Create a XYChart object of size 400 x 270 pixels
XYChart c = new XYChart(400, 270);

//Set the plotarea at (80, 25) and of size 300 x 200 pixels. Use alternate color
//background (0xe0e0e0) and (0xffffff). Set border and grid colors to grey
//(0xc0c0c0).
c.setPlotArea(50, 25, 300, 200, 0xe0e0e0, 0xffffff, 0xc0c0c0, 0xc0c0c0, 0xc0c0c0
    );

//Add a title to the chart using 14 pts Times Bold Italic font
c.addTitle("Server Monitor", "timesbi.ttf", 14);

//Add a title to the y axis
c.yAxis().setTitle("Server Load (MBytes)");

//Set the y axis width to 2 pixels
c.yAxis().setWidth(2);

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

//Set the x axis width to 2 pixels
c.xAxis().setWidth(2);

//Add a horizontal red (0x800080) mark line at y = 80
Mark yMark = c.yAxis().addMark(80, 0xff0000, "Critical Threshold Set Point");

//Set the mark line width to 2 pixels
yMark.setLineWidth(2);

//Put the mark label at the top center of the mark line
yMark.setAlignment(Chart.TopCenter);

//Add an orange (0xffcc66) zone from x = 18 to x = 20
c.xAxis().addZone(18, 20, 0xffcc66);

//Add a vertical brown (0x995500) mark line at x = 18
Mark xMark1 = c.xAxis().addMark(18, 0x995500, "Backup Start");

//Set the mark line width to 2 pixels
xMark1.setLineWidth(2);

//Put the mark label at the left of the mark line
xMark1.setAlignment(Chart.Left);

//Rotate the mark label by 90 degrees so it draws vertically
xMark1.setFontAngle(90);

//Add a vertical brown (0x995500) mark line at x = 20
Mark xMark2 = c.xAxis().addMark(20, 0x995500, "Backup End");

//Set the mark line width to 2 pixels
xMark2.setLineWidth(2);

//Put the mark label at the right of the mark line
xMark2.setAlignment(Chart.Right);

//Rotate the mark label by 90 degrees so it draws vertically
xMark2.setFontAngle(90);

//Add a green (0x00cc00) line layer with line width of 2 pixels
c.addLineLayer(data, 0xcc00).setLineWidth(2);

//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">
    Marks and Zones (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>