Skip to Main Content

How to prepare Hierarchical Tree (Table) to JSON for D3-Charts

Jegor WielerNov 15 2022

Hello everyone,
I am just diving into plugins, which is working very well so far. Thanks to all the users who have helped me here at the forum.
My previous step was to use a JSON format as the data source in the plugin (link). This worked very well.
Now my next planned step is to use a hierarchical tree table as a region source to visualize the D3-Chart.
Basically, I want to write into the region source from the following table as a query and convert the data to a JSON format via the plugin's AJAX callback.

PARENT_ID	        CHILD_ID	        NAME				level
-			1			Root				0
1			2			First Top			1
1			4			Second Top			1
2			8			First Child			2
2			9			Second Child		        2	
4			11			First Child			2
4			12			Second Child		        2
4			13			Third Child			2
12			19			value 1				3
13			14			value 1				3
13			15			value 2				3
14			17			value 1				4
17			16			value 1				5
17			18			value 2				5

The entries should be linked via Child_IDs and Parent_IDs.
I have already tried some approaches that are very close (link). Unfortunately, the approaches I researched use packages and types which not every user has installed.
Is there a way to convert the table with AJAX-Callback to JSON format so that the hierarchy structure is preserved?
I would be very grateful for any advice!

Oracle Apex Version: 22.2
Best Regards
Jegor

Comments
Post Details
Added on Nov 15 2022
4 comments
86 views