Jfreechart 饼图 和 曲线
来源:互联网 发布:中国自大 知乎 编辑:程序博客网 时间:2024/05/01 02:32
饼图:
class BChart{
public static void main(String[] args){
PieDataset dataset = getDataSet();//设置数据源
JFreeChart chart = ChartFactory.createPieChart3D(
"时延分布统计图", // chart title
dataset,// data
true,// include legend
true,
false
);
PiePlot3D plot=(PiePlot3D)chart.getPlot();
// 图片中显示百分比:默认方式
//plot.setLabelGenerator(new StandardPieSectionLabelGenerator(StandardPieToolTipGenerator.DEFAULT_TOOLTIP_FORMAT));
// 图片中显示百分比:自定义方式,{0} 表示选项, {1} 表示数值, {2} 表示所占比例 ,小数点后两位
plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}={1}({2})", NumberFormat.getNumberInstance(), new DecimalFormat("0.00%")));
// 图例显示百分比:自定义方式, {0} 表示选项, {1} 表示数值, {2} 表示所占比例
plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator("{0}={1}({2})"));
// 设置背景色为白色
chart.setBackgroundPaint(Color.white);
// 指定图片的透明度(0.0-1.0)
plot.setForegroundAlpha(1.0f);
// 指定显示的饼图上圆形(false)还椭圆形(true)
plot.setCircular(true);
// 设置图标题的字体
Font font = new Font(" 黑体",Font.CENTER_BASELINE,20);
TextTitle title = new TextTitle(" 时延分布统计图");
title.setFont(font);
chart.setTitle(title);
FileOutputStream fos_jpg = null;
try {
fos_jpg=new FileOutputStream("D://时延分布统计图.jpg");
ChartUtilities.writeChartAsJPEG(fos_jpg,100,chart,640,480,null);
fos_jpg.close();
} catch (Exception e) {
}
}
private static PieDataset getDataSet()//数据源构造
{
DefaultPieDataset dataset = new DefaultPieDataset();
dataset.setValue("login.jsp",50);
dataset.setValue("reg.jsp",60);
return dataset;
}
}
曲线:
class ZChart{
public static void main(String[] args)
{
JFreeChart chart = ChartFactory.createXYLineChart("固定uri时延分布图", "历次访问点",
"时延/ms", createDataSet(special), PlotOrientation.VERTICAL, true,
true, false);
FileOutputStream fos_jpg = null;
try {
fos_jpg=new FileOutputStream("D://mao.jpg");
ChartUtilities.writeChartAsJPEG(fos_jpg,100,chart,640,480,null);
fos_jpg.close();
} catch (Exception e) {
}
}
private static XYSeriesCollection createDataSet() {//数据源构造方法
XYSeriesCollection seriesCollection = new XYSeriesCollection();
XYSeries series1 = new XYSeries("login.jsp");
seriesCollection.addSeries(series1);
series1.add(1, 75);
series1.add(2, 41);
series1.add(3, 39);
series1.add(4, 33);
series1.add(5, 25);
series1.add(6, 36);
seriesCollection.addSeries(series1);
return seriesCollection;
}
}
- Jfreechart 饼图 和 曲线
- JFreeChart曲线
- JFreeChart实时曲线
- JFreeChart开发:利用JFreeChart开发实时曲线
- jfreechart时间类型的曲线
- JFreeChart 一个曲线的实例
- JFreeChart设置曲线颜色方法
- applet + JfreeChart 实现曲线走势图(转)
- JFreeChart---饼图
- JFreeChart饼图
- 学习曲线和遗忘曲线
- jfreechart+sql实现时间曲线图(显示曲线数据点)
- 用JFreeChart绘制光滑曲线(二) 简单实现
- 使用JFreeChart在网页上绘制平滑曲线
- 使用 jfreechart 生成 曲线、柱状图、饼状图、分布图 展示到JSP
- JfreeChart实现数据的实时动态曲线显示
- 使用 jfreechart 生成 曲线、柱状图、饼状图、分布图 展示到JSP
- Swing中嵌入动态曲线,动态图形:JFreeChart API一览
- 帝国CMS/ECMS V6.0 数据字典/数据表参考手册(已发布 在线版本 HTML多文件下载版本)
- 让虚拟机软件能支持USB设备启动
- 2010/07/22
- sql 执行语句性能测试
- Apache2 支持 https (ubuntu10.04)
- Jfreechart 饼图 和 曲线
- CPS模式是如何降低网络营销投入的?
- 设计模式之单例模式
- 小议procedure
- oracle 汉字转拼音
- Relocation the generic ELF 问题
- SQL学习 NO1
- 好系统应具有的特性
- 分析器错误信息: 未能加载类型"命名空间.类"... ---小结