0

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?

David
  • 177
  • 2
  • 11
  • Can you be more explicit under what Flex SDK do you witness this wrong behaviour? I've tested your sample with Flex 4.6 SDK, I could not get the situation illustrated by attached [Chart image] screenshot. – JabbyPanda Mar 04 '12 at 18:08
  • @JabbyPanda Thank you for your reply. It's just with the SDK 4.5 and 4.5.1 – David Mar 05 '12 at 08:22
  • That's right, this issue you've hit occurs with SDK 4.5.1, but not 4.6. If full upgrading is not an option for you, I suggest just to replace "charts.swc" library from 4.6 SDK, it works for me. – JabbyPanda Mar 05 '12 at 20:58
  • I also did some diff between charting classes in SDK 4.5.1 and SDK 4.6. The changes are indeed minor, but I failed to replace solumn CartesianChart class in 4.5.1 SDK with its counterpart from 4.6 SDK, I get some errors related to default style value, maybe you will be more lucky if you will go this route. – JabbyPanda Mar 05 '12 at 22:16
  • @JabbyPanda Again thank you, this is a really good idea. We would upgrade to SDK 4.6, but we had some performance problems, which we don't get with the SDK 4.5.1. So you just copy the "charts.swc" from the SDK 4.6 to the SDK 4.5.1? It don't works for me. – David Mar 06 '12 at 13:41
  • @JabbyPanda How did you replace the CartesianChart.as from 4.6 with the one in 4.5.1? Did you build the SDK with ANT like the instructions in the [wiki](http://opensource.adobe.com/wiki/display/flexsdk/Build+and+Test)? – David Mar 06 '12 at 14:32
  • If you are using Flash Builder, go to Flex Build Path in Project Properties, select "Library path". Navigate to "charts.swc" and remove it from a list. Then click "Add SWC" and add "charts.swc" from Flex 4.6 SDK – JabbyPanda Mar 06 '12 at 20:14
  • Please, vote on this story as resolved ;) – JabbyPanda Mar 09 '12 at 12:19

1 Answers1

0

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.

Community
  • 1
  • 1
David
  • 177
  • 2
  • 11