arraystorageexception

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
vasu

arraystorageexception

Post by vasu » Fri Jul 12, 2002 8:20 am

Dear techno savvy,

I have worked with Jfreechart and find that very flexible. My problem is, i am able to generate charts, i mean i am able to get the charts through appletviewer, but when i tried to display the same in a browser i am getting "arraystorageexception". This exception is getting arised when i am trying to display the chart in a browser and the exception is getting arised at chartFactory().createVerticalBarChart3D(String,String,String,CategoryDataset,Boolean).

Please help me out in debugging this as soon as possible.

regards
vasu.

David Gilbert

Re: arraystorageexception

Post by David Gilbert » Fri Jul 12, 2002 8:24 am

Hi Vasu,

You need to post more details about how you create your dataset. And it's also helpful to get the exact text of the exception that is being reported.

Regards,

DG.

vasu

Re: arraystorageexception

Post by vasu » Fri Jul 12, 2002 8:43 am

Dear Mr.David.

Here is the code what i have written and the exception shown in the browser.

code written for creating 3D Vertical bar char
---------------------------------------------------------

String a[] = new String[2];
a[0] ="java";
a[1]="c/c++";

Object aobj[] = new Object[3];
aobj[0] ="Jan";
aobj[1]="Feb";
aobj[2]="Mar";

Number [][] data = new Double[][]
{{new Double(10),new Double(20),new Double(30)}{new Double(10),new Double(20),new Double(50)}};

CategoryDataset data1 = new DefaultCategoryDataset(a,aobj,data);

//Exception over here
JFreeChart chart = ChartFactory.CreateVerticalBarChart3D("Vertical Bar Chart","Y-Axis","X-Axis",data1,true);


Exception shown in the Browser
----------------------------------------
java.lang.ArrayStorageException
at com/jrefinery/chart/Plot.<init>
at com/jrefinery/chart/CategoryPlot.<init>
at com/jrefinery/chart/VerticalCategoryPlot.<init>
at com/jrefinery/chart/VerticalCategoryPlot.<init>
at verticalBarChart1.init //class name
at com/ms/AppletPanel.SecuredCall0
at com/ms/AppletPanel.SecuredCall
at com/ms/AppletPanel.ProcessSentEvent
at com/ms/AppletPanel.ProcessSentEvent
at com/ms/AppletPanel.run
at java/lang/thread.run


please help me out in solving this problem...

regards
vasu

David Gilbert

Re: arraystorageexception

Post by David Gilbert » Fri Jul 12, 2002 4:00 pm

What JDK version does your browser support?

Regards,

DG.

vasu

Re: arraystorageexception

Post by vasu » Sat Jul 13, 2002 6:27 am

Mr. David,

jdk1.2.2 is the version which my browser supports

regards
vasu

Guido Laures

Re: arraystorageexception

Post by Guido Laures » Sun Jul 14, 2002 8:28 am

Sorry, but I never heard of an java.lang.ArrayStorageException. It is not present in the JDK. Where dows it come from?

vasu

Re: arraystorageexception

Post by vasu » Mon Jul 15, 2002 6:35 am

hi,
I have spelled that incorrectly. Its ArrayStoreException. Waiting for your eagerly

regards
vasu

vasu

Re: arraystoreexception

Post by vasu » Tue Jul 16, 2002 7:01 am

Mr. David/Guido,

i have misspelled the exception. Its arraystoreexception. If you could guide me, i will be very thankfull to you. Eagerly, waiting for your response.

regards
vasu

David Gilbert

Re: arraystorageexception

Post by David Gilbert » Tue Jul 16, 2002 9:19 am

Hi Vasu,

I compiled your code and apart from a couple of minor typos (you need a comma in the middle of your array data, and a lower case 'c' in createVerticalBarChart3D) it works fine for me.

Do you have some other code that might be causing the problem? The only time I've seen an ArrayStoreException is when assigning an Object of the wrong type to an array (for example, trying to add a Long to an array of Doubles).

Regards,

DG.

P.S. Here is the code I ran:

package com.jrefinery.chart.demo;

