zhangjian
2023-06-05 0976d2d0f90cff460cedfdc8bd74e98c2c31a58c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
import Eventful from 'zrender/lib/core/Eventful.js';
import * as graphic from '../../util/graphic.js';
import { Dictionary } from '../../util/types.js';
import { ZRenderType } from 'zrender/lib/zrender.js';
import { ElementEvent } from 'zrender/lib/Element.js';
import * as matrix from 'zrender/lib/core/matrix.js';
import { PathStyleProps } from 'zrender/lib/graphic/Path.js';
/**
 * BrushController not only used in "brush component",
 * but also used in "tooltip DataZoom", and other possible
 * futher brush behavior related scenarios.
 * So `BrushController` should not depends on "brush component model".
 */
export declare type BrushType = 'polygon' | 'rect' | 'lineX' | 'lineY';
/**
 * Only for drawing (after enabledBrush).
 * 'line', 'rect', 'polygon' or false
 * If passing false/null/undefined, disable brush.
 * If passing 'auto', determined by panel.defaultBrushType
 */
export declare type BrushTypeUncertain = BrushType | false | 'auto';
export declare type BrushMode = 'single' | 'multiple';
export declare type BrushDimensionMinMax = number[];
export declare type BrushAreaRange = BrushDimensionMinMax | BrushDimensionMinMax[];
export interface BrushCoverConfig {
    brushType: BrushType;
    id?: string;
    range?: BrushAreaRange;
    panelId?: string;
    brushMode?: BrushMode;
    brushStyle?: Pick<PathStyleProps, BrushStyleKey>;
    transformable?: boolean;
    removeOnClick?: boolean;
    z?: number;
}
/**
 * `BrushAreaCreatorOption` input to brushModel via `setBrushOption`,
 * merge and convert to `BrushCoverCreatorConfig`.
 */
export interface BrushCoverCreatorConfig extends Pick<BrushCoverConfig, 'brushMode' | 'transformable' | 'removeOnClick' | 'brushStyle' | 'z'> {
    brushType: BrushTypeUncertain;
}
declare type BrushStyleKey = 'fill' | 'stroke' | 'lineWidth' | 'opacity' | 'shadowBlur' | 'shadowOffsetX' | 'shadowOffsetY' | 'shadowColor';
declare const BRUSH_PANEL_GLOBAL: true;
export interface BrushPanelConfig {
    panelId: string;
    clipPath(localPoints: number[][], transform: matrix.MatrixArray): number[][];
    isTargetByCursor(e: ElementEvent, localCursorPoint: number[], transform: matrix.MatrixArray): boolean;
    defaultBrushType?: BrushType;
    getLinearBrushOtherExtent?(xyIndex: number): number[];
}
declare type BrushPanelConfigOrGlobal = BrushPanelConfig | typeof BRUSH_PANEL_GLOBAL;
interface BrushCover extends graphic.Group {
    __brushOption: BrushCoverConfig;
}
export interface BrushControllerEvents {
    brush: {
        areas: {
            brushType: BrushType;
            panelId: string;
            range: BrushAreaRange;
        }[];
        isEnd: boolean;
        removeOnClick: boolean;
    };
}
/**
 * params:
 *     areas: Array.<Array>, coord relates to container group,
 *                             If no container specified, to global.
 *     opt {
 *         isEnd: boolean,
 *         removeOnClick: boolean
 *     }
 */
declare class BrushController extends Eventful<{
    [key in keyof BrushControllerEvents]: (params: BrushControllerEvents[key]) => void | undefined;
}> {
    readonly group: graphic.Group;
    /**
     * @internal
     */
    _zr: ZRenderType;
    /**
     * @internal
     */
    _brushType: BrushTypeUncertain;
    /**
     * @internal
     * Only for drawing (after enabledBrush).
     */
    _brushOption: BrushCoverCreatorConfig;
    /**
     * @internal
     * Key: panelId
     */
    _panels: Dictionary<BrushPanelConfig>;
    /**
     * @internal
     */
    _track: number[][];
    /**
     * @internal
     */
    _dragging: boolean;
    /**
     * @internal
     */
    _covers: BrushCover[];
    /**
     * @internal
     */
    _creatingCover: BrushCover;
    /**
     * @internal
     */
    _creatingPanel: BrushPanelConfigOrGlobal;
    private _enableGlobalPan;
    private _mounted;
    /**
     * @internal
     */
    _transform: matrix.MatrixArray;
    private _uid;
    private _handlers;
    constructor(zr: ZRenderType);
    /**
     * If set to `false`, select disabled.
     */
    enableBrush(brushOption: Partial<BrushCoverCreatorConfig> | false): BrushController;
    private _doEnableBrush;
    private _doDisableBrush;
    /**
     * @param panelOpts If not pass, it is global brush.
     */
    setPanels(panelOpts?: BrushPanelConfig[]): BrushController;
    mount(opt?: {
        enableGlobalPan?: boolean;
        x?: number;
        y?: number;
        rotation?: number;
        scaleX?: number;
        scaleY?: number;
    }): BrushController;
    /**
     * Update covers.
     * @param coverConfigList
     *        If coverConfigList is null/undefined, all covers removed.
     */
    updateCovers(coverConfigList: BrushCoverConfig[]): this;
    unmount(): this;
    dispose(): void;
}
export default BrushController;