Ладно, тут я нашел решение проблемы.Похоже на то, что @fotomut упоминал выше.Я скопировал весь код из «CategoryAxis», за исключением того, что переписал метод «udpate ()».Это где этикетки генерируются.Вот моя реализация метода обновления, возможно, не идеальное решение ...
Но я столкнулся с проблемой здесь.По какой-то причине график и метки выглядят немного смещенными вправо.Я не могу опубликовать изображение, сравнивая мой CustomDateAxis с гибким, предоставленным CategoryAxis, чтобы лучше объяснить это, так как я не могу загружать какие-либо файлыЯ пытаюсь это исправить, но пока не нашел решения ...
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();
}