jfreechar 柱状图categoryaxis 怎样设置字体宽度
若以下回答无法解决问题,邀请你更新回答
1个回答
2016-07-01 · 百度知道合伙人官方认证企业
兄弟连教育
兄弟连教育成立于2006年,11年来专注IT职业教育,是国内专业的IT技术培训学校。2016年成功挂牌新三板(股票代码:839467)市值过亿。开设专注程序员培训专注php、Java、UI、云计算、Python、HTML5、
向TA提问
关注
展开全部
Java代码
String FONT="宋体";
JFreeChart localJFreeChart = ChartFactory.createBarChart(this.title, "", "金额(元)", paramCategoryDataset, PlotOrientation.VERTICAL, false, true, false);
localJFreeChart.setBackgroundPaint(new Color(255, 255, 255));
CategoryPlot localCategoryPlot = (CategoryPlot)localJFreeChart.getPlot();
CategoryAxis localCategoryAxis = localCategoryPlot.getDomainAxis();
localCategoryAxis.setMaximumCategoryLabelWidthRatio(0.8F);
localCategoryAxis.setLowerMargin(0.02D);
localCategoryAxis.setUpperMargin(0.02D);
NumberAxis localNumberAxis = (NumberAxis)localCategoryPlot.getRangeAxis();
localNumberAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
BarRenderer localBarRenderer = (BarRenderer)localCategoryPlot.getRenderer();
localBarRenderer.setDrawBarOutline(false);
[color=red] GradientPaint localGradientPaint = new GradientPaint(0.0F, 0.0F, Color.green, 0.0F, 0.0F, Color.white);[/color] localBarRenderer.setSeriesPaint(0, localGradientPaint);
TextTitle textTitle = localJFreeChart.getTitle();
textTitle.setFont(new Font(FONT, Font.PLAIN, 20));
CategoryPlot plot = localJFreeChart.getCategoryPlot();
CategoryAxis domainAxis = plot.getDomainAxis();
ValueAxis rAxis = plot.getRangeAxis();
/*------设置X轴坐标上的文字-----------*/
domainAxis.setTickLabelFont(new Font(FONT, Font.PLAIN, 12));
/*------设置X轴的标题文字------------*/
domainAxis.setLabelFont(new Font(FONT, Font.PLAIN, 12));
/*------设置Y轴坐标上的文字-----------*/
rAxis.setTickLabelFont(new Font(FONT, Font.PLAIN, 12));
domainAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45);
/*------设置Y轴的标题文字------------*/
rAxis.setLabelFont(new Font(FONT, Font.PLAIN, 12));
return localJFreeChart;
红字是设置柱的颜色及样式。
设置最高值与最低值以及中间值,你说这种估计不行吧。有几个柱状都是根据数据自动生成的。颜色也是统一设置的。
String FONT="宋体";
JFreeChart localJFreeChart = ChartFactory.createBarChart(this.title, "", "金额(元)", paramCategoryDataset, PlotOrientation.VERTICAL, false, true, false);
localJFreeChart.setBackgroundPaint(new Color(255, 255, 255));
CategoryPlot localCategoryPlot = (CategoryPlot)localJFreeChart.getPlot();
CategoryAxis localCategoryAxis = localCategoryPlot.getDomainAxis();
localCategoryAxis.setMaximumCategoryLabelWidthRatio(0.8F);
localCategoryAxis.setLowerMargin(0.02D);
localCategoryAxis.setUpperMargin(0.02D);
NumberAxis localNumberAxis = (NumberAxis)localCategoryPlot.getRangeAxis();
localNumberAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
BarRenderer localBarRenderer = (BarRenderer)localCategoryPlot.getRenderer();
localBarRenderer.setDrawBarOutline(false);
[color=red] GradientPaint localGradientPaint = new GradientPaint(0.0F, 0.0F, Color.green, 0.0F, 0.0F, Color.white);[/color] localBarRenderer.setSeriesPaint(0, localGradientPaint);
TextTitle textTitle = localJFreeChart.getTitle();
textTitle.setFont(new Font(FONT, Font.PLAIN, 20));
CategoryPlot plot = localJFreeChart.getCategoryPlot();
CategoryAxis domainAxis = plot.getDomainAxis();
ValueAxis rAxis = plot.getRangeAxis();
/*------设置X轴坐标上的文字-----------*/
domainAxis.setTickLabelFont(new Font(FONT, Font.PLAIN, 12));
/*------设置X轴的标题文字------------*/
domainAxis.setLabelFont(new Font(FONT, Font.PLAIN, 12));
/*------设置Y轴坐标上的文字-----------*/
rAxis.setTickLabelFont(new Font(FONT, Font.PLAIN, 12));
domainAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45);
/*------设置Y轴的标题文字------------*/
rAxis.setLabelFont(new Font(FONT, Font.PLAIN, 12));
return localJFreeChart;
红字是设置柱的颜色及样式。
设置最高值与最低值以及中间值,你说这种估计不行吧。有几个柱状都是根据数据自动生成的。颜色也是统一设置的。
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询