Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(types) Export cbs and their parameter types #14871

Merged
merged 1 commit into from
May 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/component/tooltip/TooltipModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
import {AxisPointerOption} from '../axisPointer/AxisPointerModel';


type TopLevelFormatterParams = CallbackDataParams | CallbackDataParams[];
export type TopLevelFormatterParams = CallbackDataParams | CallbackDataParams[];

export interface TooltipOption extends CommonTooltipOption<TopLevelFormatterParams>, ComponentOption {
mainType?: 'tooltip'
Expand Down
2 changes: 1 addition & 1 deletion src/export/all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
// This file is for providing types when import whole module.

export * from './core';
export * from './option';
export * from './option';
37 changes: 34 additions & 3 deletions src/export/option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ import type {ParallelAxisOption as ParallelAxisComponentOption} from '../coord/p
import type {ParallelCoordinateSystemOption as ParallelComponentOption} from '../coord/parallel/ParallelModel';
import type {CalendarOption as CalendarComponentOption} from '../coord/calendar/CalendarModel';
import type {ToolboxOption} from '../component/toolbox/ToolboxModel';
import type {TooltipOption as TooltipComponentOption} from '../component/tooltip/TooltipModel';
import type {
TooltipOption as TooltipComponentOption,
TopLevelFormatterParams
} from '../component/tooltip/TooltipModel';
import type {AxisPointerOption as AxisPointerComponentOption} from '../component/axisPointer/AxisPointerModel';
import type {BrushOption as BrushComponentOption} from '../component/brush/BrushModel';
import type {TitleOption as TitleComponentOption} from '../component/title/install';
Expand Down Expand Up @@ -97,7 +100,21 @@ import type {ToolboxSaveAsImageFeatureOption} from '../component/toolbox/feature
import type {ToolboxFeatureOption} from '../component/toolbox/featureManager';


import type { ECBasicOption, SeriesTooltipOption, AriaOption as AriaComponentOption } from '../util/types';
import type {
ECBasicOption,
SeriesTooltipOption,
AriaOption as AriaComponentOption,
TooltipFormatterCallback,
LabelFormatterCallback,
CallbackDataParams,
AnimationDurationCallback,
AnimationDelayCallback,
AnimationDelayCallbackParam,
LabelLayoutOptionCallbackParams,
LabelLayoutOptionCallback,
TooltipPositionCallback,
TooltipPositionCallbackParams
} from '../util/types';

interface ToolboxComponentOption extends ToolboxOption {
feature?: {
Expand Down Expand Up @@ -234,4 +251,18 @@ export interface EChartsOption extends ECBasicOption {

options?: EChartsOption[];
baseOption?: EChartsOption;
}
}

export {
AnimationDurationCallback,
AnimationDelayCallback,
AnimationDelayCallbackParam as AnimationDelayCallbackParams,
LabelFormatterCallback,
CallbackDataParams as DefaultLabelFormatterCallbackParams,
LabelLayoutOptionCallbackParams,
LabelLayoutOptionCallback,
TooltipFormatterCallback as TooltipComponentFormatterCallback,
TopLevelFormatterParams as TooltipComponentFormatterCallbackParams,
TooltipPositionCallback as TooltipComponentPositionCallback,
TooltipPositionCallbackParams as TooltipComponentPositionCallbackParams
};
11 changes: 7 additions & 4 deletions src/util/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1214,7 +1214,7 @@ export interface LabelLayoutOption {
export type LabelLayoutOptionCallback = (params: LabelLayoutOptionCallbackParams) => LabelLayoutOption;


interface TooltipFormatterCallback<T> {
export interface TooltipFormatterCallback<T> {
/**
* For sync callback
* params will be an array on axis trigger.
Expand All @@ -1232,16 +1232,19 @@ type TooltipBuiltinPosition = 'inside' | 'top' | 'left' | 'right' | 'bottom';
type TooltipBoxLayoutOption = Pick<
BoxLayoutOptionMixin, 'top' | 'left' | 'right' | 'bottom'
>;

export type TooltipPositionCallbackParams = CallbackDataParams | CallbackDataParams[];

/**
* Position relative to the hoverred element. Only available when trigger is item.
*/
interface PositionCallback {
export interface TooltipPositionCallback {
(
point: [number, number],
/**
* params will be an array on axis trigger.
*/
params: CallbackDataParams | CallbackDataParams[],
params: TooltipPositionCallbackParams,
/**
* Will be HTMLDivElement when renderMode is html
* Otherwise it's graphic.Text
Expand Down Expand Up @@ -1288,7 +1291,7 @@ export interface CommonTooltipOption<FormatterParams> {
*
* Support to be a callback
*/
position?: (number | string)[] | TooltipBuiltinPosition | PositionCallback | TooltipBoxLayoutOption
position?: (number | string)[] | TooltipBuiltinPosition | TooltipPositionCallback | TooltipBoxLayoutOption

confine?: boolean

Expand Down