Menu

setting chart series plot options formatter throws com.google.gwt.core.client.JavaScriptException: (ReferenceError): type is not defined

Phil
2011-09-13
2012-07-13
  • Phil

    Phil - 2011-09-13

    I am setting up a page with a column chart and below is the constructor. I want to format the datalabels so they show what is on the xaxis. As soon as I add the bolded piece of code below I get a javascript error saying type undefined if I remove the chunk everything works fine I just get the wrong datalabels. I copied this chunk of code pretty much exactly from the DataLabelsFormatter class javadocs. Any ideas?:

    final DynamicForm controlForm = new DynamicForm();
        controlForm.setWidth(450);
        controlForm.setIsGroup(true);
        ComboBoxItem accountCombo = new ComboBoxItem();
        accountCombo.setTitle("Account");
        accountCombo.setType("comboBox");
        accountCombo.setValueMap("1");
        DateItem fromDate = new DateItem();
        fromDate.setTitle("From");
        fromDate.setUseTextField(true);
        DateItem toDate = new DateItem();
        toDate.setTitle("To");
        toDate.setUseTextField(true);
        controlForm.setItems(accountCombo, fromDate, toDate);
    
        chart = new Chart().setType(Type.COLUMN);       
        chart.getYAxis().setAxisTitleText("% Contribution");
    

    chart.setSeriesPlotOptions(new SeriesPlotOptions().setDataLabels(new DataLabels().setFormatter(new DataLabelsFormatter()
    {
    public String format(DataLabelsData dataLabelsData)
    {
    return "A";
    }
    })));

        grid = new MultiLevelListGrid();
        grid.setAutoFetchData(true);
        dataSource = new ContributionDataSource();
        grid.setDataSource(dataSource);
        grid.setHeight(400);
        grid.addDataArrivedHandler(new ContributionDataArrivedHandler());
        grid.setShowGroupSummary(true);
        grid.setShowGroupSummaryInHeader(true);
        grid.setShowGridSummary(true);
        grid.setGroupByField("rating");
        grid.setGroupStartOpen(GroupStartOpen.NONE);
        addGridEventHandlers();
    
        this.addMember(controlForm);
        this.addMember(chart);
        this.addMember(grid);
    
     
  • Shawn Quinn

    Shawn Quinn - 2011-09-28

    I just tried the following code, and didn't run into any issues. Some of the callback handler code was adjusted in the 1.1.1 release, so it may be that it was fixed there.

        Chart chart = new Chart().setType(Series.Type.COLUMN);
        chart.setSeriesPlotOptions(new SeriesPlotOptions()
            .setDataLabels(new DataLabels()
                .setEnabled(true)
                .setFormatter(new DataLabelsFormatter() {
                    public String format(DataLabelsData dataLabelsData) {
                        return "A";
                    }
                })
            )
        );
        Series series = chart.createSeries()
            .setPoints(new Number[]{163, 203, 276, 408, 547, 729, 628});
        chart.addSeries(series);
    

    Can you try upgrading to version 1.1.1 and let us know if that clears the issue you're seeing or not?

    https://sourceforge.net/projects/gwt-highcharts/files/1.1.1/

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.