Java图形模式,jfreechart


public class App {

public static void main(String[] args) throws Exception {
//
String title = "各大公司JEE AS市场占有率统计" ;
DefaultPieDataset ds = new DefaultPieDataset();
ds.setValue("IBM", 2000);
ds.setValue("ORACLE", 3500);
ds.setValue("JBOSS", 1570);
ds.setValue("用友", 4400);
JFreeChart chart = ChartFactory.createPieChart3D(title, ds, true, false, false);

//中文
chart.getTitle().setFont(new Font("宋体", Font.BOLD, 25));//标题字体
chart.getLegend().setItemFont(new Font("宋体", Font.PLAIN, 18));

//绘图区
PiePlot plot = (PiePlot) chart.getPlot();
plot.setLabelFont(new Font("宋体", Font.PLAIN, 15));

//背景
//chart.setBackgroundImage(ImageIO.read(new File("f:/sunset.jpg")));//图表区背景
//plot.setBackgroundImage(ImageIO.read(new File("f:/water.jpg")));

//设置分裂效果
plot.setExplodePercent("IBM", 0.1f);
plot.setExplodePercent("JBOSS", 0.2f);

//设置前景色透明度
plot.setForegroundAlpha(0.7f);

//设置标签生成器
//{0}:公司名称
//{1}:销量
//{2}:百分比
//{3}:总量
//{4}:
plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}({1}/{3}-{2})"));
ChartUtilities.saveChartAsJPEG(new File("f:\\pie.jpg"), chart, 800, 500);
}
}


public class AppBar {

public static void main(String[] args) throws Exception {
DefaultCategoryDataset ds = new DefaultCategoryDataset();
ds.addValue(2000, "IBM", "一季度");
ds.addValue(2300, "ORACLE", "一季度");
ds.addValue(2800, "JBOSS", "一季度");
ds.addValue(3300, "用友", "一季度");

ds.addValue(4800, "IBM", "二季度");
ds.addValue(4300, "ORACLE", "二季度");
ds.addValue(3200, "JBOSS", "二季度");
ds.addValue(1800, "用友", "二季度");

ds.addValue(1500, "IBM", "三季度");
ds.addValue(2600, "ORACLE", "三季度");
ds.addValue(3900, "JBOSS", "三季度");
ds.addValue(2100, "用友", "三季度");

String title = "前三季度各大公司JEE AS销量统计" ;
JFreeChart chart = ChartFactory.createBarChart3D(title, "季度", "销量(单位:万台)", ds, PlotOrientation.VERTICAL, true, false, false);

//中文
chart.getTitle().setFont(new Font("宋体", Font.BOLD, 25));//大标题

//提示条
chart.getLegend().setItemFont(new Font("宋体", Font.BOLD, 15));

CategoryPlot plot = (CategoryPlot) chart.getPlot();
//域轴字体
plot.getDomainAxis().setLabelFont(new Font("宋体", Font.BOLD, 18));
plot.getDomainAxis().setTickLabelFont(new Font("宋体", Font.PLAIN, 15));//小标签字体

//range
plot.getRangeAxis().setLabelFont(new Font("宋体", Font.BOLD, 15));

plot.setForegroundAlpha(0.6f);

ChartUtilities.saveChartAsJPEG(new File("f:\\bar.jpg"), chart, 800, 500);
}
}


public class AppLine {

public static void main(String[] args) throws Exception {
DefaultCategoryDataset ds = new DefaultCategoryDataset();
ds.addValue(2000, "IBM", "一季度");
ds.addValue(2300, "ORACLE", "一季度");
ds.addValue(2800, "JBOSS", "一季度");
ds.addValue(3300, "用友", "一季度");

ds.addValue(4800, "IBM", "二季度");
ds.addValue(4300, "ORACLE", "二季度");
ds.addValue(3200, "JBOSS", "二季度");
ds.addValue(1800, "用友", "二季度");

ds.addValue(1500, "IBM", "三季度");
ds.addValue(2600, "ORACLE", "三季度");
ds.addValue(3900, "JBOSS", "三季度");
ds.addValue(2100, "用友", "三季度");

String title = "前三季度各大公司JEE AS销量统计" ;
JFreeChart chart = ChartFactory.createLineChart(title, "季度", "销量(单位:万台)", ds, PlotOrientation.VERTICAL, true, false, false);

//中文
chart.getTitle().setFont(new Font("宋体", Font.BOLD, 25));//大标题

//提示条
chart.getLegend().setItemFont(new Font("宋体", Font.BOLD, 15));

CategoryPlot plot = (CategoryPlot) chart.getPlot();
//域轴字体
plot.getDomainAxis().setLabelFont(new Font("宋体", Font.BOLD, 18));
plot.getDomainAxis().setTickLabelFont(new Font("宋体", Font.PLAIN, 15));//小标签字体

//range
plot.getRangeAxis().setLabelFont(new Font("宋体", Font.BOLD, 15));

plot.setForegroundAlpha(0.6f);

ChartUtilities.saveChartAsJPEG(new File("f:\\line.jpg"), chart, 800, 500);
}
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值