溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

java中JFreeChart API有哪些

發(fā)布時間:2021-12-30 11:02:50 來源:億速云 閱讀:156 作者:小新 欄目:編程語言

小編給大家分享一下java中JFreeChart API有哪些,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!

JFreeChart目前是最好的java圖形解決方案,基本能夠解決目前的圖形方面的需求,主要包括如下幾個方面:

JFreeChart類:
void setAntiAlias(boolean flag)字體模糊邊界
void setBackgroundImage(Image image)背景圖片
void setBackgroundImageAlignment(int alignment)背景圖片對齊方式(參數(shù)常量在org.jfree.ui.Align類中定義)
void setBackgroundImageAlpha(float alpha)背景圖片透明度(0.0~1.0)
void setBackgroundPaint(Paint paint)背景色
void setBorderPaint(Paint paint)邊界線條顏色
void setBorderStroke(Stroke stroke)邊界線條筆觸
void setBorderVisible(boolean visible)邊界線條是否可見

TextTitle類:
void setFont(Font font)標(biāo)題字體
void setPaint(Paint paint)標(biāo)題字體顏色
void setText(String text)標(biāo)題內(nèi)容

StandardLegend(Legend)類:
void setBackgroundPaint(Paint paint)圖示背景色
void setTitle(String title)圖示標(biāo)題內(nèi)容
void setTitleFont(Font font)圖示標(biāo)題字體
void setBoundingBoxArcWidth(int arcWidth)圖示邊界圓角寬
void setBoundingBoxArcHeight(int arcHeight)圖示邊界圓角高
void setOutlinePaint(Paint paint)圖示邊界線條顏色
void setOutlineStroke(Stroke stroke)圖示邊界線條筆觸
void setDisplaySeriesLines(boolean flag)圖示項是否顯示橫線(折線圖有效)
void setDisplaySeriesShapes(boolean flag)圖示項是否顯示形狀(折線圖有效)
void setItemFont(Font font)圖示項字體
void setItemPaint(Paint paint)圖示項字體顏色
void setAnchor(int anchor)圖示在圖表中的顯示位置(參數(shù)常量在Legend類中定義)

