[prev in list] [next in list] [prev in thread] [next in thread] 

List:       jetspeed-user
Subject:    RE: chart portlet on jetspeed
From:       Moabi Nyokong <MoabiN () discovery ! co ! za>
Date:       2004-08-24 6:28:45
Message-ID: 347DF22EC119A942901EC992F4DD5577EA7E0D () dhexchange2 ! discoveryhealth ! co ! za
[Download RAW message or body]


package za.co.discoverylife.mis.app.premium;

import com.jrefinery.chart.tooltips.CategoryToolTipGenerator;
import com.jrefinery.data.CategoryDataset;
import com.jrefinery.data.DefaultCategoryDataset;
import de.laures.cewolf.*;
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.math.BigDecimal;
import java.util.*;

public class PremiumGraphBean implements DatasetProducer,
CategoryToolTipGenerator, Serializable
{

    private Vector categories = new Vector();
    private Vector seriesNames = new Vector();
    private int ySelect = 0;
    private String heading = "API Statistics";
    private Integer values[][];
    private static DefaultCategoryDataset data = null;
    private int startIdx = 1, endIdx = 1;
    
    public PremiumGraphBean()
    {
    }
    
    public void setCategories(Vector i_categories){
        categories = i_categories;
    }
    
    public void setSeries(Vector series){
        seriesNames = series;
    }
    
    public void setYSelect(int i_ySel){
        ySelect = i_ySel;
    }
    
    public int getYSelect(){
        return ySelect;
    }
    
    public void setStart(int start){
        startIdx = start;
    }

    public void setEnd(int end){
        endIdx = end;
    }
    
    public void produceData(Vector data){
        categories = new Vector();
        seriesNames = new Vector();
        for(int i = startIdx; i <= endIdx; i++){
            Vector row = (Vector)data.get(i - 1);
            int size = row.size() -1;
            Object tmp = (row.elementAt(0)!= null)?row.elementAt(0):"n/a";
            categories.addElement("" + i );
            seriesNames.addElement(row.elementAt((ySelect !=
0)?ySelect:size)); 
        }
        
        values = new Integer[seriesNames.size()][categories.size()];
        for(int k = 0; ((k < categories.size())); k++)
        {
            String temp = String.valueOf(seriesNames.elementAt(k)).trim();
            while(temp.indexOf(',') != -1){
                int comma =  temp.indexOf(',');
                temp = (temp.substring(0, (comma))) + temp.substring((comma
+ 1), temp.length());
            }
            BigDecimal bd = new BigDecimal(temp);
            Integer tmpInt = new Integer(bd.intValue());
            values[0][k] = tmpInt;
        }
                    
    }
    public synchronized Object produceDataset(Map params)
        throws DatasetProduceException
    {
            String [] i_seriesNames = new String[seriesNames.size()];
            String [] i_categories  = new String[categories.size()];
            for(int i = 0; ((i < seriesNames.size())); i++){
                i_seriesNames[i] = String.valueOf(seriesNames.elementAt(i));
            }
            for(int i = 0; ((i < categories.size())); i++){
                i_categories[i] = String.valueOf(categories.elementAt(i));
            }
            data = new DefaultCategoryDataset(i_seriesNames, i_categories,
values);
        return data;
    }

    public void setHeading(String i_heading){
        heading = i_heading;
    }
    
    public String getHeading(){
        return heading;
    }
        
    public String generateToolTip(CategoryDataset data, int series, Object
category)
    {
        return String.valueOf(seriesNames.elementAt(series));
    }



} 

-----Original Message-----
From: Shen, Ching [mailto:Shenc@cboe.com] 
Sent: Thursday 19 August 2004 9:56 PM
To: Jetspeed Users List
Subject: RE: chart portlet on jetspeed

Moabi
I have problem to write an action portlet for DatasetProducer too Do you
mind share a sample action java code for action too, such as premiumGraph?
Thank you very much!

