LineSeries未动态添加到我的CartesianChart ... 这段代码有什么问题:
...
private function chartComplete():void {
var ls:LineSeries = new LineSeries();
ls.styleName = 'timeline';
ls.dataProvider = "{dataManager.tagViewTimelineModel.tags.getItemAt(0).yearPopularity}";
ls.yField = 'popularity';
//ls.s = "{new Stroke(0xCC33CC, 2)}";
AllChart.series[0] = ls;
}
...
<mx:CartesianChart id="AllChart" width="100%" height="100" creationComplete="chartComplete();">
<mx:horizontalAxis><mx:CategoryAxis id="horiz1" dataProvider="['1','2','3','4','5','6','7','8','9','10','11','23','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31']"/></mx:horizontalAxis>
<mx:horizontalAxisRenderers><mx:AxisRenderer axis="{horiz1}"/></mx:horizontalAxisRenderers>
<mx:verticalAxis><mx:LinearAxis id="vert1" /></mx:verticalAxis>
<mx:verticalAxisRenderers><mx:AxisRenderer axis="{vert1}"/></mx:verticalAxisRenderers>
<mx:series>
<mx:AreaSeries id="timeArea" styleName="timeArea" name="A" dataProvider="{dataManager.tagViewTimelineModel.tags.getItemAt(2).yearPopularity}" areaStroke="{new Stroke(0x0033CC, 2)}" areaFill="{new SolidColor(0x0033CC, 0.5)}" />
</mx:series>
</mx:CartesianChart>
如果我用MXML添加它,我只能看到TimeLine:
<mx:LineSeries styleName="timeLine" dataProvider="{dataManager.tagViewTimelineModel.tags.getItemAt(0).yearPopularity}" yField="popularity" stroke="{new Stroke(0xCC33CC, 2)}" />
但我需要更新视图,并添加N行,因此我无法使用MXML。
感谢
答案 0 :(得分:0)
您可以为图表设置系列属性。只需向该数组添加一个新的Series对象。