In StackedBarChartDemo2, I created DefaultIntervalCategoryDataset instance and used it when I created JFreeChart as follows (used DateAxis as well):
-------------------------------------------------------------------------------------
private org.jfree.data.CategoryDataset createModifiedDataset() {
Double[][] start = new Double[][]
{
{new Double(date(0, 6).getTime()), new Double(date(0, 6).getTime())},
{new Double(date(30, 7).getTime()), new Double(date(0, 10).getTime())}
};
Double[][] end = new Double[][]
{
{new Double(date(30, 7).getTime()), new Double(date(0, 10).getTime())},
{new Double(date(0, 9).getTime()), new Double(date(30, 16).getTime())}
};
String[] rowKeys = new String[]{"TD", "CS"};
String[] columnKeys = new String[]{"RO101", "RO102"};
org.jfree.data.DefaultIntervalCategoryDataset dataset =
new org.jfree.data.DefaultIntervalCategoryDataset(rowKeys, columnKeys, start, end);
return dataset;
}
public static JFreeChart createModifiedStackedBarChart(String title,
String domainAxisLabel,
String rangeAxisLabel,
CategoryDataset data,
PlotOrientation orientation,
boolean legend,
boolean tooltips,
boolean urls) {
CategoryAxis categoryAxis = new CategoryAxis(domainAxisLabel);
ValueAxis valueAxis = new DateAxis(rangeAxisLabel);
org.jfree.chart.renderer.IntervalBarRenderer renderer = new org.jfree.chart.renderer.IntervalBarRenderer();
if(tooltips) {
renderer.setItemLabelGenerator(new IntervalCategoryItemLabelGenerator(new java.text.SimpleDateFormat("hh:mma")));
}
if(urls) {
renderer.setItemURLGenerator(new StandardCategoryURLGenerator());
}
CategoryPlot plot = new CategoryPlot(data, categoryAxis, valueAxis, renderer);
plot.setOrientation(orientation);
JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
return chart;
}
-------------------------------------------------------------------------------------
The problem is each interval in a category is separated as follows:
*****
#####
I want them to be together as in StackedBarChartDemo2 as:
*****#####
Also, when I say renderer.setItemLabelsVisible(true); a time range is shown on top of each interval bar, not inside the interval bar as in StackedBarChartDemo2. Can I put "TD" or "CS" series labels (above example rowKeys) inside corresponding intervals?
Thank you.
Q