@alauda-fe/common
Version:
Alauda frontend team common codes.
121 lines (120 loc) • 4.89 kB
TypeScript
import { BaseTooltip } from '@alauda/ui';
import { ChangeDetectorRef, OnDestroy, OnInit, TemplateRef, TrackByFunction } from '@angular/core';
import { ConfigType } from 'dayjs';
import { Subject } from 'rxjs';
import { ChartData } from '../../../view-chart/public-api';
import { ContextChartService } from '../../chart.service';
import { tooltipSuffixFormat } from '../../utils';
import * as i0 from "@angular/core";
type XValue = string | number | Date;
export interface ContextItem {
name: string;
color: string;
x: XValue;
y: number;
unit?: string;
active?: boolean;
}
interface TooltipContext {
title: XValue;
source: ChartData[];
values: ContextItem[];
}
export declare function handleDateFormat(date: ConfigType, format?: string): string;
export declare class ChartTooltipComponent implements OnInit, OnDestroy {
readonly contextService: ContextChartService;
private readonly cdr;
dateFormat: string;
valuePrefix: string;
valueSuffix: string;
columnLayout: boolean;
tooltipTemplate: TemplateRef<unknown>;
pointTemplate: TemplateRef<unknown>;
pointNameTemplate: TemplateRef<unknown>;
pointTemplateContext: unknown;
titleTemplate: TemplateRef<unknown>;
autoSort: boolean;
translation: boolean;
titleTranslation: boolean;
pointFormat: (d: ContextItem) => string | number;
auiTooltipRef: BaseTooltip;
view: {
width: number;
height: number;
};
destroy$$: Subject<void>;
anchorPos: number;
anchorOpacity: number;
anchorHeight: number;
anchorY: number;
lastAnchorPos: number;
tooltipContext: TooltipContext;
hacked: boolean;
handleDateFormat: typeof handleDateFormat;
tooltipSuffixFormat: typeof tooltipSuffixFormat;
activeLegend: string;
get typeStandard(): boolean;
get isBand(): boolean;
get anchorVisibility(): "" | "hidden";
get groupPosition(): {
x1: number;
x2: number;
index: number;
groupName: string;
}[];
get calculationItemPosition(): any[];
calculateY: (_: number) => number;
constructor(contextService: ContextChartService, cdr: ChangeDetectorRef);
ngOnInit(): void;
mouseMove(e: MouseEvent, rectDom?: HTMLElement): void;
mouseLeave(): void;
mergePointContext: (context: TooltipContext) => {
context: ContextItem[];
source: ChartData[];
};
itemTrackBy: TrackByFunction<ContextItem>;
private barMouseMove;
private getBarHight;
/**
* 计算 bar 垂直 类型下 高度
* 标准:直接根据 y(0) - y(value) 计算 bar item 的高度
* 堆叠:计算 group 下所有item 的高度相加 得到堆叠的 bar 高度
*/
private getVerticalBarHeight;
private getBarYValue;
private getTooltipContext;
/**
* 获取 bar tooltip 展示数据
*/
private getBarTooltipContext;
/**
* 暂时先 通过 hack 方式 修改 pointer event 行为
* TODO: 后续内部实现 tooltip 不使用 aui tooltip
*/
hackOverlayPaneStyle(style: string): void;
/**
* 获取鼠标移动的位置所在的 bar value
* @param data 当前 bar 开始结束 x 位置
* @param xPos 当前鼠标位置
*/
private getCurrentMouseMovePositionValue;
/**
* 计算锚点 x 位置
* 当前 bar 数据 x 位置 + 当前 bar 宽度的一般
* @param currPosition 当前鼠标移入的bar 数据
*/
private getBarXAnchorPos;
/**
* 计算锚点 y 位置
* 水平:当前 bar 数据 x 位置
* 垂直:总高度 - bar 高度 (需要先计算出 bar高度)
*/
private getBarYAnchorPos;
private showTooltip;
private hideTooltip;
private limitMaxContext;
ngOnDestroy(): void;
static ɵfac: i0.ɵɵFactoryDeclaration<ChartTooltipComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<ChartTooltipComponent, "g[aclTooltip]", never, { "dateFormat": { "alias": "dateFormat"; "required": false; }; "valuePrefix": { "alias": "valuePrefix"; "required": false; }; "valueSuffix": { "alias": "valueSuffix"; "required": false; }; "columnLayout": { "alias": "columnLayout"; "required": false; }; "tooltipTemplate": { "alias": "tooltipTemplate"; "required": false; }; "pointTemplate": { "alias": "pointTemplate"; "required": false; }; "pointNameTemplate": { "alias": "pointNameTemplate"; "required": false; }; "pointTemplateContext": { "alias": "pointTemplateContext"; "required": false; }; "titleTemplate": { "alias": "titleTemplate"; "required": false; }; "autoSort": { "alias": "autoSort"; "required": false; }; "translation": { "alias": "translation"; "required": false; }; "titleTranslation": { "alias": "titleTranslation"; "required": false; }; "pointFormat": { "alias": "pointFormat"; "required": false; }; }, {}, never, never, false, never>;
}
export {};