PDA

View Full Version : my GXT charts aren't visible



jocy
25 May 2010, 12:00 AM
Good morning,
I know that this thread have already been posted but if i am here is because i tried all solution i found and nothing!!!
My charts are always invisible in hosted mode
here are my source code.

JAVA:


/*
* Ext GWT - Ext for GWT
* Copyright(c) 2007-2009, Ext JS, LLC.
* licensing@extjs.com
*
* http://extjs.com/license
*/
package com.inet.mychart.client;

import java.util.ArrayList;
import com.extjs.gxt.charts.client.Chart;
import com.extjs.gxt.charts.client.event.ChartEvent;
import com.extjs.gxt.charts.client.event.ChartListener;
import com.extjs.gxt.charts.client.model.ChartModel;
import com.extjs.gxt.charts.client.model.Legend;
import com.extjs.gxt.charts.client.model.PieDataProvider;
import com.extjs.gxt.charts.client.model.Legend.Position;
import com.extjs.gxt.charts.client.model.charts.PieChart;
import com.extjs.gxt.samples.resources.client.TestData;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.GridEvent;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.fx.Draggable;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.Info;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.form.NumberField;
import com.extjs.gxt.ui.client.widget.form.NumberPropertyEditor;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.grid.CellEditor;
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
import com.extjs.gxt.ui.client.widget.grid.EditorGrid;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.layout.MarginData;
import com.google.gwt.user.client.ui.Widget;

public class BasicChartExample extends LayoutContainer {

private ListStore<ChartData> store;

private ChartListener listener = new ChartListener() {
public void chartClick(ChartEvent ce) {
Info.display("Chart Clicked", "You selected {0}.", "" + ce.getValue());
}
};

public BasicChartExample(){
store = new ListStore<ChartData>();
store.add(TestData.getChartData());

Chart chart = new Chart("gxt/chart/open-flash-chart.swf");
chart.setBorders(true);
chart.setChartModel(createPieChart());

ContentPanel ChartP = createContent(chart,"Pie diagram", 400, 400);
Draggable d1 = new Draggable(ChartP, ChartP.getHeader());
d1.setUseProxy(false);

ContentPanel GridP = createContent(createEditorGrid(),"Pie Data", 400, 400);
Draggable d2 = new Draggable(GridP, GridP.getHeader());
d2.setUseProxy(false);

add(ChartP, new MarginData(20));
add(GridP, new MarginData(20));
}

private ChartModel createPieChart(){
ChartModel cm = new ChartModel("Sales by Region",
"font-size: 14px; font-family: Verdana; text-align: center;");
cm.setBackgroundColour("fffff5");
Legend lg = new Legend(Position.RIGHT, true);
lg.setPadding(10);
cm.setLegend(lg);

PieChart pie = new PieChart();
pie.setAlpha(0.5f);
pie.setNoLabels(true);
pie.setTooltip("#label# $#val#M<br>#percent#");
pie.setColours("#ff0000", "#00aa00", "#0000ff", "#ff00ff", "#bebdef");
for(int i=0; i<5; i++){
pie.addSlices(new PieChart.Slice(TestData.getChartData().get(i).getValue(), TestData.getChartData().get(i).getLabel()));
}
pie.addChartListener(listener);

PieDataProvider pieprovider = new PieDataProvider("value", "label", "item");
pieprovider.bind(store);
pie.setDataProvider(pieprovider);

cm.addChartConfig(pie);
return cm;
}

private EditorGrid<ChartData> createEditorGrid(){
NumberPropertyEditor npe = new NumberPropertyEditor(Integer.class);
ArrayList<ColumnConfig> cols = new ArrayList<ColumnConfig>();

ColumnConfig item = new ColumnConfig("item", "Item", 100);
cols.add(item);
item.setEditor(new CellEditor(new TextField<String>()));

ColumnConfig label = new ColumnConfig("label", "Label", 100);
cols.add(label);
label.setEditor(new CellEditor(new TextField<String>()));

ColumnConfig value = new ColumnConfig("value", "Value", 100);
cols.add(value);
NumberField nf = new NumberField();
nf.setPropertyEditor(npe);
value.setEditor(new CellEditor(nf));

ColumnConfig color = new ColumnConfig("color", "Color", 100);
cols.add(color);
color.setEditor(new CellEditor(new TextField<String>()));

ColumnModel com = new ColumnModel(cols);

EditorGrid<ChartData> ChartGrid = new EditorGrid<ChartData>(store, com);
ChartGrid.getView().setForceFit(true);
ChartGrid.getView().setShowDirtyCells(false);
ChartGrid.addListener(Events.AfterEdit, new Listener<GridEvent<ChartData>>() {
public void handleEvent(GridEvent<ChartData> be) {
store.commitChanges();
}
});

return ChartGrid;
}

private ContentPanel createContent(Widget widget, String name, int h, int w){
ContentPanel cp = new ContentPanel();
cp.setHeading(name);
cp.setFrame(true);
cp.setSize(h, w);
cp.setLayout(new FitLayout());
cp.add(widget);
return cp;
}

}


HTML:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<link rel="stylesheet" type="text/css" href="gxt/css/gxt-all.css" />
<link rel="stylesheet" type="text/css" href="gxt/css/resources.css" />

<title>My Chart</title>

<script language='javascript' src='gxt/flash/swfobject.js'></script>
<script type="text/javascript" language="javascript" src="mychart/mychart.nocache.js"></script>
</head>

<body>
<table align="center">
<tr>
<td colspan="2" style="font-weight:bold;"></td>
</tr>
<tr>
<td id="nameFieldContainer"></td>
<td id="sendButtonContainer"></td>
</tr>
</table>

</body>
</html>


XML:


<module rename-to='mychart'>
<inherits name='com.extjs.gxt.samples.resources.Resources' />
<inherits name='com.extjs.gxt.themes.Themes' />
<inherits name='com.extjs.gxt.charts.Chart' />
<inherits name="com.extjs.gxt.samples.Examples"/>
<entry-point class='com.inet.mychart.client.MyChart'/>
</module>


i try to reinstall the GWT plugin for eclipse, i install flash plugin for firefox, for IE.... but nothing
i desesperate!!!:((

thanks in advance!