在弹性图表中,
我想画一些与特定系列相关的“参考线”之类的东西,
因此,这些线不是独立的系列,不应在图例中显示。
是否可以从图表图例中排除某些系列?
谢谢!
我详细阐述了 Luis B 的答案,使其动态地反映在折线图的数据提供者上。这样,图例仅显示图表中可用的字段。有点俏皮。
这是我想出的,而且效果很好:
protected function onUpdateLinechartComplete(e:FlexEvent):void
{
//empty legend for fresh display
var legendArray:Array = new Array();
legend1.dataProvider = legendArray;
//filter Legend data so that only LineSeries with data can be shown
for(var i:int=0; i< linechart1.legendData.length; i++) {
//if data is found in the line series, let's add it to the chart legend data provider, so it can be displayed in the legend
if (linechart1.legendData[i].element.items.length != 0) {
legendArray.push(linechart1.legendData[i]);
}
}
legend1.dataProvider = legendArray;
legend1.direction = "vertical";
}
//in the page Initialize function, I add a listener event to the linechart component for when the legend update completes so it can filter lineseries on the legend's dataprovider in [onUpdateLegendComplete]
linechart1.addEventListener(FlexEvent.UPDATE_COMPLETE, onUpdateLinechartComplete);
我最终不得不使用 EventHandler 并将事件侦听器附加到折线图本身。这是因为我正在经历与传奇数据提供者的“竞争条件”。有时它会起作用,有时则不会。使用事件监听器消除了这个问题,并且仅当折线图完成加载其数据时才过滤图例。
FLEX 的朋友们,请随意投票支持这个答案!
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)