In my JFreeChart graphic entries, I find that the lines of the legends are thin in order to accurately see the color. Another post [ jfreechart - change the color swatch in the legend ] suggested overriding the rendering method as follows:
renderer = new XYLineAndShapeRenderer() { private static final long serialVersionUID = 1L; public Shape lookupLegendShape(int series) { return new Rectangle(15, 15); } };
this approach works fine until you do what i did
renderer.setSeriesShapesVisible(i, false);
Once I have done this, the legend will return to the line. Is there any way around this?
The decision I made is close to the solution proposed by TrashGod . I tried the getLegendItem () method, forcing the legend form in the desired field.
renderer = new XYLineAndShapeRenderer() { private static final long serialVersionUID = 1L; public LegendItem getLegendItem(int datasetIndex, int series) { LegendItem legend = super.getLegendItem(datasetIndex, series); return new LegendItem(legend.getLabel(), legend.getDescription(), legend.getToolTipText(), legend.getURLText(), Plot.DEFAULT_LEGEND_ITEM_BOX, legend.getFillPaint()); } };
source share