Shawn Quinn - 2012-03-28

Just let me know if you guys have any ideas on things we could/should do in GWT Highcharts to make working with SmartGWT easier! We obviously don't want to make GWT Highcharts depend on SmartGWT, but if there are tricks to get BaseChart to behave nicer within SmartGWT I'm all ears.

We also use SmartGWT for most of our apps here, and would certainly benefit from having a way to run things in dev/hosted mode as well. When we first published GWT Highcharts last year it looked like Isomorphic might be working on this issue so I was hopeful that they'd get this fixed (as it affects many other GWT widgets as well). But, it's been quite awhile with no progress, so it might be time to try and find other workarounds.

BTW - In case it's of use to others, the following is the type we've been using in our applications for including a GWT Highchart within a SmartGWT layout where we want the chart to match the size of the container:

import com.smartgwt.client.widgets.WidgetCanvas;
import com.smartgwt.client.widgets.events.DrawEvent;
import com.smartgwt.client.widgets.events.DrawHandler;
import com.smartgwt.client.widgets.events.ResizedEvent;
import com.smartgwt.client.widgets.events.ResizedHandler;
import org.moxieapps.gwt.highcharts.client.BaseChart;

/**
 * A SmartGWT container widget that will contain a GWT Highchart and automatically
 * handle growing/shrinking the chart as the SmartGWT container changes in size.
 *
 * @author squinn@moxiegroup.com (Shawn Quinn)
 * @since 1.0
 */
public class ResizeableChartCanvas extends WidgetCanvas {

    public ResizeableChartCanvas(final BaseChart chart) {
        super(chart);
        chart.setReflow(false);
        final WidgetCanvas wc = this;
        this.addResizedHandler(new ResizedHandler() {
            public void onResized(ResizedEvent event) {
                chart.setSize(wc.getWidth(), wc.getHeight(), false);
            }
        });
        this.addDrawHandler(new DrawHandler() {
            public void onDraw(DrawEvent event) {
                chart.setSize(wc.getWidth(), wc.getHeight(), false);
            }
        });
        wc.setOverflow(Overflow.HIDDEN);
    }
}
 

Last edit: Shawn Quinn 2012-04-06