JFreeChart Demo窗体示例

本示例展示了一个使用Java和JFreeChart库创建多种类型图表的应用程序。该程序通过不同的图表生成器方法创建了包括柱状图、饼图、折线图等多种图表,并将它们展示在一个图形界面上。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Image;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import org.jfree.chart.JFreeChart;
 
/** */
public class ChartFrame extends JFrame {
 
 
public ChartFrame(){
  
this.setBounds((int)((1024 - 800/ 2), (int)((768 - 600/ 2), 800600);
  
this.setTitle("JFreeChart Demo");
  
  JFreeChart Chart 
= null;
  
//  Chart = ChartCreater.createCategoryChart();
//  Chart = ChartCreater.createCategoryChart3D();
//  Chart = ChartCreater.createBarChart();
//  Chart = ChartCreater.createBarChart3D();
//  Chart = ChartCreater.createAreaChart();
//  Chart = ChartCreater.createHistogram();
//  Chart = ChartCreater.createLintChart();
//  Chart = ChartCreater.createLintChart3D();
//  Chart = ChartCreater.createMultiplePieChart();
//  Chart = ChartCreater.createMultiplePieChart3D();
//  Chart = ChartCreater.createPieChart();
  Chart = ChartCreater.createPieChart3D();
//  Chart = ChartCreater.createRingChart();
//  Chart = ChartCreater.createScatterPlot();
//  Chart = ChartCreater.createBubbleChart();
//  Chart = ChartCreater.createCandlestickChart();
//  Chart = ChartCreater.createCombinedChart();
//  Chart = ChartCreater.createGanttChart();
//  Chart = ChartCreater.createHighLowChart();
//  Chart = ChartCreater.createStackedAreaChart();
//  Chart = ChartCreater.createStackedBarChart();
//  Chart = ChartCreater.createStackedBarChart3D();
//  Chart = ChartCreater.createStackedCategoryChart();
//  Chart = ChartCreater.createStackedCategoryChart3D();
//  Chart = ChartCreater.createStackedXYAreaChart();
//  Chart = ChartCreater.createWaterfallChart();
//  Chart = ChartCreater.createXYAreaChart();  
//  Chart = ChartCreater.createXYBarChart();
//  Chart = ChartCreater.createXYLineChart();
//  Chart = ChartCreater.createXYStepAreaChart();
//  Chart = ChartCreater.createXYStepChart();
  
  Chart.getPlot().setBackgroundAlpha(
1.0f);
  Chart.getPlot().setNoDataMessage(
"当前没有有效的数据");
  
  Image chart 
= Chart.createBufferedImage(700,500);
  
  JLabel label 
= new JLabel();
  
  label.setIcon(
new ImageIcon(chart)); 
  
  
  
this.getContentPane().add(label,BorderLayout.CENTER);  
  
 }

 
  
public static void main(String[] args){
   
new ChartFrame().setVisible(true);
  }
与数据集示例/图表生成示例可以组成完整Demo工程。
Java sdk 1.4.2 / Eclipse 3.1 / JFreeChart 1.0.2
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值