JfreeChart:堆叠条形图和CategoryAxis显示日期 [英] JfreeChart: Stacked Bar Chart and CategoryAxis showing dates

查看:994
本文介绍了JfreeChart:堆叠条形图和CategoryAxis显示日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个堆叠条形图,其中显示了 y 轴上的计数和 x 轴上的日期。问题是,当我在 x 轴上有很多日期时,它变得很杂乱,不可能读取。我想只显示一些日期,例如每周一个日期。那可能吗?我使用 ChartFactory.createStackedBarChart()创建图表,我有一个 DefaultCategoryDataSet 中的数据。

解决方案

CategoryAxis ,它用于 StackedBarChart 中的域轴,您可以使用方法< a href =http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/axis/CategoryAxis.html#setCategoryLabelPositions%28org.jfree.chart.axis.CategoryLabelPositions%29 =nofollow > setCategoryLabelPositions() 。典型用法在 BarChartDemo1 源,显示为此处

  CategoryAxis domainAxis = plot.getDomainAxis(); 
domainAxis.setCategoryLabelPositions(
CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0));


I have created a stacked bar chart in which I show a count on the y axis and dates on the x axis. The problem is that when I have many dates on the x axis it gets very cluttered and impossible to read. I would like to show only some of the dates, e.g one date per week. Is that possible? I am using ChartFactory.createStackedBarChart() to create the chart, and I have the data in a DefaultCategoryDataSet.

Any input is appreciated!

解决方案

For a CategoryAxis, which is used the for the domain axis in a StackedBarChart, you have considerable flexility with the method setCategoryLabelPositions(). Typical usage is illustrated in the BarChartDemo1 source, shown here.

CategoryAxis domainAxis = plot.getDomainAxis();
domainAxis.setCategoryLabelPositions(
    CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0));

这篇关于JfreeChart:堆叠条形图和CategoryAxis显示日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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