13c2a2120bc09aa7ec4a4cef579b96ac702436955c622ccc4866326c8a12f44cdd63885aa298e816929c534e418c553d509656f3b41be8e3c529e8bd4de615 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import * as graphic from '../../util/graphic.js';
  2. import { AxisBaseModel } from '../../coord/AxisBaseModel.js';
  3. declare type AxisIndexKey = 'xAxisIndex' | 'yAxisIndex' | 'radiusAxisIndex' | 'angleAxisIndex' | 'singleAxisIndex';
  4. declare type AxisEventData = {
  5. componentType: string;
  6. componentIndex: number;
  7. targetType: 'axisName' | 'axisLabel';
  8. name?: string;
  9. value?: string | number;
  10. dataIndex?: number;
  11. tickIndex?: number;
  12. } & {
  13. [key in AxisIndexKey]?: number;
  14. };
  15. export interface AxisBuilderCfg {
  16. position?: number[];
  17. rotation?: number;
  18. /**
  19. * Used when nameLocation is 'middle' or 'center'.
  20. * 1 | -1
  21. */
  22. nameDirection?: number;
  23. tickDirection?: number;
  24. labelDirection?: number;
  25. /**
  26. * Usefull when onZero.
  27. */
  28. labelOffset?: number;
  29. /**
  30. * default get from axisModel.
  31. */
  32. axisLabelShow?: boolean;
  33. /**
  34. * default get from axisModel.
  35. */
  36. axisName?: string;
  37. axisNameAvailableWidth?: number;
  38. /**
  39. * by degree, default get from axisModel.
  40. */
  41. labelRotate?: number;
  42. strokeContainThreshold?: number;
  43. nameTruncateMaxWidth?: number;
  44. silent?: boolean;
  45. handleAutoShown?(elementType: 'axisLine' | 'axisTick'): boolean;
  46. }
  47. /**
  48. * A final axis is translated and rotated from a "standard axis".
  49. * So opt.position and opt.rotation is required.
  50. *
  51. * A standard axis is and axis from [0, 0] to [0, axisExtent[1]],
  52. * for example: (0, 0) ------------> (0, 50)
  53. *
  54. * nameDirection or tickDirection or labelDirection is 1 means tick
  55. * or label is below the standard axis, whereas is -1 means above
  56. * the standard axis. labelOffset means offset between label and axis,
  57. * which is useful when 'onZero', where axisLabel is in the grid and
  58. * label in outside grid.
  59. *
  60. * Tips: like always,
  61. * positive rotation represents anticlockwise, and negative rotation
  62. * represents clockwise.
  63. * The direction of position coordinate is the same as the direction
  64. * of screen coordinate.
  65. *
  66. * Do not need to consider axis 'inverse', which is auto processed by
  67. * axis extent.
  68. */
  69. declare class AxisBuilder {
  70. axisModel: AxisBaseModel;
  71. opt: AxisBuilderCfg;
  72. readonly group: graphic.Group;
  73. private _transformGroup;
  74. constructor(axisModel: AxisBaseModel, opt?: AxisBuilderCfg);
  75. hasBuilder(name: keyof typeof builders): boolean;
  76. add(name: keyof typeof builders): void;
  77. getGroup(): graphic.Group;
  78. static innerTextLayout(axisRotation: number, textRotation: number, direction: number): {
  79. rotation: number;
  80. textAlign: import("zrender/lib/core/types").TextAlign;
  81. textVerticalAlign: import("zrender/lib/core/types").TextVerticalAlign;
  82. };
  83. static makeAxisEventDataBase(axisModel: AxisBaseModel): AxisEventData;
  84. static isLabelSilent(axisModel: AxisBaseModel): boolean;
  85. }
  86. interface AxisElementsBuilder {
  87. (opt: AxisBuilderCfg, axisModel: AxisBaseModel, group: graphic.Group, transformGroup: graphic.Group): void;
  88. }
  89. declare const builders: Record<'axisLine' | 'axisTickLabel' | 'axisName', AxisElementsBuilder>;
  90. export default AxisBuilder;