关于jfreechart做柱状图的问题?
为什么我用jfreechart做柱状图,最多只能显示5个数据?
请高手们帮忙!
代码如下:
package jfreecharttest;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import org.jfree.data.category.*;
import org.jfree.chart.*;
import org.jfree.data.*;
import org.jfree.chart.plot.*;
public class CategoryServlet extends HttpServlet {
private static final String CONTENT_TYPE = "text/html; charset=GBK ";
//Initialize global variables
public void init() throws
ServletException {
}
//Process the HTTP Get request
public void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException,
IOException {
response.setContentType( "image/jpeg ");
response.reset();
CategoryDataset data=getDataSet();
JFreeChart chart=ChartFactory.createBarChart( "aaa ", "bbb ", "ccc ",data,PlotOrientation.VERTICAL,true,false,false);
ChartUtilities.writeChartAsJPEG(response.getOutputStream(),1,chart,1024,600,null);
}
//Process the HTTP Post request
public void doPost(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
doGet(request, response);
}
private static CategoryDataset getDataSet2() {
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.addValue(100, "北京 ", "苹果 ");
dataset.addValue(300, "上海 ", "苹果 ");
dataset.addValue(150, "广州 ", "苹果 ");