erticalBarChart3D
(strTitle, strCatTitle, strValTitle, categoryData, true);
break;
}
case 10:
{
//3D垂直条状图
chart = ChartFactory.createVerticalBarChart3D
(strTitle, strCatTitle, strValTitle, categoryData, true);
break;
}
}
// 设置合适的颜色
setupChart();
}
用Java从XML文件中获取业务图表(4)
时间:2010-12-06
代码段3
private CategoryDataset createDataset()
{
int lp,nCurrent;
String strXPath;
String strVal;
Vector[] victor= new Vector[nDataXPathCount];
//装载数据
try{
for(lp=0;lp<nDataXPathCount;lp++)
{
victor[lp] = new Vector();
strXPath = strDataXPaths.elementAt(lp).toString();
niNodeList = XPathAPI.selectNodeIterator(xmlData,strXPath);
elemItem = (Element) niNodeList.nextNode();
do{
if(elemItem.getFirstChild()!=null)
{
strVal = elemItem.getFirstChild().getNodeValue();
victor[lp].add(strVal);
}
elemItem = (Element) niNodeList.nextNode();
} while(elemItem!=null);
}
Double[][] nData = new Double[nDataXPathCount][victor[0].size()];
for(lp=0;lp<nDataXPathCount;lp++)
{
for(nCurrent=0;nCurrent<victor[0].size();nCurrent++)
{
try{
nData[lp][nCurrent] = new Double(victor[lp].elementAt
(nCurrent).toString());
}
catch (Exception e){
nData[lp][nCurrent] = new Double(0);
}
}
}
//装载类别
Vector vCategories = new Vector();
strXPath = strCategoryXPaths.elementAt(0).toString();
niNodeList = XPathAPI.selectNodeIterator(xmlData,strXPath);
elemItem = (Element) niNodeList.nextNode();
for(lp=0;lp<victor[0].size();lp++)
{
strVal = elemItem.getFirstChild().getNodeValue();
vCategories.add(strVal);
elemItem = (Element) niNodeList.nextNode();
}
DefaultCategoryDataset dSet = new DefaultCategoryDataset(nData);
// 装载系列标题
String[] strT = new String[strSTitles.size()];
for(lp=1;lp<=strSTitles.size();lp++)
{
strT[lp-1] = strSTitles.elementAt(lp-1).toString();
}
dSet.setSeriesNames(strT);
dSet.setCategories(vCategories.toArray());
return dSet;
}
catch (Exception e)
{
e.printStackTrace();
}
Double[][] nData = new Double[][]{{new Double(0)},{new Double(0)}};
return new DefaultCategoryDataset(nData);
}
用Java从XML文件中获取业务图表(5)
时间:2010-12-06
代码段4 BizCharter.java
import java.io.*;
import java.util.*;
import java.net.*;
import java.awt.Color;
import java.awt.Paint;
import java.awt.GradientPaint;
import javax.servlet.*;
import javax.servlet.http.*;
import com.jrefinery.chart.PiePlot;
import com.jrefinery.chart.JFreeChart;
import com.jrefinery.chart.ChartFactory;
import com.jrefinery.chart.ChartUtilities;
import com.jrefinery.chart.Plot;
import com.jrefinery.chart.CategoryPlot;
import com.jrefinery.chart.XYPlot;
import com.jrefinery.chart.Axis;
import com.jrefinery.chart.HorizontalCategoryAxis;
import com.jrefinery.chart.NumberAxis;
import com.jrefinery.chart.VerticalNumberAxis;
import com.jrefinery.chart.data.PlotFit;
import com.jrefinery.chart.data.LinearPlotFitAlgorithm;
import com.jrefinery.chart.data.MovingAveragePlotFitAlgorithm;
import com.jrefinery.data.CategoryDataset;
import com.jrefinery.data.DefaultCategoryData
|