I'm trying to display formatted Strings within JFreeChart's legend. The APIAPI shows support for this, but however I cannot get it to display. The aim is to get superscripts, subscripts displayed in jfreecharts legend..
I've written my own renderer and overriden the following:
@Override
public LegendItem getLegendItem(int datasetIndex, int series) {
LegendItem legendItem = super.getLegendItem(datasetIndex, series);
AttributedString attString = new AttributedString("s14");
attString.addAttribute(TextAttribute.FONT, new Font(Font.SANS_SERIF, Font.PLAIN, 10));
attString.addAttribute(TextAttribute.SUPERSCRIPT, TextAttribute.SUPERSCRIPT_SUB, 1,3);
Shape shape = getLegendBar();
Paint paint = getBaseFillPaint();
legendItem = new LegendItem(attString, null, null, null, shape, paint);
return legendItem;
}
But this shows only "s14" as normal string. I need to get the "14" to display in subscript. Does anyone know, what I am doing wrong or how to achieve this ?