Re: Using jqPlot library (javascript chart) with the MVP pattern
I'm currently creating a GWT / JQplot wrapper on Google code: project name vklgraph. Still in development. see: http://code.google.com/p/vklgraph/ Regards =) -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: Using jqPlot library (javascript chart) with the MVP pattern
Thank you very much for this explication. However I had already added a div id=chart1/div Element into the HTML page to be sure that it was adding correctly. But I will use your method for the wrapper. After this I make two different test. First I used only the JQuery library with a simple $wnd.$ ('#chart1').text('Salut');. It works perfectly and Salut has been added inside the div Element. The same method just replacing the code with the chart's code print the error message : $ is not defined. So it seems that the problem comes from jqPlot only. I developped also a simple HTML page with the chart's code and all is ok. As a result my external jqPlot file doesn't have some problems (hopefully). So now I don't know if there is a conflict between JQuery and jqPlot, but I'm going to make some others test. Thank you. -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: Using jqPlot library (javascript chart) with the MVP pattern
I'm a stupid boy... I forgot to replace ALL $.jqplot() by $wnd. $.jqplot(); It's an improvement, but now the error has changed by : com.google.gwt.core.client.JavaScriptException: (String): Improper Data Array The table works in a HTML page, so I don't know why not here :/ I'm going to continue my research. Thanks a lot for your help. -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: Using jqPlot library (javascript chart) with the MVP pattern
Because the array is bound to the sub-frame used by GWT. When you create an array using [], the Array function is called. This is the same as new Array(). Then the following condition returns true: [].constructor == Array. But, there is an Array function for each frame. If you create an array in one frame, and use the same comparison in another, it will returns false. You must create your array using new $wnd.Array(). That's another reason to do a real wrapper ;). Olivier On 10 juin, 14:06, Rizen vianney.dep...@gmail.com wrote: I'm a stupid boy... I forgot to replace ALL $.jqplot() by $wnd. $.jqplot(); It's an improvement, but now the error has changed by : com.google.gwt.core.client.JavaScriptException: (String): Improper Data Array The table works in a HTML page, so I don't know why not here :/ I'm going to continue my research. Thanks a lot for your help. -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: Using jqPlot library (javascript chart) with the MVP pattern
Finally I think I'm going to try with the JavaScriptObject class, cause I can cast it in Element object. public class CallChartView extends Widget implements CallChartPresenter.Display { public CallChartView() { setElement(Element.as(createChart())); } public native JavaScriptObject createChart() /*-{ line1 = [1,4,9, 16]; line2 = [25, 12.5, 6.25, 3.125]; plot = $.jqplot('chart1', [line1, line2], { legend:{show:true, location:'ne'},title:'Bar Chart', series:[ {label:'Profits', renderer: $.jqplot.BarRenderer}, {label:'Expenses', renderer: $.jqplot.BarRenderer} ], axes:{ xaxis:{renderer:$.jqplot.CategoryAxisRenderer}, yaxis:{min:0} } }); return plot; }-*/; } But now I have an error from the GWT console : $ is not defined. I have already tried to change the javascript configuration but the problem is always present. -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: Using jqPlot library (javascript chart) with the MVP pattern
Try to replace your $.jqplot by $wnd.$.jqplot. The window object where the JSNI is run is not the main window. You can access it through $wnd. Olivier On 9 juin, 11:39, Rizen vianney.dep...@gmail.com wrote: Finally I think I'm going to try with the JavaScriptObject class, cause I can cast it in Element object. public class CallChartView extends Widget implements CallChartPresenter.Display { public CallChartView() { setElement(Element.as(createChart())); } public native JavaScriptObject createChart() /*-{ line1 = [1,4,9, 16]; line2 = [25, 12.5, 6.25, 3.125]; plot = $.jqplot('chart1', [line1, line2], { legend:{show:true, location:'ne'},title:'Bar Chart', series:[ {label:'Profits', renderer: $.jqplot.BarRenderer}, {label:'Expenses', renderer: $.jqplot.BarRenderer} ], axes:{ xaxis:{renderer:$.jqplot.CategoryAxisRenderer}, yaxis:{min:0} } }); return plot; }-*/; } But now I have an error from the GWT console : $ is not defined. I have already tried to change the javascript configuration but the problem is always present. -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: Using jqPlot library (javascript chart) with the MVP pattern
I've already tried but it's exactly the same problem. Here is a part of the error log : [...] com.google.gwt.core.client.JavaScriptException: (ReferenceError): $ is not defined fileName: http://127.0.0.1: lineNumber: 4 stack: ()@http://127.0.0.1::4 [...] -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: Using jqPlot library (javascript chart) with the MVP pattern
Okay, next try (I've read your post this time ;)). You want to cast a JavaScriptObject to an Element. You can... but it's a bad idea. A Widget needs an Element because it offer some DOM manipulation. Providing a JSO may lead to strange behavior. You need to write a clean GWT wrapper around jqPlot. For your current problem, $ is not defined, are you sure you have included the jqPlot library? Using the FireBug's console, can you access the $ (try typeof($))? Olivier On 9 juin, 13:04, Rizen vianney.dep...@gmail.com wrote: I've already tried but it's exactly the same problem. Here is a part of the error log : [...] com.google.gwt.core.client.JavaScriptException: (ReferenceError): $ is not defined fileName:http://127.0.0.1: lineNumber: 4 stack: ()@http://127.0.0.1::4 [...] -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: Using jqPlot library (javascript chart) with the MVP pattern
I want to cast a JavaScriptObject to an Element cause I think is the best solution for the moment. Using the MVP architecture I don't know how to do that in a different way. If there is something better I will be interested as well. About the problem with $, I wrote typeof($) in FireBug's console. It return function. So I think it's ok for the include, I've tried via the .html and the xml configuration. Thank you very much for your help until now. -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: Using jqPlot library (javascript chart) with the MVP pattern
For the $, maybe the library is not loaded when you try to create your chart. As I told before, you need to write a wrapper. This wrapper create the div needed by jqPlot and add an unique ID to it. This ID is used as the first argument to jqPlot JavaScript function. But you can't create your chart in your Widget constructor. The div is not attached to the DOM so jqPlot will no find it. You need to create your chart when onLoad is called. This can look like (not tested): class JqPlot extends Widget { // Used to generate unique ID private static int count = 0; public JqPlot() { setElement(Document.get().createDivElement()); // Add a unique id to your div getElement().setId(__jsplot__gwt__ + count++); } @Override public void onLoad() { // Now the div is attached to the DOM, jqPlot will find it createGraph(getElement().getId()); } private native void createGraph(String id) /*-{ ... $.jsPlot(id, ); }-*/; } But you need many more work. You need to handle multiple call to onLoad. You need also to wrap all arguments needed by jsPlot and cache them into your Widget until you create the chart... You problem is not jqPlot and MVP, it's just jqPlot and GWT. Olivier On 9 juin, 15:55, Rizen vianney.dep...@gmail.com wrote: I want to cast a JavaScriptObject to an Element cause I think is the best solution for the moment. Using the MVP architecture I don't know how to do that in a different way. If there is something better I will be interested as well. About the problem with $, I wrote typeof($) in FireBug's console. It return function. So I think it's ok for the include, I've tried via the .html and the xml configuration. Thank you very much for your help until now. -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.