I tried the above suggestion, but it didn't seem to work for me. If you just want to remove a series from a legend, you can do this using the setSeriesVisibleInLegend() method. My scenario was that some of my episodes do not have a legend key. If they do not have a legend key, the series should not be visible in the legend. I implemented this with the following code:
for(int i = 0; i < seriesList.size(); i++){ if(seriesList.get(i).getKey() == null || seriesList.get(i).getKey().equals("")){ graph.getXYPlot().getRenderer().setSeriesVisibleInLegend(i, Boolean.FALSE); } }
seriesList is a list of the seriesData pojo I created that contains all the graph data for creating a graph. If the value of the seriesData key of the object is null or = "" , then the series will not be visible in the legend.
Jason
source share