Using graph methods – PB Docs 126

Using graph methods

You call the data-access methods after a graph has been created
and populated with data. Some graphs, such as graphs that display
data for a page or group of data, are destroyed and re-created internally
as the user pages through the data. Any changes you made to the
display of a graph, such as changing the color of a series, are
lost when the graph is re-created.

Event for graph creation

To be assured that data-access methods are called whenever
a graph has been created and populated with data, you can call the
methods in the code for an event that is triggered when a graph
is created. The
event is:

  • PowerBuilder

    Event ID pbm_dwngraphcreate, which you can assign
    to a user event for a DataWindow control (described below)

  • Web ActiveX

    The onGraphCreate event

The graph-creation event is triggered by the DataWindow control
after it has created a graph and populated it with data, but before
it has displayed the graph. By accessing the data in the graph in
this event, you are assured that you are accessing the current data
and that the data displays the way you want it.

Setting up the PowerBuilder user event

PowerBuilder provides an event ID, pbm_dwngraphcreate,
that you can assign to a user event for a DataWindow control.

proc.png To access data properties of a graph in a DataWindow

  1. Place the DataWindow control in a window
    or user object and associate it with the DataWindow object containing
    the graph.

    Next you create a user event for the DataWindow control that
    is triggered whenever a graph in the control is created or changed.

  2. Select Insert>Event from the menu bar.

    The Script view displays and includes prototype fields for
    adding a new event.

  3. Select the DataWindow control in the first drop-down
    list of the prototype window.

    If the second drop-down list also changes to display an existing DataWindow
    event prototype, scroll to the top of the list to select New Event
    or select Insert>Event once again from the menu bar.

  4. Name the user event you are creating.

    For example, you might call it GraphCreate.

  5. Select pbm_dwngraphcreate for the event

  6. Click OK to save the new user event.

  7. Write a script for the new GraphCreate event that
    accesses the data in the graph.

    Calling data access methods in the GraphCreate event assures
    you that the data access happens each time the graph has been created
    or changed in the DataWindow.



The following statement sets to black the foreground (fill) color
of the Q1 series in the graph gr_quarter, which is in the
DataWindow control dw_report. The statement is in the GraphCreate
event, which is associated with the event ID pbm_dwngraphcreate
in PowerBuilder:

The following statement changes the foreground (fill) color
to red of the second data point in the Stellar series in the graph
gr_sale in a window. The statement can be in a script for
any event:

Web ActiveX

The following statement sets the foreground (fill) color to black
in one of the series in the graph gr_quarter, which is
in the DataWindow control dw_report. The statement is in
the onGraphCreate event:

For more information

For complete information about the data-access graph methods,
see the DataWindow Reference.

For more about PowerBuilder user events, see the PowerBuilder
Users Guide

Document get from Powerbuilder help
Thank you for watching.
Was this article helpful?
Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x