Axis類:
void setVisible(boolean flag)坐標(biāo)軸是否可見
void setAxisLinePaint(Paint paint)坐標(biāo)軸線條顏色(3D軸無效)
void setAxisLineStroke(Stroke stroke)坐標(biāo)軸線條筆觸(3D軸無效)
void setAxisLineVisible(boolean visible)坐標(biāo)軸線條是否可見(3D軸無效)
void setFixedDimension(double dimension)(用于復(fù)合表中對多坐標(biāo)軸的設(shè)置)
void setLabel(String label)坐標(biāo)軸標(biāo)題
void setLabelFont(Font font)坐標(biāo)軸標(biāo)題字體
void setLabelPaint(Paint paint)坐標(biāo)軸標(biāo)題顏色
void setLabelAngle(double angle)`坐標(biāo)軸標(biāo)題旋轉(zhuǎn)角度(縱坐標(biāo)可以旋轉(zhuǎn))
void setTickLabelFont(Font font)坐標(biāo)軸標(biāo)尺值字體
void setTickLabelPaint(Paint paint)坐標(biāo)軸標(biāo)尺值顏色
void setTickLabelsVisible(boolean flag)坐標(biāo)軸標(biāo)尺值是否顯示
void setTickMarkPaint(Paint paint)坐標(biāo)軸標(biāo)尺顏色
void setTickMarkStroke(Stroke stroke)坐標(biāo)軸標(biāo)尺筆觸
void setTickMarksVisible(boolean flag)坐標(biāo)軸標(biāo)尺是否顯示

ValueAxis(Axis)類:
void setAutoRange(boolean auto)自動設(shè)置數(shù)據(jù)軸數(shù)據(jù)范圍
void setAutoRangeMinimumSize(double size)自動設(shè)置數(shù)據(jù)軸數(shù)據(jù)范圍時數(shù)據(jù)范圍的最小跨度
void setAutoTickUnitSelection(boolean flag)數(shù)據(jù)軸的數(shù)據(jù)標(biāo)簽是否自動確定(默認(rèn)為true)
void setFixedAutoRange(double length)數(shù)據(jù)軸固定數(shù)據(jù)范圍(設(shè)置100的話就是顯示MAXVALUE到MAXVALUE-100那段數(shù)據(jù)范圍)
void setInverted(boolean flag)數(shù)據(jù)軸是否反向(默認(rèn)為false)
void setLowerMargin(double margin)數(shù)據(jù)軸下(左)邊距
void setUpperMargin(double margin)數(shù)據(jù)軸上(右)邊距
void setLowerBound(double min)數(shù)據(jù)軸上的顯示最小值
void setUpperBound(double max)數(shù)據(jù)軸上的顯示最大值
void setPositiveArrowVisible(boolean visible)是否顯示正向箭頭(3D軸無效)
void setNegativeArrowVisible(boolean visible)是否顯示反向箭頭(3D軸無效)
void setVerticalTickLabels(boolean flag)數(shù)據(jù)軸數(shù)據(jù)標(biāo)簽是否旋轉(zhuǎn)到垂直
void setStandardTickUnits(TickUnitSource source)數(shù)據(jù)軸的數(shù)據(jù)標(biāo)簽(可以只顯示整數(shù)標(biāo)簽,需要將AutoTickUnitSelection設(shè)false)

NumberAxis(ValueAxis)類:
void setAutoRangeIncludesZero(boolean flag)是否強制在自動選擇的數(shù)據(jù)范圍中包含0
void setAutoRangeStickyZero(boolean flag)是否強制在整個數(shù)據(jù)軸中包含0,即使0不在數(shù)據(jù)范圍中
void setNumberFormatOverride(NumberFormat formatter)數(shù)據(jù)軸數(shù)據(jù)標(biāo)簽的顯示格式
void setTickUnit(NumberTickUnit unit)數(shù)據(jù)軸的數(shù)據(jù)標(biāo)簽(需要將AutoTickUnitSelection設(shè)false)

DateAxis(ValueAxis)類:
void setMaximumDate(Date maximumDate)日期軸上的最小日期
void setMinimumDate(Date minimumDate)日期軸上的最大日期
void setRange(Date lower,Date upper)日期軸范圍
void setDateFormatOverride(DateFormat formatter)日期軸日期標(biāo)簽的顯示格式
void setTickUnit(DateTickUnit unit)日期軸的日期標(biāo)簽(需要將AutoTickUnitSelection設(shè)false)
void setTickMarkPosition(DateTickMarkPosition position)日期標(biāo)簽位置(參數(shù)常量在org.jfree.chart.axis.DateTickMarkPosition類中定義)

CategoryAxis(Axis)類:
void setCategoryMargin(double margin)分類軸邊距
void setLowerMargin(double margin)分類軸下(左)邊距
void setUpperMargin(double margin)分類軸上(右)邊距
void setVerticalCategoryLabels(boolean flag)分類軸標(biāo)題是否旋轉(zhuǎn)到垂直
void setMaxCategoryLabelWidthRatio(float ratio)分類軸分類標(biāo)簽的最大寬度

AbstractRenderer類:
void setItemLabelAnchorOffset(double offset)數(shù)據(jù)標(biāo)簽的與數(shù)據(jù)點的偏移
void setItemLabelsVisible(boolean visible)數(shù)據(jù)標(biāo)簽是否可見
void setItemLabelFont(Font font)數(shù)據(jù)標(biāo)簽的字體
void setItemLabelPaint(Paint paint)數(shù)據(jù)標(biāo)簽的字體顏色
void setItemLabelPosition(ItemLabelPosition position)數(shù)據(jù)標(biāo)簽位置
void setPositiveItemLabelPosition(ItemLabelPosition position)正數(shù)標(biāo)簽位置
void setNegativeItemLabelPosition(ItemLabelPosition position)負(fù)數(shù)標(biāo)簽位置
void setOutLinePaint(Paint paint)圖形邊框的線條顏色
void setOutLineStroke(Stroke stroke)圖形邊框的線條筆觸
void setPaint(Paint paint)所有分類圖形的顏色
void setShape(Shape shape)所有分類圖形的形狀(如折線圖的點)
void setStroke(Stroke stroke)所有分類圖形的筆觸(如折線圖的線)
void setSeriesItemLabelsVisible(int series,boolean visible)指定分類的數(shù)據(jù)標(biāo)簽是否可見
void setSeriesItemLabelFont(int series,Font font)指定分類的數(shù)據(jù)標(biāo)簽的字體
void setSeriesItemLabelPaint(int series,Paint paint)指定分類的數(shù)據(jù)標(biāo)簽的字體顏色
void setSeriesItemLabelPosition(int series,ItemLabelPosition position)數(shù)據(jù)標(biāo)簽位置
void setSeriesPositiveItemLabelPosition(int series,ItemLabelPosition position)正數(shù)標(biāo)簽位置
void setSeriesNegativeItemLabelPosition(int series,ItemLabelPosition position)負(fù)數(shù)標(biāo)簽位置
void setSeriesOutLinePaint(int series,Paint paint)指定分類的圖形邊框的線條顏色
void setSeriesOutLineStroke(int series,Stroke stroke)指定分類的圖形邊框的線條筆觸
void setSeriesPaint(int series,Paint paint)指定分類圖形的顏色
void setSeriesShape(int series,Shape shape)指定分類圖形的形狀(如折線圖的點)
void setSeriesStroke(int series,Stroke stroke)指定分類圖形的筆觸(如折線圖的線)

AbstractCategoryItemRenderer(AbstractRenderer)類:
void setLabelGenerator(CategoryLabelGenerator generator)數(shù)據(jù)標(biāo)簽的格式
void setToolTipGenerator(CategoryToolTipGenerator generator)MAP中鼠標(biāo)移上的顯示格式
void setItemURLGenerator(CategoryURLGenerator generator)MAP中鉆取鏈接格式
void setSeriesLabelGenerator(int series,CategoryLabelGenerator generator)指定分類的數(shù)據(jù)標(biāo)簽的格式
void setSeriesToolTipGenerator(int series,CategoryToolTipGenerator generator)指定分類的MAP中鼠標(biāo)移上的顯示格式
void setSeriesItemURLGenerator(int series,CategoryURLGenerator generator)指定分類的MAP中鉆取鏈接格式

BarRenderer(AbstractCategoryItemRenderer)類:
void setDrawBarOutline(boolean draw)是否畫圖形邊框
void setItemMargin(double percent)每個BAR之間的間隔
void setMaxBarWidth(double percent)每個BAR的最大寬度
void setMinimumBarLength(double min)最短的BAR長度,避免數(shù)值太小而顯示不出
void setPositiveItemLabelPositionFallback(ItemLabelPosition position)無法在BAR中顯示的正數(shù)標(biāo)簽位置
void setNegativeItemLabelPositionFallback(ItemLabelPosition position)無法在BAR中顯示的負(fù)數(shù)標(biāo)簽位置

BarRenderer3D(BarRenderer)類:
void setWallPaint(Paint paint)3D坐標(biāo)軸的墻體顏色

StackedBarRenderer(BarRenderer)類:
沒有特殊的設(shè)置

StackedBarRenderer3D(BarRenderer3D)類:
沒有特殊的設(shè)置

GroupedStackedBarRenderer(StackedBarRenderer)類:
void setSeriesToGroupMap(KeyToGroupMap map)將分類自由的映射成若干個組(KeyToGroupMap.mapKeyToGroup(series,group))

LayeredBarRenderer(BarRenderer)類:
void setSeriesBarWidth(int series,double width)設(shè)定每個分類的寬度(注意設(shè)置不要使某分類被覆蓋)

WaterfallBarRenderer(BarRenderer)類:
void setFirstBarPaint(Paint paint)第一個柱圖的顏色
void setLastBarPaint(Paint paint)最后一個柱圖的顏色
void setPositiveBarPaint(Paint paint)正值柱圖的顏色
void setNegativeBarPaint(Paint paint)負(fù)值柱圖的顏色

IntervalBarRenderer(BarRenderer)類:
需要傳IntervalCategoryDataset作為數(shù)據(jù)源

GanttBarRenderer(IntervalBarRenderer)類:
void setCompletePaint(Paint paint)完成進度顏色
void setIncompletePaint(Paint paint)未完成進度顏色
void setStartPercent(double percent)設(shè)置進度條在整條中的起始位置(0.0~1.0)
void setEndPercent(double percent)設(shè)置進度條在整條中的結(jié)束位置(0.0~1.0)

StatisticBarRenderer(BarRenderer)類:
需要傳StatisticCategoryDataset作為數(shù)據(jù)源

LineAndShapeRenderer(AbstractCategoryItemRenderer)類:
void setDrawLines(boolean draw)是否折線的數(shù)據(jù)點之間用線連
void setDrawShapes(boolean draw)是否折線的數(shù)據(jù)點根據(jù)分類使用不同的形狀
void setShapesFilled(boolean filled)所有分類是否填充數(shù)據(jù)點圖形
void setSeriesShapesFilled(int series,boolean filled)指定分類是否填充數(shù)據(jù)點圖形
void setUseFillPaintForShapeOutline(boolean use)指定是否填充數(shù)據(jù)點的Paint也被用于畫數(shù)據(jù)點形狀的邊框

LevelRenderer(AbstractCategoryItemRenderer)類:
void setItemMargin(double percent)每個分類之間的間隔
void setMaxItemWidth(double percent)每個分類的最大寬度

CategoryStepRenderer(AbstractCategoryItemRenderer)類:
void setStagger(boolean shouldStagger)不同分類的圖是否交錯

MinMaxCategoryRenderer(AbstractCategoryItemRenderer)類:
void setDrawLines(boolean drawLines)是否在每個分類線間畫連接線
void setGroupPaint(Paint groupPaint)一組圖形連接線的顏色
void setGroupStroke(Stroke groupStroke)一組圖形連接線的筆觸
void setMaxIcon(Icon maxIcon)最大值的ICON
void setMinIcon(Icon minIcon)最小值的ICON
void setObjectIcon(Icon objectIcon)所有值的ICON

AreaRender(AbstractCategoryItemRenderer)類:
沒有特殊的設(shè)置

StackedAreaRender(AreaRender)類:
沒有特殊的設(shè)置

關(guān)鍵就是用好Renderer這個類了,再貼個例子:

String sFont = "宋體";   chart.setBorderVisible(true);   chart.setBorderPaint(new Color(0xFF,0x66,0x00));   chart.setBackgroundPaint(new Color(0xFF,0xF3,0xDE));   chart.getTitle().setPaint(Color.red);   chart.getTitle().setFont(new Font(sFont,Font.BOLD,14));    //設(shè)置Plot,不顯示所有網(wǎng)格   ((CategoryPlot)chart.getPlot()).setOutlinePaint(null);   ((CategoryPlot)chart.getPlot()).setDomainGridlinesVisible(false);   ((CategoryPlot)chart.getPlot()).setRangeGridlinesVisible(false);    //設(shè)置橫軸字體,設(shè)定橫軸軸線不可見,隱藏縱軸   ((CategoryPlot)chart.getPlot()).getDomainAxis().setTickLabelFont(new Font(sFont,Font.PLAIN,12));   ((CategoryPlot)chart.getPlot()).getDomainAxis().setAxisLineVisible(false);   ((CategoryPlot)chart.getPlot()).getRangeAxis().setVisible(false);    //采用BarRenderer作為表示器   BarRenderer renderer = new BarRenderer();   renderer.setPaint(new GradientPaint(0.0f,0.0f,Color.orange,0.0f,0.0f,Color.yellow));   renderer.setOutlinePaint(Color.orange);   renderer.setDrawBarOutline(true);    //在條中央顯示投票數(shù)值   renderer.setItemLabelAnchorOffset(-20.0f);   renderer.setLabelGenerator(new StandardCategoryLabelGenerator("{2}",new DecimalFormat()));   renderer.setPositiveItemLabelPosition(new ItemLabelPosition());   renderer.setItemLabelsVisible(true);

pie charts (2D and 3D):餅圖(平面和立體)

bar charts (regular and stacked, with an optional 3D effect):柱狀圖

line and area charts:曲線圖

scatter plots and bubble charts

time series, high/low/open/close charts and candle stick charts:時序圖

combination charts:復(fù)合圖

Pareto charts

Gantt charts:甘特圖

wind plots, meter charts and symbol charts

wafer map charts

(態(tài)圖表,餅圖(二維和三維) , 柱狀圖 (水平,垂直),線圖,點圖,時間變化圖,甘特圖, 股票行情圖,混和圖, 溫度計圖, 刻度圖等常用商用圖表)

圖形可以導(dǎo)出成PNG和JPEG格式,同時還可以與PDF和EXCEL關(guān)聯(lián)

JFreeChart核心類庫介紹:

研究jfreechart源碼發(fā)現(xiàn)源碼的主要由兩個大的包組成:org.jfree.chart,org.jfree.data。其中前者主要與圖形本身有關(guān),后者與圖形顯示的數(shù)據(jù)有關(guān)。

核心類主要有:

org.jfree.chart.JFreeChart:圖表對象,任何類型的圖表的最終表現(xiàn)形式都是在該對象進行一些屬性的定制。JFreeChart引擎本身提供了一個工廠類用于創(chuàng)建不同類型的圖表對象

org.jfree.data.category.XXXDataSet:數(shù)據(jù)集對象,用于提供顯示圖表所用的數(shù)據(jù)。根據(jù)不同類型的圖表對應(yīng)著很多類型的數(shù)據(jù)集對象類

org.jfree.chart.plot.XXXPlot:圖表區(qū)域?qū)ο?,基本上這個對象決定著什么樣式的圖表,創(chuàng)建該對象的時候需要Axis、Renderer以及數(shù)據(jù)集對象的支持

org.jfree.chart.axis.XXXAxis:用于處理圖表的兩個軸:縱軸和橫軸

org.jfree.chart.render.XXXRender:負(fù)責(zé)如何顯示一個圖表對象

org.jfree.chart.urls.XXXURLGenerator:用于生成Web圖表中每個項目的鼠標(biāo)點擊鏈接

XXXXXToolTipGenerator:用于生成圖象的幫助提示,不同類型圖表對應(yīng)不同類型的工具提示類

JFreeChart類:

void setAntiAlias(boolean flag) 字體模糊邊界
void setBackgroundImage(Image image) 背景圖片
void setBackgroundImageAlignment(int alignment) 背景圖片對齊方式(參數(shù)常量在org.jfree.ui.Align類中定義)
void setBackgroundImageAlpha(float alpha) 背景圖片透明度(0.0~1.0)
void setBackgroundPaint(Paint paint) 背景色
void setBorderPaint(Paint paint) 邊界線條顏色
void setBorderStroke(Stroke stroke) 邊界線條筆觸
void setBorderVisible(boolean visible) 邊界線條是否可見

TextTitle類:
void setFont(Font font) 標(biāo)題字體
void setPaint(Paint paint) 標(biāo)題字體顏色
void setText(String text) 標(biāo)題內(nèi)

StandardLegend(Legend)類:
void setBackgroundPaint(Paint paint) 圖示背景色
void setTitle(String title) 圖示標(biāo)題內(nèi)容
void setTitleFont(Font font) 圖示標(biāo)題字體
void setBoundingBoxArcWidth(int arcWidth) 圖示邊界圓角寬
void setBoundingBoxArcHeight(int arcHeight) 圖示邊界圓角高
void setOutlinePaint(Paint paint) 圖示邊界線條顏色
void setOutlineStroke(Stroke stroke) 圖示邊界線條筆觸
void setDisplaySeriesLines(boolean flag) 圖示項是否顯示橫線(折線圖有效)
void setDisplaySeriesShapes(boolean flag) 圖示項是否顯示形狀(折線圖有效)
void setItemFont(Font font) 圖示項字體
void setItemPaint(Paint paint) 圖示項字體顏色
void setAnchor(int anchor) 圖示在圖表中的顯示位置(參數(shù)常量在Legend類中定義)

Axis類:
void setVisible(boolean flag) 坐標(biāo)軸是否可見
void setAxisLinePaint(Paint paint) 坐標(biāo)軸線條顏色(3D軸無效)
void setAxisLineStroke(Stroke stroke) 坐標(biāo)軸線條筆觸(3D軸無效)
void setAxisLineVisible(boolean visible) 坐標(biāo)軸線條是否可見(3D軸無效)
void setFixedDimension(double dimension) (用于復(fù)合表中對多坐標(biāo)軸的設(shè)置)
void setLabel(String label) 坐標(biāo)軸標(biāo)題
void setLabelFont(Font font) 坐標(biāo)軸標(biāo)題字體
void setLabelPaint(Paint paint) 坐標(biāo)軸標(biāo)題顏色
void setLabelAngle(double angle)` 坐標(biāo)軸標(biāo)題旋轉(zhuǎn)角度(縱坐標(biāo)可以旋轉(zhuǎn))
void setTickLabelFont(Font font) 坐標(biāo)軸標(biāo)尺值字體
void setTickLabelPaint(Paint paint) 坐標(biāo)軸標(biāo)尺值顏色
void setTickLabelsVisible(boolean flag) 坐標(biāo)軸標(biāo)尺值是否顯示
void setTickMarkPaint(Paint paint) 坐標(biāo)軸標(biāo)尺顏色
void setTickMarkStroke(Stroke stroke) 坐標(biāo)軸標(biāo)尺筆觸
void setTickMarksVisible(boolean flag) 坐標(biāo)軸標(biāo)尺是否顯示

