Oracle had this excellent graph utility in the earlier releases of Jdeveloper. It was Bi-graph, which user can use to represent the data in graphical forms.

This has been replaced in JDeveloper 11g by DVT component. However, the new Faces DVT component forces user to use Faces components, which may not be a requirement always. Neverthless, both the components (old BI graph and latest DVT components) are closely tied to the Datacontrols. What if user has Hibernate at the server side and want to use these components. The writeup, descibes one of the different ways, to show the data using BI Graph.

The IDE used was Oracle Jdeveloper

Idea is to create an oracle.dss.thin.beans.graph.ThinGraph object in the background, set the data from any datasource (dummy data in this example), export the graph as image, and show in the JSP

Idea GraphUtil.java creates a Graph object. The visual properties required by Graph will be provided by an xml file. Jdeveloper provides a wizard to edit the xml. This however can be edited without Jdeveloper, if user is aware of the elements required:


package com.aminur.graph.legacy.model.util;

import java.awt.Dimension;

import java.io.OutputStream;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

import oracle.dss.dataView.Dataview;
import oracle.dss.thin.beans.graph.ThinGraph;

/* 
 * @author Aminur Rashid (aminur ^ aminurrashid.com) 
 * Utility method that generates graph.
 * Currently uses the dummy data but can be customized as per
 * project requirements to fetch data from any of the VO/DAO class.
 * It creates a oracle.dss.graph.Graph object and exports it to an Image.
 */ 

public class GraphUtil {
    private ThinGraph graph1 = new ThinGraph();
    private static List dummyData = null;
    public GraphUtil() {

        try {
            graph1.readXML(this.getClass().getClassLoader().getResourceAsStream("BIGraphDef.xml"),
                       Dataview.RESET_XML_PROPERTIES);
            graph1.setImageSize(new Dimension(600,500));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    

    public void getGraphImageInStream (OutputStream o, String gType){
        if (gType==null || !gType.equals("Line"))
                   graph1.setGraphType(ThinGraph.BAR_VERT_CLUST );
        else{
            graph1.setGraphType(ThinGraph.LINE_VERT_ABS);
        }
        // = OrderCountDAO.getOrderStats();
        // fetch from real Dao,VO, ??
        List ls  = fetchDummyData();
        reSetGraph(ls);
       graph1.exportToGIF(o);
    }
    
    private void reSetGraph(List ls)
    {
         graph1.setTabularData(ls);
        
    }
    
    public static List fetchDummyData(){
        if(dummyData==null){
            dummyData = new ArrayList();
            java.util.Date dt = Calendar.getInstance().getTime();
            String masterSystemId = "SLS (12)";
            createDummyData(dummyData, 12, masterSystemId);
            masterSystemId = "DWP (5)";
            createDummyData(dummyData, 5, masterSystemId);
            masterSystemId = "OAT (6)";
            createDummyData(dummyData, 6, masterSystemId);
            masterSystemId = "Portal (7)";
            createDummyData(dummyData, 7, masterSystemId);
        }
        return dummyData;
    }
    
    private static void createDummyData(List dataVector, int unique, String masterSystemid)
    {
        for(int k = 0; k <span data-mce-type="bookmark" style="display: inline-block; width: 0px; overflow: hidden; line-height: 0;" class="mce_SELRES_start"></span>< 4; k++)
        {
            Object rows[] = new Object[3];
            rows[0] = Integer.valueOf(k);
            rows[1] = masterSystemid;
            if(k == 3)
                rows[2] = Integer.valueOf(k * unique);
            else
                rows[2] = Integer.valueOf(k * unique * 2);
            dataVector.add(((Object) (rows)));
        }

    }
}

BIGraphDef.xml

<?xml version="1.0" ?>
<Graph version="11.1.1.0" name="Graph" stylePath="/oracle/dss/graph/styles/autumn_simple.xml" depthAngle="50" depthRadius="12" pieDepth="100" markerDisplayed="false" pieTilt="41" seriesEffect="SE_AUTO_GRADIENT" graphType="BAR_VERT_CLUST">
  <DataviewTitle text="Order Statistics" visible="true"/>
  <ImageSize width="400" height="400"/>
  <MarkerText visible="true">
    <GraphFont name="SansSerif.plain" size="11" fontColor="#3b3b3b"/>
    <Y1ViewFormat>
      <ViewFormat numberType="NUMTYPE_GENERAL" thousandSeparator="THOU_SEP_BY_LOCALE" decimalDigit="0" negNumFmt="NEG_NUMFMT_NEG_NUM" numberTypeUsed="true" thousandSeparatorUsed="true" leadingZeroUsed="true" decimalDigitUsed="true" negNumFmtUsed="true"/>
      </Y1ViewFormat>
  </MarkerText>
  <O1Title text="Time (in hours)" visible="true"/>
  <Slice labelPosition="LP_OUTSIDE_WITH_FEELER"/>
  <Y1Axis scaledLogarithmic="false" axisMinAutoScaled="true" axisMaxAutoScaled="true" majorTickStepAutomatic="true">
    <ViewFormat numberType="NUMTYPE_GENERAL" thousandSeparator="THOU_SEP_BY_LOCALE" negNumFmt="NEG_NUMFMT_NEG_NUM" numberTypeUsed="true" thousandSeparatorUsed="true" leadingZeroUsed="true" negNumFmtUsed="true"/>
  </Y1Axis>
  <Y1TickLabel textRotation="TR_HORIZ">
    <GraphFont name="SansSerif" size="11"/>
  </Y1TickLabel>
  <Y1Title text="Orders (Numbers)" visible="true"/>
</Graph><span data-mce-type="bookmark" style="display: inline-block; width: 0px; overflow: hidden; line-height: 0;" class="mce_SELRES_start"></span>

Image Servlet: Helper Servlet to write GraphImage to a HttpServletResponse servlet

package com.aminur.graph.legacy.model.util;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/* 
 * @author Aminur Rashid (aminur ^ aminurrashid.com) 
 * Helper class to write the GraphImage to a HttpServletResponse servlet 
 * © http://aminurrashid.com
 */ 
public class ImageServlet extends HttpServlet {

    public void doGet(HttpServletRequest request,
                      HttpServletResponse response) throws ServletException,
                                                           IOException {
        GraphUtil gp = new GraphUtil();
        // Set Content type
        String contentType = getServletContext().getMimeType("image/gif");
        // Stream the image
        try {
            response.setContentType(contentType);
            response.setHeader("Content-Disposition", " inline; filename");

            ServletOutputStream o = response.getOutputStream();
            gp.getGraphImageInStream(o, request.getParameter("graphType"));
            o.flush();
            o.close();
        } catch (Exception e) {
            e.printStackTrace();
            return;
        }
    }
}

The example also shows how to change the graph at runtime

One running the JSP, user should be able to see the desired graph as shown below:

The jars used in the application came with Oracle BI beans, 1012, which can be dowbloaded from
http://www.oracle.com/technology/software/products/bib/download.html
The jars used were:
bipres.jar
bibeaninfo.jar
bicmn.jar
jewt.jar (it came from Jdev)

PS: With the new DVT components, user may need to use oracle.adf.view.faces.bi.component.graph.UIGraph instead of ThinGraph and may have to set all the properties directly to the UIGraph instance instead of using the xml.