base.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var tslib_1 = require("tslib");
  4. var matrix_util_1 = require("@antv/matrix-util");
  5. var util_1 = require("@antv/util");
  6. var group_component_1 = require("../abstract/group-component");
  7. var matrix_1 = require("../util/matrix");
  8. var state_1 = require("../util/state");
  9. var theme_1 = require("../util/theme");
  10. var AxisBase = /** @class */ (function (_super) {
  11. tslib_1.__extends(AxisBase, _super);
  12. function AxisBase() {
  13. return _super !== null && _super.apply(this, arguments) || this;
  14. }
  15. AxisBase.prototype.getDefaultCfg = function () {
  16. var cfg = _super.prototype.getDefaultCfg.call(this);
  17. return tslib_1.__assign(tslib_1.__assign({}, cfg), { name: 'axis', ticks: [], line: {}, tickLine: {}, subTickLine: null, title: null,
  18. /**
  19. * 文本标签的配置项
  20. */
  21. label: {},
  22. /**
  23. * 垂直于坐标轴方向的因子,决定文本、title、tickLine 在坐标轴的哪一侧
  24. */
  25. verticalFactor: 1,
  26. // 垂直方向限制的长度,对文本自适应有很大影响
  27. verticalLimitLength: null, overlapOrder: ['autoRotate', 'autoEllipsis', 'autoHide'], tickStates: {}, optimize: {}, defaultCfg: {
  28. line: {
  29. // @type {Attrs} 坐标轴线的图形属性,如果设置成null,则不显示轴线
  30. style: {
  31. lineWidth: 1,
  32. stroke: theme_1.default.lineColor,
  33. },
  34. },
  35. tickLine: {
  36. // @type {Attrs} 标注坐标线的图形属性
  37. style: {
  38. lineWidth: 1,
  39. stroke: theme_1.default.lineColor,
  40. },
  41. alignTick: true,
  42. length: 5,
  43. displayWithLabel: true,
  44. },
  45. subTickLine: {
  46. // @type {Attrs} 标注坐标线的图形属性
  47. style: {
  48. lineWidth: 1,
  49. stroke: theme_1.default.lineColor,
  50. },
  51. count: 4,
  52. length: 2,
  53. },
  54. label: {
  55. autoRotate: true,
  56. autoHide: false,
  57. autoEllipsis: false,
  58. style: {
  59. fontSize: 12,
  60. fill: theme_1.default.textColor,
  61. fontFamily: theme_1.default.fontFamily,
  62. fontWeight: 'normal',
  63. },
  64. offset: 10,
  65. offsetX: 0,
  66. offsetY: 0,
  67. },
  68. title: {
  69. autoRotate: true,
  70. spacing: 5,
  71. position: 'center',
  72. style: {
  73. fontSize: 12,
  74. fill: theme_1.default.textColor,
  75. textBaseline: 'middle',
  76. fontFamily: theme_1.default.fontFamily,
  77. textAlign: 'center',
  78. },
  79. iconStyle: {
  80. fill: theme_1.default.descriptionIconFill,
  81. stroke: theme_1.default.descriptionIconStroke,
  82. },
  83. description: ''
  84. },
  85. tickStates: {
  86. active: {
  87. labelStyle: {
  88. fontWeight: 500,
  89. },
  90. tickLineStyle: {
  91. lineWidth: 2,
  92. },
  93. },
  94. inactive: {
  95. labelStyle: {
  96. fill: theme_1.default.uncheckedColor,
  97. },
  98. },
  99. },
  100. // 针对大数据量进行优化配置
  101. optimize: {
  102. enable: true,
  103. threshold: 400,
  104. },
  105. }, theme: {} });
  106. };
  107. /**
  108. * 绘制组件
  109. */
  110. AxisBase.prototype.renderInner = function (group) {
  111. if (this.get('line')) {
  112. this.drawLine(group);
  113. }
  114. // drawTicks 包括 drawLabels 和 drawTickLines
  115. this.drawTicks(group);
  116. if (this.get('title')) {
  117. this.drawTitle(group);
  118. }
  119. };
  120. // 实现 IList 接口
  121. AxisBase.prototype.isList = function () {
  122. return true;
  123. };
  124. /**
  125. * 获取图例项
  126. * @return {ListItem[]} 列表项集合
  127. */
  128. AxisBase.prototype.getItems = function () {
  129. return this.get('ticks');
  130. };
  131. /**
  132. * 设置列表项
  133. * @param {ListItem[]} items 列表项集合
  134. */
  135. AxisBase.prototype.setItems = function (items) {
  136. this.update({
  137. ticks: items,
  138. });
  139. };
  140. /**
  141. * 更新列表项
  142. * @param {ListItem} item 列表项
  143. * @param {object} cfg 列表项
  144. */
  145. AxisBase.prototype.updateItem = function (item, cfg) {
  146. util_1.mix(item, cfg);
  147. this.clear(); // 由于单个图例项变化,会引起全局变化,所以全部更新
  148. this.render();
  149. };
  150. /**
  151. * 清空列表
  152. */
  153. AxisBase.prototype.clearItems = function () {
  154. var itemGroup = this.getElementByLocalId('label-group');
  155. itemGroup && itemGroup.clear();
  156. };
  157. /**
  158. * 设置列表项的状态
  159. * @param {ListItem} item 列表项
  160. * @param {string} state 状态名
  161. * @param {boolean} value 状态值, true, false
  162. */
  163. AxisBase.prototype.setItemState = function (item, state, value) {
  164. item[state] = value;
  165. this.updateTickStates(item); // 应用状态样式
  166. };
  167. /**
  168. * 是否存在指定的状态
  169. * @param {ListItem} item 列表项
  170. * @param {boolean} state 状态名
  171. */
  172. AxisBase.prototype.hasState = function (item, state) {
  173. return !!item[state];
  174. };
  175. AxisBase.prototype.getItemStates = function (item) {
  176. var tickStates = this.get('tickStates');
  177. var rst = [];
  178. util_1.each(tickStates, function (v, k) {
  179. if (item[k]) {
  180. // item.selected
  181. rst.push(k);
  182. }
  183. });
  184. return rst;
  185. };
  186. /**
  187. * 清楚所有列表项的状态
  188. * @param {string} state 状态值
  189. */
  190. AxisBase.prototype.clearItemsState = function (state) {
  191. var _this = this;
  192. var items = this.getItemsByState(state);
  193. util_1.each(items, function (item) {
  194. _this.setItemState(item, state, false);
  195. });
  196. };
  197. /**
  198. * 根据状态获取图例项
  199. * @param {string} state [description]
  200. * @return {ListItem[]} [description]
  201. */
  202. AxisBase.prototype.getItemsByState = function (state) {
  203. var _this = this;
  204. var items = this.getItems();
  205. return util_1.filter(items, function (item) {
  206. return _this.hasState(item, state);
  207. });
  208. };
  209. AxisBase.prototype.getSidePoint = function (point, offset) {
  210. var self = this;
  211. var vector = self.getSideVector(offset, point);
  212. return {
  213. x: point.x + vector[0],
  214. y: point.y + vector[1],
  215. };
  216. };
  217. AxisBase.prototype.getTextAnchor = function (vector) {
  218. var align;
  219. if (util_1.isNumberEqual(vector[0], 0)) {
  220. align = 'center';
  221. }
  222. else if (vector[0] > 0) {
  223. align = 'start';
  224. }
  225. else if (vector[0] < 0) {
  226. align = 'end';
  227. }
  228. return align;
  229. };
  230. AxisBase.prototype.getTextBaseline = function (vector) {
  231. var base;
  232. if (util_1.isNumberEqual(vector[1], 0)) {
  233. base = 'middle';
  234. }
  235. else if (vector[1] > 0) {
  236. base = 'top';
  237. }
  238. else if (vector[1] < 0) {
  239. base = 'bottom';
  240. }
  241. return base;
  242. };
  243. AxisBase.prototype.processOverlap = function (labelGroup) { };
  244. // 绘制坐标轴线
  245. AxisBase.prototype.drawLine = function (group) {
  246. var path = this.getLinePath();
  247. var line = this.get('line'); // line 的判空在调用 drawLine 之前,不在这里判定
  248. this.addShape(group, {
  249. type: 'path',
  250. id: this.getElementId('line'),
  251. name: 'axis-line',
  252. attrs: util_1.mix({
  253. path: path,
  254. }, line.style),
  255. });
  256. };
  257. AxisBase.prototype.getTickLineItems = function (ticks) {
  258. var _this = this;
  259. var tickLineItems = [];
  260. var tickLine = this.get('tickLine');
  261. var alignTick = tickLine.alignTick;
  262. var tickLineLength = tickLine.length;
  263. var tickSegment = 1;
  264. var tickCount = ticks.length;
  265. if (tickCount >= 2) {
  266. tickSegment = ticks[1].value - ticks[0].value;
  267. }
  268. util_1.each(ticks, function (tick) {
  269. var point = tick.point;
  270. if (!alignTick) {
  271. // tickLine 不同 tick 对齐时需要调整 point
  272. point = _this.getTickPoint(tick.value - tickSegment / 2);
  273. }
  274. var endPoint = _this.getSidePoint(point, tickLineLength);
  275. tickLineItems.push({
  276. startPoint: point,
  277. tickValue: tick.value,
  278. endPoint: endPoint,
  279. tickId: tick.id,
  280. id: "tickline-" + tick.id,
  281. });
  282. });
  283. // 如果 tickLine 不居中对齐,则需要在最后面补充一个 tickLine
  284. // if (!alignTick && tickCount > 0) {
  285. // const tick = ticks[tickCount - 1];
  286. // const point = this.getTickPoint(tick.value + tickSegment / 2);
  287. // }
  288. return tickLineItems;
  289. };
  290. AxisBase.prototype.getSubTickLineItems = function (tickLineItems) {
  291. var subTickLineItems = [];
  292. var subTickLine = this.get('subTickLine');
  293. var subCount = subTickLine.count;
  294. var tickLineCount = tickLineItems.length;
  295. // 刻度线的数量大于 2 时,才绘制子刻度
  296. if (tickLineCount >= 2) {
  297. for (var i = 0; i < tickLineCount - 1; i++) {
  298. var pre = tickLineItems[i];
  299. var next = tickLineItems[i + 1];
  300. for (var j = 0; j < subCount; j++) {
  301. var percent = (j + 1) / (subCount + 1);
  302. var tickValue = (1 - percent) * pre.tickValue + percent * next.tickValue;
  303. var point = this.getTickPoint(tickValue);
  304. var endPoint = this.getSidePoint(point, subTickLine.length);
  305. subTickLineItems.push({
  306. startPoint: point,
  307. endPoint: endPoint,
  308. tickValue: tickValue,
  309. id: "sub-" + pre.id + "-" + j,
  310. });
  311. }
  312. }
  313. }
  314. return subTickLineItems;
  315. };
  316. AxisBase.prototype.getTickLineAttrs = function (tickItem, type, index, tickItems) {
  317. var style = this.get(type).style;
  318. // 保持和 grid 相同的数据结构
  319. var item = {
  320. points: [tickItem.startPoint, tickItem.endPoint],
  321. };
  322. var defaultTickLineStyle = util_1.get(this.get('theme'), ['tickLine', 'style'], {});
  323. style = util_1.isFunction(style) ? util_1.mix({}, defaultTickLineStyle, style(item, index, tickItems)) : style;
  324. var startPoint = tickItem.startPoint, endPoint = tickItem.endPoint;
  325. return tslib_1.__assign({ x1: startPoint.x, y1: startPoint.y, x2: endPoint.x, y2: endPoint.y }, style);
  326. };
  327. // 绘制坐标轴刻度线
  328. AxisBase.prototype.drawTick = function (tickItem, tickLineGroup, type, index, tickItems) {
  329. this.addShape(tickLineGroup, {
  330. type: 'line',
  331. id: this.getElementId(tickItem.id),
  332. name: "axis-" + type,
  333. attrs: this.getTickLineAttrs(tickItem, type, index, tickItems),
  334. });
  335. };
  336. // 绘制坐标轴刻度线,包括子刻度线
  337. AxisBase.prototype.drawTickLines = function (group) {
  338. var _this = this;
  339. var ticks = this.get('ticks');
  340. var subTickLine = this.get('subTickLine');
  341. var tickLineItems = this.getTickLineItems(ticks);
  342. var tickLineGroup = this.addGroup(group, {
  343. name: 'axis-tickline-group',
  344. id: this.getElementId('tickline-group'),
  345. });
  346. var tickCfg = this.get('tickLine');
  347. util_1.each(tickLineItems, function (item, index) {
  348. if (tickCfg.displayWithLabel) {
  349. // 如果跟随 label 显示,则检测是否存在对应的 label
  350. var labelId = _this.getElementId("label-" + item.tickId);
  351. if (group.findById(labelId)) {
  352. _this.drawTick(item, tickLineGroup, 'tickLine', index, tickLineItems);
  353. }
  354. }
  355. else {
  356. _this.drawTick(item, tickLineGroup, 'tickLine', index, tickLineItems);
  357. }
  358. });
  359. if (subTickLine) {
  360. var subTickLineItems_1 = this.getSubTickLineItems(tickLineItems);
  361. util_1.each(subTickLineItems_1, function (item, index) {
  362. _this.drawTick(item, tickLineGroup, 'subTickLine', index, subTickLineItems_1);
  363. });
  364. }
  365. };
  366. // 预处理 ticks 确定位置和补充 id
  367. AxisBase.prototype.processTicks = function () {
  368. var _this = this;
  369. var ticks = this.get('ticks');
  370. util_1.each(ticks, function (tick) {
  371. tick.point = _this.getTickPoint(tick.value);
  372. // 补充 tick 的 id,为动画和更新做准备
  373. if (util_1.isNil(tick.id)) {
  374. // 默认使用 tick.name 作为id
  375. tick.id = tick.name;
  376. }
  377. });
  378. };
  379. // 绘制 ticks 包括文本和 tickLine
  380. AxisBase.prototype.drawTicks = function (group) {
  381. var _this = this;
  382. this.optimizeTicks();
  383. this.processTicks();
  384. if (this.get('label')) {
  385. this.drawLabels(group);
  386. }
  387. if (this.get('tickLine')) {
  388. this.drawTickLines(group);
  389. }
  390. var ticks = this.get('ticks');
  391. util_1.each(ticks, function (tick) {
  392. _this.applyTickStates(tick, group);
  393. });
  394. };
  395. /**
  396. * 根据 optimize 配置对 ticks 进行抽样,对抽样过后的 ticks 才进行真实的渲染
  397. */
  398. AxisBase.prototype.optimizeTicks = function () {
  399. var optimize = this.get('optimize');
  400. var ticks = this.get('ticks');
  401. if (optimize && optimize.enable && optimize.threshold > 0) {
  402. var len = util_1.size(ticks);
  403. if (len > optimize.threshold) {
  404. var page_1 = Math.ceil(len / optimize.threshold);
  405. var optimizedTicks = ticks.filter(function (tick, idx) { return idx % page_1 === 0; });
  406. this.set('ticks', optimizedTicks);
  407. this.set('originalTicks', ticks);
  408. }
  409. }
  410. };
  411. // 获取 label 的配置项
  412. AxisBase.prototype.getLabelAttrs = function (tick, index, ticks) {
  413. var labelCfg = this.get('label');
  414. var offset = labelCfg.offset, offsetX = labelCfg.offsetX, offsetY = labelCfg.offsetY, rotate = labelCfg.rotate, formatter = labelCfg.formatter;
  415. var point = this.getSidePoint(tick.point, offset);
  416. var vector = this.getSideVector(offset, point);
  417. var text = formatter ? formatter(tick.name, tick, index) : tick.name;
  418. var style = labelCfg.style;
  419. style = util_1.isFunction(style) ? util_1.get(this.get('theme'), ['label', 'style'], {}) : style;
  420. var attrs = util_1.mix({
  421. x: point.x + offsetX,
  422. y: point.y + offsetY,
  423. text: text,
  424. textAlign: this.getTextAnchor(vector),
  425. textBaseline: this.getTextBaseline(vector),
  426. }, style);
  427. if (rotate) {
  428. attrs.matrix = matrix_1.getMatrixByAngle(point, rotate);
  429. }
  430. return attrs;
  431. };
  432. // 绘制文本
  433. AxisBase.prototype.drawLabels = function (group) {
  434. var _this = this;
  435. var ticks = this.get('ticks');
  436. var labelGroup = this.addGroup(group, {
  437. name: 'axis-label-group',
  438. id: this.getElementId('label-group'),
  439. });
  440. util_1.each(ticks, function (tick, index) {
  441. _this.addShape(labelGroup, {
  442. type: 'text',
  443. name: 'axis-label',
  444. id: _this.getElementId("label-" + tick.id),
  445. attrs: _this.getLabelAttrs(tick, index, ticks),
  446. delegateObject: {
  447. tick: tick,
  448. item: tick,
  449. index: index,
  450. },
  451. });
  452. });
  453. this.processOverlap(labelGroup);
  454. // 处理完后再进行 style 回调处理
  455. var labels = labelGroup.getChildren();
  456. var defaultLabelStyle = util_1.get(this.get('theme'), ['label', 'style'], {});
  457. var _a = this.get('label'), style = _a.style, formatter = _a.formatter;
  458. if (util_1.isFunction(style)) {
  459. var afterProcessTicks_1 = labels.map(function (label) { return util_1.get(label.get('delegateObject'), 'tick'); });
  460. util_1.each(labels, function (label, index) {
  461. var tick = label.get('delegateObject').tick;
  462. var text = formatter ? formatter(tick.name, tick, index) : tick.name;
  463. var newStyle = util_1.mix({}, defaultLabelStyle, style(text, index, afterProcessTicks_1));
  464. label.attr(newStyle);
  465. });
  466. }
  467. };
  468. // 标题的属性
  469. AxisBase.prototype.getTitleAttrs = function () {
  470. var titleCfg = this.get('title');
  471. var style = titleCfg.style, position = titleCfg.position, offset = titleCfg.offset, _a = titleCfg.spacing, spacing = _a === void 0 ? 0 : _a, autoRotate = titleCfg.autoRotate;
  472. var titleHeight = style.fontSize;
  473. var percent = 0.5;
  474. if (position === 'start') {
  475. percent = 0;
  476. }
  477. else if (position === 'end') {
  478. percent = 1;
  479. }
  480. var point = this.getTickPoint(percent); // 标题对应的坐标轴上的点
  481. // 如果没有指定 titleOffset 也没有渲染 label,这里需要自动计算 offset
  482. var titlePoint = this.getSidePoint(point, offset || spacing + titleHeight / 2); // 标题的点
  483. var attrs = util_1.mix({
  484. x: titlePoint.x,
  485. y: titlePoint.y,
  486. text: titleCfg.text,
  487. }, style);
  488. var rotate = titleCfg.rotate; // rotate 是角度值
  489. var angle = rotate;
  490. if (util_1.isNil(rotate) && autoRotate) {
  491. // 用户没有设定旋转角度,同时设置自动旋转
  492. var vector = this.getAxisVector(point);
  493. var v1 = [1, 0]; // 水平方向的向量
  494. angle = matrix_util_1.ext.angleTo(vector, v1, true);
  495. }
  496. if (angle) {
  497. var matrix = matrix_1.getMatrixByAngle(titlePoint, angle);
  498. attrs.matrix = matrix;
  499. }
  500. return attrs;
  501. };
  502. // 绘制标题
  503. AxisBase.prototype.drawTitle = function (group) {
  504. var _a;
  505. var titleAttrs = this.getTitleAttrs();
  506. var titleShape = this.addShape(group, {
  507. type: 'text',
  508. id: this.getElementId('title'),
  509. name: 'axis-title',
  510. attrs: titleAttrs
  511. });
  512. // description字段存在时,显示icon
  513. if ((_a = this.get('title')) === null || _a === void 0 ? void 0 : _a.description) {
  514. this.drawDescriptionIcon(group, titleShape, titleAttrs.matrix);
  515. }
  516. };
  517. AxisBase.prototype.drawDescriptionIcon = function (group, titleShape, matrix) {
  518. var descriptionShape = this.addGroup(group, {
  519. name: 'axis-description',
  520. id: this.getElementById('description')
  521. });
  522. var _a = titleShape.getBBox(), maxX = _a.maxX, maxY = _a.maxY, height = _a.height;
  523. var iconStyle = this.get('title').iconStyle;
  524. var spacing = 4; // 设置icon与文本之间距离
  525. var r = height / 2;
  526. var lineWidth = r / 6;
  527. var startX = maxX + spacing;
  528. var startY = maxY - height / 2;
  529. // 绘制 information icon 路径
  530. // 外圆环path
  531. var _b = [startX + r, startY - r], x0 = _b[0], y0 = _b[1];
  532. var _c = [x0 + r, y0 + r], x1 = _c[0], y1 = _c[1];
  533. var _d = [x0, y1 + r], x2 = _d[0], y2 = _d[1];
  534. var _e = [startX, y0 + r], x3 = _e[0], y3 = _e[1];
  535. // i path
  536. var _f = [startX + r, startY - height / 4], x4 = _f[0], y4 = _f[1];
  537. var _g = [x4, y4 + lineWidth], x5 = _g[0], y5 = _g[1];
  538. var _h = [x5, y5 + lineWidth], x6 = _h[0], y6 = _h[1];
  539. var _j = [x6, y6 + r * 3 / 4], x7 = _j[0], y7 = _j[1];
  540. this.addShape(descriptionShape, {
  541. type: 'path',
  542. id: this.getElementId('title-description-icon'),
  543. name: 'axis-title-description-icon',
  544. attrs: tslib_1.__assign({ path: [
  545. ['M', x0, y0],
  546. ['A', r, r, 0, 0, 1, x1, y1],
  547. ['A', r, r, 0, 0, 1, x2, y2],
  548. ['A', r, r, 0, 0, 1, x3, y3],
  549. ['A', r, r, 0, 0, 1, x0, y0],
  550. ['M', x4, y4],
  551. ['L', x5, y5],
  552. ['M', x6, y6],
  553. ['L', x7, y7]
  554. ], lineWidth: lineWidth,
  555. matrix: matrix }, iconStyle),
  556. });
  557. // 点击热区,设置透明矩形
  558. this.addShape(descriptionShape, {
  559. type: 'rect',
  560. id: this.getElementId('title-description-rect'),
  561. name: 'axis-title-description-rect',
  562. attrs: {
  563. x: startX,
  564. y: startY - height / 2,
  565. width: height,
  566. height: height,
  567. stroke: '#000',
  568. fill: '#000',
  569. opacity: 0,
  570. matrix: matrix,
  571. cursor: 'pointer'
  572. }
  573. });
  574. };
  575. AxisBase.prototype.applyTickStates = function (tick, group) {
  576. var states = this.getItemStates(tick);
  577. if (states.length) {
  578. var tickStates = this.get('tickStates');
  579. // 分别更新 label 和 tickLine
  580. var labelId = this.getElementId("label-" + tick.id);
  581. var labelShape = group.findById(labelId);
  582. if (labelShape) {
  583. var labelStateStyle = state_1.getStatesStyle(tick, 'label', tickStates);
  584. labelStateStyle && labelShape.attr(labelStateStyle);
  585. }
  586. var tickLineId = this.getElementId("tickline-" + tick.id);
  587. var tickLineShape = group.findById(tickLineId);
  588. if (tickLineShape) {
  589. var tickLineStateStyle = state_1.getStatesStyle(tick, 'tickLine', tickStates);
  590. tickLineStateStyle && tickLineShape.attr(tickLineStateStyle);
  591. }
  592. }
  593. };
  594. AxisBase.prototype.updateTickStates = function (tick) {
  595. var states = this.getItemStates(tick);
  596. var tickStates = this.get('tickStates');
  597. var labelCfg = this.get('label');
  598. var labelShape = this.getElementByLocalId("label-" + tick.id);
  599. var tickLineCfg = this.get('tickLine');
  600. var tickLineShape = this.getElementByLocalId("tickline-" + tick.id);
  601. if (states.length) {
  602. if (labelShape) {
  603. var labelStateStyle = state_1.getStatesStyle(tick, 'label', tickStates);
  604. labelStateStyle && labelShape.attr(labelStateStyle);
  605. }
  606. if (tickLineShape) {
  607. var tickLineStateStyle = state_1.getStatesStyle(tick, 'tickLine', tickStates);
  608. tickLineStateStyle && tickLineShape.attr(tickLineStateStyle);
  609. }
  610. }
  611. else {
  612. if (labelShape) {
  613. labelShape.attr(labelCfg.style);
  614. }
  615. if (tickLineShape) {
  616. tickLineShape.attr(tickLineCfg.style);
  617. }
  618. }
  619. };
  620. return AxisBase;
  621. }(group_component_1.default));
  622. exports.default = AxisBase;
  623. //# sourceMappingURL=base.js.map