ValueAxis(Axis)類:
void setAutoRange(boolean auto) 自動設(shè)置數(shù)據(jù)軸數(shù)據(jù)范圍
void setAutoRangeMinimumSize(double size) 自動設(shè)置數(shù)據(jù)軸數(shù)據(jù)范圍時數(shù)據(jù)范圍的最小跨度
void setAutoTickUnitSelection(boolean flag) 數(shù)據(jù)軸的數(shù)據(jù)標(biāo)簽是否自動確定(默認(rèn)為true)
void setFixedAutoRange(double length) 數(shù)據(jù)軸固定數(shù)據(jù)范圍(設(shè)置100的話就是顯示MAXVALUE到MAXVALUE-100那段數(shù)據(jù)范圍)
void setInverted(boolean flag) 數(shù)據(jù)軸是否反向(默認(rèn)為false)
void setLowerMargin(double margin) 數(shù)據(jù)軸下(左)邊距
void setUpperMargin(double margin) 數(shù)據(jù)軸上(右)邊距
void setLowerBound(double min) 數(shù)據(jù)軸上的顯示最小值
void setUpperBound(double max) 數(shù)據(jù)軸上的顯示最大值
void setPositiveArrowVisible(boolean visible) 是否顯示正向箭頭(3D軸無效)
void setNegativeArrowVisible(boolean visible) 是否顯示反向箭頭(3D軸無效)
void setVerticalTickLabels(boolean flag) 數(shù)據(jù)軸數(shù)據(jù)標(biāo)簽是否旋轉(zhuǎn)到垂直
void setStandardTickUnits(TickUnitSource source) 數(shù)據(jù)軸的數(shù)據(jù)標(biāo)簽(可以只顯示整數(shù)標(biāo)簽,需要將AutoTickUnitSelection設(shè)false)