import com.jrefinery.data.CategoryDataset;
import com.jrefinery.data.DefaultCategoryDataset;
import com.jrefinery.chart.JFreeChart;
import com.jrefinery.chart.ChartFactory;
import com.jrefinery.chart.ChartPanel;
import com.jrefinery.chart.CategoryPlot;
import com.jrefinery.chart.HorizontalCategoryAxis;
import com.jrefinery.chart.VerticalLogarithmicAxis;
import com.jrefinery.ui.ApplicationFrame;
import java.awt.Paint;
import java.awt.Color;

/**
* A simple demonstration application showing how to create a vertical bar chart.
*/
public class TestVerticalBarChart extends ApplicationFrame {

/** The data. */
protected CategoryDataset data;

/**
* Default constructor.
*/
public TestVerticalBarChart(String title) {

super(title);

String a[] = new String[2];
a[0] ="java";
a[1]="c/c++";

Object aobj[] = new Object[3];
aobj[0] ="Jan";
aobj[1]="Feb";
aobj[2]="Mar";

Number [][] data = new Double[][]
{{new Double(10),new Double(20),new Double(30)},
{new Double(10),new Double(20),new Double(50)}};

CategoryDataset data1 = new DefaultCategoryDataset(a,aobj,data);

JFreeChart chart = ChartFactory.createVerticalBarChart3D("Vertical Bar Chart","Y-Axis","X-Axis",data1,true);

// add the chart to a panel...
ChartPanel chartPanel = new ChartPanel(chart);
this.setContentPane(chartPanel);

}

/**
* Starting point for the demonstration application.
*/
public static void main(String[] args) {

TestVerticalBarChart demo = new TestVerticalBarChart("Vertical Bar Chart Demo");
demo.pack();
demo.setVisible(true);

}

}

vasu

Re: arraystorageexception

Post by vasu » Wed Jul 17, 2002 10:06 am

hi,

Thanks for sending the code, i have tested it. This basically works at the command prompt which is not compatible with an applet. If i tried to extend an applet to the class and tried to display in a Browser, its giving a problem saying java.lang.ArrayStoreException. I am sending the code what i have tried.

***********************************************

This is the code what i have tried.

***********************************************

import com.jrefinery.data.*;
import com.jrefinery.chart.*;
import com.jrefinery.ui.*;
import java.awt.*;
import java.applet.*;

public class TestVerticalBarChart extends Applet{

public void init(){

Panel pnl = new Panel(new BorderLayout());

String a[] = new String[2];
a[0] ="java";
a[1]="c/c++";

Object aobj[] = new Object[3];
aobj[0] ="Jan";
aobj[1]="Feb";
aobj[2]="Mar";

Number [][] data = new Double[][]
{{new Double(10),new Double(20),new Double(30)},
{new Double(10),new Double(20),new Double(50)}};

CategoryDataset data1 = new DefaultCategoryDataset(a,aobj,data);

JFreeChart chart = ChartFactory.createVerticalBarChart3D("Vertical Bar Chart","Y-Axis","X-Axis",data1,true);

ChartPanel chartPanel = new ChartPanel(chart);

pnl.add((Component)chartPanel);
this.add(pnl);

} //end of init

} //end of class

****************************************************
This is the html file

****************************************************

<html>
<body>
<applet code='TestVerticalBarChart ' width=750 height=500>
</applet>
</body>
</html>

****************************************************


The ultimate thing what i am in need of is i want a graph in a browser.
Looking forward for your furthur co-operation.

regards
vasu

Navin Pathuru

Re: arraystorageexception

Post by Navin Pathuru » Wed Jul 17, 2002 2:33 pm

Hi Vasu, did you try to search in the Java.sun.com forums for any help. That is another good place to look for help for java related questions. I did a search there and got a few topics, may be you could find them of help.

Regards,
Navin Pathuru

vasu

Re: arraystorageexception

Post by vasu » Thu Jul 18, 2002 7:21 am

The reason for array store exception that was given in Java Documentation was that when you try to store an incompatible type or an object in an array which is intended to store only one type or one object types only.the code submitted to you above doesn't store any incompatible types even then it's giving this runtime exception as arrystore exception.If you got any information on how to proceed please help in this matter.I would like to try abt this in java.sun.com forums too.Navin Pathuru wrote:
>
> Hi Vasu, did you try to search in the Java.sun.com forums for
> any help. That is another good place to look for help for
> java related questions. I did a search there and got a few
> topics, may be you could find them of help.
>
> Regards,
> Navin Pathuru

Locked