I have a chart with multiple series (Area and Plot). The Area series has 'xField' as 'timeStamp' and 'yField' as 'price'. The Plot Series has 'xField' as 'timeStamp' and no 'yField'.... ! Can I position the plot series though I do not have a corresponding 'yField' value ? Can I assign a default value to the 'yField' (say '10' for all...?)
This is how I create my AreaChart initially. At this point, I have no idea whether to render events or not, so I do not attempt to create a 'plot series' at this point.
//Note: 'AreaSeries' and 'PlotSeries' have different dataproviders
var areaChart:AreaChart = new AreaChart();
areaChart.width = width;
areaChart.height = height;
areaChart.showDataTips = true;
var vAxis:LinearAxis = new LinearAxis();
if(vAxisLblFunction != null){
vAxis.labelFunction = vAxisLblFunction;
areaChart.verticalAxis = vAxis;
}
var hAxis:CategoryAxis = new CategoryAxis();
hAxis.categoryField = "timeStamp";
areaChart.horizontalAxis = hAxis;
areaChart.horizontalAxisRenderer = createHAxisRenderer(hAxis);
var areaChartSeries:AreaSeries = new AreaSeries();
areaChartSeries.yField = "price";
areaChartSeries.displayName = "Stock Price";
areaChartSeries.setStyle("form", "segment");
var chartStroke:Stroke = new Stroke();
chartStroke.color = 0xFF0000;
chartStroke.weight = CHART_STROKE_WEIGHT;
var chartColor:SolidColor = new SolidColor();
chartColor.alpha = CHART_ALPHA;
chartColor.color = 0x000000;
areaChartSeries.setStyle("areaStroke", chartStroke);
areaChartSeries.setStyle("areaFill", chartColor);
chartSeriesArr.push(areaChartSeries);
Now, during run-time I want to plot some events as required.
var evtSer:PlotSeries = new PlotSeries();
evtSer.dataProvider = devEventsAC; //Assume that I get the 'eventsDataProvider' somehow at run-time
evtSer.xField = "timeStamp"; //Notice there is no 'yField' to map here.
//evtSer.dataFunction = eventSerDataFunc; //Tried with a 'dataFunction' assigning default value of '10' to the 'yField'
var fillColor:SolidColor = new SolidColor();
fillColor.color = 0xA933DC;
fillColor.alpha = 0.8;
evtSer.setStyle("fill", fillColor);
var strokeColor:SolidColorStroke = new SolidColorStroke();
strokeColor.color = 0x9494B8;
strokeColor.weight = 1;
evtSer.setStyle("stroke", strokeColor);
var chartSeriesArr:Array = trendPanel.areaChart.series;
chartSeriesArr.push(evtSer);
trendPanel.areaChart.series = chartSeriesArr;
So, my problem is that how do I plot the 'events' without a 'yField'. Is there a way to assign 'yField' value using the series's 'dataFunction' ?
Here is my thought:
- In the 'dataFunction' we get a reference to the 'series' object. Using the series object get the 'parent' which is the chart and then get the series array for that chart.
- Now, get the 'yField' value fron the 'AreaSeries' and return it as the 'yField' valu开发者_JAVA技巧e for the 'plot series'.
- But, if I have multiple events with same 'yField' value there is a very good chance that all the events plotted top of each other. (First I am not sure whether 1 & 2 works here...)
Second approach is using the 'CartesianDataCanvas'. Again, here it requires datapoints (x,y) which I don't have.
You can use the CartesianDataCanvas to draw stuff on a chart using data coordinates. But if you really want to use a PlotSeries to display time events on your chart, you can loop over your dataProvider and add a property with a default value that you will use in your plotSeries as an yField...
精彩评论