1. 功能介绍

    统计图表

  2. 代码片段

    1. 配置文件代码

    2. HTML写法(参考quickstart/web/../Desktop.html)

      <span jwcid="@wade:Chart" pageName="Desktop" listener="getStatChart" height="400"/>
      
    3. JAVA(PAGE)写法

      /** 饼状图 */
      	public void getStatChart(IRequestCycle cycle) throws Exception {
      		PageData pd = getPageData();
      		
      		PieChart piechart = new PieChart();
      		piechart.setTitle("饼状图"); //设置标题
      	piechart.setWidth(600);//设置宽度,默认为400
      	piechart.setWidth(400);//设置高度,默认为300
      		/* 数据集 */
      		DefaultPieDataset piedataset = new DefaultPieDataset();
      		piedataset.setValue("苹果", 100);
      		piedataset.setValue("梨子", 200);
      		piedataset.setValue("葡萄", 300);
      		piedataset.setValue("香蕉", 400);
      		piedataset.setValue("荔枝", 500);
      		ChartManager.createPieChart(pd.getResponse(), piechart, piedataset);
      	}
      	/** 柱状图 */
      public void getStatChart(IRequestCycle cycle) throws Exception {
      	BarChart barchart = new BarChart();
      	barchart.setTitle("柱状图"); //设置标题
      	barchart.setHorizontalTitle("水果"); //设置横向标题
      	barchart.setVerticalTitle("产量"); //设置纵向标题
      	barchart.setWidth(600);//设置宽度,默认为400
      	barchart.setWidth(400);//设置高度,默认为300
      	barchart.setCutline(false); //是否显示柱状图底下的图例说明,默认显示
      	/* 数据集 */
      	DefaultCategoryDataset bardataset = new DefaultCategoryDataset();
      	
      //单纬度柱状图
      bardataset.addValue(100, "", "苹果"); 
      	bardataset.addValue(200, "", "梨子");
      	bardataset.addValue(300, "", "葡萄");
      	bardataset.addValue(400, "", "香蕉");
      	bardataset.addValue(500, "", "荔枝");
      	…
      //多纬度柱状图
      	bardataset.addValue(100, "广东", "苹果");
      	bardataset.addValue(200, "上海", "苹果");
      bardataset.addValue(100, "广东", "梨子");
      	bardataset.addValue(200, "上海", "梨子");
      	…
      	ChartManager.createBarChart(pd.getResponse(), barchart, bardataset);
      }
      	/** 趋势图 */
      public void getStatChart(IRequestCycle cycle) throws Exception {
      	LineChart linechart = new LineChart();;
      	linechart.setTitle("趋势图"); //设置标题
      	linechart.setHorizontalTitle("季度"); //设置横向标题
      	linechart.setVerticalTitle("地区"); //设置纵向标题
      	linechart.setWidth(600);//设置宽度,默认为400
      	linechart.setWidth(400);//设置高度,默认为300
      	linechart.setCutline(false); //是否显示柱状图底下的图例说明,默认显示
      	/* 数据集 */
      	DefaultCategoryDataset bardataset = new DefaultCategoryDataset();
      	
      	//单曲线趋势图
      	bardataset.addValue(90, "", "湖南");
      	bardataset.addValue(80, "", "湖北");
      	bardataset.addValue(100, "", "河南");
      	bardataset.addValue(150, "", "河北");
      	
      	//多曲线趋势图
      	bardataset.addValue(90, "一季度", "湖南");
      	bardataset.addValue(80, "一季度", "湖北");
      	bardataset.addValue(100, "一季度", "河南");
      	bardataset.addValue(150, "一季度", "河北");
      	bardataset.addValue(105, "二季度", "湖南");
      	bardataset.addValue(90, "二季度", "湖北");
      	bardataset.addValue(110, "二季度", "河南");
      	bardataset.addValue(160, "二季度", "河北");
      	bardataset.addValue(155, "二季度", "湖南");
      	bardataset.addValue(190, "三季度", "湖北");
      	bardataset.addValue(150, "三季度", "河南");
      	bardataset.addValue(120, "三季度", "河北");
      	bardataset.addValue(75, "四季度", "湖南");
      	bardataset.addValue(80, "四季度", "湖北");
      	bardataset.addValue(120, "四季度", "河南");
      	bardataset.addValue(180, "四季度", "河北");
      	
      	ChartManager.createLineChart(pd.getResponse(), linechart, bardataset);
       }
      
      说明: 对于unix/linux机器上部署的应用无法显示图片的问题,需要在java命令中加上-Dheadless=true,如:java … -Dheadless=true