FLEX: how to dynamically add LineSeries to CartesianChart
Posted
by Patrick
on Stack Overflow
See other posts from Stack Overflow
or by Patrick
Published on 2010-05-04T16:46:04Z
Indexed on
2010/05/04
16:48 UTC
Read the original article
Hit count: 453
flex
hi,
the LineSeries is not dynamically added to my CartesianChart... What's wrong in this code:
...
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>
I can only see the TimeLine if I added it with MXML:
<mx:LineSeries styleName="timeLine" dataProvider="{dataManager.tagViewTimelineModel.tags.getItemAt(0).yearPopularity}" yField="popularity" stroke="{new Stroke(0xCC33CC, 2)}" />
But I need to update the view, and add N lines so I cannot do it with MXML.
thanks
© Stack Overflow or respective owner