06f21f27ed5bda306bb839c0012f67cf0eb69314e35cbd7d6443e350df658c5469ff67dc894d2635d0c4279073efd6137fc56674b0a916882d0d37769b2e9f 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. import * as pathTool from 'zrender/lib/tool/path.js';
  2. import * as matrix from 'zrender/lib/core/matrix.js';
  3. import * as vector from 'zrender/lib/core/vector.js';
  4. import Path from 'zrender/lib/graphic/Path.js';
  5. import Transformable from 'zrender/lib/core/Transformable.js';
  6. import ZRImage from 'zrender/lib/graphic/Image.js';
  7. import Group from 'zrender/lib/graphic/Group.js';
  8. import ZRText from 'zrender/lib/graphic/Text.js';
  9. import Circle from 'zrender/lib/graphic/shape/Circle.js';
  10. import Ellipse from 'zrender/lib/graphic/shape/Ellipse.js';
  11. import Sector from 'zrender/lib/graphic/shape/Sector.js';
  12. import Ring from 'zrender/lib/graphic/shape/Ring.js';
  13. import Polygon from 'zrender/lib/graphic/shape/Polygon.js';
  14. import Polyline from 'zrender/lib/graphic/shape/Polyline.js';
  15. import Rect from 'zrender/lib/graphic/shape/Rect.js';
  16. import Line from 'zrender/lib/graphic/shape/Line.js';
  17. import BezierCurve from 'zrender/lib/graphic/shape/BezierCurve.js';
  18. import Arc from 'zrender/lib/graphic/shape/Arc.js';
  19. import CompoundPath from 'zrender/lib/graphic/CompoundPath.js';
  20. import LinearGradient from 'zrender/lib/graphic/LinearGradient.js';
  21. import RadialGradient from 'zrender/lib/graphic/RadialGradient.js';
  22. import BoundingRect from 'zrender/lib/core/BoundingRect.js';
  23. import OrientedBoundingRect from 'zrender/lib/core/OrientedBoundingRect.js';
  24. import Point from 'zrender/lib/core/Point.js';
  25. import IncrementalDisplayable from 'zrender/lib/graphic/IncrementalDisplayable.js';
  26. import * as subPixelOptimizeUtil from 'zrender/lib/graphic/helper/subPixelOptimize.js';
  27. import { Dictionary } from 'zrender/lib/core/types.js';
  28. import { DisplayableProps } from 'zrender/lib/graphic/Displayable.js';
  29. import Element from 'zrender/lib/Element.js';
  30. import Model from '../model/Model.js';
  31. import { AnimationOptionMixin, ZRRectLike, CommonTooltipOption } from './types.js';
  32. import ComponentModel from '../model/Component.js';
  33. import { updateProps, initProps, removeElement, removeElementWithFadeOut, isElementRemoved } from '../animation/basicTransition.js';
  34. /**
  35. * @deprecated export for compatitable reason
  36. */
  37. export { updateProps, initProps, removeElement, removeElementWithFadeOut, isElementRemoved };
  38. declare type ExtendShapeOpt = Parameters<typeof Path.extend>[0];
  39. declare type ExtendShapeReturn = ReturnType<typeof Path.extend>;
  40. /**
  41. * Extend shape with parameters
  42. */
  43. export declare function extendShape(opts: ExtendShapeOpt): ExtendShapeReturn;
  44. declare const extendPathFromString: typeof pathTool.extendFromString;
  45. declare type SVGPathOption = Parameters<typeof extendPathFromString>[1];
  46. declare type SVGPathCtor = ReturnType<typeof extendPathFromString>;
  47. declare type SVGPath = InstanceType<SVGPathCtor>;
  48. /**
  49. * Extend path
  50. */
  51. export declare function extendPath(pathData: string, opts: SVGPathOption): SVGPathCtor;
  52. /**
  53. * Register a user defined shape.
  54. * The shape class can be fetched by `getShapeClass`
  55. * This method will overwrite the registered shapes, including
  56. * the registered built-in shapes, if using the same `name`.
  57. * The shape can be used in `custom series` and
  58. * `graphic component` by declaring `{type: name}`.
  59. *
  60. * @param name
  61. * @param ShapeClass Can be generated by `extendShape`.
  62. */
  63. export declare function registerShape(name: string, ShapeClass: {
  64. new (): Path;
  65. }): void;
  66. /**
  67. * Find shape class registered by `registerShape`. Usually used in
  68. * fetching user defined shape.
  69. *
  70. * [Caution]:
  71. * (1) This method **MUST NOT be used inside echarts !!!**, unless it is prepared
  72. * to use user registered shapes.
  73. * Because the built-in shape (see `getBuiltInShape`) will be registered by
  74. * `registerShape` by default. That enables users to get both built-in
  75. * shapes as well as the shapes belonging to themsleves. But users can overwrite
  76. * the built-in shapes by using names like 'circle', 'rect' via calling
  77. * `registerShape`. So the echarts inner featrues should not fetch shapes from here
  78. * in case that it is overwritten by users, except that some features, like
  79. * `custom series`, `graphic component`, do it deliberately.
  80. *
  81. * (2) In the features like `custom series`, `graphic component`, the user input
  82. * `{tpye: 'xxx'}` does not only specify shapes but also specify other graphic
  83. * elements like `'group'`, `'text'`, `'image'` or event `'path'`. Those names
  84. * are reserved names, that is, if some user register a shape named `'image'`,
  85. * the shape will not be used. If we intending to add some more reserved names
  86. * in feature, that might bring break changes (disable some existing user shape
  87. * names). But that case probably rearly happen. So we dont make more mechanism
  88. * to resolve this issue here.
  89. *
  90. * @param name
  91. * @return The shape class. If not found, return nothing.
  92. */
  93. export declare function getShapeClass(name: string): {
  94. new (): Path;
  95. };
  96. /**
  97. * Create a path element from path data string
  98. * @param pathData
  99. * @param opts
  100. * @param rect
  101. * @param layout 'center' or 'cover' default to be cover
  102. */
  103. export declare function makePath(pathData: string, opts: SVGPathOption, rect: ZRRectLike, layout?: 'center' | 'cover'): SVGPath;
  104. /**
  105. * Create a image element from image url
  106. * @param imageUrl image url
  107. * @param opts options
  108. * @param rect constrain rect
  109. * @param layout 'center' or 'cover'. Default to be 'cover'
  110. */
  111. export declare function makeImage(imageUrl: string, rect: ZRRectLike, layout?: 'center' | 'cover'): ZRImage;
  112. export declare const mergePath: typeof pathTool.mergePath;
  113. /**
  114. * Resize a path to fit the rect
  115. * @param path
  116. * @param rect
  117. */
  118. export declare function resizePath(path: SVGPath, rect: ZRRectLike): void;
  119. /**
  120. * Sub pixel optimize line for canvas
  121. */
  122. export declare function subPixelOptimizeLine(shape: {
  123. x1: number;
  124. y1: number;
  125. x2: number;
  126. y2: number;
  127. }, lineWidth: number): {
  128. x1: number;
  129. y1: number;
  130. x2: number;
  131. y2: number;
  132. };
  133. /**
  134. * Sub pixel optimize rect for canvas
  135. */
  136. export declare function subPixelOptimizeRect(param: {
  137. shape: {
  138. x: number;
  139. y: number;
  140. width: number;
  141. height: number;
  142. };
  143. style: {
  144. lineWidth: number;
  145. };
  146. }): {
  147. shape: {
  148. x: number;
  149. y: number;
  150. width: number;
  151. height: number;
  152. };
  153. style: {
  154. lineWidth: number;
  155. };
  156. };
  157. /**
  158. * Sub pixel optimize for canvas
  159. *
  160. * @param position Coordinate, such as x, y
  161. * @param lineWidth Should be nonnegative integer.
  162. * @param positiveOrNegative Default false (negative).
  163. * @return Optimized position.
  164. */
  165. export declare const subPixelOptimize: typeof subPixelOptimizeUtil.subPixelOptimize;
  166. /**
  167. * Get transform matrix of target (param target),
  168. * in coordinate of its ancestor (param ancestor)
  169. *
  170. * @param target
  171. * @param [ancestor]
  172. */
  173. export declare function getTransform(target: Transformable, ancestor?: Transformable): matrix.MatrixArray;
  174. /**
  175. * Apply transform to an vertex.
  176. * @param target [x, y]
  177. * @param transform Can be:
  178. * + Transform matrix: like [1, 0, 0, 1, 0, 0]
  179. * + {position, rotation, scale}, the same as `zrender/Transformable`.
  180. * @param invert Whether use invert matrix.
  181. * @return [x, y]
  182. */
  183. export declare function applyTransform(target: vector.VectorArray, transform: Transformable | matrix.MatrixArray, invert?: boolean): number[];
  184. /**
  185. * @param direction 'left' 'right' 'top' 'bottom'
  186. * @param transform Transform matrix: like [1, 0, 0, 1, 0, 0]
  187. * @param invert Whether use invert matrix.
  188. * @return Transformed direction. 'left' 'right' 'top' 'bottom'
  189. */
  190. export declare function transformDirection(direction: 'left' | 'right' | 'top' | 'bottom', transform: matrix.MatrixArray, invert?: boolean): 'left' | 'right' | 'top' | 'bottom';
  191. /**
  192. * Apply group transition animation from g1 to g2.
  193. * If no animatableModel, no animation.
  194. */
  195. export declare function groupTransition(g1: Group, g2: Group, animatableModel: Model<AnimationOptionMixin>): void;
  196. export declare function clipPointsByRect(points: vector.VectorArray[], rect: ZRRectLike): number[][];
  197. /**
  198. * Return a new clipped rect. If rect size are negative, return undefined.
  199. */
  200. export declare function clipRectByRect(targetRect: ZRRectLike, rect: ZRRectLike): ZRRectLike;
  201. export declare function createIcon(iconStr: string, // Support 'image://' or 'path://' or direct svg path.
  202. opt?: Omit<DisplayableProps, 'style'>, rect?: ZRRectLike): SVGPath | ZRImage;
  203. /**
  204. * Return `true` if the given line (line `a`) and the given polygon
  205. * are intersect.
  206. * Note that we do not count colinear as intersect here because no
  207. * requirement for that. We could do that if required in future.
  208. */
  209. export declare function linePolygonIntersect(a1x: number, a1y: number, a2x: number, a2y: number, points: vector.VectorArray[]): boolean;
  210. /**
  211. * Return `true` if the given two lines (line `a` and line `b`)
  212. * are intersect.
  213. * Note that we do not count colinear as intersect here because no
  214. * requirement for that. We could do that if required in future.
  215. */
  216. export declare function lineLineIntersect(a1x: number, a1y: number, a2x: number, a2y: number, b1x: number, b1y: number, b2x: number, b2y: number): boolean;
  217. export declare function setTooltipConfig(opt: {
  218. el: Element;
  219. componentModel: ComponentModel;
  220. itemName: string;
  221. itemTooltipOption?: string | CommonTooltipOption<unknown>;
  222. formatterParamsExtra?: Dictionary<unknown>;
  223. }): void;
  224. export declare function traverseElements(els: Element | Element[] | undefined | null, cb: (el: Element) => boolean | void): void;
  225. export { Group, ZRImage as Image, ZRText as Text, Circle, Ellipse, Sector, Ring, Polygon, Polyline, Rect, Line, BezierCurve, Arc, IncrementalDisplayable, CompoundPath, LinearGradient, RadialGradient, BoundingRect, OrientedBoundingRect, Point, Path };