360cf71d5808c318cacc92c050e6fa8a224c494e6318d9bfb17500f6fab1a065ef3b947cce0f0b161b27b50b2b9f62651cc7e22b05bb465e26f0f9c895ce6c 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. import GlobalModel from '../model/Global.js';
  2. import { ParsedModelFinder } from '../util/model.js';
  3. import ExtensionAPI from '../core/ExtensionAPI.js';
  4. import { DimensionDefinitionLoose, ScaleDataValue, DimensionName } from '../util/types.js';
  5. import Axis from './Axis.js';
  6. import { BoundingRect } from '../util/graphic.js';
  7. import { MatrixArray } from 'zrender/lib/core/matrix.js';
  8. import ComponentModel from '../model/Component.js';
  9. import { RectLike } from 'zrender/lib/core/BoundingRect.js';
  10. import type { PrepareCustomInfo } from '../chart/custom/CustomSeries.js';
  11. export interface CoordinateSystemCreator {
  12. create: (ecModel: GlobalModel, api: ExtensionAPI) => CoordinateSystemMaster[];
  13. dimensions?: DimensionName[];
  14. getDimensionsInfo?: () => DimensionDefinitionLoose[];
  15. }
  16. /**
  17. * The instance get from `CoordinateSystemManger` is `CoordinateSystemMaster`.
  18. */
  19. export interface CoordinateSystemMaster {
  20. dimensions: DimensionName[];
  21. model?: ComponentModel;
  22. update?: (ecModel: GlobalModel, api: ExtensionAPI) => void;
  23. convertToPixel?(ecModel: GlobalModel, finder: ParsedModelFinder, value: ScaleDataValue | ScaleDataValue[]): number | number[];
  24. convertFromPixel?(ecModel: GlobalModel, finder: ParsedModelFinder, pixelValue: number | number[]): number | number[];
  25. containPoint(point: number[]): boolean;
  26. getAxes?: () => Axis[];
  27. axisPointerEnabled?: boolean;
  28. getTooltipAxes?: (dim: DimensionName | 'auto') => {
  29. baseAxes: Axis[];
  30. otherAxes: Axis[];
  31. };
  32. /**
  33. * Get layout rect or coordinate system
  34. */
  35. getRect?: () => RectLike;
  36. }
  37. /**
  38. * For example: cartesian is CoordinateSystem.
  39. * series.coordinateSystem is CoordinateSystem.
  40. */
  41. export interface CoordinateSystem {
  42. type: string;
  43. /**
  44. * Master of coordinate system. For example:
  45. * Grid is master of cartesian.
  46. */
  47. master?: CoordinateSystemMaster;
  48. dimensions: DimensionName[];
  49. model?: ComponentModel;
  50. /**
  51. * @param data
  52. * @param reserved Defined by the coordinate system itself
  53. * @param out
  54. * @return {Array.<number>} point Point in global pixel coordinate system.
  55. */
  56. dataToPoint(data: ScaleDataValue | ScaleDataValue[], reserved?: any, out?: number[]): number[];
  57. /**
  58. * Some coord sys (like Parallel) might do not have `pointToData`,
  59. * or the meaning of this kind of features is not clear yet.
  60. * @param point point Point in global pixel coordinate system.
  61. * @param clamp Clamp range
  62. * @return data
  63. */
  64. pointToData?(point: number[], clamp?: boolean): number | number[];
  65. containPoint(point: number[]): boolean;
  66. getAxis?: (dim?: DimensionName) => Axis;
  67. getBaseAxis?: () => Axis;
  68. getOtherAxis?: (baseAxis: Axis) => Axis;
  69. clampData?: (data: ScaleDataValue[], out?: number[]) => number[];
  70. getRoamTransform?: () => MatrixArray;
  71. getArea?: () => CoordinateSystemClipArea;
  72. getBoundingRect?: () => BoundingRect;
  73. getAxesByScale?: (scaleType: string) => Axis[];
  74. prepareCustoms?: PrepareCustomInfo;
  75. }
  76. /**
  77. * Like GridModel, PolarModel, ...
  78. */
  79. export interface CoordinateSystemHostModel extends ComponentModel {
  80. coordinateSystem?: CoordinateSystemMaster;
  81. }
  82. /**
  83. * Clip area will be returned by getArea of CoordinateSystem.
  84. * It is used to clip the graphic elements with the contain methods.
  85. */
  86. export interface CoordinateSystemClipArea {
  87. contain(x: number, y: number): boolean;
  88. }
  89. export declare function isCoordinateSystemType<T extends CoordinateSystem, S = T['type']>(coordSys: CoordinateSystem, type: S): coordSys is T;