Загрузка данных


private getGeometry(): RectangleGeometry | null {
  if (this.startTime === null || this.endTime === null || this.startPrice === null || this.endPrice === null) {
    return null;
  }

  const startX = getXCoordinateFromTime(this.chart, this.startTime, this.series);
  const endX = getXCoordinateFromTime(this.chart, this.endTime, this.series);
  const startY = getYCoordinateFromPrice(this.series, this.startPrice);
  const endY = getYCoordinateFromPrice(this.series, this.endPrice);

  if (startX === null || endX === null || startY === null || endY === null) {
    return null;
  }

  const left = Math.round(Math.min(Number(startX), Number(endX)));
  const right = Math.round(Math.max(Number(startX), Number(endX)));
  const top = Math.round(Math.min(Number(startY), Number(endY)));
  const bottom = Math.round(Math.max(Number(startY), Number(endY)));

  const centerX = (left + right) / 2;
  const centerY = (top + bottom) / 2;

  return {
    left,
    right,
    top,
    bottom,
    width: right - left,
    height: bottom - top,
    handles: {
      nw: { x: left, y: top },
      n: { x: centerX, y: top },
      ne: { x: right, y: top },
      e: { x: right, y: centerY },
      se: { x: right, y: bottom },
      s: { x: centerX, y: bottom },
      sw: { x: left, y: bottom },
      w: { x: left, y: centerY },
    },
  };
}