动态添加LineChart的线条

private function setDataXML(datas:String)
	 		{
	 			var s:Array = datas.split("*");
	 			dataXML = new XML(s[0]);
	 			//var seriec:Series = new Series();
	 			
	 			var array:Array = new Array();
	 		    for(var i:Number=1;i<s.length-1;i++)
	 		    {
	 		    	var lineSeries:LineSeries = new LineSeries();
	 		    	lineSeries.id = i as String;
	 		    	lineSeries.xField="@name";
	 		    	lineSeries.yField="@"+s[i];
	 		    	lineSeries.displayName=s[i];
	 		    	array.push(lineSeries);
	 		        //seriec.addChild(lineSeries);
	 		        //seriec.legendData
	 		    }
	 		    linechart.series = array;  
	 		   // Alert.show(lineSeries.yField);
	 		   //  linechart.addChild(seriec);
	 		}

<mx:LineChart id="linechart" dataProvider="{dataXML.Row}" paddingLeft="5" paddingRight="5" width="100%" showDataTips="true">
	 	<mx:horizontalAxis>
                <mx:CategoryAxis categoryField="@name"/>
        </mx:horizontalAxis>
        <!--
        <mx:series>
        	<mx:LineSeries xField="@name" yField="@收入" displayName="收入" form="curve"/>
        </mx:series>
        -->
	 </mx:LineChart>
	 
	 <mx:Legend dataProvider="{linechart}" direction="horizontal" doubleClick="hiddenShow(event)" doubleClickEnabled="true" buttonMode="true"/>

你可能感兴趣的:(xml)