CombinedChart with Same Legend

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Casey Rodgers

CombinedChart with Same Legend

Post by Casey Rodgers » Mon Oct 14, 2002 10:09 pm

I have a combined XYPlot with three sub-charts. Each sub-chart as a single point called DataPoint. Is it possible for each plot to have the same color line and to share the legend entry .. instead of having three legend entries called DataPoint?


Thanks,

-- Casey

Lee Irvine

Re: CombinedChart with Same Legend

Post by Lee Irvine » Tue Oct 15, 2002 5:13 pm

Why do you need to recreate the DataPoint 3 times. Is it not possible to have another sub-plot just with this DataPoint on it?
The same color line can be achieved by using a renderer and specifying your own set of colors (each the same), but I don't know how to apply a single legend for 3 different lines. Hope this helps, LEE

Casey Rodgers

Re: CombinedChart with Same Legend

Post by Casey Rodgers » Tue Oct 15, 2002 9:13 pm

The three data points are from three different sources, just the same name.

For example. I need to track kW used at three different locations. Each location with a different sub-chart. I want the legend to just show one kW.

Thanks for the help!


-- Casey

R. Teekema

CombinedXYPlot series colors

Post by R. Teekema » Wed Nov 06, 2002 12:06 pm

I have been using the CombinedXYPlot displaying multiple plots with each another color from the Paint set (default JFreeChart behaviour)
After upgrading to 0.9.4, each chart starts with the first color from the set. Why doesn't it cycle through the default paint set anymore??

Dave Gilbert

Re: CombinedXYPlot series colors

Post by Dave Gilbert » Wed Nov 06, 2002 6:27 pm

R. Teekema wrote:
> I have been using the CombinedXYPlot displaying multiple
> plots with each another color from the Paint set (default
> JFreeChart behaviour)
> After upgrading to 0.9.4, each chart starts with the first
> color from the set. Why doesn't it cycle through the default
> paint set anymore??

Each subplot now uses it's own color set, rather than referring up to the parent plot. This makes a lot of things much simpler in the code, but it does mean that you have to manually set unique colors for each subplot, because they all start off with the same default color set. I will try to find a way to fix this...

Regards,

DG

Dave Gilbert

Re: CombinedChart with Same Legend

Post by Dave Gilbert » Wed Nov 06, 2002 6:28 pm

Casey Rodgers wrote:

> I have a combined XYPlot with three sub-charts. Each
> sub-chart as a single point called DataPoint. Is it
> possible for each plot to have the same color line and to
> share the legend entry .. instead of having three legend
> entries called DataPoint?

You could subclass CombinedXYPlot and override the getLegendItems(...) method. By default, it collects all the legend items from all of the subplots, but you could easily change this.

Regards,

DG

Bjarni

Re: CombinedChart with Same Legend

Post by Bjarni » Tue Nov 19, 2002 5:39 pm

I'm trying to overwrite the getLegendItem() function ... how can I get access to all the subplots within that CombinedXYPlot. Shouldn't there be a sort of "getSubplots()" function in the CombinedXYPlot ? ..

Regards ,
Bjarni

Locked