Article View: borland.public.jbuilder.java.language
Article #18033Re: Chart
From: suchitha
Date: Mon, 24 Aug 1998 00:00
Date: Mon, 24 Aug 1998 00:00
97 lines
4137 bytes
4137 bytes
Claire
Thanks a lot
Suchitha
In article <35DA840B.B194F27B@casecorp.com>,
claire Lecarpentier <clecarpentier@casecorp.com> wrote:
> Suchitha,
>
> You can use the JCChart. It is a KL Group bean that is filled from an array.
>
> Here is the code of the array class :
>
> import jclass.chart.Chartable;
> import java.util.Vector;
> public class ArrayData implements Chartable{
> public double rawData[][]= new double[2][50];
> Vector data = new Vector();
> public ArrayData() {
> makeData(rawData);}
> public ArrayData(double data[][]) {
> makeData(data);}
> private void makeData(double array[][]) {
> for (int i=0; i<array.length;i++){
> Vector row = new Vector();
> for (int j=0; j<array[i].length;j++){
> row.addElement(new Double(array[i][j]));}
> data.addElement(row);}}
> public Object getDataItem(int row, int column){
> Object rval = null;
> try {rval = ((Vector)data.elementAt(row)).elementAt(column);}
> catch (Exception ex){}
> return rval;}
> public Vector getRow(int row){
> Vector rval = null;
> try {rval = (Vector)data.elementAt(row);}
> catch (Exception ex){}
> return rval;}
> public int getDataInterpretation(){
> return ARRAY;}
> public int getNumRows(){
> if (data == null) return 0;
> return data.size();}
> public String[] getPointLabels(){
> return null;}
> public String getSeriesName(int row){
> return null;}
> public String getSeriesLabel(int row){
> return getSeriesName(row);}
> public String getName(){
> return new String("Array Data");}
> }
>
> And here is the code for filling the array with the data countained in your
> database :
>
> int nb_rows=0;
> It is what you will put in the array :
> Variant v1=new Variant();
> Variant v2=new Variant();
> try {
> I define the parameter row I need for the query :
> pRow.setString("C_CompanyID",S_CompetitorID);
> I execute the query :
> qds_Chart1.executeQuery();
> I store the number of records in the query :
> nb_rows = qds_Chart1.getRowCount();
> double tab_chart[][]=new double[2][nb_rows];
> And I fill the array with the value of the fields :
> if (nb_rows != 0){
> for (int i=0;i<nb_rows;i++){
> The fields are define as float in the database and as double in the
> queryDataSet:
> qds_Chart1.getVariant("year_fin",i,v1);
> qds_Chart1.getVariant("net_sales",i,v2);
> tab_chart[0][i]=v1.getAsDouble();
> tab_chart[1][i]=v2.getAsDouble();
> }
> }
> jCChart_Financial.getDataView(0).setDataSource(new
> ArrayData(tab_chart));
>
> I hope it will help you, good luck, Claire.
>
> Suchitha Madapoosi a οΏ½crit:
>
> > I am trying to create a chart using data from some database.I am using
> > Jbuilder tool. I am open to any other tool if jbuilder doesn't support
> > this. Help will be appreciated. I know you could do this using KLgroup.
> > Please help me.
> > Thanks
> > Suchitha
>
>
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
Technical Details
Message-ID:
<6rsmi8$r3k$1@nnrp1.dejanews.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<35C91C11.93B6BB8F@home.com> <35DA840B.B194F27B@casecorp.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: f74b3,e46e72fae189a41e X-Google-Attributes: gidf74b3,public From: suchitha@my-dejanews.com Subject: Re: Chart Date: 1998/08/24 Message-ID: <6rsmi8$r3k$1@nnrp1.dejanews.com> X-Deja-AN: 384301654 References: <35C91C11.93B6BB8F@home.com> <35DA840B.B194F27B@casecorp.com> Organization: Deja News - The Leader in Internet Discussion X-Article-Creation-Date: Mon Aug 24 21:39:20 1998 GMT Newsgroups: borland.public.jbuilder.java.language X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows 95)