Programmatic DVT charts in Oracle ADF

JDev: 12.2.1.3.0
Source: GitHub

This article talks about programmatic approach of creating dvt components or charts, using Java objects, and more importantly, without ADF bindings. This is quite helpful when you deal with data which does not change often and can be pre-loaded into Java objects. The biggest advantage of this is of course, performance, since you do away with any database interaction.

The sample code has a table based on Department pojo. Each department object has a List of Employee pojo. On table row selection, I retrieve the list of employees, and I use this list to create the Object array required for each chart type.



There are a couple of key points to this approach:
1) Your Java data model should be prepared to provide all the required information to the chart.
2) You need to know the "Tabular Data" format for each graph.

My data-model consists of a Department object, having a list of Employee objects.



Each graph's tabular data format is an array of Objects (Object[]). The exact format of data can be obtained for each chart type's documentation.

I am providing the Oracle documentation links for three of these components - pie, bar and gauge - the ones I have used in my sample.

dvt:barGraph - The bar graph documentation says, the first member of the array is the column label, the second member is the row label and the third member is the data value.

BarChart.java



dvt:pieGraph - The pie graph implementation is similar to bar graph.

PieChart.java



dvt:gauge

GaugeChart.java



Cheers!

Comments