NumberAxis(ValueAxis)類:
void setAutoRangeIncludesZero(boolean flag) 是否強制在自動選擇的數(shù)據(jù)范圍中包含0
void setAutoRangeStickyZero(boolean flag) 是否強制在整個數(shù)據(jù)軸中包含0,即使0不在數(shù)據(jù)范圍中
void setNumberFormatOverride(NumberFormat formatter) 數(shù)據(jù)軸數(shù)據(jù)標(biāo)簽的顯示格式
void setTickUnit(NumberTickUnit unit) 數(shù)據(jù)軸的數(shù)據(jù)標(biāo)簽(需要將AutoTickUnitSelection設(shè)false)

DateAxis(ValueAxis)類:
void setMaximumDate(Date maximumDate) 日期軸上的最小日期
void setMinimumDate(Date minimumDate) 日期軸上的最大日期
void setRange(Date lower,Date upper) 日期軸范圍
void setDateFormatOverride(DateFormat formatter) 日期軸日期標(biāo)簽的顯示格式
void setTickUnit(DateTickUnit unit) 日期軸的日期標(biāo)簽(需要將AutoTickUnitSelection設(shè)false)
void setTickMarkPosition(DateTickMarkPosition position) 日期標(biāo)簽位置(參數(shù)常量在org.jfree.chart.axis.DateTickMarkPosition類中定義)

