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!
Have you tried overriding the generateLabel methods in the label generator? Something like:
I haven't tested the code, but it should only output a label every 7 columns. More info on the label generator is here: http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/labels/CategoryItemLabelGenerator.html
For a
CategoryAxis
, which is used the for the domain axis in aStackedBarChart
, you have considerable flexility with the methodsetCategoryLabelPositions()
. Typical usage is illustrated in theBarChartDemo1
source, shown here.