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.