initFormats method

void initFormats()

Implementation

void initFormats() {
  if (this.chartStyle.dateTimeFormat != null) {
    mFormats = this.chartStyle.dateTimeFormat!;
    return;
  }

  if (mItemCount < 2) {
    mFormats = [yyyy, '-', mm, '-', dd, ' ', HH, ':', nn];
    return;
  }

  int firstTime = datas!.first.time ?? 0;
  int secondTime = datas![1].time ?? 0;
  int time = secondTime - firstTime;
  time ~/= 1000;
  //月线
  if (time >= 24 * 60 * 60 * 28)
    mFormats = [yy, '-', mm];
  //日线等
  else if (time >= 24 * 60 * 60)
    mFormats = [yy, '-', mm, '-', dd];
  //小时线等
  else
    mFormats = [mm, '-', dd, ' ', HH, ':', nn];
}