Menu

Dynamically removing series from stock chart is broken

videv
2012-06-13
2012-07-18
  • videv

    videv - 2012-06-13

    Hello,

    When I dynamically remove a data series from a stock chart, it breaks.

    I can not reproduce the issue using pure JavaScript.

    Below is a working example.

    :::java
    public class ChartBugExample implements IsWidget
    {
        private StockChart stockChart = null;
        private boolean plotSeriesOne = true;
    
        public ChartBugExample()
        {
            stockChart = new StockChart();
    
            final Series seriesOne = stockChart.createSeries();
            final Series seriesTwo = stockChart.createSeries();
    
            stockChart.addSeries( seriesOne );
            stockChart.addSeries( seriesTwo );
    
            //Remove series one after 10 seconds
            new Timer()
            {
                @Override
                public void run()
                {
                    plotSeriesOne = false;
                    stockChart.removeSeries( seriesOne );
                }
            }.schedule( 10000 );
    
            //Plot random values every second
            new Timer()
            {
                @Override
                public void run()
                {
                    Long valueXParam = Long.valueOf( new Date().getTime() );
                    Double valueYParam = Double.valueOf( (Math.random()* 100.0) );
    
                    if( plotSeriesOne )
                    {
                        seriesOne.addPoint(valueXParam, valueYParam);
                    }
    
                    valueXParam = Long.valueOf( new Date().getTime() );
                    valueYParam = Double.valueOf( (Math.random()* 100.0) );
    
                    seriesTwo.addPoint(valueXParam, valueYParam);
                }
            }.scheduleRepeating( 1000 );
        }
    
        @Override
        public Widget asWidget()
        {
            return stockChart;
        }
    }
    
     
  • Shawn Quinn

    Shawn Quinn - 2012-07-05

    Very interesting. Thanks to your example code there I was able to duplicate the problem, and then traced the logic all the way down to native call to the HighStocks JS library. Everything on the GWT Highcharts side appears to be functioning correctly, so I'd suspect a Highstocks problem. But, you mentioned you weren't able to reproduce this issue in native JS code? If so, could you post a jsFiddle link (or just some sample code) that shows this working in pure Javascript? I can then try and better discern where the root issue might be.

     
  • videv

    videv - 2012-07-18

    Hey Shawn,

    Here is a jsfiddle example http://jsfiddle.net/5RutC/112/

    Thanks.

     

Log in to post a comment.