Solution: ADF Faces 11.1.2.4, How to programmatically build a dvt:pieGraph with List of elements.

While looking for a programmatic approach to generating a dvt:pieGraph, I noticed the collection data is slightly different compared to rendering a dvt:barGraph. After a quick search on the OTN Forum returned a thread but it looks like it was never answered entirely.

See the example solution below:

Within the backing bean:

public List<Object[]> getListObject() {
if (listObject == null) {
listObject = new ArrayList<Object[]>();
Object[] obj1 = { "Example_Bar_1", "Series_1", 10 };
Object[] obj2 = { "Example_Bar_1", "Series_2", 15 };
Object[] obj3 = { "Example_Bar_1", "Series_3", 75 };

listObject.add(obj1);
listObject.add(obj2);
listObject.add(obj3);

}
return listObject;
}

JSF code:

<dvt:pieGraph id="graph2" subType="PIE" tabularData="#{YOURBEAN.listObject}">
<dvt:graphPieFrame/>
<dvt:sliceLabel/>
<dvt:pieLabel rendered="true"/>
<dvt:legendArea automaticPlacement="AP_NEVER"/>
</dvt:pieGraph>

Runtime render:
Image

Advertisements

About wesfang

www.linkedin.com/in/wesfang/ https://twitter.com/wesleyfang
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s