Menu

adding a Chart to VLayout ::: Problem

Adil
2012-07-16
2012-07-16
  • Adil

    Adil - 2012-07-16

    hello ,

    i'm triying to add a chart to a VLayout , but i face a problem....this is the message Error :

    (TypeError): Cannot read property 'Chart' of undefined


    please i don't know why it's not working !!!!!!!!!
    thanks


    this is my code :

    public class Test implements EntryPoint {

    public void onModuleLoad() {
    
       /* Window.enableScrolling(true);
        Window.setMargin("0px");*/
    
        VLayout vl = new VLayout();
        vl.setWidth100();
        vl.setHeight100();
    
        HLayout top = new HLayout();
        HLayout bottom = new HLayout();
        VLayout topLeft = new VLayout();
        VLayout topRight = new VLayout();
        VLayout bottomLeft = new VLayout();
        VLayout bottomRight = new VLayout();
    
        topLeft.addMember(drawCharts());
        topRight.addMember(drawCharts());
        bottomLeft.addMember(drawCharts());
        bottomRight.addMember(drawCharts());
    
        top.setMembers(topLeft, topRight);
        bottom.setMembers(bottomLeft, bottomRight);
    
        vl.setMembers(top, bottom);
    
        RootPanel.get().add(vl);
    }
    
    private Chart drawCharts() {
    
        final Chart chart = new Chart()
                .setType(Series.Type.PIE)
                .setPlotBackgroundColor((String) null)
                .setPlotBorderWidth(null)
                .setPlotShadow(false)
                .setOption("/chart/marginTop", 0)
                .setOption("/chart/marginBottom", 10)
                .setPiePlotOptions(
                        new PiePlotOptions()
                                .setAllowPointSelect(true)
                                .setCursor(PlotOptions.Cursor.POINTER)
                                .setPieDataLabels(
                                        new PieDataLabels().setEnabled(false))
                                .setShowInLegend(true))
                .setToolTip(new ToolTip().setFormatter(new ToolTipFormatter() {
                    public String format(ToolTipData toolTipData) {
                        return "<b>" + toolTipData.getPointName() + "</b>: "
                                + toolTipData.getYAsDouble() + " %";
                    }
                }));
        chart.addSeries(chart
                .createSeries()
                .setName("Browser share")
                .setPoints(
                        new Point[] {
                                new Point("Firefox", 45.0),
                                new Point("IE", 26.8),
                                new Point("Chrome", 12.8).setSliced(true)
                                        .setSelected(true),
                                new Point("Safari", 8.5),
                                new Point("Opera", 6.2),
                                new Point("Others", 0.7) }));
    
        return chart;
    }
    

    }

     
  • Adil

    Adil - 2012-07-16

    thanks Shawn Quinn , it's working now :)

     

Log in to post a comment.