Package demo

Source Code of demo.ChartServlet

package demo;

import javax.servlet.http.*;
import com.trulytech.mantis.system.*;
import com.trulytech.mantis.result.*;
import com.trulytech.mantis.util.ChartManagement;
import java.awt.image.BufferedImage;
import com.trulytech.mantis.util.ImageUtils;

public class ChartServlet extends ActionServlet {

  // 重载身份校验函数
  protected int HasPermission(HttpServletRequest request,
      HttpServletResponse response, SQLParser Parser) throws Exception {
    return Permission.ALLOW;

  }

  protected String PerformGet(HttpServletRequest request,
      HttpServletResponse response, SQLParser Parser) throws Exception

  {
    DBResult Result = Parser
        .QueryExecute("select label,value from piechart order by id desc");
    DBResult ResultBar = Parser
        .QueryExecute("select name,income1,income2 from barchart ");
    DBResult ResultXY = Parser
        .QueryExecute("select name,X,Y from xychart ");
    String[] Legend = new String[2];
    Legend[0] = "收入1";
    Legend[1] = "收入2";

    ChartManagement chartmgr = null;
    String Type = getParameter(request, "type");

    if (Type.equalsIgnoreCase("0"))

      chartmgr = new ChartManagement(ChartManagement.PIE, response,
          Result, false);

    else if (Type.equalsIgnoreCase("1"))

      chartmgr = new ChartManagement(ChartManagement.PIE, response,
          Result, true);
    else if (Type.equalsIgnoreCase("2"))
      chartmgr = new ChartManagement(ChartManagement.BAR, response,
          ResultBar, false, Legend);

    else if (Type.equalsIgnoreCase("3"))
      chartmgr = new ChartManagement(ChartManagement.LINE, response,
          ResultBar, false, Legend);
    else if (Type.equalsIgnoreCase("4"))
      chartmgr = new ChartManagement(ChartManagement.LINE, response,
          ResultBar, true, Legend);
    else if (Type.equalsIgnoreCase("5"))
      chartmgr = new ChartManagement(ChartManagement.STACKBAR, response,
          ResultBar, false, Legend);
    else if (Type.equalsIgnoreCase("6"))
      chartmgr = new ChartManagement(ChartManagement.STACKBAR, response,
          ResultBar, true, Legend);
    else if (Type.equalsIgnoreCase("7"))
      chartmgr = new ChartManagement(ChartManagement.AREA, response,
          ResultBar, false, Legend);
    else if (Type.equalsIgnoreCase("8"))
      chartmgr = new ChartManagement(ChartManagement.STACKAREA, response,
          ResultBar, false, Legend);

    else if (Type.equalsIgnoreCase("10"))
      chartmgr = new ChartManagement(ChartManagement.RING, response,
          Result, false, Legend);
    else if (Type.equalsIgnoreCase("11"))
      chartmgr = new ChartManagement(ChartManagement.XYLINE, response,
          ResultXY, false);
    else if (Type.equalsIgnoreCase("12"))
      chartmgr = new ChartManagement(ChartManagement.XYAREA, response,
          ResultXY, false);
    chartmgr.setWidth(600);
    chartmgr.setHeight(400);
    // 产生图片
    return chartmgr.generateChart();

  }

}
TOP

Related Classes of demo.ChartServlet

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.