JFreechart 学习笔记 二

比较难懂的英文词

domain axis : 域轴

range axis  : 范围轴,值轴

renderer : 渲染

chart :图表

horizontal 横向

vertical 纵向

plot 图表(JFreechart中设置图表对象的各种类型的属性值)

Legend 推测可能是下面类型的对象.

核心类:

 

1.       org.jfree.chart.JFreeChart :图表对象,任何类型的图表的最终表现形式都是在该对象进行一些属性的定制。JFreeChart引擎本身提供了一个工厂类用于创建不同类型的图表对象.

   

 

2.       org.jfree.data.category.XXXDataSet : 数据集对象,用于提供显示图表所用的数据。根据不同类型的图表对应着很多类型的数据集对象类.

 

3.       org.jfree.chart.plot.XXXPlot图表区域对象,基本上这个对象决定着什么样式的图表,创建该对象的时候需要AxisRenderer以及数据集对象的支持

比如:生成的是柱状图:

CategoryPlot plot = chart.getCategoryPlot();

        生成的是饼状图:

                     PiePlot plot = (PiePlot)a.getPlot();

      然后用plot对象去取得该显示对象的属性.

 

 

4.       org.jfree.chart.axis.XXXAxis用于处理图表的两个轴:纵轴(RangeAxis)和横轴(DomainAxis)

 

5.       org.jfree.chart.render.XXXRender负责如何显示一个图表对象

6.       org.jfree.chart.urls.XXXURLGenerator:用于生成Web图表中每个项目的鼠标点击链接

7.       XXXXXToolTipGenerator:用于生成图象的帮助提示,不同类型图表对应不同类型的工具提示类.

 

8. Class TimeSeries: Represents a sequence of zero or more data items in the form (period, value) where 'period' is some instance of a subclass of RegularTimePeriod. The time series will ensure that (a) all data items have the same type of period (for example, Day) and (b) that each period appears at most one time in the series. (//时间序列对象,第一个参数表示时间序列的名字,第二个参数是时间类型.原文意思是,0个或者多个在表单中的数据项, form(period, value)组成, periodRegularTimePeriod的子类的实例组成,时间序列确定(a)所有的数据项必须有相同的类型,并且每一个类型在序列中出现最多一次)

9. Class TimeSeriesCollection: A collection of time series objects. This class implements the XYDataset interface, as well as the extended IntervalXYDataset interface. This makes it a convenient dataset for use with the XYPlot class. 时间序列对象的集合类.这个类继承了XYDataset接口, IntervalXYDataset接口.使得XYPlot可以很方便的调用这个数据集.

 

10 . Class Plot : The base class for all plots in JFreeChart. The JFreeChart class delegates the drawing of axes and data to the plot. This base class provides facilities common to most plot types. (JFreeChart的所有类型plot的基础类, 这个类表示了The JFreeChart class的轴和数据对象,这个类提供了大部分plot的类型)

setURLGenerator(PieURLGenerator generator)
         
 Sets the URL generator and sends a PlotChangeEvent to all registered listeners. 设置url对象,并且发送一个plot改变时间给所有注册了的监听器

interface PieURLGenerator

Interface for a URL generator for plots that use data from a PieDataset. Classes that implement this interface: (为一个PieDataset的数据对象添加一个url)

  • are responsible for correctly escaping any text that is derived from the dataset, as this may be user-specified and could pose a security risk; (这个类负责转义来自dateset的文字,这些文字是用户指定的并带有一定风险)
  • should be either (a) immutable, or (b) cloneable via the PublicCloneable interface (defined in the JCommon class library). This provides a mechanism for the referring plot to clone the generator if necessary. (提供了一个机制在必要的情况下填满plot去克隆发生器)

 

 

 

 

 

 

首先得到数据集(对于柱状图):

(C)DefaultCategoryDataset :A default implementation of the CategoryDataset interface. CategoryDataset这个接口的默认实现)

(I) CategoryDataset:  The interface for a dataset with one or more series, and values associated with categories. The categories are represented by Comparable instance, with the category label being provided by the toString method.

                     (这个接口关系到Category的类型和值, The categories提供了toString 方法来显示可比的实例)

void

addValue(double value, java.lang.Comparable rowKey, java.lang.Comparable columnKey)
          Adds a value to the table.

 void

addValue(java.lang.Number value, java.lang.Comparable rowKey, java.lang.Comparable columnKey)
          Adds a value to the table.

dataset.addValue(300, "广州", "苹果")

dataset.addValue(400, "北京", "苹果")

 

第一个参数,是比较对象的数量,

第二个参数,lable ,是比较不同对象还是比较同一个对象的数量

第三个参数,domain,是对象要比较的参数.

static JFreeChart

createBarChart3D(java.lang.String title, java.lang.String categoryAxisLabel, java.lang.String valueAxisLabel, CategoryDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls)
          Creates a bar chart with a 3D effect.

JFreeChart chart = ChartFactory.createBarChart3D(

              "水果产量图", // 图表标题

              "水果", // 目录轴的显示标签categoryAxisLabel, (分类的标签)

              "产量", // 数值轴的显示标签valueAxisLabel(range轴的标签)

              dataset, // 数据集

              PlotOrientation.VERTICAL, // 图表方向:水平、垂直

//PlotOrientation orientation, the plot orientation (horizontal 横向or vertical 纵向)  not permitted).代表你生成图表是水平的还是横向的表

              true, // 是否显示图例(对于简单的柱状图必须是false)

              false, // 是否生成工具

              false // 是否生成URL链接

                         );

 

 org.jfree.chart.JFreeChart:图表对象,任何类型的图表的最终表现形式都是在该对象进行一些属性的定制。JFreeChart引擎本身提供了一个工厂类用于创建不同类型的图表对象

 org.jfree.data.category.CategoryDataset:数据集对象,用于提供显示图表所用的数据。根据不同类型的图表对应着很多类型的数据集对象类

 org.jfree.chart.plot.CategoryPlot:图表区域对象,基本上这个对象决定着什么样式的图表,创建该对象的时候需要AxisRenderer以及数据集对象的支持

 org.jfree.chart.axis.CategoryAxis:用于处理图表的两个轴:纵轴和横轴

 org.jfree.chart.render.CategoryRender:负责如何显示一个图表对象 (针对图形)

 org.jfree.chart.urls.CategoryURLGenerator:用于生成Web图表中每个项目的鼠标点击链接

 CategoryToolTipGenerator:用于生成图象的帮助提示,不同类型图表对应不同类型的工具提示类

 org.jfree.chart.axis.ValueAxis:用于处理图表中的柱

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值