Flex的AreaChart错误是什么,有人知道如何修复它吗?它会导致一个工具提示显示minFields的错误值。
即。为:
<mx:AreaSeries yField="TotalVariableCost" minField="TotalFixedCost" displayName="Total Cost">
它会显示:
Total Cost
high: TotalVariableCost
low: TotalVariableCost
相反:
Total Cost
high: TotalVariableCost
low: TotalFixedCost
这个错误假设在AreaSeries.as的2058到2083行 - 但这些东西超出了我的理解范围。
斯蒂芬 -
答案 0 :(得分:1)
是的,这是AreaSeries中的一个错误。由于设计了柔性图表的愚蠢方式,唯一真正的解决方法是在AreaChart上设置自定义dataTipFunction
。
以下是修复错误的相关代码的副本:
/**
* Create a data tip function for the given AreaSeries. Uses a copy of
* the formatDataTip code from AreaSeries with the minValue bug fixed.
*
* @param series
* @return a data tip function
*
*/
private function createAreaSeriesTipFunc(series:AreaSeries):Function {
var displayName:String = series.displayName;
var dataTransform:DataTransform = series.dataTransform;
var xField:String = series.xField;
var minField:String = series.minField;
// formatDataTip relies on AreaSeries member data so simulate that
// with a closure to minimize code modifications
return function(hd:HitData):String {
var dt:String = "";
var n:String = displayName;
if (n && n != "")
dt += "<b>"+ n + "</b><BR/>";
var xName:String = dataTransform.getAxis(CartesianTransform.HORIZONTAL_AXIS).displayName;
if (xName == "")
xName = xField;
if (xName != "")
dt += "<i>" + xName + ": </i>";
var item:AreaSeriesItem = AreaSeriesItem(hd.chartItem);
var lowItem:AreaSeriesItem = (minField != "") ?
item :
null;
dt += dataTransform.getAxis(CartesianTransform.HORIZONTAL_AXIS).formatForScreen(item.xValue) + "\n";
var yName:String = dataTransform.getAxis(CartesianTransform.VERTICAL_AXIS).displayName;
if (!lowItem)
{
if (yName != "")
dt += "<i>" + yName + ":</i> ";
dt += dataTransform.getAxis(CartesianTransform.VERTICAL_AXIS).formatForScreen(item.yValue) + "\n";
}
else
{
if (yName != "")
dt += "<i>" + yName + " (high):</i> ";
else
dt += "<i>high: </i>";
dt += dataTransform.getAxis(CartesianTransform.VERTICAL_AXIS).formatForScreen(item.yValue) + "\n";
if (yName != "")
dt += "<i>" + yName + " (low):</i> ";
else
dt += "<i>low:</i> ";
dt += dataTransform.getAxis(CartesianTransform.VERTICAL_AXIS).formatForScreen(lowItem.minValue) + "\n";
}
return dt;
};
}
我刚刚在一个地方将formatForScreen(lowItem.yValue)
更改为formatForScreen(lowItem.minValue)
。您可以像这样使用它:
<mx:AreaChart dataProvider="{chartData}" showDataTips="true" dataTipFunction="{createAreaSeriesTipFunc(areaSeries)}">
<mx:series>
<mx:AreaSeries id="areaSeries" yField="TotalVariableCost" minField="TotalFixedCost" displayName="Total Cost" />
</mx:series>
</mx:AreaChart>