0584bc0f1a4206aa72ad0f07c5a2750e8d856fb5eb0608e14363108ecd9780282ff9c32e72f2efbbc4c9baf0f5109a98fd76a0378a826ca6000f4ccef9df88 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. import { createAxisLabels, calculateCategoryInterval } from './axisTickLabelBuilder.js';
  2. import Scale from '../scale/Scale.js';
  3. import { DimensionName, ScaleDataValue, ScaleTick } from '../util/types.js';
  4. import Model from '../model/Model.js';
  5. import { AxisBaseOption, CategoryAxisBaseOption, OptionAxisType } from './axisCommonTypes.js';
  6. import { AxisBaseModel } from './AxisBaseModel.js';
  7. interface TickCoord {
  8. coord: number;
  9. tickValue?: ScaleTick['value'];
  10. }
  11. /**
  12. * Base class of Axis.
  13. */
  14. declare class Axis {
  15. /**
  16. * Axis type
  17. * - 'category'
  18. * - 'value'
  19. * - 'time'
  20. * - 'log'
  21. */
  22. type: OptionAxisType;
  23. readonly dim: DimensionName;
  24. scale: Scale;
  25. private _extent;
  26. model: AxisBaseModel;
  27. onBand: CategoryAxisBaseOption['boundaryGap'];
  28. inverse: AxisBaseOption['inverse'];
  29. constructor(dim: DimensionName, scale: Scale, extent: [number, number]);
  30. /**
  31. * If axis extent contain given coord
  32. */
  33. contain(coord: number): boolean;
  34. /**
  35. * If axis extent contain given data
  36. */
  37. containData(data: ScaleDataValue): boolean;
  38. /**
  39. * Get coord extent.
  40. */
  41. getExtent(): [number, number];
  42. /**
  43. * Get precision used for formatting
  44. */
  45. getPixelPrecision(dataExtent?: [number, number]): number;
  46. /**
  47. * Set coord extent
  48. */
  49. setExtent(start: number, end: number): void;
  50. /**
  51. * Convert data to coord. Data is the rank if it has an ordinal scale
  52. */
  53. dataToCoord(data: ScaleDataValue, clamp?: boolean): number;
  54. /**
  55. * Convert coord to data. Data is the rank if it has an ordinal scale
  56. */
  57. coordToData(coord: number, clamp?: boolean): number;
  58. /**
  59. * Convert pixel point to data in axis
  60. */
  61. pointToData(point: number[], clamp?: boolean): number;
  62. /**
  63. * Different from `zrUtil.map(axis.getTicks(), axis.dataToCoord, axis)`,
  64. * `axis.getTicksCoords` considers `onBand`, which is used by
  65. * `boundaryGap:true` of category axis and splitLine and splitArea.
  66. * @param opt.tickModel default: axis.model.getModel('axisTick')
  67. * @param opt.clamp If `true`, the first and the last
  68. * tick must be at the axis end points. Otherwise, clip ticks
  69. * that outside the axis extent.
  70. */
  71. getTicksCoords(opt?: {
  72. tickModel?: Model;
  73. clamp?: boolean;
  74. }): TickCoord[];
  75. getMinorTicksCoords(): TickCoord[][];
  76. getViewLabels(): ReturnType<typeof createAxisLabels>['labels'];
  77. getLabelModel(): Model<AxisBaseOption['axisLabel']>;
  78. /**
  79. * Notice here we only get the default tick model. For splitLine
  80. * or splitArea, we should pass the splitLineModel or splitAreaModel
  81. * manually when calling `getTicksCoords`.
  82. * In GL, this method may be overrided to:
  83. * `axisModel.getModel('axisTick', grid3DModel.getModel('axisTick'));`
  84. */
  85. getTickModel(): Model;
  86. /**
  87. * Get width of band
  88. */
  89. getBandWidth(): number;
  90. /**
  91. * Get axis rotate, by degree.
  92. */
  93. getRotate: () => number;
  94. /**
  95. * Only be called in category axis.
  96. * Can be overrided, consider other axes like in 3D.
  97. * @return Auto interval for cateogry axis tick and label
  98. */
  99. calculateCategoryInterval(): ReturnType<typeof calculateCategoryInterval>;
  100. }
  101. export default Axis;