2ee89142712bc7e64040394bee42f6efcfd09e1a4aeebef34e828396b2f12cef7cd207d9607947b0bc8657f35afbb1554e9eaf89e162964f4899ff7f9ad560 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. import Displayable from 'zrender/lib/graphic/Displayable.js';
  2. import { ImageProps, ImageStyleProps } from 'zrender/lib/graphic/Image.js';
  3. import { PathProps, PathStyleProps } from 'zrender/lib/graphic/Path.js';
  4. import { ZRenderType } from 'zrender/lib/zrender.js';
  5. import { BarGridLayoutOptionForCustomSeries, BarGridLayoutResult } from '../../layout/barGrid.js';
  6. import { AnimationOption, BlurScope, CallbackDataParams, Dictionary, DimensionLoose, ItemStyleOption, LabelOption, OptionDataValue, OrdinalRawValue, ParsedValue, SeriesDataType, SeriesEncodeOptionMixin, SeriesOnCalendarOptionMixin, SeriesOnCartesianOptionMixin, SeriesOnGeoOptionMixin, SeriesOnPolarOptionMixin, SeriesOnSingleOptionMixin, SeriesOption, TextCommonOption, ZRStyleProps } from '../../util/types.js';
  7. import Element from 'zrender/lib/Element.js';
  8. import SeriesData, { DefaultDataVisual } from '../../data/SeriesData.js';
  9. import GlobalModel from '../../model/Global.js';
  10. import { CoordinateSystem } from '../../coord/CoordinateSystem.js';
  11. import SeriesModel from '../../model/Series.js';
  12. import { Arc, BezierCurve, Circle, CompoundPath, Ellipse, Line, Polygon, Polyline, Rect, Ring, Sector } from '../../util/graphic.js';
  13. import { TextProps, TextStyleProps } from 'zrender/lib/graphic/Text.js';
  14. import { GroupProps } from 'zrender/lib/graphic/Group.js';
  15. import { TransitionOptionMixin, TransitionBaseDuringAPI, TransitionDuringAPI } from '../../animation/customGraphicTransition.js';
  16. import { TransformProp } from 'zrender/lib/core/Transformable.js';
  17. import { ElementKeyframeAnimationOption } from '../../animation/customGraphicKeyframeAnimation.js';
  18. export declare type CustomExtraElementInfo = Dictionary<unknown>;
  19. export declare const STYLE_VISUAL_TYPE: {
  20. readonly color: "fill";
  21. readonly borderColor: "stroke";
  22. };
  23. export declare type StyleVisualProps = keyof typeof STYLE_VISUAL_TYPE;
  24. export declare const NON_STYLE_VISUAL_PROPS: {
  25. readonly symbol: 1;
  26. readonly symbolSize: 1;
  27. readonly symbolKeepAspect: 1;
  28. readonly legendIcon: 1;
  29. readonly visualMeta: 1;
  30. readonly liftZ: 1;
  31. readonly decal: 1;
  32. };
  33. export declare type NonStyleVisualProps = keyof typeof NON_STYLE_VISUAL_PROPS;
  34. declare type ShapeMorphingOption = {
  35. /**
  36. * If do shape morphing animation when type is changed.
  37. * Only available on path.
  38. */
  39. morph?: boolean;
  40. };
  41. export interface CustomBaseElementOption extends Partial<Pick<Element, TransformProp | 'silent' | 'ignore' | 'textConfig'>> {
  42. type: string;
  43. id?: string;
  44. name?: string;
  45. info?: CustomExtraElementInfo;
  46. textContent?: CustomTextOption | false;
  47. clipPath?: CustomBaseZRPathOption | false;
  48. extra?: Dictionary<unknown> & TransitionOptionMixin;
  49. during?(params: TransitionBaseDuringAPI): void;
  50. enterAnimation?: AnimationOption;
  51. updateAnimation?: AnimationOption;
  52. leaveAnimation?: AnimationOption;
  53. }
  54. export interface CustomDisplayableOption extends CustomBaseElementOption, Partial<Pick<Displayable, 'zlevel' | 'z' | 'z2' | 'invisible'>> {
  55. style?: ZRStyleProps;
  56. during?(params: TransitionDuringAPI): void;
  57. /**
  58. * @deprecated
  59. */
  60. styleEmphasis?: ZRStyleProps | false;
  61. emphasis?: CustomDisplayableOptionOnState;
  62. blur?: CustomDisplayableOptionOnState;
  63. select?: CustomDisplayableOptionOnState;
  64. }
  65. export interface CustomDisplayableOptionOnState extends Partial<Pick<Displayable, TransformProp | 'textConfig' | 'z2'>> {
  66. style?: ZRStyleProps | false;
  67. }
  68. export interface CustomGroupOption extends CustomBaseElementOption, TransitionOptionMixin<GroupProps> {
  69. type: 'group';
  70. width?: number;
  71. height?: number;
  72. diffChildrenByName?: boolean;
  73. children: CustomElementOption[];
  74. $mergeChildren?: false | 'byName' | 'byIndex';
  75. keyframeAnimation?: ElementKeyframeAnimationOption<GroupProps> | ElementKeyframeAnimationOption<GroupProps>[];
  76. }
  77. export interface CustomBaseZRPathOption<T extends PathProps['shape'] = PathProps['shape']> extends CustomDisplayableOption, ShapeMorphingOption, TransitionOptionMixin<PathProps & {
  78. shape: T;
  79. }> {
  80. autoBatch?: boolean;
  81. shape?: T & TransitionOptionMixin<T>;
  82. style?: PathProps['style'] & TransitionOptionMixin<PathStyleProps>;
  83. during?(params: TransitionDuringAPI<PathStyleProps, T>): void;
  84. keyframeAnimation?: ElementKeyframeAnimationOption<PathProps & {
  85. shape: T;
  86. }> | ElementKeyframeAnimationOption<PathProps & {
  87. shape: T;
  88. }>[];
  89. }
  90. interface BuiltinShapes {
  91. circle: Partial<Circle['shape']>;
  92. rect: Partial<Rect['shape']>;
  93. sector: Partial<Sector['shape']>;
  94. polygon: Partial<Polygon['shape']>;
  95. polyline: Partial<Polyline['shape']>;
  96. line: Partial<Line['shape']>;
  97. arc: Partial<Arc['shape']>;
  98. bezierCurve: Partial<BezierCurve['shape']>;
  99. ring: Partial<Ring['shape']>;
  100. ellipse: Partial<Ellipse['shape']>;
  101. compoundPath: Partial<CompoundPath['shape']>;
  102. }
  103. interface CustomSVGPathShapeOption {
  104. pathData?: string;
  105. d?: string;
  106. layout?: 'center' | 'cover';
  107. x?: number;
  108. y?: number;
  109. width?: number;
  110. height?: number;
  111. }
  112. export interface CustomSVGPathOption extends CustomBaseZRPathOption<CustomSVGPathShapeOption> {
  113. type: 'path';
  114. }
  115. interface CustomBuitinPathOption<T extends keyof BuiltinShapes> extends CustomBaseZRPathOption<BuiltinShapes[T]> {
  116. type: T;
  117. }
  118. declare type CreateCustomBuitinPathOption<T extends keyof BuiltinShapes> = T extends any ? CustomBuitinPathOption<T> : never;
  119. export declare type CustomPathOption = CreateCustomBuitinPathOption<keyof BuiltinShapes> | CustomSVGPathOption;
  120. export interface CustomImageOptionOnState extends CustomDisplayableOptionOnState {
  121. style?: ImageStyleProps;
  122. }
  123. export interface CustomImageOption extends CustomDisplayableOption, TransitionOptionMixin<ImageProps> {
  124. type: 'image';
  125. style?: ImageStyleProps & TransitionOptionMixin<ImageStyleProps>;
  126. emphasis?: CustomImageOptionOnState;
  127. blur?: CustomImageOptionOnState;
  128. select?: CustomImageOptionOnState;
  129. keyframeAnimation?: ElementKeyframeAnimationOption<ImageProps> | ElementKeyframeAnimationOption<ImageProps>[];
  130. }
  131. export interface CustomTextOptionOnState extends CustomDisplayableOptionOnState {
  132. style?: TextStyleProps;
  133. }
  134. export interface CustomTextOption extends CustomDisplayableOption, TransitionOptionMixin<TextProps> {
  135. type: 'text';
  136. style?: TextStyleProps & TransitionOptionMixin<TextStyleProps>;
  137. emphasis?: CustomTextOptionOnState;
  138. blur?: CustomTextOptionOnState;
  139. select?: CustomTextOptionOnState;
  140. keyframeAnimation?: ElementKeyframeAnimationOption<TextProps> | ElementKeyframeAnimationOption<TextProps>[];
  141. }
  142. export declare type CustomElementOption = CustomPathOption | CustomImageOption | CustomTextOption | CustomGroupOption;
  143. export declare type CustomRootElementOption = CustomElementOption & {
  144. focus?: 'none' | 'self' | 'series' | ArrayLike<number>;
  145. blurScope?: BlurScope;
  146. emphasisDisabled?: boolean;
  147. };
  148. export declare type CustomElementOptionOnState = CustomDisplayableOptionOnState | CustomImageOptionOnState;
  149. export interface CustomSeriesRenderItemAPI extends CustomSeriesRenderItemCoordinateSystemAPI {
  150. getWidth(): number;
  151. getHeight(): number;
  152. getZr(): ZRenderType;
  153. getDevicePixelRatio(): number;
  154. value(dim: DimensionLoose, dataIndexInside?: number): ParsedValue;
  155. ordinalRawValue(dim: DimensionLoose, dataIndexInside?: number): ParsedValue | OrdinalRawValue;
  156. /**
  157. * @deprecated
  158. */
  159. style(userProps?: ZRStyleProps, dataIndexInside?: number): ZRStyleProps;
  160. /**
  161. * @deprecated
  162. */
  163. styleEmphasis(userProps?: ZRStyleProps, dataIndexInside?: number): ZRStyleProps;
  164. visual<VT extends NonStyleVisualProps | StyleVisualProps>(visualType: VT, dataIndexInside?: number): VT extends NonStyleVisualProps ? DefaultDataVisual[VT] : VT extends StyleVisualProps ? PathStyleProps[typeof STYLE_VISUAL_TYPE[VT]] : void;
  165. barLayout(opt: BarGridLayoutOptionForCustomSeries): BarGridLayoutResult;
  166. currentSeriesIndices(): number[];
  167. font(opt: Pick<TextCommonOption, 'fontStyle' | 'fontWeight' | 'fontSize' | 'fontFamily'>): string;
  168. }
  169. export interface CustomSeriesRenderItemParamsCoordSys {
  170. type: string;
  171. }
  172. export interface CustomSeriesRenderItemCoordinateSystemAPI {
  173. coord(data: OptionDataValue | OptionDataValue[], clamp?: boolean): number[];
  174. size?(dataSize: OptionDataValue | OptionDataValue[], dataItem?: OptionDataValue | OptionDataValue[]): number | number[];
  175. }
  176. export declare type WrapEncodeDefRet = Dictionary<number[]>;
  177. export interface CustomSeriesRenderItemParams {
  178. context: Dictionary<unknown>;
  179. dataIndex: number;
  180. seriesId: string;
  181. seriesName: string;
  182. seriesIndex: number;
  183. coordSys: CustomSeriesRenderItemParamsCoordSys;
  184. encode: WrapEncodeDefRet;
  185. dataIndexInside: number;
  186. dataInsideLength: number;
  187. actionType?: string;
  188. }
  189. export declare type CustomSeriesRenderItemReturn = CustomRootElementOption | undefined | null;
  190. export declare type CustomSeriesRenderItem = (params: CustomSeriesRenderItemParams, api: CustomSeriesRenderItemAPI) => CustomSeriesRenderItemReturn;
  191. export interface CustomSeriesOption extends SeriesOption<unknown>, // don't support StateOption in custom series.
  192. SeriesEncodeOptionMixin, SeriesOnCartesianOptionMixin, SeriesOnPolarOptionMixin, SeriesOnSingleOptionMixin, SeriesOnGeoOptionMixin, SeriesOnCalendarOptionMixin {
  193. type?: 'custom';
  194. coordinateSystem?: string | 'none';
  195. renderItem?: CustomSeriesRenderItem;
  196. /**
  197. * @deprecated
  198. */
  199. itemStyle?: ItemStyleOption;
  200. /**
  201. * @deprecated
  202. */
  203. label?: LabelOption;
  204. /**
  205. * @deprecated
  206. */
  207. emphasis?: {
  208. /**
  209. * @deprecated
  210. */
  211. itemStyle?: ItemStyleOption;
  212. /**
  213. * @deprecated
  214. */
  215. label?: LabelOption;
  216. };
  217. clip?: boolean;
  218. }
  219. export declare const customInnerStore: (hostObj: Element<import("zrender/lib/Element").ElementProps>) => {
  220. info: CustomExtraElementInfo;
  221. customPathData: string;
  222. customGraphicType: string;
  223. customImagePath: CustomImageOption['style']['image'];
  224. txConZ2Set: number;
  225. option: CustomElementOption;
  226. };
  227. export default class CustomSeriesModel extends SeriesModel<CustomSeriesOption> {
  228. static type: string;
  229. readonly type: string;
  230. static dependencies: string[];
  231. currentZLevel: number;
  232. currentZ: number;
  233. static defaultOption: CustomSeriesOption;
  234. optionUpdated(): void;
  235. getInitialData(option: CustomSeriesOption, ecModel: GlobalModel): SeriesData;
  236. getDataParams(dataIndex: number, dataType?: SeriesDataType, el?: Element): CallbackDataParams & {
  237. info: CustomExtraElementInfo;
  238. };
  239. }
  240. export declare type PrepareCustomInfo = (coordSys: CoordinateSystem) => {
  241. coordSys: CustomSeriesRenderItemParamsCoordSys;
  242. api: CustomSeriesRenderItemCoordinateSystemAPI;
  243. };
  244. export {};