Changed de colors in

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

Changed de colors in

Post by Inma » Tue Jul 02, 2002 3:48 pm

I have a Line chart with 3 lines, their line colors are automatically red , blue and green. If I want the colors are red, green and blue, then how could I do it?

Help me, please.
Inma.

EKN

Re: Changed de colors in

Post by EKN » Tue Jul 02, 2002 4:20 pm

Hi!!

You have to create an XYPlot object from your JFreeChart object using the getXYPlot() method and then use the method: setSeriesPaint(java.awt.Paint[] paint) to change the color of the lines.

It will look like:

myXYPlot = myJFreeChart.getXYPlot();
myXYPlot.setSeriesPaint(new Paint[] {Color.red, Color.green, Color.blue});

Inma

Re: Changed de colors in

Post by Inma » Tue Jul 02, 2002 4:57 pm

Hi!!
thanks for your answer,

I´m try to do the solution that you give me, but I obtain an exception :
com.jrefinery.chart.VerticalCategoryPlot but I dont Know why... :(

Elio

Re: Changed de colors in

Post by Elio » Tue Jul 02, 2002 5:42 pm

Hi again!!!

Sorry!!!

It isn't a XYPlot. Your chart has a CategoryPlot (or something like this). Try to change the method getXYPlot() by getDataset().

It will look like:

myPlot = myJFreeChart.getDataset();
myPlot.setSeriesPaint(new Paint[] {Color.red, Color.green, Color.blue});

Elio.

Inma

Re: Changed de colors in

Post by Inma » Tue Jul 02, 2002 5:55 pm

Thanks for your help !

Exactly, my chart has a CategoryPlot I try to do something like:

CategoryPlot cPlot = chart.getCategoryPlot();
cPlot.setSeriesPaint(new Paint[] {Color.red, Color.green, Color.blue});

and It´s working!!!!

thanks again ;)
Inma.

Elio

Re: Changed de colors in

Post by Elio » Tue Jul 02, 2002 6:55 pm

Thanks for your correction!!!

;-)

Elio

Locked