From: jc_usernet on 14 Feb 2010 22:18 Hello. I am working with JFreeChart (1.0.13) and wish to modify the manner the legend displays entries for the multiple XY time series. I want to display 2 series on the graph with one entry into the legend. The example is grouping a Max and a Min series which gives a graph above and below an Avg series. As such I want them displayed together under the name of "Max&Min". My current code is; -------------------- this.plot.setDataset( dataset_Index[i], createDataset(dataset_DBColumnName[i]) ); this.plot.setRenderer( dataset_Index[i], dataset_Renderer[i] ); where plot is a class XYPlot -------------------- I have tried setting the display name in the legend (which comes from dataset_DBColumnName[i]) - the name of the generated series ) to null and "" without success. The first gives a run time error while the second makes a legend entry with the "" string. Is there a way I can control this legend entries while I create events loading in these different series into the Dataset? A possible work around (which I have not tried) is concatenation the 2 series (Min and Max) together, but a fly back line might occur (most likely). Regards JC.....
From: John B. Matthews on 15 Feb 2010 10:36 In article <08df2d97-d6dc-400a-9a24-93dc48542ae5(a)f17g2000prh.googlegroups.com>, jc_usernet <jc_usernet(a)aanet.com.au> wrote: > I am working with JFreeChart (1.0.13) and wish to modify the manner > the legend displays entries for the multiple XY time series. I want > to display 2 series on the graph with one entry into the legend. The > example is grouping a Max and a Min series which gives a graph above > and below an Avg series. As such I want them displayed together > under the name of "Max&Min". > My current code is; > -------------------- > this.plot.setDataset( dataset_Index[i], > createDataset(dataset_DBColumnName[i]) ); > this.plot.setRenderer( dataset_Index[i], dataset_Renderer[i] ); > > where plot is a class XYPlot > -------------------- > I have tried setting the display name in the legend (which comes from > dataset_DBColumnName[i]) - the name of the generated series ) to null > and "" without success. The first gives a run time error while the > second makes a legend entry with the "" string. > > Is there a way I can control this legend entries while I create > events loading in these different series into the Dataset? A possible > work around (which I have not tried) is concatenation the 2 series > (Min and Max) together, but a fly back line might occur (most > likely). I've never combined legend items this way; I'd argue against it. Of course, you can always add another legend: LegendItemSource lis = new LegendItemSource() { LegendItem li = new LegendItem("Min&Max"); LegendItemCollection lic = new LegendItemCollection(); { lic.add(li); } public LegendItemCollection getLegendItems() { return lic; } }; chart.addLegend(new LegendTitle(lis)); <http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/LegendItem.html> -- John B. Matthews trashgod at gmail dot com <http://sites.google.com/site/drjohnbmatthews>
|
Pages: 1 Prev: Newbie question: Signing a Java applet Next: How do i know which superclass to inherit from... |