GAPBAR.jsp 1.98 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
<%@page import="ChartDirector.*" %>
<%!
void createChart(HttpServletRequest request, String img)
{
    double bargap = Integer.parseInt(img) * 0.25 - 0.25;

    //The data for the bar chart
    double[] data = {100, 125, 245, 147, 67};

    //The labels for the bar chart
    String[] labels = {"Mon", "Tue", "Wed", "Thu", "Fri"};

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

    //Set the plotarea at (27, 20) and of size 120 x 100 pixels
    c.setPlotArea(27, 20, 120, 100);

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

    if (bargap >= 0) {
        //Add a title to display to bar gap using 8 pts Arial font
        c.addTitle("      Bar Gap = " + bargap, "arial.ttf", 8);
    } else {
        //Use negative value to mean TouchBar
        c.addTitle("      Bar Gap = TouchBar", "arial.ttf", 8);
        bargap = Chart.TouchBar;
    }

    //Add a bar chart layer using the given data and set the bar gap
    c.addBarLayer(data).setBarGap(bargap);

    //output the chart
    request.getSession().setAttribute("chart" + img, c.makeChart2(Chart.PNG));
}
%>
<%
createChart(request, "0");
createChart(request, "1");
createChart(request, "2");
createChart(request, "3");
createChart(request, "4");
createChart(request, "5");
%>
<html>
<body topmargin=0 leftmargin=5 rightmargin=0 marginwidth=5 marginheight=0>
<div style="font-size:18pt; font-family:verdana; font-weight:bold">
    Bar Gap
</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()%>">
<img src="chart4.chart?no_cache=<%=Chart.getUniqueId()%>">
<img src="chart5.chart?no_cache=<%=Chart.getUniqueId()%>">
</body>
</html>