ChartDirector除了一个英文件的帮助以外也没有再提供JAVA DOC形式的文档为了方便写以下一个例子说明使用ChartDirector生成柱状图的方法jsp方式实质与JAVA方式没有区别这里是我从JSP中取的代码(JSP改起来方便不过手动) 代码如下: <%@ page language=java contentType=text/html; charset=UTF pageEncoding=UTF import=ChartDirector*;%> <% requestsetCharacterEncoding(UTF); //以两个系列数据为例 double[] data = { }; double[] data = { }; //数据列名 String[] labels = {一月 二月 三月 四月 五月}; //生成图片大小 x XYChart c = new XYChart( ); //图标题 caddTitle(第一个图); //支持中文 csetDefaultFonts(SIMSUNTTCf); //图表在图片中的定位及区域大小 csetPlotArea( ); //========================= //加入单个数据 //BarLayer layer = caddBarLayer(dataxff我的测试); //========================= //加入多个BAR数据(多个datasets) BarLayer layer = caddBarLayer(ChartSide ); layeraddDataSet(data xff 我测试); layeraddDataSet(data x 你也测); //d化 layersetD(); //设置BAR边框形式 layersetBarShape(); //bar宽度 layersetBarWidth(); //设置BAR边框颜色 //layersetBorderColor(xff); //图例形式 layersetLegend(); //每个BAR顶部加入数据显示 layersetAggregateLabelStyle(); //设置BAR底部的名称显示 TextBox t = cxAxis()setLabels(labels); //名称文字大小 tsetFontSize(); //加图例 //LegendBox legend = caddLegend( true); //legendaddKey(钱财xff); //图例位置 caddLegend( true); //output the chart String chartURL = cmakeSession(request chart); //include tool tip for the chart String imageMap = cgetHTMLImageMap(# title={xLabel}: US${value}K); %><!DOCTYPE HTML PUBLIC //WC//DTD HTML Transitional//EN> <html> <head> <meta httpequiv=ContentType content=text/html; charset=UTF> <title>图表测试</title> </head> <body> <h>中文</h> <hr color=#> <br> <img src=<%=responseencodeURL(getchartjsp?+chartURL)%> usemap=#map border=> <map name=map><%=imageMap%></map> </body> </html> |