-----Original Message-----
From: Moabi Nyokong [mailto:MoabiN@discovery.co.za]
Sent: Wednesday, August 18, 2004 2:12 AM
To: 'Jetspeed Users List'
Subject: RE: chart portlet on jetspeed


We use cewolf over here...same thing applies. Create data for the chart in
an action, pick up this data in a JSPPortlet with cewolf taglibs added...

This is what one of my graph pages looks like:

<!-- JSPPortlet page -->

<%@ taglib uri='/templates/jsp/tld/template.tld' prefix='jetspeed' %>
//Jetspeed taglib <%@ taglib uri='/templates/jsp/tld/cewolf-1.1.tld'
prefix='cewolf' %> //Cewolf taglib <jsp:useBean id="premiumGraph"
scope="session" class="PremiumGraphBean"/> //PremiumGraph implements a
cewolf DatasetProducer, and holds a 2D Integer array created from
java.sql.ResultSet
 
    <cewolf:chart id="line" title="<%= premiumGraph.getHeading()%>"
type="Pie" xaxislabel="Time"
                  yaxislabel="Premium" showlegend="false">
	    <cewolf:data>
		    <cewolf:producer id="premiumGraph"/> //Names the object
holding graph
	    </cewolf:data>
    </cewolf:chart>

    <cewolf:img chartid="line" renderer="cewolf" width="800" height="300">
        <cewolf:map id="premiumGraph"/> //Prompts the graph object for data.
    </cewolf:img>

<!--// JSPPortlet page -->

-----Original Message-----
From: Devinder Sachdeva [mailto:devinder.sachdeva@db.com]
Sent: Tuesday 17 August 2004 11:56 PM
To: Jetspeed Users List
Subject: RE: chart portlet on jetspeed

Just create portlet as steps mentioned in the JetSpeed .
 I'm not aware how  does cewolf and jfreechart work but for easycharts  add
the following lines in the JSP or VM portlet .
There are a quite bit good examples in the easychart .

<applet code=com.objectplanet.chart.ext.TimeLineChartApplet
CODEBASE="."
archive="/chart.ext.jar" width=700 height=350>

<param name=chartTitle value="2004 Monthly Revenues"> <param
name=seriesCount value=3>

>




"Shen, Ching" <Shenc@cboe.com>
08/17/2004 05:47 PM
Please respond to "Jetspeed Users List"

 
        To:     "Jetspeed Users List" <jetspeed-user@jakarta.apache.org>
        cc: 
        Subject:        RE: chart portlet on jetspeed


There are also other chart packages, such as  cewolf and jfreechart.
The problem is I need a  portlet sample which can embeded chart capability
since I don't know what it should looks like.
Any samples you can share?

-----Original Message-----
From: Devinder Sachdeva [mailto:devinder.sachdeva@db.com]
Sent: Tuesday, August 17, 2004 3:00 PM
To: Jetspeed Users List
Subject: Re: chart portlet on jetspeed


Ching-
Create a Portlet (VM) or JSP include applet as <applet
code=com.objectplanet.chart.ext.TimeLineChartApplet
CODEBASE="."
archive="/chart.ext.jar" width=700 height=350>

<param name=chartTitle value="2004 Monthly Revenues"> <param
name=seriesCount value=3> ..
....................................................................

We used http://www.objectplanet.com/EasyCharts/
Keep EasyChart jar in classpath .It works fine.

Thanks
Devinder




"Shen, Ching" <Shenc@cboe.com>
08/17/2004 03:51 PM
Please respond to "Jetspeed Users List"

 
        To:     <jetspeed-user@jakarta.apache.org>
        cc: 
        Subject:        chart portlet on jetspeed


Does anybody have a portlet for chart,  from 2 columns,  with at least 1
column data , whether from a file or from database?
I am new in jetspeed and is looking for an example Any suggestion/comments
will be greatly appreciated.


Thank you!

Ching Shen



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-user-help@jakarta.apache.org





---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-user-help@jakarta.apache.org





---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-user-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-user-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-user-help@jakarta.apache.org

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic