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)圖示項(xiàng)是否顯示橫線(折線圖有效)
void setDisplaySeriesShapes(boolean flag)圖示項(xiàng)是否顯示形狀(折線圖有效)
void setItemFont(Font font)圖示項(xiàng)字體
void setItemPaint(Paint paint)圖示項(xiàng)字體顏色
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)是否強(qiáng)制在自動選擇的數(shù)據(jù)范圍中包含0
void setAutoRangeStickyZero(boolean flag)是否強(qiáng)制在整個數(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ù)點(diǎn)的偏移
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)所有分類圖形的形狀(如折線圖的點(diǎn))
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)指定分類圖形的形狀(如折線圖的點(diǎn))
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)完成進(jìn)度顏色
void setIncompletePaint(Paint paint)未完成進(jìn)度顏色
void setStartPercent(double percent)設(shè)置進(jìn)度條在整條中的起始位置(0.0~1.0)
void setEndPercent(double percent)設(shè)置進(jìn)度條在整條中的結(jié)束位置(0.0~1.0)
StatisticBarRenderer(BarRenderer)類:
需要傳StatisticCategoryDataset作為數(shù)據(jù)源
LineAndShapeRenderer(AbstractCategoryItemRenderer)類:
void setDrawLines(boolean draw)是否折線的數(shù)據(jù)點(diǎn)之間用線連
void setDrawShapes(boolean draw)是否折線的數(shù)據(jù)點(diǎn)根據(jù)分類使用不同的形狀
void setShapesFilled(boolean filled)所有分類是否填充數(shù)據(jù)點(diǎn)圖形
void setSeriesShapesFilled(int series,boolean filled)指定分類是否填充數(shù)據(jù)點(diǎn)圖形
void setUseFillPaintForShapeOutline(boolean use)指定是否填充數(shù)據(jù)點(diǎn)的Paint也被用于畫數(shù)據(jù)點(diǎn)形狀的邊框
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);