Search code examples
apache-flexchartsflex4.5flex-charting

Bug/Error in the Adobe Flex SDK 4.5 when removing series from Cartesian Charts


I have a problem with the cartesian charts in the Adobe Flex SDK 4.5 and 4.5.1. Perhaps it's a bug, because it's not in the SDK 4.0, 4.1 and 4.6. Or it's just a problem of my code.

I made a little example project to range over series data in a CartesianChart (Line/Area/Column/Bar), a little bit like the google finance chart. When I add all series to the chart, the problem didn't occur. Only when I have multiple series and remove one or more series and than range over the data, the series data get compressed:

Chart image

It seems like the horizontal axis didn't change or didn't get an update that the chart data changed, when I range over the current data.

Here is the main code of my project, where I add series to the line chart, remove a series and range over all chartseries.

        public function addChartSeries(name:String, dataProvider:Array):void
        {
            var lineSeries:LineSeries = new LineSeries();
            lineSeries.xField = "date";
            lineSeries.yField = "value";
            lineSeries.displayName = name;
            lineSeries.dataProvider = dataProvider;
            var mySeries:Array = new Array();
            mySeries = lineChart.series;
            mySeries.push(lineSeries);
            lineChart.series = mySeries;
        }

        public function removeSeries(index:int):void
        {
            var mySeries:Array = new Array();
            mySeries = lineChart.series;
            mySeries.splice(index, 1);
            lineChart.series = mySeries;
        }

        private function changeDataProvider():void
        {
            var series:Array = lineChart.series;
            for (var i:int = 0; i < series.length; i++) 
            {
                var lineSeries:LineSeries = series[i];
                var item:ChartItem = chartItems.getItemAt(i) as ChartItem;
                lineSeries.dataProvider = item.data.slice(leftindex, rightIndex);
            }
            lineChart.series = series;
        }

Had someone the same problem or has an idea how to remove a series in another way?


Solution

  • Much thanks to JabbyPanda, his comment above describe how to resolve the problem. Just "replace" the charts.swc from SDK 4.6 with the one from the SDK 4.5.1.