base.d.ts 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. import { IGroup } from '@antv/g-base';
  2. import GroupComponent from '../abstract/group-component';
  3. import { IList } from '../interfaces';
  4. import { AxisBaseCfg, ListItem, Point } from '../types';
  5. declare abstract class AxisBase<T extends AxisBaseCfg = AxisBaseCfg> extends GroupComponent<T> implements IList {
  6. getDefaultCfg(): {
  7. name: string;
  8. ticks: any[];
  9. line: {};
  10. tickLine: {};
  11. subTickLine: any;
  12. title: any;
  13. /**
  14. * 文本标签的配置项
  15. */
  16. label: {};
  17. /**
  18. * 垂直于坐标轴方向的因子,决定文本、title、tickLine 在坐标轴的哪一侧
  19. */
  20. verticalFactor: number;
  21. verticalLimitLength: any;
  22. overlapOrder: string[];
  23. tickStates: {};
  24. optimize: {};
  25. defaultCfg: {
  26. line: {
  27. style: {
  28. lineWidth: number;
  29. stroke: string;
  30. };
  31. };
  32. tickLine: {
  33. style: {
  34. lineWidth: number;
  35. stroke: string;
  36. };
  37. alignTick: boolean;
  38. length: number;
  39. displayWithLabel: boolean;
  40. };
  41. subTickLine: {
  42. style: {
  43. lineWidth: number;
  44. stroke: string;
  45. };
  46. count: number;
  47. length: number;
  48. };
  49. label: {
  50. autoRotate: boolean;
  51. autoHide: boolean;
  52. autoEllipsis: boolean;
  53. style: {
  54. fontSize: number;
  55. fill: string;
  56. fontFamily: string;
  57. fontWeight: string;
  58. };
  59. offset: number;
  60. offsetX: number;
  61. offsetY: number;
  62. };
  63. title: {
  64. autoRotate: boolean;
  65. spacing: number;
  66. position: string;
  67. style: {
  68. fontSize: number;
  69. fill: string;
  70. textBaseline: string;
  71. fontFamily: string;
  72. textAlign: string;
  73. };
  74. iconStyle: {
  75. fill: string;
  76. stroke: string;
  77. };
  78. description: string;
  79. };
  80. tickStates: {
  81. active: {
  82. labelStyle: {
  83. fontWeight: number;
  84. };
  85. tickLineStyle: {
  86. lineWidth: number;
  87. };
  88. };
  89. inactive: {
  90. labelStyle: {
  91. fill: string;
  92. };
  93. };
  94. };
  95. optimize: {
  96. enable: boolean;
  97. threshold: number;
  98. };
  99. };
  100. theme: {};
  101. container: any;
  102. shapesMap: {};
  103. group: any;
  104. capture: boolean;
  105. isRegister: boolean;
  106. isUpdating: boolean;
  107. isInit: boolean;
  108. id: string;
  109. type: string;
  110. locationType: string;
  111. offsetX: number;
  112. offsetY: number;
  113. animate: boolean;
  114. updateAutoRender: boolean;
  115. animateOption: {
  116. appear: any;
  117. update: {
  118. duration: number;
  119. easing: string;
  120. };
  121. enter: {
  122. duration: number;
  123. easing: string;
  124. };
  125. leave: {
  126. duration: number;
  127. easing: string;
  128. };
  129. };
  130. events: any;
  131. visible: boolean;
  132. };
  133. /**
  134. * 绘制组件
  135. */
  136. renderInner(group: IGroup): void;
  137. isList(): boolean;
  138. /**
  139. * 获取图例项
  140. * @return {ListItem[]} 列表项集合
  141. */
  142. getItems(): ListItem[];
  143. /**
  144. * 设置列表项
  145. * @param {ListItem[]} items 列表项集合
  146. */
  147. setItems(items: ListItem[]): void;
  148. /**
  149. * 更新列表项
  150. * @param {ListItem} item 列表项
  151. * @param {object} cfg 列表项
  152. */
  153. updateItem(item: ListItem, cfg: object): void;
  154. /**
  155. * 清空列表
  156. */
  157. clearItems(): void;
  158. /**
  159. * 设置列表项的状态
  160. * @param {ListItem} item 列表项
  161. * @param {string} state 状态名
  162. * @param {boolean} value 状态值, true, false
  163. */
  164. setItemState(item: ListItem, state: string, value: boolean): void;
  165. /**
  166. * 是否存在指定的状态
  167. * @param {ListItem} item 列表项
  168. * @param {boolean} state 状态名
  169. */
  170. hasState(item: ListItem, state: string): boolean;
  171. getItemStates(item: ListItem): string[];
  172. /**
  173. * 清楚所有列表项的状态
  174. * @param {string} state 状态值
  175. */
  176. clearItemsState(state: string): void;
  177. /**
  178. * 根据状态获取图例项
  179. * @param {string} state [description]
  180. * @return {ListItem[]} [description]
  181. */
  182. getItemsByState(state: string): ListItem[];
  183. /**
  184. * @protected
  185. * 获取坐标轴线的路径,不同的坐标轴不一样
  186. */
  187. protected abstract getLinePath(): any[];
  188. /**
  189. * 获取坐标轴垂直方向的向量
  190. * @param {number} offset 距离点距离
  191. * @param {Point} point 坐标轴上的一点
  192. */
  193. protected abstract getSideVector(offset: number, point: Point): any;
  194. /**
  195. * 获取坐标轴的向量
  196. * @param {Point} point 坐标轴上的点
  197. */
  198. protected abstract getAxisVector(point: Point): [number, number];
  199. protected getSidePoint(point: Point, offset: number): Point;
  200. /**
  201. * 根据 tick.value 获取坐标轴上对应的点
  202. * @param {number} tickValue
  203. * @returns {Point}
  204. */
  205. protected abstract getTickPoint(tickValue: number): Point;
  206. protected getTextAnchor(vector: number[]): string;
  207. protected getTextBaseline(vector: number[]): string;
  208. protected processOverlap(labelGroup: any): void;
  209. private drawLine;
  210. private getTickLineItems;
  211. private getSubTickLineItems;
  212. private getTickLineAttrs;
  213. private drawTick;
  214. private drawTickLines;
  215. private processTicks;
  216. private drawTicks;
  217. /**
  218. * 根据 optimize 配置对 ticks 进行抽样,对抽样过后的 ticks 才进行真实的渲染
  219. */
  220. private optimizeTicks;
  221. private getLabelAttrs;
  222. private drawLabels;
  223. private getTitleAttrs;
  224. private drawTitle;
  225. private drawDescriptionIcon;
  226. private applyTickStates;
  227. private updateTickStates;
  228. }
  229. export default AxisBase;