我有一个包含多个系列的图表(Area和Plot)。 Area系列的'xField'为'timeStamp','yField'为'price'。 Plot Series的'xField'为'timeStamp'而没有'yField'....!虽然我没有相应的'yField'值,但我可以定位情节系列吗?我可以为'yField'指定一个默认值(对所有......来说'10')
这是我最初创建AreaChart的方法。此时,我不知道是否渲染事件,因此我不会尝试在此时创建“情节系列”。
//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);
现在,在运行期间,我想根据需要绘制一些事件。
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;
所以,我的问题是如何在没有'yField'的情况下绘制'事件'。有没有办法使用系列的'dataFunction'来分配'yField'值?
以下是我的想法:
第二种方法是使用'CartesianDataCanvas'。同样,这里需要我没有的数据点(x,y)。
答案 0 :(得分:0)
您可以使用CartesianDataCanvas使用数据坐标在图表上绘制内容。但是如果你真的想使用PlotSeries在你的图表上显示时间事件,你可以遍历你的dataProvider并添加一个默认值的属性,你将在plotSeries中用作yField ......