如何动态地将columnSeries添加到flex中的柱形图?

时间:2014-02-19 05:53:58

标签: flex flex4 flex3 flex4.5

这是我的完整代码。我正在尝试阅读示例xmllist并动态绘制列系列。理论上我的代码是正确的但实际上这不起作用。你可以帮我解决这个问题。

private var testXML:XML=<main>
                                <data Country="USA" Gold1="10" Silver1="20" Bronze1="15"/>
                                <data Country="China" Gold="15" Silver="10" Bronze="25"/>
                            </main>;

protected function creationCompleteEvent(event:FlexEvent):void
    {
        var List:XMLList=testXML.children();

        var attr:XMLList=List.attributes();

        column.dataProvider=List; ///data provider

        cat.categoryField=attr[List[0].attributes().length()].name();

        for(var j:Number=0 ; j<List.length() ; j++)
        {
            var currentSeries:Array = column.series; 

            var columnSeries:ColumnSeries=new ColumnSeries();

            for(var i:Number=0;i<List[j].attributes().length();i++)
            {
                //Alert.show(List[j].attributes()[i].name());

                //Alert.show(attr[List[j].attributes().length()].name());


                //Alert.show(List[j].attributes()[i]);

                columnSeries.dataProvider=List;

                columnSeries.xField=attr[List[j].attributes().length()].name();
                columnSeries.yField=List[j].attributes()[i];
                columnSeries.displayName=List[j].attributes()[i].name().toString();


                currentSeries.push(columnSeries); 
            }

            column.series = currentSeries;  
        }

    }

“column”是柱形图的id。

0 个答案:

没有答案
相关问题