Would you mind, briefly, telling us what authoring a component for JSC / VWP was like? What was easy? What sucked? Where did you get the info?
On the VWP issues database is a cover-all for someone to make authoring new compnents more user friendly. It's a noble goal and I'm sure your experience will be of interest to the person looking into this enhancement.
Hello.
Major source of knowledge was sample-simple.2.2.1 component library.
Also useful was document "Sun Java Studio Creator 2 Design-Time API User Guide".
Unfortunately no documentation about jsfmeta generator and that is why I decided to remove dependance on it.
Any specific questions and/or suggestions are welcome.
Andrew
Hello Andrew,
I downloaded the jsChart component and I'm planning to use it within NB5.5 + vwp. Unfortunately I'm not quit familiar with JSF components yet although I'm starting to read the " Java studio creator field guide ". Can you please provide an example for using the jsChart component?
Kind regards,
Henri
Hello Henri,
Before you start - VWP must be installed into NB5.5.
Next you have to import component library into NB:
Tools->Component library manager.
Press "Import..." button. "Browse..." botton.
Choose jschart-1.0.1.complib file and press "Open".
Press "Ok", then "Close".
Then, create Visual Web Application. On Pallette you will see 'Chart' component and several Datasets. Just drag-and-drop it from pallete to the page.
When you change any properties press 'refresh' menu item on right-click mouse button on designing page.
You have option to create your own Dataset for org.jfreechart.Chart or use provided wrappers.
Wrappers uses standard TableDataProvider as data source like any other components.
Don't forget to add Chartlet Servlet reference into web.xml as described at http://jschart.sourceforge.net
Take care,
Andrew
Hello Andrew,
Thank you for your quick reaction!! It was really useful. I have added the servlet reference in the web.xml file and dropped to chart component onto the canvas.
Can I use an org.jfree.data.xy.XYSeriesCollection (it implements the org.jfree.data.general.Dataset interface) to provide data to the chart? For example:
I made an property binding #{Page1.XYSerie} (XYSerie is an pagebean property of the type XYSeriesCollection) for the value property of the chart component. Within the button1_action() event I added several XYSeries objects to the XYSeriesCollection object. When pressing button 1 the page is rendered but the chart is not changed. Do I have to add some sort of datalistener to the XYSeriesCollection?
As you probably noticed I'm new to Java programming. Can you please provide another example of how to bind data to the chart component from an array within an button action event?
Kind regards,
Henri de Ruiter
Hello Henri,
1. I think this is lifecycle issue.
AFAIK page bean properties lives only when page creates and renders. They restores on postbacks from browser's values but your property can't have HTML form equivalent field.
So, if you want to keep and/or update something between actions you should use session or application bean.
2. You can try to use "Object Array Data Provider" wrapper for your array. And then bind it to XYDataset from jschart library. And remember lifecycle: your array should be in session or application scope.
Regards,
Andrew
Hello Andrew,
Thank you for your effort.
I'm unfortunately unable to get it work. I tried to use an array with x and y values (in the session bean) and bind it to the object array data provider. The object array provider is binded to the xyDataset which is connected to the graph.
I also tried property binding for Value to an XYSeriesCollection in a javabean (as property in the session bean, as described in chapter 6 of field guide java studio creator) . I also binded the title property of the chart to a string property of the java bean (the sameway as the XYSeriesCollection) and the title was diplayed correctly so it seems to work fine for the title.
Is it possible to bind the value (object) property of the graph to an XYSeriesCollection?
Can you please provide some sort of demo program?
Kind regards, Henri
This jschart is fantastic!! I just found it after two days of search of free charting libraries...
Unfortunately I have troubles using it... could you please help me out with this?
My application calculates and shows a value y for each value x inserted.
I would like to store all values y for x from 0 to xInserted and show the result in a graph XY. (not sure if it matters, but y is double and x is int) Now, is it possible to pass the xy data from a double[][] to the jschart component without passing through a database?
I tried with this button1_action to initiate the data for the chart. The data is stored in the sessionbean, but it did not work:
public String button1_action() {
double costSerie[] = {0,0,10,30,70,100,50,20,55,132,25,35,55,99,10,100,0,17,18,19,20};
double[][] loccone = new double[3][];
for (int i=1;i<21;i++) {
loccone[0]=i;
loccone[1]=1;
loccone[2]=costSerie;
}
getSessionBean1().setLocco(loccone);
return "case1";//goes to the page with the graph
}
This is the property in the session bean:
private double[][] locco;
public double[][] getLocco() {
return this.locco;
}
public void setLocco(double[][] locco) {
this.locco = locco;
}
Is there any other reference or example on how to use the jschart? I already studied the only example in boundle with the installation instructions but it strictly refers to the connection with a database.
Thanks
Max
Hello,
It easy! You can do it by standard for the jfreechart way by using org.jfree.data.xy.DefaultXYDataset.
Better to create session property of "org.jfree.data.xy.XYDataset" type.
Then In button1_action you can do:
public String button1_action() {
double costSerie[] = {0,0,10,30,70,100,50,20,55,132,25,35,55,99,10,100,0,17,18,19,20};
double[][] loccone = new double[2][];
or (int i=1;i<21;i++) {
loccone[0]=i;
loccone[1]=costSerie;
}
XYDataset ds = new DefaultXYDataset();
ds.addSeries("Serie title", loccone);
getSessionBean1().setLoccoDs(ds);
}
And bind datasource property in chart to this: "#{sessionBean1.loccoDs}"
Thanks a lot!!!
You have been VERY helpful. The code you gave me did not work as but you gave me the right direction for further temptatives.
I just had to change something in the code you proposed me (i.e. I had to use DefaultXYDataset instead of XYDataset everywhere) and I used XYSeries to define the array before passing it to DefaultXYDataset.
Now that the preliminary example works I will try to implement it to my webapplication as soon as I can!
Just a couple of questions more:
1- If I understood well, the dataset installed by jschart in the palette component are used only to help connecting the chart with data from a database, right?
2- I could not understand all of the properties for the chart component. Where can i look for information about the properties? (i.e. use of chartlet)
3- Is it possible to set the range of X and/or Y values shown in the graph? In other words: how to zoom?
Thanks again.
Max
> Thanks a lot!!!
You are welcome!
>
... skipped
>
> Just a couple of questions more:
>
> 1- If I understood well, the dataset installed by
> jschart in the palette component are used only to
> help connecting the chart with data from a database,
> right?
>
Exactly
> 2- I could not understand all of the properties for
> the chart component. Where can i look for
> information about the properties? (i.e. use of
> chartlet)
Please upgrade to jschart 1.0.2. It eliminates usage of chartlet and provides more functionality. Short description should be shown as tooltips on property titles.
I'm working on extended documentation for jschart.
>
> 3- Is it possible to set the range of X and/or Y
> values shown in the graph? In other words: how to
> zoom?
In your case the right way will be to create new class inherited from DefaultXYDataset and implements org.jfree.data.DomainInfo for X axis and org.jfree.data.RangeInfo for Y axis interfaces.
Take care,
Andrew
Please, could you help me to install SJSC chart component, I've downloaded the file but it hasn't the .complib extension it is just .zip and I could not import in the IDE and I don磘 understand where is the option component library->'install' that someone mention in some of these forums to install it with the zip file.
Thank you.
Hello,
It should be .complib! I've checked it many times!
I think this is issue with your internet browser. It tries to be very smart :-)
My be browser just add .zip extention or rename it. Take a look into archive.
If it contains only one file with .complib extract it else rename the archive to have .complib extension.
If nothing help, please, try to click this link: http://downloads.sourceforge.net/jschart/jschart-1.0.2.complib?modtime=11738992 81&big_mirror=0
Then in SJSC: Tools->Component Library Manager->Import
Take care,
Andrew
Hi, I have a new problem with the chart component library, when I create a new project and follow the steps described in the web tutorial all work ok, but when i follow these steps in exactly the same way in my own project appears this message:
invalid chart component:net.sf:jschart.component.Chart.
Could you help please?
thank you.
Hello,
Too few information to understand the problem!
When it happens? When you design or run application?
Sometimes it happens at design time due a bug in SJSC.
It calls renderer with very strange object that can not be casted to net.sf.jschart.component.Chart but getClass().toString() returns exactly same name.
Just keep going. It will restore working after couple refreshes.
Take care,
Andrew
Hello, im trying to use jchat but its not working, i droped a generic dataset, and the property dataprovider is linked to a dataprovider, and the rest of the fields are selected, then i droped a chart, and linked to generic dataset, when i do refresh on chart, creator gives me a error in output, document error:
Missing stylesheet: file:/Creator/Projects/Test/web/estadistic/resources/net.sf.jschart/chart.css
if i run my app, in the browsert the chart show me: no data!
and when i go back to the design view in creator and click on generic dataset the dataprovider property is emtpty
why is this? tnks in advance!
Belthazor
Hello,
I just discovered the JSChart and it seems to be a great tool for what I want to do.
Actually I'am working with NetBeans 5.5 + VWP and I need to display some simple XY graphics.
I am trying to do it the easiest way possible.
My applcation calculates a value y for each value x inserted, so it already has a set of value ready to be displayed. I don't need to use a database to store the data.
I'm experiencing troubles when trying to link the chart component with a datasource.
I tried many ways :
- Creating a (net.jsf.jschart.component)XYDataset component (and passing it a dataprovider to get the data to be displayed) and applying it as the datasource ofr the chart component. I had an error executing it : Invalid dataset type
-Then I tried with a DefaultXYDataset object, as it was exposed before by maxruffo. I used the funcion addSeries() with the DefaultXYDataset object to provide the data to be displayed. An other error occured : ChartRenderer.renderEnd:
java.lang.ClassCastException: org.jfree.data.xy.DefaultXYDataset cannot be cast to org.jfree.data.category.CategoryDataset
- I finally tried with a org.jfree.data.xy.XYDataset object. I had no problems with the execution but I just don't know how to bind this object with the data to display.
What should be the right method? What am I doing wrong?
Does someone has an example that works?
Thanks in advance for your answers.
Hello,
> I just discovered the JSChart and it seems to be a
> great tool for what I want to do.
> Actually I'am working with NetBeans 5.5 + VWP and I
> need to display some simple XY graphics.
> I am trying to do it the easiest way possible.
> My applcation calculates a value y for each value x
> inserted, so it already has a set of value ready to
> be displayed. I don't need to use a database to store
> the data.
>
> I'm experiencing troubles when trying to link the
> chart component with a datasource.
> I tried many ways :
> - Creating a (net.jsf.jschart.component)XYDataset
> component (and passing it a dataprovider to get the
> data to be displayed) and applying it as the
> datasource ofr the chart component. I had an error
> executing it : Invalid dataset type
>
> -Then I tried with a DefaultXYDataset object, as it
> was exposed before by maxruffo. I used the funcion
> addSeries() with the DefaultXYDataset object to
> provide the data to be displayed. An other error
> occured : ChartRenderer.renderEnd:
> java.lang.ClassCastException:
> org.jfree.data.xy.DefaultXYDataset cannot be cast to
> org.jfree.data.category.CategoryDataset
It can happens if you don't set property 'type' of chart component properly.
It should be one of "xyline", "xybar", "xyarea" etc.
>
> - I finally tried with a org.jfree.data.xy.XYDataset
> object. I had no problems with the execution but I
> just don't know how to bind this object with the data
> to display.
>
> What should be the right method? What am I doing
> wrong?
> Does someone has an example that works?
>
> Thanks in advance for your answers.
Take care.
Hello ,
Thks for your speed respons.
I get over the problem by importing the designtime.jar & propertyeditors.jar from the modules folder in Netbeans source.
I success to run chart with dataset populated manually. Now i'm trying to use dataprovider. I get this error :
loader constraint violation: when resolving method "net.sf.jschart.component.GenericDataset.setDataProvider(Lcom/sun/data/provider /TableDataProvider;)V" the class loader (instance of org/apache/catalina/loader/WebappClassLoader) of the current class, webapplication4/ChartwithDB, and the class loader (instance of com/sun/appserv/server/util/ASURLClassLoader) for resolved class, net/sf/jschart/component/GenericDataset, have different Class objects for the type com/sun/data/provider/TableDataProvider used in the signature
Can you show me the right way to select, from the rowset, the data fitting with the dataset of the chart?
Thks,
Hello,
I think this problem with different com.sun.data.provider.TableDataProvider classes used from different jars. It's possible when you mix different versions of jars in same application or deploy WAR file built for one version to the application server that use another version.
Try to remove dependence to dataprovider.jar from project to disable packing it into WAR.
Andrew