Syntax 1 For setting a data point’s colors
Description
Specifies the colors of a data point in a graph.
Controls
Graph controls in windows and user objects, and graphs in
DataWindow controls
Syntax
|
1 |
<span>controlname</span>.<span>SetDataStyle</span> ( { <span>graphcontrol</span>, } <span>seriesnumber</span>, <span><br> datapointnumber</span>, <span>colortype</span>, <span>color</span> ) |
|
Argument |
Description |
|---|---|
|
controlname |
The name of the graph in which you want |
|
graphcontrol (DataWindow control |
A string whose value is the name of the |
|
seriesnumber |
The number of the series in which you |
|
datapointnumber |
The number of the data point for which |
|
colortype |
A value of the grColorType enumerated
|
|
color |
A long whose value is the new color for colortype. |
Return Values
Integer. Returns 1 if it succeeds and
-1 if an error occurs. If any argument’s value is null, SetDataStyle returns null.
Usage
To change the appearance of a series, use SetSeriesStyle.
The settings you make for the series are the defaults for all data
points in the series.
To reset the color of individual points back to the series
color, call ResetDataColors.
For a graph in a DataWindow, you can specify the appearance
of a data point in the graph before PowerBuilder draws the graph.
To do so, define a user event for pbm_dwngraphcreate and
call SetDataStyle in the script for that event.
The event pbm_dwngraphcreate is triggered
just before a graph is created in a DataWindow object.
Using SetDataStyle with DirectX 3D Graphs
You can only set the color for the foreground. Background,
line color, and shade are not supported.
Examples
This example checks the background color for data
point 6 in the series named Salary in the graph gr_emp_data.
If it is red, SetDataStyle sets it to black:
|
1 |
long color_nbr |
|
1 |
integer SeriesNbr |
|
1 |
// Get the number of the series |
|
1 |
SeriesNbr = gr_emp_data.FindSeries("Salary") |
|
1 |
// Get the background color |
|
1 |
gr_emp_data.GetDataStyle(SeriesNbr, 6, & |
|
1 |
Background!, color_nbr) |
|
1 |
// If color is red, change it to black |
|
1 |
IF color_nbr = 255 THEN & |
|
1 |
gr_emp_data.<span>SetDataStyle</span>(SeriesNbr, 6, & |
|
1 |
Background!, 0) |
These statements set the text (foreground) color
to black for data point 6 in the series named Salary in the graph gr_depts in
the DataWindow control dw_employees:
|
1 |
integer SeriesNbr |
|
1 |
// Get the number of the series |
|
1 |
SeriesNbr = & |
|
1 |
dw_employees.FindSeries("gr_depts" <span>,</span> "Salary") |
|
1 |
// Set the background color |
|
1 |
dw_employees.<span>SetDataStyle</span>("gr_depts" <span>,</span> SeriesNbr, & |
|
1 |
6, Background!, 0) |