All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.highcharts4gwt.client.view.widget.HighchartsLayoutPanel Maven / Gradle / Ivy

There is a newer version: 0.0.7
Show newest version
package com.github.highcharts4gwt.client.view.widget;

import com.github.highcharts4gwt.model.highcharts.api.ChartOptions;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.SimpleLayoutPanel;

public class HighchartsLayoutPanel extends SimpleLayoutPanel
{
    private final DelayRenderingTimer timer;
    private final String id;
    private ChartOptions chartOptions;
    
    public HighchartsLayoutPanel()
    {
        id = HTMLPanel.createUniqueId();
        this.getElement().setId(id);

        timer = new DelayRenderingTimer();
    }

    public void renderChart(ChartOptions options)
    {
        this.chartOptions = options;

        timer.schedule(100); // hack to let the dom the time to render first to have the parent container size...
    }

    private native JavaScriptObject drawChart(String containerId, ChartOptions options)
    /*-{
        return $wnd.jQuery('#'+containerId).highcharts(options);
    }-*/;

    private class DelayRenderingTimer extends Timer
    {
        @Override
        public void run()
        {
            if (chartOptions != null)
            {
                drawChart(id, chartOptions);
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy