Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Populating ofcgwt chart with data from the server

    Hi,

    I created a Pie Chart using ofcgwt.

    I want to populate this chart from a data that I am getting from the server using RPC.

    The chart is only displayed when created and I am not able to refresh it neither from onSuccess of CallBack method nor from onClick of ClickHandler.

    I tried the below and my chart is always empty.

    Any idea?

    Code:
    ChartWidget    chart1 = new ChartWidget();
    WidgetCanvas      wCanvas = new WidgetCanvas(chart1);
    
    
    
    
    chartsService
                    .getData(new AsyncCallback<HashMap<String, Integer>>() {
                        public void onFailure(Throwable caught)
                        {
                            System.out.println("Error Fetching TasksDue Data");
                        }
    
                        public void onSuccess(HashMap<String, Integer> result)
                        {
                            chart1 = new ChartWidget();
                            ChartData cd1 = new ChartData(chartTitle
                                    .getDisplayValue(),
                                    "font-size: 14px; font-family: Verdana; text-align: center;");
                            cd1.setBackgroundColour("#ffffff");
                            PieChart pchart1 = new PieChart();
                            pchart1.setTooltip("$#val#");
                            pchart1.addSlice(result
                                    .get(ChartsConstants.TasksDueDiff.ONTIME),
                                    ChartsConstants.TasksDueDiff.ONTIME);
                            pchart1.addSlice(result
                                    .get(ChartsConstants.TasksDueDiff.ONEWEEK),
                                    ChartsConstants.TasksDueDiff.ONEWEEK);
                            pchart1.addSlice(result
                                    .get(ChartsConstants.TasksDueDiff.MOREWEEK),
                                    ChartsConstants.TasksDueDiff.MOREWEEK);
                            cd1.addElements(pchart1);
                            chart1.setSize("100%", "100%");
    
                            HTML label1 = new HTML(
                                    "<u>TASKS DUE DATE PERCENTAGE Chart</u>");
                            label1.setWidth("100%");
                          label1.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    
                            chart1.setChartData(cd1);
                            wCanvas.removeChild(wCanvas);
                            wCanvas.addChild(chart1);
                        }
                    });
    
        formLayout.addMember(wCanvas);

    #2
    I closed this issue.

    I had an error on the server side which was not catched.

    Comment

    Working...
    X