8 Visualizing SQL Graph Queries Using the APEX Graph Visualization Plug-in
You can use the Oracle Application Express (APEX) Graph Visualization plug-in to visualize and interact with SQL property graphs in an APEX application.
The following topics explain more about the plug-in:
- About the APEX Graph Visualization Plug-in
The APEX Graph Visualization plug-in integrates a Java Script Library that supports graph visualization in APEX applications. - Getting Started with the APEX Graph Visualization Plug-in
This section helps you get started with the Graph Visualization plug-in in your APEX application. - Configure Attributes for the APEX Graph Visualization Plug-in
Learn how to customize your graph visualization using the Graph Visualization plug-in attributes in your APEX application.
Parent topic: SQL Property Graphs
8.1 About the APEX Graph Visualization Plug-in
The APEX Graph Visualization plug-in integrates a Java Script Library that supports graph visualization in APEX applications.
See Graph JavaScript API Reference for Property Graph Visualization for more information.
The plug-in mainly allows you to:
- Visualize SQL property graph queries from the graph data in your database.
- Explore the graph vertices and edges. You can also select and visualize these graph elements individually or in groups.
- Interact with the graph visualization by performing various actions such as changing the graph layouts, grouping or ungrouping selected vertices, removing selected vertices or edges, and so on.
- Style the vertices and edges in the graph by configuring the style settings such as size, color, icon, label values, and so on.
- Visualize and study the evolution of the graph over time.
The following figure shows an example of graph visualization in an APEX application using the plug-in:
Description of the illustration apex_graphviz_plugin.png
8.2 Getting Started with the APEX Graph Visualization Plug-in
This section helps you get started with the Graph Visualization plug-in in your APEX application.
- The target application into which you want to import the plug-in exists.
- The SQL property graph to be used for visualization exists in the
default database schema.
Using the command editor in the SQL Workshop component, you can create a SQL property graph using the
CREATE PROPERTY GRAPH
DDL statement (see Using the Command Editor).
- Importing the Sample Graph Visualizations Application in APEX
The Sample Graph Visualizations application demonstrates the use of the Graph Visualization plug-in. - Graph Visualization with Pagination
You can implement pagination when using theORA_SQLGRAPH_TO_JSON
function.
8.2.1 Importing the Sample Graph Visualizations Application in APEX
The Sample Graph Visualizations application demonstrates the use of the Graph Visualization plug-in.
To view the visualization for a SQL property graph query using
the ORA_SQLGRAPH_TO_JSON
function (shown highlighted in the
preceding figure), you need to perform the following additional steps:
8.2.2 Graph Visualization with Pagination
You can implement pagination when using the
ORA_SQLGRAPH_TO_JSON
function.
ORA_SQLGRAPH_TO_JSON
function, you must ensure the following:
- Switch ON the SQL Query Supports Pagination setting in the Attributes tab of the Property Editor for the graph visualization component in your APEX application.
- Add the
page_start
andpage_size
parameters in the helper function as shown in the following example code:CREATE OR REPLACE FUNCTION bank_sqlgraph_json ( QUERY VARCHAR2, PAGE_START NUMBER DEFAULT -1, PAGE_SIZE NUMBER DEFAULT -1 ) RETURN CLOB AUTHID CURRENT_USER IS INCUR SYS_REFCURSOR; L_CUR NUMBER; RETVALUE CLOB; BEGIN OPEN INCUR FOR QUERY; L_CUR := DBMS_SQL.TO_CURSOR_NUMBER(INCUR); RETVALUE := ORA_SQLGRAPH_TO_JSON(L_CUR, PAGE_START, PAGE_SIZE); DBMS_SQL.CLOSE_CURSOR(L_CUR); RETURN RETVALUE; END;
- Bind variables to
page_start
andpage_size
when calling the helper function in the SQL Query input in the Region tab of the Property Editor:SELECT bank_sqlgraph_json('SELECT id_a, id_e, id_b FROM GRAPH_TABLE (bank_sql_pg MATCH (a IS accounts) -[e IS transfers]-> (b IS accounts) WHERE a.id = 816 COLUMNS (vertex_id(a) AS id_a, edge_id(e) AS id_e, vertex_id(b) AS id_b) )', :page_start, :page_size ) AS result_column FROM DUAL;
Note that the
page_start
value is automatcially set. You can set the value ofpage_size
in the Attributes tab of the Property Editor.
8.3 Configure Attributes for the APEX Graph Visualization Plug-in
Learn how to customize your graph visualization using the Graph Visualization plug-in attributes in your APEX application.
You can configure the attributes for the plug-in component in the Attributes tab (Property Editor) on the right pane of the Page Designer.
Description of the illustration apex_plugin_attr.png
See the Interface page in Graph JavaScript API Reference for Property Graph Visualization which describes the interface mapping for the plugin attributes.
The attributes are grouped as per their scope in the following panels:
Settings
Attribute | Description |
---|---|
Page Size | Specify the number of vertices and edges to be displayed per page. |
Settings | Specify the graph settings in JSON format. See Settings for more information. |
SQL Query supports Pagination | Switch on this toggle if you are implementing the
paginate
interface.
See Graph Visualization with Pagination for more information. |
Appearance
Attribute | Description |
---|---|
Layout | Specify the graph layout. |
Group Edges | Switch on this toggle to group edges. |
Vertex Label | Specify the property to be used for the vertex label. |
Edge Label | Specify the property to be used for the edge label. |
Maximum Label Length | Specify the maximum length of the label. |
Display Modes | Select this checkbox to display the modes panel with the
following options:
|
Display Exploration | Select this checkbox to display the following graph exploration
actions:
|
Styles | Specify the styles configuration in JSON format. See Styles for more information. |
Callbacks
Attribute | Description |
---|---|
Expand | To expand a selected vertex in the graph visualization, see Expand for more information. |
FetchActions | To retrieve the graph actions from a data source, refer to fetchActions for more information. |
Persist | To persist the graph actions to a data source, refer to persist for more information. |
- Settings
You can apply different graph settings such as switching layouts, grouping edges, or showing the evolution of the graph entities based on a property using the Settings attribute in the Property Editor of the Page Designer. - Styles
You can style a graph using the Styles attribute in the Property Editor of the Page Designer. - Expand
You can expand a selected vertex in the graph and fetch the adjacent vertices using the Expand attribute in the Property Editor of the Page Designer.
8.3.1 Settings
You can apply different graph settings such as switching layouts, grouping edges, or showing the evolution of the graph entities based on a property using the Settings attribute in the Property Editor of the Page Designer.
8.3.2 Styles
You can style a graph using the Styles attribute in the Property Editor of the Page Designer.