奥凯找到了解决这一问题的办法。 类似于上文提及的“@fotomut”。 除重写假法外,我从Axis类复制了所有代码。 这就是标签产生的地方。 我在此采用更新方法,可能不是一个完美的解决办法。
但我在此面临一个问题。 出于某种原因,图表和标签倾向于右侧。 我无法画出一个图象,把我的习惯性轴比同提供的各类轴体相比较,以更好地解释这一点,因为我仅限于不上任何档案。 我正试图解决这一问题,但还没有找到解决办法。
if (!_labelSet)
{
//I do not need label for each item in my dataprovider.
//Hence creating a categoryValues array with limited labels.
var chartDP:ArrayCollection = this.dataProvider as ArrayCollection;
var axisLabels:Array /* of AxisLabel */ = [];
var labelsArr:Array = [];
var categoryItems:Array = [];
var dataMap:Object = {};
_catMap = {};
_categoryValues = [];
_labelsMatchToCategoryValuesByIndex = [];
if(chartDP.length != 0) {
for(var indx:int=0; indx<chartDP.length; indx++){
// Add each item to the map.
//This is mandatory as it s being used internally to draw the Y-value
_catMap[chartDP.getItemAt(indx).timeStamp.toString()] = indx;
}
var firstItem:Object = chartDP.getItemAt(0);
var lastItem:Object = chartDP.getItemAt(chartDP.length - 1);
var incrCounter:int;
var timeDiffInMillis:Number = (lastItem.timeStamp) - (firstItem.timeStamp);
var arrIndx:int=0;
if(timeDiffInMillis <= MILLISECONDS_IN_HOUR){
LIMIT_LABEL_CNT = 12;
INT_LBL_UNITS = "MINUTES";
}else if(timeDiffInMillis > MILLISECONDS_IN_HOUR && timeDiffInMillis <= MILLISECONDS_IN_DAY){
LIMIT_LABEL_CNT = 12;
INT_LBL_UNITS = "HOURS";
}else if(timeDiffInMillis > MILLISECONDS_IN_DAY && timeDiffInMillis <= MILLISECONDS_IN_WEEK){
LIMIT_LABEL_CNT = 7;
INT_LBL_UNITS = "DAYS";
}else if(timeDiffInMillis > MILLISECONDS_IN_WEEK && timeDiffInMillis <= MILLISECONDS_IN_MONTH){
LIMIT_LABEL_CNT = 4;
INT_LBL_UNITS = "WEEKS";
}else if(timeDiffInMillis > MILLISECONDS_IN_MONTH && timeDiffInMillis <= MILLISECONDS_IN_YEAR) {
LIMIT_LABEL_CNT = 12;
INT_LBL_UNITS = "MONTHS"
}
if(chartDP.length <= LIMIT_LABEL_CNT)
incrCounter = 1;
else
incrCounter = chartDP.length/LIMIT_LABEL_CNT;
var i:int=0;
for(i=0,arrIndx=0; i<chartDP.length; i=i+incrCounter){
arrIndx = i;
_categoryValues[arrIndx] = chartDP.getItemAt(i).timeStamp;
dataMap[arrIndx] = chartDP.getItemAt(i);
//There is a very good chance for the incrCounter to omit
//the last items in the DataProvider.
if((chartDP.length-i) <= incrCounter){
arrIndx=arrIndx+incrCounter;
_categoryValues[arrIndx] = chartDP.getItemAt(chartDP.length-1).timeStamp;
dataMap[arrIndx] = chartDP.getItemAt(chartDP.length-1);
}
}
var min:Number = -_padding;
var max:Number = _categoryValues.length - 1 + _padding;
var alen:Number = max - min;
var label:AxisLabel;
var n:int = _categoryValues.length;
if (_labelFunction != null)
{
var previousValue:Object = null;
for (i=0; i<n; i++)
{
if (_categoryValues[i] == null)
continue;
if(previousValue != null && _categoryValues[i] != null){
if(previousValue == _categoryValues[i])
continue;
}
label = new AxisLabel((i - min) / alen, _categoryValues[i],
timeLblFormatFunction(_categoryValues[i], previousValue,
this, dataMap[i]));
_labelsMatchToCategoryValuesByIndex[i] = label;
axisLabels.push(label);
previousValue = _categoryValues[i];
}
}
else
{
for (i = 0; i < n; i++)
{
if (!_categoryValues[i])
continue;
label = new AxisLabel((i - min) / alen, _categoryValues[i],
_categoryValues[i].toString());
_labelsMatchToCategoryValuesByIndex[i] = label;
axisLabels.push(label);
}
}
}
_labelSet = new AxisLabelSet();
_labelSet.labels = axisLabels;
_labelSet.accurate = true;
_labelSet.minorTicks = minorTicks;
_labelSet.ticks = generateTicks();
}