Default Colours

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Alan - Blue
Posts: 5
Joined: Wed Nov 15, 2006 5:03 pm

Default Colours

Post by Alan - Blue » Tue Mar 13, 2007 5:52 pm

Just noticed that when I have so many categories the colours on the bars repeat them selves.

anyone else has a simular problem? and how does one change this without specifying every single colour.

skunk
Posts: 1087
Joined: Thu Jun 02, 2005 10:14 pm
Location: Brisbane, Australia

Post by skunk » Tue Mar 13, 2007 8:40 pm

Crate your own instance of a class that implements

Code: Select all

org.jfree.chart.plot.DrawingSupplier
Then call

Code: Select all

plot.setDrawingSupplier(...)
and pass in your new class

matinh
Posts: 483
Joined: Fri Aug 11, 2006 10:08 am
Location: Austria

Post by matinh » Wed Mar 14, 2007 9:13 am

Or even simpler: create your own DrawingSupplier like this:

Code: Select all

new DefaultDrawingSupplier(
                        new Paint[] {
                                new Color(0x55, 0x55, 0xFF),
                                new Color(0x55, 0xFF, 0xFF),
                                ... },
                        DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE,
                        DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE,
                        DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE,
                        DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE));
And set it like skunk wrote above. This way you don't have to implement the whole interface.

hth,
- martin

tatia34
Posts: 23
Joined: Fri Apr 27, 2007 2:11 pm
Location: France

Post by tatia34 » Wed May 16, 2007 10:43 am

hi, I have a problem with this code.... I do that, but the colors always are red, blue,green.... as the default sequence.

my code : (where jfc is a correctly create JFreeChart)

Code: Select all

                jfc.getPlot().setDrawingSupplier(new DefaultDrawingSupplier(
                        new Paint[] {Color.ORANGE,Color.green},
                        new Paint[] {Color.darkGray},
                        DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE,
                        DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE,
                        DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE)
                );
four hours that i try some differents ways but no results :shock:
please, some help would be welcome

tatia34
Posts: 23
Joined: Fri Apr 27, 2007 2:11 pm
Location: France

Post by tatia34 » Mon May 21, 2007 9:20 am

just before, I do jfc.setTitle(title); and it changes the title of my chart... so the jfc variable is OK and is the chart that I have to modify. but no color changes .... I don't understand what isn't going...

edit : more test, and it's ok for PiePlot but not for CategoryPlot and XYPlot...

tatia34
Posts: 23
Joined: Fri Apr 27, 2007 2:11 pm
Location: France

Post by tatia34 » Tue May 22, 2007 3:23 pm

mystery… yesterday evening, that did not draw with good colors, and this morning, I have restart my computer and there were good colors. :roll:
Last edited by tatia34 on Mon Jun 04, 2007 11:19 am, edited 1 time in total.

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Tue May 22, 2007 4:23 pm

You have to be sure to set the drawing supplier *before* the chart is drawn for the first time, because it only consults the drawing supplier once and after that it uses the cached values.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

Locked