Colors and Shading

In this section:

These properties and methods control the color and shading of objects in a graph:

When you select a data point, you can change its color as described above, except that if ExactColorByHeight is false, the graphing engine changes the color of the appropriate spectral legend marker's value instead of the color for the exact data value.

Example:

setExactColorByHeight(false);

When you use data ranges from 23 to 57, the gradient goes from blue (20) to red (60). There are spectral markers at 20, 25, 30, ...60. When you click on marker 20 and change it to black, the colors are interpolated from black (20) to red (60). When you click on data point 31 and change its color to green, a new pin with the color green is added at 0.25 (31 is colored as if it were 30 and 30 is 25% of the way from 20 to 60). Now the colors are interpolated as follows: black (20) to green (30); green (30) to red (60).

setExactColorByHeight(true);

When the user clicks on data point 48 and changes its color to yellow, a new pin is added at 0.7 (48 is 70% between 20 and 60) with the color yellow. Now the colors are interpolated as follows: black (20) to green (30); green (30) to yellow (48); yellow (48) to red (60).

You can use the following properties and methods to control the display of shadows in a graph.


Top of page

x
Defining Colors

How to:

Reference:

You can set the color of most graph objects. A color can be defined as rgb values or hex values that specify the intensities of the red, green, and blue components of the color. For some objects, such as rectangular series risers and chart backgrounds, you can also define a transparency value for the fill color.



x
Syntax: How to Define a Color for a Graph Object
setobjectColor(new Color(newValue));

where:

setobjectColor

Is the API call to set the color for the specified object.

newValue

Is the default color value in one of the following formats:

r, g, b is the desired intensity of red, green, and blue, respectively. The values are on a scale of 0 to 255, where 0 is the least intense and 255 is the most intense.

r, g, b, t is the desired intensity of red, green, and blue, respectively, and a transparency value. The values are on a scale of 0 to 255, where 0 is the least intense and 255 is the most intense. For transparency, 0 is fully transparent and 255 is fully opaque.

#hexcolor is the hexadecimal color code, preceded by a pound sign (#). The hexadecimal color value has two hexadecimal digits each for the combination of red, green, and blue color values (RGB). The lowest value for each component is 0 (hex 00). The highest value is 255 (hex FF).

For example, black is #000000, which corresponds to rgb(0,0,0) . Red is #FF0000, which corresponds to rgb(255,0,0). White is #FFFFFF, which corresponds to rgb(255,255,255).



Example: Setting a Fill Color for the Chart Frame

The following request sets the chart frame fill color to aqua (rgb 0,255,255):

GRAPH FILE WF_RETAIL_LITE
SUM COGS_US REVENUE_US GROSS_PROFIT_US
BY PRODUCT_CATEGORY
ON GRAPH PCHOLD FORMAT PNG
ON GRAPH SET LOOKGRAPH VBAR
ON GRAPH SET STYLE *
*GRAPH_SCRIPT
 setFillColor(getFrame(),new Color(0,255,255));    
setPlace(true);
*END 
 ENDSTYLE
 END

The output is:

To express the color as a hex value, the equivalent API call is:

setFillColor(getFrame(),new Color(#00FFFF));


x
Reference: Usage Notes for Color Transparency

Color transparency support is limited and only applies to transparent rectangular regions (so, for example, it is not supported for pie slices). In addition:



Example: Setting a Color Transparency for a Series Fill Color

The following request sets the series 0 (cost of goods) fill color to fully transparent (transparency 0):

GRAPH FILE WF_RETAIL_LITE
SUM COGS_US REVENUE_US GROSS_PROFIT_US
BY PRODUCT_CATEGORY
ON GRAPH PCHOLD FORMAT PNG
ON GRAPH SET LOOKGRAPH VBAR
ON GRAPH SET STYLE *
*GRAPH_SCRIPT
setFillColor(getSeries(0),new Color(192,192,192,0));
setPlace(true);
*END 
 ENDSTYLE
 END

The output is:

Changing the transparency value to 255 makes the fill totally opaque:

setFillColor(getSeries(0),new Color(192,192,192,255));

Changing the transparency value to 100 makes the fill partially transparent:

setFillColor(getSeries(0),new Color(192,192,192,100));



Example: Setting a Transparency Value for the Chart Background and Frame

The following request makes the chart frame black with a transparency value of 128, makes the chart background aqua with a transparency value of 128, and uses the transparent fill color for the frame side:

GRAPH FILE WF_RETAIL_LITE
SUM COGS_US REVENUE_US GROSS_PROFIT_US
BY PRODUCT_CATEGORY
ON GRAPH PCHOLD FORMAT PNG
ON GRAPH SET LOOKGRAPH VBAR
ON GRAPH SET STYLE *
*GRAPH_SCRIPT
  setFillColor(getFrame(),new Color(0,0,0,128));
  setFillColor(getChartBackground(),new Color(0,255,255,128));
  setTransparentFillColor(getFrameSide(),true);
setO1AxisLineDisplay(true);
setO1MajorGridDisplay(true);
setO1MajorGridStyle(0);
setY1AxisLineDisplay(true);
setY1MajorGridDisplay(true);
setY1MajorGridStyle(0);
setPlace(true);
*END 
 ENDSTYLE
 END

The output is:


WebFOCUS