I need to get the FacetChart ChartDrawn code working...
I want to get the getChartRaduis() and getChartCenter working..
I have tried getting the values in the Chart Drawn Handler
Nothing works... what am i missing?
// Edited very tired.
and simple data
I want to get the getChartRaduis() and getChartCenter working..
I have tried getting the values in the Chart Drawn Handler
Nothing works... what am i missing?
// Edited very tired.
Code:
// your package here /* * Smart GWT (GWT for SmartClient) * Copyright 2008 and beyond, Isomorphic Software, Inc. * * Smart GWT is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3 * as published by the Free Software Foundation. Smart GWT is also * available under typical commercial license terms - see * http://smartclient.com/license * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ import java.util.HashMap; import gov.dtra.gkmc.shared.SimpleData; import com.smartgwt.client.data.AdvancedCriteria; //import com.smartgwt.client.data.Criteria; import com.smartgwt.client.data.DSCallback; import com.smartgwt.client.data.DSRequest; import com.smartgwt.client.data.DSResponse; import com.smartgwt.client.data.DataSource; import com.smartgwt.client.data.Record; //import com.smartgwt.client.data.Record; import com.smartgwt.client.data.RecordList; import com.smartgwt.client.widgets.chart.ChartDrawnEvent; import com.smartgwt.client.widgets.chart.ChartDrawnHandler; import com.smartgwt.client.widgets.chart.ChartPointClickEvent; import com.smartgwt.client.widgets.chart.ChartPointClickHandler; import com.smartgwt.client.widgets.chart.DrawnValue; //import com.smartgwt.client.data.ResultSet; //import com.smartgwt.client.data.DataSource.*; //import com.smartgwt.client.data.RestDataSource; //import com.smartgwt.client.data.XJSONDataSource; import com.smartgwt.client.data.fields.DataSourceTextField; import com.smartgwt.client.rpc.RPCManager; import com.smartgwt.client.types.DSDataFormat; import com.smartgwt.client.types.DSProtocol; import com.smartgwt.client.widgets.chart.FacetChart; import com.smartgwt.client.widgets.cube.Facet; import com.smartgwt.client.widgets.drawing.DrawSector; import com.smartgwt.client.widgets.drawing.Point; //import com.smartgwt.client.widgets.cube.Facet; import com.smartgwt.client.types.ChartType; //import com.smartgwt.client.types.ListGridFieldType; import com.smartgwt.client.types.OperatorId; import com.smartgwt.client.types.TreeModelType; //import com.smartgwt.client.util.JSOHelper; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.Hover; import com.smartgwt.client.widgets.Label; //import com.smartgwt.client.widgets.drawing.ColorStop; import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.form.fields.ButtonItem; import com.smartgwt.client.widgets.form.fields.TextItem; //import com.smartgwt.client.widgets.Window; //import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.form.fields.events.ClickEvent; import com.smartgwt.client.widgets.form.fields.events.ClickHandler; //import com.smartgwt.client.widgets.grid.ListGridRecord; import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.layout.VLayout; import com.smartgwt.client.widgets.layout.VStack; import com.smartgwt.client.widgets.tab.Tab; import com.smartgwt.client.widgets.tab.TabSet; import com.smartgwt.client.widgets.tile.TileGrid; import com.smartgwt.client.widgets.tree.Tree; import com.smartgwt.client.widgets.tree.TreeGrid; import com.smartgwt.client.widgets.tree.TreeGridField; import com.smartgwt.client.widgets.tree.TreeNode; import com.smartgwt.client.widgets.tree.events.LeafClickEvent; import com.smartgwt.client.widgets.tree.events.LeafClickHandler; import com.google.gwt.core.client.EntryPoint; //import com.google.gwt.core.client.JavaScriptObject; //import com.google.gwt.core.client.JsArrayString; //import com.google.gwt.json.client.JSONObject; import com.google.gwt.user.client.Window; public class JsonXPathSample implements EntryPoint { @Override public void onModuleLoad() { SimpleData ds; final FacetChart chart = new FacetChart(); chart.setData(SimpleData.getData()); chart.setFacets(new Facet("Label", "Label")); chart.setValueProperty("count"); chart.setChartType(ChartType.PIE); chart.setShowHover(true); chart.setTitle("Sample"); com.smartgwt.client.widgets.events.ClickHandler charthandler = new com.smartgwt.client.widgets.events.ClickHandler() { @Override public void onClick(com.smartgwt.client.widgets.events.ClickEvent event) { // TODO Auto-generated method stub Window.alert("msg"); // float distance = Math.sqrt((chartcenterpoint.getX()-event.getX())^2+(chartcenterpoint.getY()-event.getY())^2); // Window.alert("distance"+distance+" and "+chart.getChartRadiusAsDouble()); //in the pie // if (distance<chart.getChartRadius()) { Window.alert("Choice = - x= "+ chart.getNearestDrawnValue().getAttribute("x")+ " y = " + chart.getNearestDrawnValue().getAttribute("y")+ " "+ chart.getNearestDrawnValue().getAttributeAsRecord("record").getAttribute("Label")); /*event. AdvancedCriteria adCriteria = new AdvancedCriteria("_id", OperatorId.IN_SET, chart.getNearestDrawnValue().getAttributeAsRecord("record") .getAttributeAsStringArray("FilterIds")); */ int len = chart.getNearestDrawnValue().getAttributeAsRecord("record").getAttributeAsStringArray("FilterIds").length; for (int i = 0; i < len; i++) { Window.alert("Choice = " + chart.getNearestDrawnValue().getAttributeAsRecord("record").getAttributeAsStringArray("FilterIds")[i]); } /*grid.setData(griddata.findAll(adCriteria));*/ // grid.redraw(); Window.alert("We finished and filtered the grid"); //} //outside the pie } }; VLayout layout = new VLayout(15); layout.setWidth(400); layout.setHeight(400); layout.addMember(chart); chart.addClickHandler(charthandler); chart.setWidth100(); chart.setHeight100(); layout.draw(); } }
Code:
// your package import java.util.Map; import com.google.gwt.core.client.JavaScriptObject; import com.smartgwt.client.data.Record; //package com.smartgwt.sample.showcase.client.chart; import com.smartgwt.client.data.Record; public class SimpleData extends Record { public SimpleData(int ct, String lbl, String [] filterids) { setAttribute("count", ct); setAttribute("Label", lbl); setAttribute("FilterIds", filterids); //detail filter ids. } static String [] strarray = {"1","3"}; // filters a list grid when pie section is selected static String [] strarray2 = {"2","6"}; static String [] strarray3 = {"4","5","7"}; public static SimpleData[] getData() { return new SimpleData[] { new SimpleData(10, "Cars",strarray), new SimpleData(23, "Bikes",strarray2 ), new SimpleData(14, "Trukes",strarray3 ) }; } }
Comment