Automatic generate line color visible on white background

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
yccheok
Posts: 48
Joined: Mon Feb 16, 2009 4:58 am

Automatic generate line color visible on white background

Post by yccheok » Sun Mar 18, 2012 6:28 am

Currently, I have a chart which is using white color as background. Most of the time, the drawn line series with auto color, may yield certain line colors, which its color is hardly visible on white background.

I try to manual specific the color.

Code: Select all

    public static void setPriceSeriesPaint(XYItemRenderer xyItemRenderer) {
        xyItemRenderer.setSeriesPaint(0, new Color(255, 88, 88));
        xyItemRenderer.setSeriesPaint(1, new Color(0, 255, 0));
        xyItemRenderer.setSeriesPaint(2, new Color(0, 0, 255));
        xyItemRenderer.setSeriesPaint(3, new Color(255, 0, 0));
    }
However, there is no limits on the line series which can be drawn. Hence, after specific several colors manually, I find it is rather difficult to provide a reasonable large set (says 50) of color which is visible on white background, by doing it manually.

Is there any automated way, which I can use. Instead of choosing the color manually?

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

Re: Automatic generate line color visible on white backgroun

Post by John Matthews » Sun Mar 18, 2012 12:15 pm

Cross-posted here.

Although now deleted, a commenter there suggested the Q&A How to automatically generate N “distinct” colors.

Locked