Загрузка данных
protected getTimeAxisSegments(): AxisSegment[] {
if (this.profileKind === 'visibleRange') {
return [];
}
const geometry = this.getGeometry();
return this.createAxisSegments(geometry?.left ?? null, geometry?.right ?? null);
}
protected getPriceAxisSegments(): AxisSegment[] {
if (this.profileKind === 'visibleRange') {
return [];
}
const geometry = this.getGeometry();
return this.createAxisSegments(geometry?.top ?? null, geometry?.bottom ?? null);
}
protected getTimeAxisLabel(kind: string): AxisLabel | null {
if (
this.profileKind === 'visibleRange' ||
(!this.isSelected() && !this.isCreationPending()) ||
(kind !== 'start' && kind !== 'end')
) {
return null;
}
const anchor = kind === 'start' ? this.startAnchor : this.endAnchor;
if (!anchor || typeof anchor.time !== 'number') {
return null;
}
return createAxisLabel(
getXCoordinateFromTime(this.chart, anchor.time, this.series),
formatDate(
anchor.time as UTCTimestamp,
this.displayFormat.dateFormat,
this.displayFormat.timeFormat,
this.displayFormat.showTime,
),
);
}
protected getPriceAxisLabel(kind: string): AxisLabel | null {
if (
this.profileKind === 'visibleRange' ||
(!this.isSelected() && !this.isCreationPending()) ||
(kind !== 'start' && kind !== 'end')
) {
return null;
}
const price = kind === 'start' ? this.profileMinPrice : this.profileMaxPrice;
if (price === null) {
return null;
}
return createAxisLabel(getYCoordinateFromPrice(this.series, price), formatPrice(price));
}
private handleFixedRangePointerDown(event: PointerEvent, point: Point): void {
if (
this.handleTwoPointCreation(
event,
point,
(nextPoint) => this.startDrawing(nextPoint),
(nextPoint) => this.updateDrawing(nextPoint),
() => this.finishDrawing(),
)
) {
return;
}
if (this.mode !== 'ready') {
return;
}
const dragTarget = this.getFixedRangeDragTarget(point);
if (!this.isSelected()) {
if (!dragTarget) {
return;
}
event.preventDefault();
event.stopPropagation();
this.select();
return;
}
if (!dragTarget) {
this.deselect();
return;
}
event.preventDefault();
event.stopPropagation();
this.startDragging(point, event.pointerId, dragTarget);
}
protected getTimeAxisSegments(): AxisSegment[] {
const geometry = this.getGeometry();
return this.createAxisSegments(geometry?.left ?? null, geometry?.right ?? null);
}
protected getPriceAxisSegments(): AxisSegment[] {
const geometry = this.getGeometry();
return this.createAxisSegments(geometry?.top ?? null, geometry?.bottom ?? null);
}
protected getTimeAxisLabel(kind: string): AxisLabel | null {
if (kind !== 'main' || !this.isSelected() || !this.point || typeof this.point.time !== 'number') {
return null;
}
return createAxisLabel(
getXCoordinateFromTime(this.chart, this.point.time, this.series),
formatDate(
this.point.time as UTCTimestamp,
this.displayFormat.dateFormat,
this.displayFormat.timeFormat,
this.displayFormat.showTime,
),
);
}
protected getPriceAxisLabel(kind: string): AxisLabel | null {
if (kind !== 'main' || !this.isSelected() || !this.point) {
return null;
}
return createAxisLabel(
getYCoordinateFromPrice(this.series, this.point.price),
formatPrice(this.point.price),
);
}
protected getTimeAxisSegments(): AxisSegment[] {
const bounds = this.getTimeBounds();
return this.createAxisSegments(bounds?.left ?? null, bounds?.right ?? null);
}
protected getPriceAxisSegments(): AxisSegment[] {
const geometry = this.getGeometry();
if (!geometry) {
return [];
}
return [
...this.createAxisSegments(geometry.profitTop, geometry.profitBottom),
...this.createAxisSegments(geometry.lossTop, geometry.lossBottom),
];
}
protected getTimeAxisSegments(): AxisSegment[] {
const geometry = this.getGeometry();
return this.createAxisSegments(geometry?.left ?? null, geometry?.right ?? null);
}
protected getPriceAxisSegments(): AxisSegment[] {
const geometry = this.getGeometry();
return this.createAxisSegments(geometry?.top ?? null, geometry?.bottom ?? null);
}
protected getTimeAxisLabel(kind: string): AxisLabel | null {
if ((!this.isSelected() && !this.isCreationPending()) || (kind !== 'start' && kind !== 'end')) {
return null;
}
const anchor = kind === 'start' ? this.startAnchor : this.endAnchor;
if (!anchor || typeof anchor.time !== 'number') {
return null;
}
return createAxisLabel(
getXCoordinateFromTime(this.chart, anchor.time, this.series),
formatDate(
anchor.time as UTCTimestamp,
this.displayFormat.dateFormat,
this.displayFormat.timeFormat,
this.displayFormat.showTime,
),
);
}
protected getPriceAxisLabel(kind: string): AxisLabel | null {
if ((!this.isSelected() && !this.isCreationPending()) || !isPriceLabelKind(kind)) {
return null;
}
const price = this.getPriceLabelValue(kind);
if (price === null) {
return null;
}
return createAxisLabel(getYCoordinateFromPrice(this.series, price), formatPrice(price));
}
protected getTimeAxisLabel(kind: string): AxisLabel | null {
if (kind !== 'main' || this.direction !== 'vertical' || !this.isSelected() || this.time === null) {
return null;
}
if (typeof this.time !== 'number') {
return null;
}
return createAxisLabel(
getXCoordinateFromTime(this.chart, this.time, this.series),
formatDate(
this.time as UTCTimestamp,
this.displayFormat.dateFormat,
this.displayFormat.timeFormat,
this.displayFormat.showTime,
),
);
}
protected getPriceAxisLabel(kind: string): AxisLabel | null {
if (kind !== 'main' || this.direction !== 'horizontal' || !this.isSelected() || this.price === null) {
return null;
}
return createAxisLabel(getYCoordinateFromPrice(this.series, this.price), formatPrice(this.price));
}