export declare enum DomPosition { Root = “root”, Main = “main”, YAxis = “yAxis” } export…
- User
export declare enum DomPosition { Root = “root”, Main = “main”, YAxis = “yAxis” }
export interface Chart { getDom: (paneId?: string, position?: DomPosition) => Nullable; getSize: (paneId?: string, position?: DomPosition) => Nullable; setLocale: (locale: string) => void; getLocale: () => string; setStyles: (styles: string | DeepPartial) => void; getStyles: () => Styles; setCustomApi: (customApi: Partial) => void; setPriceVolumePrecision: (pricePrecision: number, volumePrecision: number) => void; getPriceVolumePrecision: () => Precision; setTimezone: (timezone: string) => void; getTimezone: () => string; setOffsetRightDistance: (space: number) => void; getOffsetRightDistance: () => number; setLeftMinVisibleBarCount: (barCount: number) => void; setRightMinVisibleBarCount: (barCount: number) => void; setBarSpace: (space: number) => void; getBarSpace: () => number; getVisibleRange: () => VisibleRange; clearData: () => void; getDataList: () => KLineData[]; applyNewData: (dataList: KLineData[], more?: boolean, callback?: () => void) => void; applyMoreData: (dataList: KLineData[], more?: boolean, callback?: () => void) => void; updateData: (data: KLineData, callback?: () => void) => void; loadMore: (cb: LoadMoreCallback) => void; createIndicator: (value: string | IndicatorCreate, isStack?: boolean, paneOptions?: PaneOptions, callback?: () => void) => Nullable; overrideIndicator: (override: IndicatorCreate, paneId?: string, callback?: () => void) => void; getIndicatorByPaneId: (paneId?: string, name?: string) => Nullable | Nullable<Map<string, Indicator>> | Map<string, Map<string, Indicator>>; removeIndicator: (paneId: string, name?: string) => void; createOverlay: (value: string | OverlayCreate, paneId?: string) => Nullable; getOverlayById: (id: string) => Nullable; overrideOverlay: (override: Partial) => void; removeOverlay: (remove?: string | OverlayRemove) => void; setPaneOptions: (options: PaneOptions) => void; setZoomEnabled: (enabled: boolean) => void; isZoomEnabled: () => boolean; setScrollEnabled: (enabled: boolean) => void; isScrollEnabled: () => boolean; scrollByDistance: (distance: number, animationDuration?: number) => void; scrollToRealTime: (animationDuration?: number) => void; scrollToDataIndex: (dataIndex: number, animationDuration?: number) => void; scrollToTimestamp: (timestamp: number, animationDuration?: number) => void; zoomAtCoordinate: (scale: number, coordinate?: Coordinate, animationDuration?: number) => void; zoomAtDataIndex: (scale: number, dataIndex: number, animationDuration?: number) => void; zoomAtTimestamp: (scale: number, timestamp: number, animationDuration?: number) => void; convertToPixel: (points: Partial | Array<Partial>, finder: ConvertFinder) => Partial | Array<Partial>; convertFromPixel: (coordinates: Array<Partial>, finder: ConvertFinder) => Partial | Array<Partial>; executeAction: (type: ActionType, data: any) => void; subscribeAction: (type: ActionType, callback: ActionCallback) => void; unsubscribeAction: (type: ActionType, callback?: ActionCallback) => void; getConvertPictureUrl: (includeOverlay?: boolean, type?: string, backgroundColor?: string) => string; resize: () => void; destroy: () => void; }
- Assistant
Для выполнения желаемого эффекта сжатия графика к центру по оси Y при отрисовке, вам понадобится использовать методы и свойства объекта Chart.
- Установите значение свойства barSpace() на максимально возможное значение, чтобы уменьшить пространство между столбцами графика:
typescriptchart.current?.setBarSpace(0);- Получите текущий диапазон видимости на оси Y с помощью метода getVisibleRange():
typescriptconst visibleRange = chart.current?.getVisibleRange();- Рассчитайте центральное значение на оси Y, используя полученный диапазон видимости:
typescriptconst centerY = (visibleRange.max + visibleRange.min) / 2;- Установите новый диапазон видимости на оси Y так, чтобы центральное значение стало равным centerY:
typescriptchart.current?.scrollToDataIndex(centerY);