【问题标题】:Change font-size of domain axis label and range axis label for jfreechart更改 jfreechart 的域轴标签和范围轴标签的字体大小
【发布时间】:2014-02-19 12:20:30
【问题描述】:

我的目标是增加“Revenue ($)”和“Years”的大小。但是我不知道怎么做。我可以增加“Apples, Durians,Oranges”和“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); 

【问题讨论】:

标签: java jfreechart font-size axis-labels


【解决方案1】:

使用

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

【讨论】:

    猜你喜欢
    • 2022-09-28
    • 2016-04-25
    • 2022-07-20
    • 1970-01-01
    • 2016-11-11
    • 2018-07-20
    • 1970-01-01
    • 1970-01-01
    • 2013-02-03
    相关资源
    最近更新 更多