`
编程足球
  • 浏览: 249853 次
  • 性别: Icon_minigender_1
  • 来自: 福州
社区版块
存档分类
最新评论

报表 Openchart2

阅读更多
1. 简介
Openchart2 is a full-featured 2D plotting solution for Java applications.

Graph Types
Openchart2 supports a variety of chart types, including:

1. Bar Charts - including Stacked Bar Charts
2. Pie Charts
3. Radar Charts
4. Scatter Plots - including Line Charts, Point Charts, or combinations
5. Dot Plots - for the visualization of (x,y,z) data

The Openchart2 rendering system allows multiple types of plots to be drawn on the same view, enabling unlike graphs to appear together.

Simple Data Passing
Openchart2 allows for a variety of techniques to be used for passing data into the plotting routines.  Simple arrays or full database sources can provide data to the plotting routines.

Dynamic Zooming
All chart types support dynamic zooming.  Sample Swing chart panels are provided in the library with complete mouse-controlled dynamic zoom implemented for ease of use.
上面信息来源于官网http://approximatrix.com/products/openchart2/features

2.例子

1. BarChart
package com.Openchart2;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JMenuBar;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import com.approximatrix.charting.model.ObjectChartDataModel;
import com.approximatrix.charting.model.ChartDataModel;
import com.approximatrix.charting.swing.ChartPanel;
import com.approximatrix.charting.render.BarChartRenderer;
import com.approximatrix.charting.render.PieChartRenderer;
import com.approximatrix.charting.CoordSystem;

public class BarChart extends JDialog implements ActionListener {
	private static final long serialVersionUID = 1L;

	/** 每个bar对应的label */
	String[] names = {"aaa","bbb","ccc"};
	
	/** 每个bar对应的值 */
	double[] values = {10.0,30.0,60.0};
	
	/** Initializes the dialog and its chart in a ChartPanel dialog */
	@SuppressWarnings("deprecation")
	public BarChart() {
		super();
		
//		对这个dialog进行初始化
		this.setTitle("Bar 的例子");
		this.setSize(500, 400);
		this.setResizable(true);
		
		JPanel contentPane = new JPanel();
		contentPane.setLayout(new BorderLayout());
		this.setContentPane(contentPane);
		
		// 定义当点击x的时候窗口是Hide还是Destroy
		this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
		
		/**
		 * 初始化必要的数据 存放在二维数组中
		 * data[0][i]	每个系列的数(就像这次结果的one   two   three   four 四个系列)
		 * data[i][0]	每个系列中具体的值    和 name进行一一对应
		 * 
		 * eg:
		 * 	data[0][0]   data[1][0]   data[2][0]	都是names[0] 的值
		 * 	data[0][1]   data[1][1]   data[2][1]	都是names[1] 的值
		 * 
		 * 
		 * 	data[0][0]   data[0][1]   data[0][2]	都是series_names[0]一组中的数据
		 * 	data[1][0]   data[1][1]   data[1][2]	都是series_names[1]一组中的数据
		 * 
		 * 
		 */
		Double[][] data = new Double[values.length][names.length];
		for(int i=0;i<values.length;i++) {
			for (int j = 0; j < names.length; j++) {
				data[i][j] = new Double(values[i]);
			}
		}
		// We need to pass a title for this series as well
		String[] series_names = {"one","two","three","four"};
		
		// 根据传递的数据 创建ChartDataModel 数据模型
		ChartDataModel model = new ObjectChartDataModel(data, names, series_names); 
		
		// 根据对象模型创建坐标系统
		CoordSystem coord = new CoordSystem(model);
		
		// 创建一个默认的图形面板
		ChartPanel chart_panel = new ChartPanel(model,"Openchart2 图形测试");
		
		// 设置图形面板的坐标
		chart_panel.setCoordSystem(coord);
		
		// 指定要生成的图形BarChartRenderer 还是 PieChartRenderer 等等..
		chart_panel.addChartRenderer(new BarChartRenderer(coord,model), 0);
//		chart_panel.addChartRenderer(new PieChartRenderer(coord,model),0);
		// 定义位置
		contentPane.add(chart_panel,BorderLayout.CENTER);
		
		model.setManualScale(true);
		model.setMinimumValue(new Double(0.0));
		model.setMaximumValue(new Double(100.0));
		
	}
	
	/**
	 * mian 函数
	 * @param args
	 */
	public static void main(String[] args) {
		BarChart temp = new BarChart();
		temp.setVisible(true);
	}

	/**
	 * 事件监听
	 */
	public void actionPerformed(ActionEvent e) {
		
	}
}



结果如图:


2. PieChart
package com.Openchart2;
import javax.swing.JApplet;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;

import com.approximatrix.charting.DefaultChart;
import com.approximatrix.charting.CoordSystem;
import com.approximatrix.charting.model.ObjectChartDataModel;
import com.approximatrix.charting.render.PieChartRenderer;

public class PieChart extends JApplet {

	// 定义char的基本数据
	private static final long serialVersionUID = 1L;
	private static final String[] markDate = {"one","Two","Three","Four","Five","Six"};
	private static final int[] amount = {10,20,30, 40,50,60};
	DefaultChart chart = null;
	
	/** Constructor for our pie chart applet
	 * 
	 */
	@SuppressWarnings("deprecation")
	public PieChart() {
		int data[][] = new int[amount.length][1];
		for(int i=0;i<amount.length;i++) {
			data[i][0] = amount[i];
		}
		
//		暂时无作用,仅仅初始化模型时候会用到	x轴坐标值
		String[] column_id = {"column1","column2"};
		
//		创建一个数据模型
//		data - 		the array of values. The first index specifies the datasets, 
//					the last one is the value index.
//		columns - 	the array of x-axis values. The length of the datasets and 
//					the length of the column should be equal and the columns should be ordered.
//		rows - 		the DataSet titles	每个date对应的titles
		ObjectChartDataModel model = new ObjectChartDataModel(data, column_id, markDate);
		
//		model - the ChartDataModel	数据模型
//		title - the title String	标题
		chart = new DefaultChart(model,"饼状图例子");
		
//		根据数据模型创建一个饼状图
//		model - the DataModel that should be rendered
		PieChartRenderer renderer = new PieChartRenderer(model);
		
//		render - the ChartRenderer
//		z - the z-coordinate, the highest coordinate is in front.
		chart.addChartRenderer(renderer, 0);
		
		// A coordinate system is necessary for any chart, regardless of type.  A pie chart,
		// however, really doesn't need to use one.  After creating the default CoordSystem
		// object, turn off all axis drawing since we don't need to see the axes.
		CoordSystem coord = new CoordSystem(model);
		coord.setPaintAxes(true);	// 是否显示x-y轴坐标
		chart.setCoordSystem(coord);
		
		// Our graph is now constructed
	}
	
	/** Override the paint routine to draw the graph
	*/
	public void paint(Graphics g) {
		super.paint(g);
		chart.setBounds(new Rectangle(this.getWidth(), this.getHeight()));
        chart.render((Graphics2D)g);
	} 
}


分享到:
评论

相关推荐

    Open Flash Chart 报表插件相关

    使用ofc进行图形报表的生成。 内涵多种开发语言和demo.

    Open Flash Chart2 相关资料

    1.Open Flash Chart2官网最后版本; 2.Open Flash Chart2非官方后续开发最新版本; 3.Open Flash Chart2 Java中所需的扩展Jofc2最新版本; 4.Open Flash Chart2的基础入门教程。 (压缩包中的jofc版本可能有点旧,...

    Open Flash Chart的应用(java),就是很炫的报表了

    这里面有两个java代码工程和 Open Flash Chart API。工程都是调试过的直接导入可用,代码都有详细的注释,如果你真是想用到报表之类的东西,肯定很不错了。 工程所需的jar 包 js文件都有,基本上很全。 第一步:...

    open-flash-chart2

    DEMO:VS2010 ASP.NET MVC3.0 包含了多种图形报表:竖柱、横柱、曲线、网状、块状、混合(竖柱+曲线) ...对open-flash-chart源码做了一些优化:主要针对横柱,可以对每条柱设置颜色和显示值,鼠标悬停优化等...

    open flash chart 2.0

    OpenFlashChart是一个开源的报表制作组件,该组件能够自动生成一个好看的、动态的flash报表; 该组件使用flash展示报表能够很好的做到与浏览器进行集成,目前浏览器基本都能很好的支持flash; 该组件还支持一些简单...

    Open Flash Chart例子、中文版PDF说明文档、参数表

    Open Flash Chart(简称OFC),是一个开源的flash报表组件。我们不仅可以免费使用,而且还可以修改源码,来达到我们想要的效果。客户端在得到数据以后,在Flash Player中渲染出报表图。  附带PDF说明文档,是中文版...

    open flash chart 1.9.7

    open flash chart 1.9.7 是一个免费的 快捷的网络报表设计工具 很好用

    Web Chart 极品web报表控件收集Web+Chart

    Open Flash Chart - Open Flash Chart 是一个 Flash 图表组件,很容易安装,提供以下语言的API: PHP, Perl, Python, Java, Ruby on Rails, and .Net 来控制图表。 ? AmCharts - AmCharts 是一个动画交互Flash图表...

    open-flash-chart2使用总结

    通过flash展示各种各样的动态报表 效果相当不错!!

    open flash chart 制图Demo及文档

    demo 导入开发工具部署至WEB服务器即可看到展示绚丽报表制图效果

    open-flash-chart-1[1].9.7.zip_flash chart tr_open flash chart

    flash 报表的源码,不亚于Jfreechart

    flex用openflashchart制作图表报表

    NULL 博文链接:https://67566894.iteye.com/blog/715118

    open flash char2 操作文当

    Open flash chart 简称OFC,是一个开源的flash报表组件。我们不仅可以免费使用,而且还可以修改源代码,来达到我们想要的效果。客户端在得到数据以后,在Flash Player中渲染出报表图。 目前通用的OFC版本为2 Lug ...

    OPEN FLASH CHART

    OpenFlashChart是一个开源的报表制作组件,该组件能够自动生成一个好看的、动态的flash报表;该组件使用flash展示报表能够很好的做到与浏览器进行集成,目前浏览器基本都能很好的支持flash;该组件还支持一些简单的...

    FlashChart技术研究

    Open Flash Chart组件的使用 简介 OpenFlashChart是一个开源的报表制作组件,该组件能够自动生成一个好看的、动态的flash报表;该组件使用flash展示报表能够很好的做到与浏览器进行集成,目前浏览器基本都能很好的...

    a-small-project.zip_open

    利用open flash chart 创建报表

    Chart 极品web报表控件收集(Flot,AmCharts, Emprise JavaScript Charts...)

    Open Flash Chart - Open Flash Chart 是一个 Flash 图表组件,很容易安装,提供以下语言的API: PHP, Perl, Python, Java, Ruby on Rails, and .Net 来控制图表。 • AmCharts - AmCharts 是一个动画交互Flash...

    funsionchart 的demo,包括funsionchart的通用类和dom4j的通用类

    flash报表中,比较出名的有以下三个,open flash chart(OFC),amcharts, funsionchart,OFC开源,但是感觉没其他两个漂亮。amcahrts感觉太复杂,功能太强一般都用不到。funsionchart,分为免费版和商业版,一般免费版...

    JavaScript图表框架比较

    详细比较了Fusion Chart,Flot,Highcharts,Open flash chart几个js图形框架的优缺点。

Global site tag (gtag.js) - Google Analytics