I have a followed the demo from JFreeChart (StackedBarChartDemo5) in order to create a plot allowing me to use the GroupedStackedBarRenderer
.
Basically, I'm plotting air times for each station (represents a stack in a bar), connected to a radio (represents a bar in the plot), for both receive and transmit (RX and TX).
The plot looks something like this :
There are two categories (RX and TX) and several groups (radios). As you can see, currently, the radio MACs are unreadable.
I would like to rotate these labels, in order to make the plot legible.
I have used the following piece of code in order to try and rotate the labels: subCategoryAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 4));
This only rotated the labels of the categories (RX and TX) instead of the labels of the groups (radio MACs):
I have also tried several other approaches, all of which lead to nowhere... How do I rotate these sublabels?
Here is the underlying code that I used to populate the labels with :
SubCategoryAxis subCategoryAxis = new SubCategoryAxis("Radio MACs (separate Rx and Tx plots)");
subCategoryAxis.setCategoryMargin(0.05D);
// subCategoryAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 4));
KeyToGroupMap keyToGroupMap = null;
final Set<String> radios = Sets.newHashSet();
for (Entry<XRadio, Triplet<XStation, Double, Double>> entryMap: channelTimes.entries()) {
final String radioMac = entryMap.getKey().getMac();
if (keyToGroupMap == null)
keyToGroupMap = new KeyToGroupMap(radioMac);
if (!radios.contains(radioMac)) {
subCategoryAxis.addSubCategory(radioMac);
radios.add(radioMac);
}
final Triplet<XStation, Double, Double> chTriplet = entryMap.getValue();
final String seriesKey = radioMac + ":" + chTriplet.a.getMac();
keyToGroupMap.mapKeyToGroup(seriesKey, radioMac);
model.getDataset().addValue(chTriplet.b, seriesKey, "Rx");
model.getDataset().addValue(chTriplet.c, seriesKey, "Tx");
}
if (keyToGroupMap == null)
return;
groupedStackedBarRenderer.setSeriesToGroupMap(keyToGroupMap);
groupedStackedBarRenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
groupedStackedBarRenderer.setBaseItemLabelsVisible(true);
groupedStackedBarRenderer.setItemMargin(0.1D); // 10 %
groupedStackedBarRenderer.getPlot().setDomainAxis(subCategoryAxis);