Menu

Bug when detach & re-attach GWT highcharts

tvhnet
2012-08-10
2012-08-10
  • tvhnet

    tvhnet - 2012-08-10

    GWT Highcharts does not retain original view if I detach and re-attach a rendered chart. This problem happens when Axis categories is set and the chart is inverted.

    I suspect BaseChart.onLoad() causes it.

    Here is my test code in GWT:

            String[] categories = new String[12];
            Number[] values = new Number[12];
            for (int i = 0; i < 12; i++)
            {
                categories[i] = String.valueOf((char) (65 + Random.nextInt(25))) + String.valueOf((char) (65 + Random.nextInt(25)));
                values[i] = Random.nextDouble();
            }
    
            final Chart chart = new Chart()
                    .setWidth(400)
                    .setHeight(400)
                    .setInverted(true)
                    .setType(Series.Type.COLUMN);
            RootPanel.get().add(chart);
    
            chart.getXAxis().setCategories(categories);
            chart.addSeries(chart.createSeries().setPoints(values));
    
            RootPanel.get().add(new Button("test", new ClickHandler()
            {
                @Override
                public void onClick(ClickEvent event)
                {
                    chart.removeFromParent();
                    RootPanel.get().add(chart);
                }
            }));
    

    When click on "test" button, labels of xAxis are changed. My expectation is nothing changed.

    I also test this case on pure Highcharts. This problem does not happen. Check it here:

     
  • tvhnet

    tvhnet - 2012-08-10

    This problem still happens if I remove chart.setInverted(true) and change series type to BAR.

     
  • tvhnet

    tvhnet - 2012-08-10

    It seems that chart.setPersistent(true) should keep axis categories together with point array. I also wonder about axis min/max, chart extremes, plot line/band...

     

    Last edit: tvhnet 2012-08-10

Log in to post a comment.