JFreeChart 零散

本文介绍如何在DynamicReports中使用JFreeChart定制图表样式,包括移除图例边框、调整图表方向、隐藏坐标轴及网格线等操作。

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

*

主要是dynamicreports 和 jfreechart结合的时候,进行的一些配置:

1,移除legend的黑色边框

LegendTitle legend = chart.getLegend();
        //legend.setFrame(new BlockBorder(Color.green));
        if(legend!=null){
            legend.setFrame(BlockBorder.NONE);//去除legend的黑线框
        }

2,图的方向调换,

.setOrientation(Orientation.HORIZONTAL)

 3,在dynamic-reports中客制化jfreechart

private class AxisLineCustomizer implements DRIChartCustomizer, Serializable {
        private static final long serialVersionUID = 1L;

        @Override
        public void customize(JFreeChart chart, ReportParameters reportParameters) {
            BarRenderer renderer = (BarRenderer) chart.getCategoryPlot().getRenderer();
            CategoryPlot categoryPlot=chart.getCategoryPlot();
            categoryPlot.setRangeGridlinesVisible(false);//数据区的网格线删除
            
            //chart.getLegend().setFrame(BlockBorder.NONE);//去除legend的黑边框
            LegendTitle legend = chart.getLegend();
            //legend.setFrame(new BlockBorder(Color.green));
            if(legend!=null){
                legend.setFrame(BlockBorder.NONE);//去除legend的黑线框
            }
            
            CategoryAxis domainAxis = categoryPlot.getDomainAxis();
            categoryPlot.setRangeZeroBaselineVisible(true);//显示出0的线
            domainAxis.setAxisLineVisible(false);//不显示x轴的线
            domainAxis.setTickMarksVisible(false);//不显示x轴的标尺
            
            renderer.setNegativeItemLabelPosition(new ItemLabelPosition());
            ValueAxis valueAxis=(ValueAxis) chart.getCategoryPlot().getRangeAxis();
            categoryPlot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
            //domainAxis.setInverted(true);//数据轴倒过来
            //categoryPlot.setOrientation(PlotOrientation.VERTICAL);
        }
    }

4,xy轴的标签

//.setCategoryAxisFormat(cht.axisFormat().setLabel("一万个理由"))//x轴标签
.setValueAxisFormat(cht.axisFormat().setLabel("(%)"))//y轴标签

 *5,.setUseSeriesAsCategory(true)

 *

更多属性设置,参考 JFreeChart中文API

*

转载于:https://www.cnblogs.com/qingmaple/p/6170750.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值