initFormats method

void initFormats()

init format time

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;
  // monthly line
  if (time >= 24 * 60 * 60 * 28) {
    mFormats = [yy, '-', mm];
  } else if (time >= 24 * 60 * 60) {
    // daily line
    mFormats = [yy, '-', mm, '-', dd];
  } else {
    // hour line
    mFormats = [mm, '-', dd, ' ', HH, ':', nn];
  }
}