CategoryAxis(Axis)類:
void setCategoryMargin(double margin) 分類軸邊距
void setLowerMargin(double margin) 分類軸下(左)邊距
void setUpperMargin(double margin) 分類軸上(右)邊距
void setVerticalCategoryLabels(boolean flag) 分類軸標(biāo)題是否旋轉(zhuǎn)到垂直
void setMaxCategoryLabelWidthRatio(float ratio) 分類軸分類標(biāo)簽的最大寬度

Plot類:
void setBackgroundImage(Image image) 數(shù)據(jù)區(qū)的背景圖片
void setBackgroundImageAlignment(int alignment) 數(shù)據(jù)區(qū)的背景圖片對齊方式(參數(shù)常量在org.jfree.ui.Align類中定義)
void setBackgroundPaint(Paint paint) 數(shù)據(jù)區(qū)的背景圖片背景色
void setBackgroundAlpha(float alpha) 數(shù)據(jù)區(qū)的背景透明度(0.0~1.0)
void setForegroundAlpha(float alpha) 數(shù)據(jù)區(qū)的前景透明度(0.0~1.0)
void setDataAreaRatio(double ratio) 數(shù)據(jù)區(qū)占整個圖表區(qū)的百分比
void setOutLinePaint(Paint paint) 數(shù)據(jù)區(qū)的邊界線條顏色
void setOutLineStroke(Stroke stroke) 數(shù)據(jù)區(qū)的邊界線條筆觸
void setNoDataMessage(String message) 沒有數(shù)據(jù)時顯示的消息
void setNoDataMessageFont(Font font) 沒有數(shù)據(jù)時顯示的消息字體
void setNoDataMessagePaint(Paint paint) 沒有數(shù)據(jù)時顯示的消息顏色

