JFreeChart chart = ChartFactory.createVerticalBarChart3D
dataset,true,true,false);chart.setBackgroundPaint(new GradientPaint(0.0F, 0.0F, Color.white, 1000F, 0.0F, Color.red));
chart.setTitle(new TextTitle(title, new Font("隶书", Font.ITALIC, 15)));Font font=new Font("黑体",Font.TRUETYPE_FONT, 12);
StandardLegend legend = (StandardLegend) chart.getLegend();
legend.setItemFont(font);CategoryPlot plot = (CategoryPlot)chart.getPlot();
plot.setForegroundAlpha(0.9F);
CategoryAxis domain_axis = plot.getDomainAxis();
domain_axis.setTickLabelFont(font);ValueAxis value_axis=plot.getRangeAxis();
value_axis.setTickLabelFont(font);
dataset,true,true,false);chart.setBackgroundPaint(new GradientPaint(0.0F, 0.0F, Color.white, 1000F, 0.0F, Color.red));
chart.setTitle(new TextTitle(title, new Font("隶书", Font.ITALIC, 15)));Font font=new Font("黑体",Font.TRUETYPE_FONT, 12);
StandardLegend legend = (StandardLegend) chart.getLegend();
legend.setItemFont(font);CategoryPlot plot = (CategoryPlot)chart.getPlot();
plot.setForegroundAlpha(0.9F);
CategoryAxis domain_axis = plot.getDomainAxis();
domain_axis.setTickLabelFont(font);ValueAxis value_axis=plot.getRangeAxis();
value_axis.setTickLabelFont(font);
解决方案 »
- 求简单漂亮的二级树状菜单!!!
- jsp中从oracle数据库选择日期在t1与t2之间的where语句怎么写?
- 数据库连接池的问题,请高手解答~
- 如何找bug
- linux(Red Hat 9.0)下用组建JspSmartUpload上传文件中文显示为乱码,见到的方法都式了,但不起作用,高手求助呀!!
- java.lang.NoSuchFieldException: DEFAULT_PARAM如何处理
- 在javabean中,查询出来的多个字段的数据集,如何返回到jsp页面去?
- 不通过JDBC-ODBC来联接FOXPRO的驱动哪里有下!?
- 表单提交的问题!!
- 一个写好的servlet程序应该以什么后缀名保存,如何在IE中访问
- 结交jsp程序员,水平不限,有兴趣即可!
- 关于打印输出的一个问题,请大家多帮忙,多谢!!!
* Chart.java
*/
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator;
import java.util.Map;import org.jfree.chart.ChartColor;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartRenderingInfo;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.entity.StandardEntityCollection;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.renderer.VerticalBarRenderer;
import org.jfree.data.CategoryDataset;
import org.jfree.data.DatasetUtilities;
import org.jfree.data.DefaultKeyedValues;
public class Chart {
//图片文件的名字(用生成图片的日期和毫秒数值表示)
private String chartname;
//设置图片文件的部分名字(系统当时的毫秒数值)
private String partname;
/**
* @param map
* @return
* @throws IOException
*/
public String createChart(Map map) throws IOException {
//将map中的数据导入DefaultKeyedValues
DefaultKeyedValues kvs = new DefaultKeyedValues();
Iterator iterator = map.keySet().iterator();
while (iterator.hasNext()) {
String key = (String) iterator.next();
Double value = (Double) map.get(key);
kvs.addValue(key, value);
}
//创建CategoryDataset
CategoryDataset dataset = DatasetUtilities.createCategoryDataset("", kvs);
//创建JFreeChart
JFreeChart chart = ChartFactory.createVerticalBarChart3D("", // chart title
"", // domain axis label
"pageview", // range axis label
dataset, // data
false, // include legend
true, true);
//设置图片
CategoryPlot plot = chart.getCategoryPlot();
//显示数值在数据条柱上面
plot.setValueLabelsVisible(true); VerticalBarRenderer vbr = (VerticalBarRenderer) plot.getRenderer();
//设置数据条柱的颜色
vbr.setSeriesPaint(0, ChartColor.LIGHT_BLUE);
ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
//格式化日期
SimpleDateFormat DateFormat = new SimpleDateFormat("yyyyMMdd");
Date date = new Date();
String chartname = DateFormat.format(date) + "-" + partname;
File f=new File("."+ File.separator+ "webapps"+ File.separator + "weblog"+ File.separator+ "charts");
if(!f.exists())
new File("."+ File.separator+ "webapps"+ File.separator + "weblog"+ File.separator+ "charts").mkdirs();
//File file1 = new File("."+File.separator+"charts"+File.separator+chartname + ".png");
File file1 =
new File(
"."
+ File.separator
+ "webapps"
+ File.separator
+ "weblog"
+ File.separator
+ "charts"
+ File.separator
+ chartname
+ ".png");
//生成图片
ChartUtilities.saveChartAsPNG(file1, chart, 600, 400, info);
String file = "." + File.separator + "charts" + File.separator + chartname + ".png";
return file;
} /**
* @param string
*/
public void setPartname(String string) {
partname = string;
}}
祝好运!
请问把字符集拷贝到jdk下的哪个地方?是把他放到.jar文件里去吗?如果是的话,放到哪个包里呢?是不是要重新编译呢?我是个新手,请多指教,谢谢
[email protected]
我很想学习.