Hi all,
I have today upgraded our dev environment from 2.2 to 2.4 as I have a need to do some reporting and I see that charts is a new addition to SmartGWT.
Having searched this forum I found an example for a FacetChart and the same example (almost) is in the nightly builds for the showcase. My code based on that...
That is the example code, slightly tweaked, the issue I get is upon loading of the module, I get the following error...
The code is more or less the same as the example except I have not used the line setFacets() for the FacetChart object as that method does not exist.
Is the error due to that piece of code not being present, so if that is removed, what do I use instead? There is a setFacetId() but that only suggests to take one ID, I took a punt and tried it but it did nothing different.
Any advice much appreciated as I really want to find out if this would be fit for purpose in my instance.
Thanks
Dale
I have today upgraded our dev environment from 2.2 to 2.4 as I have a need to do some reporting and I see that charts is a new addition to SmartGWT.
Having searched this forum I found an example for a FacetChart and the same example (almost) is in the nightly builds for the showcase. My code based on that...
Code:
package com.serengetisystems.tcrm.client.tab; import com.serengetisystems.srgutils.marker.Reloadable; import com.serengetisystems.tcrm.client.pages.AbstractPage; import com.serengetisystems.tcrm.client.util.DictionaryUtils; import com.serengetisystems.tcrm.util.constants.DictionaryConstants; import com.smartgwt.client.data.Record; import com.smartgwt.client.types.ChartType; import com.smartgwt.client.widgets.chart.FacetChart; import com.smartgwt.client.widgets.cube.Facet; import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.form.fields.SelectItem; import com.smartgwt.client.widgets.form.fields.events.ChangedEvent; import com.smartgwt.client.widgets.form.fields.events.ChangedHandler; import com.smartgwt.client.widgets.layout.VLayout; import com.smartgwt.client.widgets.tab.Tab; import java.util.HashMap; import java.util.Map; /** * TODO: code description here * * @author dale.ellis * @version 1.0 * Version History * ----------------------------------------------------------------------------------- * Changed By When Description * dale.ellis 13/05/11 Initial release */ public class ReportsTab extends AbstractPage implements Reloadable { public ReportsTab() { super("Reports"); setPane(layout); layout.setWidth100(); layout.setHeight100(); layout.setMembersMargin(20); drawChart(); } private void drawChart() { final FacetChart simpleChart = new FacetChart(); simpleChart.setData(chartData); simpleChart.setValueProperty("sales"); simpleChart.setChartType(ChartType.BAR); // Changed to BAR because example one doesn't exist simpleChart.setTitle("Sales by Product and Region"); // Specify facets where ID is set to the key used for this facet in the data above // and title is the user-visible title you want in the chart Facet regionFacet = new Facet("region", "Region"); Facet productFacet = new Facet("product", "Product"); //simpleChart.setFacets(regionFacet, productFacet); // Doesn't exist // This is a form which you can use to change the chart type DynamicForm chartSelector = new DynamicForm(); SelectItem chartType = new SelectItem("chartType"); chartType.setTitle("Chart Type"); chartType.setValueMap("Bar", "Column","Line", "Radar"); chartType.setDefaultValue("Area"); // Add form to form chartSelector.setItems(chartType); layout.addMember(chartSelector); simpleChart.draw(); layout.addMember(simpleChart); chartType.addChangedHandler(new ChangedHandler() { private Map<String, ChartType> chartTypes = new HashMap<String, ChartType>() {{ put("Bar", ChartType.BAR); put("Column", ChartType.COLUMN); put("Line", ChartType.LINE); put("Radar", ChartType.RADAR); }}; @Override public void onChanged(ChangedEvent event) { String typeName = (String)event.getValue(); simpleChart.setChartType(chartTypes.get(typeName)); } }); } Record[] chartData = new Record[] { new SalesRecord("West", "Cars", 37), new SalesRecord("North", "Cars", 29), new SalesRecord("East", "Cars", 80), new SalesRecord("South", "Cars", 87), new SalesRecord("West", "Trucks", 23), new SalesRecord("North", "Trucks", 45), new SalesRecord("East", "Trucks", 32), new SalesRecord("South", "Trucks", 67), new SalesRecord("West", "Motorcycles", 12), new SalesRecord("North", "Motorcycles", 4), new SalesRecord("East", "Motorcycles", 23), new SalesRecord("South", "Motorcycles", 45) }; class SalesRecord extends Record { SalesRecord(String region, String product, Integer sales) { setAttribute("region", region); setAttribute("product", product); setAttribute("sales", sales); } }; @Override public void reload() { //To change body of implemented methods use File | Settings | File Templates. } }
Code:
com.google.gwt.core.client.JavaScriptException: (TypeError): Unable to get value of the property 'create': object is null or undefined description: Unable to get value of the property 'create': object is null or undefined number: -2146823281 at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:195) at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:120) at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:507) at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:264) at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91) at com.google.gwt.core.client.impl.Impl.apply(Impl.java) at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:188) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103) at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71) at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:157) at com.google.gwt.dev.shell.BrowserChannel.reactToMessages(BrowserChannel.java:1669) at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:401) at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:222) at java.lang.Thread.run(Thread.java:662)
Is the error due to that piece of code not being present, so if that is removed, what do I use instead? There is a setFacetId() but that only suggests to take one ID, I took a punt and tried it but it did nothing different.
Any advice much appreciated as I really want to find out if this would be fit for purpose in my instance.
Thanks
Dale
Comment