CategoryPlot(Plot)類:
void setDataset(CategoryDataset dataset) 數(shù)據(jù)區(qū)的2維數(shù)據(jù)表
void setColumnRenderingOrder(SortOrder order) 數(shù)據(jù)分類的排序方式
void setAxisOffset(Spacer offset) 坐標(biāo)軸到數(shù)據(jù)區(qū)的間距
void setOrientation(PlotOrientation orientation) 數(shù)據(jù)區(qū)的方向(PlotOrientation.HORIZONTAL或PlotOrientation.VERTICAL)
void setDomainAxis(CategoryAxis axis) 數(shù)據(jù)區(qū)的分類軸
void setDomainAxisLocation(AxisLocation location) 分類軸的位置(參數(shù)常量在org.jfree.chart.axis.AxisLocation類中定義)
void setDomainGridlinesVisible(boolean visible) 分類軸網(wǎng)格是否可見
void setDomainGridlinePaint(Paint paint) 分類軸網(wǎng)格線條顏色
void setDomainGridlineStroke(Stroke stroke) 分類軸網(wǎng)格線條筆觸
void setRangeAxis(ValueAxis axis) 數(shù)據(jù)區(qū)的數(shù)據(jù)軸
void setRangeAxisLocation(AxisLocation location) 數(shù)據(jù)軸的位置(參數(shù)常量在org.jfree.chart.axis.AxisLocation類中定義)
void setRangeGridlinesVisible(boolean visible) 數(shù)據(jù)軸網(wǎng)格是否可見
void setRangeGridlinePaint(Paint paint) 數(shù)據(jù)軸網(wǎng)格線條顏色
void setRangeGridlineStroke(Stroke stroke) 數(shù)據(jù)軸網(wǎng)格線條筆觸
void setRenderer(CategoryItemRenderer renderer) 數(shù)據(jù)區(qū)的表示者(詳見Renderer組)
void addAnnotation(CategoryAnnotation annotation) 給數(shù)據(jù)區(qū)加一個注釋
void addRangeMarker(Marker marker,Layer layer) 給數(shù)據(jù)區(qū)加一個數(shù)值范圍區(qū)域

