Search code examples
javajdeveloperoracle-adf

Java ADF using stored parameter from data control class with stacked bar-graph


I am working with a dual-axis stacked bar graph (ADF component) using a List of objects containing the x-axis labels and the values to be displayed/stacked in the graph.

I'm relatively new to ADF & EJB so I want to apologise in advance if this question seems rudimentary to any of you.

I should mention that I'm using JDeveloper 11.1.1.5

I'm having a hard time with retrieving the value from a variable to be assigned to a property of the bar graph I'm trying to display on my JSF page.

I have briefly summarised the logic below for reference.

The data/list is retrieved from the following class data control:

public class ActivityChart {

 private Double axisScale;

 public ActivityChart() {
     super();
     axisScale = 0.0;
 }

 public List<ActivityDTO> getActivityDetail(List<String> businessUnits) {
     List<ActivityDTO> returnNewList = new ArrayList<ActivityDTO>();
     List<TransactionDTO> dataList = new ArrayList<TransactionDTO>();
     TransactionSessionBean transBean = lookupTransactionSessionBean();

     if (businessUnits != null && !businessUnits.isEmpty()){
         dataList = transBean.getActivityData(SystemUtil.getCurrentUser(), businessUnits);            
         returnNewList = processTransactions(dataList);
         axisScale = calcAxisScale(returnNewList);
     }

     return returnNewList;
 }
 ...

The TransactionDTO object is basically a mirror of the entity object to store the fields from the queried db transactions. The ActivityDTO object contains a String value (x-axis label) and 3 Double values for the values required for the bar graph.

What I'm trying to do is dynamically set the scale for the 2 y-axes (I'm using a dual-axis stacked bar graph) because the auto calculated values are not aligned.

Right now I've got the two relevant elements of the bar graph hard-coded with a specific axis value:

<dvt:y1Axis axisMaxAutoScaled="false" axisMaxValue="100.0"/>
<dvt:y2Axis axisMaxAutoScaled="false" axisMaxValue="100.0"/>

The value I want to use for the Y-axis is calculated and stored in the "axisScale" variable in the above class.

Really at a loss of how to move forward from here.

Would very much appreciate any guidance/direction offered.

Thanks, Karim


Solution

  • Add a getter for axisScale & regenerate your data control. Add a binding for axisScale to your page & then use that as your maximum value.

    The pageDef:

    <attributeValues IterBinding="ActivityChartIterator" id="axisScale">
      <AttrNames>
        <Item Value="axisScale"/>
      </AttrNames>
    </attributeValues>
    

    The page:

    <dvt:y1Axis axisMaxValue="#{bindings.axisScale.attributeValue}" axisMaxAutoScaled="false"/>
    <dvt:y2Axis axisMaxValue="#{bindings.axisScale.attributeValue}" axisMaxAutoScaled="false"/>