Contents Previous Next

4.8 Specifying colors in JpGraph

Colors can be specified in three different ways
  1. By using one of the, roughly, 400 pre-defined color names, e.g
     
    SetColor("khaki");

    A named color can also be modified by adding a adjustment factor. An adjustment factor, 0 < f < 1, a smaller value will give a darker version and a value of 0 or 1 will return the original color. A value > 1 will make the color brighter. A few examples
     

    SetColor("khaki:0.5"); // A darker version of "khaki"
    SetColor("yellow:1.2"); // A slightly lighter version of "yellow"

  2. By specifying a RGB triple, e.g.
     
    SetColor(array(65,100,176));

  3. By specifying the color as a hex string value
     
    SetColor("#A16BFF");

4.8.1 Adjusting the transparency

From version 1.10 JpGraph also supports the use of Alpha Blending together with GD2.x This lets you specify how much of the underlying color should be visible. You specify the amount of transparency for a color by adding an extra parameter to the color specification separated by an '@' (at) character.

For example to specify a red color which is 40% transparent you write
 

SetColor("red@0.4");

or to specify 90% transperancy you write
 

SetColor("red@0.9");

Below is an example of how a bar graph with a background image can make use of transperancy

4.8.2 Available named colors

The chart below shows all available named colors.


4.8.3 Theme colors for pie:s

For more on how to use the different themes see Working with 2D &3D pie plots
Theme 1: Earth

 
Theme 2: Pastel

 
Theme 3: Water

 
Theme 4: Sand


Contents Previous Next