PiePlot(Plot)類:
void setDataset(PieDataset dataset) 數(shù)據(jù)區(qū)的1維數(shù)據(jù)表
void setIgnoreNullValues(boolean flag) 忽略無值的分類
void setCircular(boolean flag) 餅圖是否一定是正圓
void setStartAngle(double angle) 餅圖的初始角度
void setDirection(Rotation direction) 餅圖的旋轉(zhuǎn)方向
void setExplodePercent(int section,double percent) 抽取的那塊(1維數(shù)據(jù)表的分類下標(biāo))以及抽取出來的距離(0.0~1.0),3D餅圖無效
void setLabelBackgroundPaint(Paint paint) 分類標(biāo)簽的底色
void setLabelFont(Font font) 分類標(biāo)簽的字體
void setLabelPaint(Paint paint) 分類標(biāo)簽的字體顏色
void setLabelLinkMargin(double margin) 分類標(biāo)簽與圖的連接線邊距
void setLabelLinkPaint(Paint paint) 分類標(biāo)簽與圖的連接線顏色
void setLabelLinkStroke(Stroke stroke) 分類標(biāo)簽與圖的連接線筆觸
void setLabelOutlinePaint(Paint paint) 分類標(biāo)簽邊框顏色
void setLabelOutlineStroke(Paint paint) 分類標(biāo)簽邊框筆觸
void setLabelShadowPaint(Paint paint) 分類標(biāo)簽陰影顏色
void setMaximumLabelWidth(double width) 分類標(biāo)簽的最大長度(0.0~1.0)
void setPieIndex(int index) 餅圖的索引(復(fù)合餅圖中用到)
void setSectionOutlinePaint(int section,Paint paint) 指定分類餅的邊框顏色
void setSectionOutlineStroke(int section,Stroke stroke) 指定分類餅的邊框筆觸
void setSectionPaint(int section,Paint paint) 指定分類餅的顏色
void setShadowPaint(Paint paint) 餅圖的陰影顏色
void setShadowXOffset(double offset) 餅圖的陰影相對圖的水平偏移
void setShadowYOffset(double offset) 餅圖的陰影相對圖的垂直偏移
void setLabelGenerator(PieSectionLabelGenerator generator) 分類標(biāo)簽的格式,設(shè)置成null則整個標(biāo)簽包括連接線都不顯示
void setToolTipGenerator(PieToolTipGenerator generator) MAP中鼠標(biāo)移上的顯示格式
void setURLGenerator(PieURLGenerator generator) MAP中鉆取鏈接格式

PiePlot3D(PiePlot)類:
void setDepthFactor(double factor) 3D餅圖的Z軸高度(0.0~1.0)

MultiplePiePlot(Plot)類:
void setLimit(double limit) 每個餅圖之間的數(shù)據(jù)關(guān)聯(lián)(詳細(xì)比較復(fù)雜)
void setPieChart(JFreeChart pieChart) 每個餅圖的顯示方式(見JFreeChart類個PiePlot類)

AbstractRenderer類:
void setItemLabelAnchorOffset(double offset) 數(shù)據(jù)標(biāo)簽的與數(shù)據(jù)點的偏移
void setItemLabelsVisible(boolean visible) 數(shù)據(jù)標(biāo)簽是否可見
void setItemLabelFont(Font font) 數(shù)據(jù)標(biāo)簽的字體
void setItemLabelPaint(Paint paint) 數(shù)據(jù)標(biāo)簽的字體顏色
void setItemLabelPosition(ItemLabelPosition position) 數(shù)據(jù)標(biāo)簽位置
void setPositiveItemLabelPosition(ItemLabelPosition position) 正數(shù)標(biāo)簽位置
void setNegativeItemLabelPosition(ItemLabelPosition position) 負(fù)數(shù)標(biāo)簽位置
void setOutLinePaint(Paint paint) 圖形邊框的線條顏色
void setOutLineStroke(Stroke stroke) 圖形邊框的線條筆觸
void setPaint(Paint paint) 所有分類圖形的顏色
void setShape(Shape shape) 所有分類圖形的形狀(如折線圖的點)
void setStroke(Stroke stroke) 所有分類圖形的筆觸(如折線圖的線)
void setSeriesItemLabelsVisible(int series,boolean visible) 指定分類的數(shù)據(jù)標(biāo)簽是否可見
void setSeriesItemLabelFont(int series,Font font) 指定分類的數(shù)據(jù)標(biāo)簽的字體
void setSeriesItemLabelPaint(int series,Paint paint) 指定分類的數(shù)據(jù)標(biāo)簽的字體顏色
void setSeriesItemLabelPosition(int series,ItemLabelPosition position) 數(shù)據(jù)標(biāo)簽位置
void setSeriesPositiveItemLabelPosition(int series,ItemLabelPosition position) 正數(shù)標(biāo)簽位置
void setSeriesNegativeItemLabelPosition(int series,ItemLabelPosition position) 負(fù)數(shù)標(biāo)簽位置
void setSeriesOutLinePaint(int series,Paint paint) 指定分類的圖形邊框的線條顏色
void setSeriesOutLineStroke(int series,Stroke stroke) 指定分類的圖形邊框的線條筆觸
void setSeriesPaint(int series,Paint paint) 指定分類圖形的顏色
void setSeriesShape(int series,Shape shape) 指定分類圖形的形狀(如折線圖的點)
void setSeriesStroke(int series,Stroke stroke) 指定分類圖形的筆觸(如折線圖的線)

