PaintscaleLegend problem with the jfreechart

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
ekta1994
Posts: 26
Joined: Fri May 12, 2017 8:06 am
antibot: No, of course not.

PaintscaleLegend problem with the jfreechart

Post by ekta1994 » Thu Jun 22, 2017 4:59 pm

Hi
I am trying to display the PaintScaleLegend for the chart whose paintscale is the variable paintScale in the below code. What I am doing is this:

Code: Select all

SymbolAxis scaleAxis = new SymbolAxis("", new String[]{"Minimum", "Maximum"});
		scaleAxis.setGridBandsVisible(false);
		PaintScaleLegend psLegend = new PaintScaleLegend(paintScale, scaleAxis);
		psLegend.setPosition(RectangleEdge.RIGHT);
		psLegend.setMargin(new RectangleInsets(5, 5, 5, 5));
		chart.addSubtitle(psLegend );
I want only "Minimum" and "Maximum" to be dsiplayed on the extremes of the paintscale. But it shows only "Minimum". I don't know why "Maximum' is not visible. How can this be corrected?

John Matthews
Posts: 513
Joined: Wed Sep 12, 2007 3:18 pm

Re: PaintscaleLegend problem with the jfreechart

Post by John Matthews » Fri Jun 23, 2017 2:57 pm

SymbolAxis "replaces integer values with symbols." How many values are in your PaintScale? If it's not two, you might be able to override SymbolAxis::valueToString to return the desired strings.

ekta1994
Posts: 26
Joined: Fri May 12, 2017 8:06 am
antibot: No, of course not.

Re: PaintscaleLegend problem with the jfreechart

Post by ekta1994 » Fri Jun 23, 2017 4:31 pm

Yes. My paintscale had 100 values(0-100). So I did as mentioned (overriding valuetoString method) and it worked like a charm. Thanks :)
But when my symbol axis has only two items, it was displaying Minimum for zero value, then why wasn't it displaying Maximum for 1 value?

John Matthews
Posts: 513
Joined: Wed Sep 12, 2007 3:18 pm

Re: PaintscaleLegend problem with the jfreechart

Post by John Matthews » Fri Jun 23, 2017 4:38 pm

Glad it helped. I'm not sure about your Maximum value. Maybe rounding, overlap or a scale artifact.

Locked