更改jfreechart的域轴标签和范围轴标签的字体大小 [英] Change font-size of domain axis label and range axis label for jfreechart

查看:249
本文介绍了更改jfreechart的域轴标签和范围轴标签的字体大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标是增加收入($)和年的大小。但是我不知道怎么做。我能够增加苹果,榴莲,橘子和2012年,2013年。

My goal is to increase the size of "Revenue ($) " and "Years". But I do not know how. I am able to increase the "Apples, Durians,Oranges" and "2012, 2013".

以下是我的代码。

    JFreeChart chart = ChartFactory.createBarChart3D("", // chart title
                "Years", // domain axis label
                "Revenue ($)", // range axis label
                dataset, // data
                PlotOrientation.VERTICAL, // orientation
                false, // include legend
                false, // tooltips
                false);

CategoryPlot plot = chart.getCategoryPlot();
        CategoryAxis axis = plot.getDomainAxis();

        CategoryPlot p = chart.getCategoryPlot(); 
         ValueAxis axis2 = p.getRangeAxis();

        Font font = new Font("Dialog", Font.PLAIN, 25);
        axis.setTickLabelFont(font);
        Font font2 = new Font("Dialog", Font.PLAIN, 15);
        axis2.setTickLabelFont(font2);

        LegendTitle legend = new LegendTitle(plot.getRenderer());

        Font font3 = new Font("Dialog", Font.PLAIN, 20); 
        legend.setItemFont(font3); 
        legend.setPosition(RectangleEdge.BOTTOM); 
        chart.addLegend(legend); 


推荐答案

使用

Font font3 = new Font("Dialog", Font.PLAIN, 25); 
plot.getDomainAxis().setLabelFont(font3);
plot.getRangeAxis().setLabelFont(font3);

这篇关于更改jfreechart的域轴标签和范围轴标签的字体大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