AbstractCategoryItemRenderer(AbstractRenderer)類:
void setLabelGenerator(CategoryLabelGenerator generator) 數(shù)據(jù)標(biāo)簽的格式
void setToolTipGenerator(CategoryToolTipGenerator generator) MAP中鼠標(biāo)移上的顯示格式
void setItemURLGenerator(CategoryURLGenerator generator) MAP中鉆取鏈接格式
void setSeriesLabelGenerator(int series,CategoryLabelGenerator generator) 指定分類的數(shù)據(jù)標(biāo)簽的格式
void setSeriesToolTipGenerator(int series,CategoryToolTipGenerator generator) 指定分類的MAP中鼠標(biāo)移上的顯示格式
void setSeriesItemURLGenerator(int series,CategoryURLGenerator generator) 指定分類的MAP中鉆取鏈接格式

BarRenderer(AbstractCategoryItemRenderer)類:
void setDrawBarOutline(boolean draw) 是否畫圖形邊框
void setItemMargin(double percent) 每個BAR之間的間隔
void setMaxBarWidth(double percent) 每個BAR的最大寬度
void setMinimumBarLength(double min) 最短的BAR長度,避免數(shù)值太小而顯示不出
void setPositiveItemLabelPositionFallback(ItemLabelPosition position) 無法在BAR中顯示的正數(shù)標(biāo)簽位置
void setNegativeItemLabelPositionFallback(ItemLabelPosition position) 無法在BAR中顯示的負(fù)數(shù)標(biāo)簽位置

BarRenderer3D(BarRenderer)類:
void setWallPaint(Paint paint) 3D坐標(biāo)軸的墻體顏色

StackedBarRenderer(BarRenderer)類:
沒有特殊的設(shè)置

StackedBarRenderer3D(BarRenderer3D)類:
沒有特殊的設(shè)置

GroupedStackedBarRenderer(StackedBarRenderer)類:
void setSeriesToGroupMap(KeyToGroupMap map) 將分類自由的映射成若干個組(KeyToGroupMap.mapKeyToGroup(series,group))

LayeredBarRenderer(BarRenderer)類:
void setSeriesBarWidth(int series,double width) 設(shè)定每個分類的寬度(注意設(shè)置不要使某分類被覆蓋)

WaterfallBarRenderer(BarRenderer)類:
void setFirstBarPaint(Paint paint) 第一個柱圖的顏色
void setLastBarPaint(Paint paint) 最后一個柱圖的顏色
void setPositiveBarPaint(Paint paint) 正值柱圖的顏色
void setNegativeBarPaint(Paint paint) 負(fù)值柱圖的顏色

IntervalBarRenderer(BarRenderer)類:
需要傳IntervalCategoryDataset作為數(shù)據(jù)源

GanttBarRenderer(IntervalBarRenderer)類:
void setCompletePaint(Paint paint) 完成進度顏色
void setIncompletePaint(Paint paint) 未完成進度顏色
void setStartPercent(double percent) 設(shè)置進度條在整條中的起始位置(0.0~1.0)
void setEndPercent(double percent) 設(shè)置進度條在整條中的結(jié)束位置(0.0~1.0)

StatisticBarRenderer(BarRenderer)類:
需要傳StatisticCategoryDataset作為數(shù)據(jù)源

LineAndShapeRenderer(AbstractCategoryItemRenderer)類:
void setDrawLines(boolean draw) 是否折線的數(shù)據(jù)點之間用線連
void setDrawShapes(boolean draw) 是否折線的數(shù)據(jù)點根據(jù)分類使用不同的形狀
void setShapesFilled(boolean filled) 所有分類是否填充數(shù)據(jù)點圖形
void setSeriesShapesFilled(int series,boolean filled) 指定分類是否填充數(shù)據(jù)點圖形
void setUseFillPaintForShapeOutline(boolean use) 指定是否填充數(shù)據(jù)點的Paint也被用于畫數(shù)據(jù)點形狀的邊框

LevelRenderer(AbstractCategoryItemRenderer)類:
void setItemMargin(double percent) 每個分類之間的間隔
void setMaxItemWidth(double percent) 每個分類的最大寬度

CategoryStepRenderer(AbstractCategoryItemRenderer)類:
void setStagger(boolean shouldStagger) 不同分類的圖是否交錯

MinMaxCategoryRenderer(AbstractCategoryItemRenderer)類:
void setDrawLines(boolean drawLines) 是否在每個分類線間畫連接線
void setGroupPaint(Paint groupPaint) 一組圖形連接線的顏色
void setGroupStroke(Stroke groupStroke) 一組圖形連接線的筆觸
void setMaxIcon(Icon maxIcon) 最大值的ICON
void setMinIcon(Icon minIcon) 最小值的ICON
void setObjectIcon(Icon objectIcon) 所有值的ICON

AreaRender(AbstractCategoryItemRenderer)類:
沒有特殊的設(shè)置

StackedAreaRender(AreaRender)類:
沒有特殊的設(shè)置


以上是“java中JFreeChart API有哪些”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對大家有所幫助,如果還想學(xué)習(xí)更多知識,歡迎關(guān)注億速云行業(yè)資訊頻道!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI