legend « Dataset « JFreeChart Q&A





3. 2 datasets with the same legend    jfree.org

try this: LegendTitle leg_title1 = new LegendTitle(plot.getRenderer(0)); leg_title1.setMargin(new RectangleInsets(2, 2, 2, 2)); leg_title1.setBorder(new BlockBorder()); leg_title1.setBackgroundPaint(Color.WHITE); LegendTitle leg_title2 = new LegendTitle(plot.getRenderer(1)); leg_title2.setMargin(new RectangleInsets(2, 2, 2, 2)); leg_title2.setBorder(new BlockBorder()); leg_title2.setBackgroundPaint(Color.WHITE); BlockContainer container1 = new BlockContainer(new BorderArrangement()); container1.add(leg_title1, RectangleEdge.LEFT); BlockContainer container2 = new BlockContainer(new BorderArrangement()); container2.add(leg_title2, RectangleEdge.RIGHT); CompositeTitle comp_title_1 = new CompositeTitle(container1); CompositeTitle comp_title_2 = new CompositeTitle(container2); comp_title_1.setPosition(RectangleEdge.BOTTOM); comp_title_2.setPosition(RectangleEdge.BOTTOM); chart.addSubtitle(comp_title_1); chart.addSubtitle(comp_title_2);

4. Trying to create custom Legend with Values from dataset    jfree.org

This feature is not available in JFreeChart (I inquired about it a couple years ago). You could use a JTable to display the table below the frame. It is fairly easy to write a TableModel that queries the dataset and populates the table. The 'legend' is easily accomplished via a custom TableCellRenderer which queries the legend information from the plot. If ...