utils.d.ts 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import { Coordinate } from '@antv/coord';
  2. import { Path as D3Path } from 'd3-path';
  3. import { G2Theme, Primitive, Vector2 } from '../runtime';
  4. import { Selection } from '../utils/selection';
  5. export declare function applyStyle(selection: Selection, style: Record<string, Primitive>): void;
  6. /**
  7. * Draw polygon path with points.
  8. * @param path
  9. * @param points
  10. */
  11. export declare function appendPolygon(path: D3Path, points: Vector2[]): D3Path;
  12. export type ArrowOptions = {
  13. /**
  14. * Whether show arrow of line.
  15. */
  16. arrow?: boolean;
  17. /**
  18. * Arrow size, can be a px number, or a percentage string. Default: '40%'
  19. */
  20. arrowSize?: number | string;
  21. };
  22. /**
  23. * Draw arrow between `from` and `to`.
  24. * @param from
  25. * @param to
  26. * @returns
  27. */
  28. export declare function arrowPoints(from: Vector2, to: Vector2, options: ArrowOptions): [Vector2, Vector2];
  29. /**
  30. * Draw arc by from -> to, with center and radius.
  31. * @param path
  32. * @param from
  33. * @param to
  34. * @param center
  35. * @param radius
  36. */
  37. export declare function appendArc(path: D3Path, from: Vector2, to: Vector2, center: Vector2, radius: number): D3Path;
  38. /**
  39. * @todo Fix wrong key point.
  40. */
  41. export declare function computeGradient(C: string[], X: number[], Y: number[], from?: string | boolean, mode?: 'between' | 'start' | 'end'): string;
  42. export declare function reorder(points: Vector2[]): Vector2[];
  43. export declare function getArcObject(coordinate: Coordinate, points: Vector2[], Y: [number, number]): {
  44. startAngle: number;
  45. endAngle: number;
  46. innerRadius: number;
  47. outerRadius: number;
  48. };
  49. /**
  50. * Get the mark.shape's style object.
  51. * @returns
  52. */
  53. export declare function getShapeTheme(theme: G2Theme, mark: string, shape: string, defaultShape: string): any;
  54. /**
  55. * Pick connectStyle from style.
  56. * @param style
  57. */
  58. export declare function getConnectStyle(style: Record<string, any>): Record<string, any>;
  59. export declare function toOpacityKey(options: any): string;
  60. export declare function getTransform(coordinate: any, value: any): string;
  61. export declare function getOrigin(points: Vector2[]): number[];