GaugeView.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. * KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations
  17. * under the License.
  18. */
  19. /**
  20. * AUTO-GENERATED FILE. DO NOT MODIFY.
  21. */
  22. /*
  23. * Licensed to the Apache Software Foundation (ASF) under one
  24. * or more contributor license agreements. See the NOTICE file
  25. * distributed with this work for additional information
  26. * regarding copyright ownership. The ASF licenses this file
  27. * to you under the Apache License, Version 2.0 (the
  28. * "License"); you may not use this file except in compliance
  29. * with the License. You may obtain a copy of the License at
  30. *
  31. * http://www.apache.org/licenses/LICENSE-2.0
  32. *
  33. * Unless required by applicable law or agreed to in writing,
  34. * software distributed under the License is distributed on an
  35. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  36. * KIND, either express or implied. See the License for the
  37. * specific language governing permissions and limitations
  38. * under the License.
  39. */
  40. import { __extends } from "tslib";
  41. import PointerPath from './PointerPath.js';
  42. import * as graphic from '../../util/graphic.js';
  43. import { setStatesStylesFromModel, toggleHoverEmphasis } from '../../util/states.js';
  44. import { createTextStyle, setLabelValueAnimation, animateLabelValue } from '../../label/labelStyle.js';
  45. import ChartView from '../../view/Chart.js';
  46. import { parsePercent, round, linearMap } from '../../util/number.js';
  47. import Sausage from '../../util/shape/sausage.js';
  48. import { createSymbol } from '../../util/symbol.js';
  49. import ZRImage from 'zrender/lib/graphic/Image.js';
  50. import { extend, isFunction, isString, isNumber, each } from 'zrender/lib/core/util.js';
  51. import { setCommonECData } from '../../util/innerStore.js';
  52. import { normalizeArcAngles } from 'zrender/lib/core/PathProxy.js';
  53. function parsePosition(seriesModel, api) {
  54. var center = seriesModel.get('center');
  55. var width = api.getWidth();
  56. var height = api.getHeight();
  57. var size = Math.min(width, height);
  58. var cx = parsePercent(center[0], api.getWidth());
  59. var cy = parsePercent(center[1], api.getHeight());
  60. var r = parsePercent(seriesModel.get('radius'), size / 2);
  61. return {
  62. cx: cx,
  63. cy: cy,
  64. r: r
  65. };
  66. }
  67. function formatLabel(value, labelFormatter) {
  68. var label = value == null ? '' : value + '';
  69. if (labelFormatter) {
  70. if (isString(labelFormatter)) {
  71. label = labelFormatter.replace('{value}', label);
  72. } else if (isFunction(labelFormatter)) {
  73. label = labelFormatter(value);
  74. }
  75. }
  76. return label;
  77. }
  78. var GaugeView = /** @class */function (_super) {
  79. __extends(GaugeView, _super);
  80. function GaugeView() {
  81. var _this = _super !== null && _super.apply(this, arguments) || this;
  82. _this.type = GaugeView.type;
  83. return _this;
  84. }
  85. GaugeView.prototype.render = function (seriesModel, ecModel, api) {
  86. this.group.removeAll();
  87. var colorList = seriesModel.get(['axisLine', 'lineStyle', 'color']);
  88. var posInfo = parsePosition(seriesModel, api);
  89. this._renderMain(seriesModel, ecModel, api, colorList, posInfo);
  90. this._data = seriesModel.getData();
  91. };
  92. GaugeView.prototype.dispose = function () {};
  93. GaugeView.prototype._renderMain = function (seriesModel, ecModel, api, colorList, posInfo) {
  94. var group = this.group;
  95. var clockwise = seriesModel.get('clockwise');
  96. var startAngle = -seriesModel.get('startAngle') / 180 * Math.PI;
  97. var endAngle = -seriesModel.get('endAngle') / 180 * Math.PI;
  98. var axisLineModel = seriesModel.getModel('axisLine');
  99. var roundCap = axisLineModel.get('roundCap');
  100. var MainPath = roundCap ? Sausage : graphic.Sector;
  101. var showAxis = axisLineModel.get('show');
  102. var lineStyleModel = axisLineModel.getModel('lineStyle');
  103. var axisLineWidth = lineStyleModel.get('width');
  104. var angles = [startAngle, endAngle];
  105. normalizeArcAngles(angles, !clockwise);
  106. startAngle = angles[0];
  107. endAngle = angles[1];
  108. var angleRangeSpan = endAngle - startAngle;
  109. var prevEndAngle = startAngle;
  110. var sectors = [];
  111. for (var i = 0; showAxis && i < colorList.length; i++) {
  112. // Clamp
  113. var percent = Math.min(Math.max(colorList[i][0], 0), 1);
  114. endAngle = startAngle + angleRangeSpan * percent;
  115. var sector = new MainPath({
  116. shape: {
  117. startAngle: prevEndAngle,
  118. endAngle: endAngle,
  119. cx: posInfo.cx,
  120. cy: posInfo.cy,
  121. clockwise: clockwise,
  122. r0: posInfo.r - axisLineWidth,
  123. r: posInfo.r
  124. },
  125. silent: true
  126. });
  127. sector.setStyle({
  128. fill: colorList[i][1]
  129. });
  130. sector.setStyle(lineStyleModel.getLineStyle(
  131. // Because we use sector to simulate arc
  132. // so the properties for stroking are useless
  133. ['color', 'width']));
  134. sectors.push(sector);
  135. prevEndAngle = endAngle;
  136. }
  137. sectors.reverse();
  138. each(sectors, function (sector) {
  139. return group.add(sector);
  140. });
  141. var getColor = function (percent) {
  142. // Less than 0
  143. if (percent <= 0) {
  144. return colorList[0][1];
  145. }
  146. var i;
  147. for (i = 0; i < colorList.length; i++) {
  148. if (colorList[i][0] >= percent && (i === 0 ? 0 : colorList[i - 1][0]) < percent) {
  149. return colorList[i][1];
  150. }
  151. }
  152. // More than 1
  153. return colorList[i - 1][1];
  154. };
  155. this._renderTicks(seriesModel, ecModel, api, getColor, posInfo, startAngle, endAngle, clockwise, axisLineWidth);
  156. this._renderTitleAndDetail(seriesModel, ecModel, api, getColor, posInfo);
  157. this._renderAnchor(seriesModel, posInfo);
  158. this._renderPointer(seriesModel, ecModel, api, getColor, posInfo, startAngle, endAngle, clockwise, axisLineWidth);
  159. };
  160. GaugeView.prototype._renderTicks = function (seriesModel, ecModel, api, getColor, posInfo, startAngle, endAngle, clockwise, axisLineWidth) {
  161. var group = this.group;
  162. var cx = posInfo.cx;
  163. var cy = posInfo.cy;
  164. var r = posInfo.r;
  165. var minVal = +seriesModel.get('min');
  166. var maxVal = +seriesModel.get('max');
  167. var splitLineModel = seriesModel.getModel('splitLine');
  168. var tickModel = seriesModel.getModel('axisTick');
  169. var labelModel = seriesModel.getModel('axisLabel');
  170. var splitNumber = seriesModel.get('splitNumber');
  171. var subSplitNumber = tickModel.get('splitNumber');
  172. var splitLineLen = parsePercent(splitLineModel.get('length'), r);
  173. var tickLen = parsePercent(tickModel.get('length'), r);
  174. var angle = startAngle;
  175. var step = (endAngle - startAngle) / splitNumber;
  176. var subStep = step / subSplitNumber;
  177. var splitLineStyle = splitLineModel.getModel('lineStyle').getLineStyle();
  178. var tickLineStyle = tickModel.getModel('lineStyle').getLineStyle();
  179. var splitLineDistance = splitLineModel.get('distance');
  180. var unitX;
  181. var unitY;
  182. for (var i = 0; i <= splitNumber; i++) {
  183. unitX = Math.cos(angle);
  184. unitY = Math.sin(angle);
  185. // Split line
  186. if (splitLineModel.get('show')) {
  187. var distance = splitLineDistance ? splitLineDistance + axisLineWidth : axisLineWidth;
  188. var splitLine = new graphic.Line({
  189. shape: {
  190. x1: unitX * (r - distance) + cx,
  191. y1: unitY * (r - distance) + cy,
  192. x2: unitX * (r - splitLineLen - distance) + cx,
  193. y2: unitY * (r - splitLineLen - distance) + cy
  194. },
  195. style: splitLineStyle,
  196. silent: true
  197. });
  198. if (splitLineStyle.stroke === 'auto') {
  199. splitLine.setStyle({
  200. stroke: getColor(i / splitNumber)
  201. });
  202. }
  203. group.add(splitLine);
  204. }
  205. // Label
  206. if (labelModel.get('show')) {
  207. var distance = labelModel.get('distance') + splitLineDistance;
  208. var label = formatLabel(round(i / splitNumber * (maxVal - minVal) + minVal), labelModel.get('formatter'));
  209. var autoColor = getColor(i / splitNumber);
  210. var textStyleX = unitX * (r - splitLineLen - distance) + cx;
  211. var textStyleY = unitY * (r - splitLineLen - distance) + cy;
  212. var rotateType = labelModel.get('rotate');
  213. var rotate = 0;
  214. if (rotateType === 'radial') {
  215. rotate = -angle + 2 * Math.PI;
  216. if (rotate > Math.PI / 2) {
  217. rotate += Math.PI;
  218. }
  219. } else if (rotateType === 'tangential') {
  220. rotate = -angle - Math.PI / 2;
  221. } else if (isNumber(rotateType)) {
  222. rotate = rotateType * Math.PI / 180;
  223. }
  224. if (rotate === 0) {
  225. group.add(new graphic.Text({
  226. style: createTextStyle(labelModel, {
  227. text: label,
  228. x: textStyleX,
  229. y: textStyleY,
  230. verticalAlign: unitY < -0.8 ? 'top' : unitY > 0.8 ? 'bottom' : 'middle',
  231. align: unitX < -0.4 ? 'left' : unitX > 0.4 ? 'right' : 'center'
  232. }, {
  233. inheritColor: autoColor
  234. }),
  235. silent: true
  236. }));
  237. } else {
  238. group.add(new graphic.Text({
  239. style: createTextStyle(labelModel, {
  240. text: label,
  241. x: textStyleX,
  242. y: textStyleY,
  243. verticalAlign: 'middle',
  244. align: 'center'
  245. }, {
  246. inheritColor: autoColor
  247. }),
  248. silent: true,
  249. originX: textStyleX,
  250. originY: textStyleY,
  251. rotation: rotate
  252. }));
  253. }
  254. }
  255. // Axis tick
  256. if (tickModel.get('show') && i !== splitNumber) {
  257. var distance = tickModel.get('distance');
  258. distance = distance ? distance + axisLineWidth : axisLineWidth;
  259. for (var j = 0; j <= subSplitNumber; j++) {
  260. unitX = Math.cos(angle);
  261. unitY = Math.sin(angle);
  262. var tickLine = new graphic.Line({
  263. shape: {
  264. x1: unitX * (r - distance) + cx,
  265. y1: unitY * (r - distance) + cy,
  266. x2: unitX * (r - tickLen - distance) + cx,
  267. y2: unitY * (r - tickLen - distance) + cy
  268. },
  269. silent: true,
  270. style: tickLineStyle
  271. });
  272. if (tickLineStyle.stroke === 'auto') {
  273. tickLine.setStyle({
  274. stroke: getColor((i + j / subSplitNumber) / splitNumber)
  275. });
  276. }
  277. group.add(tickLine);
  278. angle += subStep;
  279. }
  280. angle -= subStep;
  281. } else {
  282. angle += step;
  283. }
  284. }
  285. };
  286. GaugeView.prototype._renderPointer = function (seriesModel, ecModel, api, getColor, posInfo, startAngle, endAngle, clockwise, axisLineWidth) {
  287. var group = this.group;
  288. var oldData = this._data;
  289. var oldProgressData = this._progressEls;
  290. var progressList = [];
  291. var showPointer = seriesModel.get(['pointer', 'show']);
  292. var progressModel = seriesModel.getModel('progress');
  293. var showProgress = progressModel.get('show');
  294. var data = seriesModel.getData();
  295. var valueDim = data.mapDimension('value');
  296. var minVal = +seriesModel.get('min');
  297. var maxVal = +seriesModel.get('max');
  298. var valueExtent = [minVal, maxVal];
  299. var angleExtent = [startAngle, endAngle];
  300. function createPointer(idx, angle) {
  301. var itemModel = data.getItemModel(idx);
  302. var pointerModel = itemModel.getModel('pointer');
  303. var pointerWidth = parsePercent(pointerModel.get('width'), posInfo.r);
  304. var pointerLength = parsePercent(pointerModel.get('length'), posInfo.r);
  305. var pointerStr = seriesModel.get(['pointer', 'icon']);
  306. var pointerOffset = pointerModel.get('offsetCenter');
  307. var pointerOffsetX = parsePercent(pointerOffset[0], posInfo.r);
  308. var pointerOffsetY = parsePercent(pointerOffset[1], posInfo.r);
  309. var pointerKeepAspect = pointerModel.get('keepAspect');
  310. var pointer;
  311. // not exist icon type will be set 'rect'
  312. if (pointerStr) {
  313. pointer = createSymbol(pointerStr, pointerOffsetX - pointerWidth / 2, pointerOffsetY - pointerLength, pointerWidth, pointerLength, null, pointerKeepAspect);
  314. } else {
  315. pointer = new PointerPath({
  316. shape: {
  317. angle: -Math.PI / 2,
  318. width: pointerWidth,
  319. r: pointerLength,
  320. x: pointerOffsetX,
  321. y: pointerOffsetY
  322. }
  323. });
  324. }
  325. pointer.rotation = -(angle + Math.PI / 2);
  326. pointer.x = posInfo.cx;
  327. pointer.y = posInfo.cy;
  328. return pointer;
  329. }
  330. function createProgress(idx, endAngle) {
  331. var roundCap = progressModel.get('roundCap');
  332. var ProgressPath = roundCap ? Sausage : graphic.Sector;
  333. var isOverlap = progressModel.get('overlap');
  334. var progressWidth = isOverlap ? progressModel.get('width') : axisLineWidth / data.count();
  335. var r0 = isOverlap ? posInfo.r - progressWidth : posInfo.r - (idx + 1) * progressWidth;
  336. var r = isOverlap ? posInfo.r : posInfo.r - idx * progressWidth;
  337. var progress = new ProgressPath({
  338. shape: {
  339. startAngle: startAngle,
  340. endAngle: endAngle,
  341. cx: posInfo.cx,
  342. cy: posInfo.cy,
  343. clockwise: clockwise,
  344. r0: r0,
  345. r: r
  346. }
  347. });
  348. isOverlap && (progress.z2 = maxVal - data.get(valueDim, idx) % maxVal);
  349. return progress;
  350. }
  351. if (showProgress || showPointer) {
  352. data.diff(oldData).add(function (idx) {
  353. var val = data.get(valueDim, idx);
  354. if (showPointer) {
  355. var pointer = createPointer(idx, startAngle);
  356. // TODO hide pointer on NaN value?
  357. graphic.initProps(pointer, {
  358. rotation: -((isNaN(+val) ? angleExtent[0] : linearMap(val, valueExtent, angleExtent, true)) + Math.PI / 2)
  359. }, seriesModel);
  360. group.add(pointer);
  361. data.setItemGraphicEl(idx, pointer);
  362. }
  363. if (showProgress) {
  364. var progress = createProgress(idx, startAngle);
  365. var isClip = progressModel.get('clip');
  366. graphic.initProps(progress, {
  367. shape: {
  368. endAngle: linearMap(val, valueExtent, angleExtent, isClip)
  369. }
  370. }, seriesModel);
  371. group.add(progress);
  372. // Add data index and series index for indexing the data by element
  373. // Useful in tooltip
  374. setCommonECData(seriesModel.seriesIndex, data.dataType, idx, progress);
  375. progressList[idx] = progress;
  376. }
  377. }).update(function (newIdx, oldIdx) {
  378. var val = data.get(valueDim, newIdx);
  379. if (showPointer) {
  380. var previousPointer = oldData.getItemGraphicEl(oldIdx);
  381. var previousRotate = previousPointer ? previousPointer.rotation : startAngle;
  382. var pointer = createPointer(newIdx, previousRotate);
  383. pointer.rotation = previousRotate;
  384. graphic.updateProps(pointer, {
  385. rotation: -((isNaN(+val) ? angleExtent[0] : linearMap(val, valueExtent, angleExtent, true)) + Math.PI / 2)
  386. }, seriesModel);
  387. group.add(pointer);
  388. data.setItemGraphicEl(newIdx, pointer);
  389. }
  390. if (showProgress) {
  391. var previousProgress = oldProgressData[oldIdx];
  392. var previousEndAngle = previousProgress ? previousProgress.shape.endAngle : startAngle;
  393. var progress = createProgress(newIdx, previousEndAngle);
  394. var isClip = progressModel.get('clip');
  395. graphic.updateProps(progress, {
  396. shape: {
  397. endAngle: linearMap(val, valueExtent, angleExtent, isClip)
  398. }
  399. }, seriesModel);
  400. group.add(progress);
  401. // Add data index and series index for indexing the data by element
  402. // Useful in tooltip
  403. setCommonECData(seriesModel.seriesIndex, data.dataType, newIdx, progress);
  404. progressList[newIdx] = progress;
  405. }
  406. }).execute();
  407. data.each(function (idx) {
  408. var itemModel = data.getItemModel(idx);
  409. var emphasisModel = itemModel.getModel('emphasis');
  410. var focus = emphasisModel.get('focus');
  411. var blurScope = emphasisModel.get('blurScope');
  412. var emphasisDisabled = emphasisModel.get('disabled');
  413. if (showPointer) {
  414. var pointer = data.getItemGraphicEl(idx);
  415. var symbolStyle = data.getItemVisual(idx, 'style');
  416. var visualColor = symbolStyle.fill;
  417. if (pointer instanceof ZRImage) {
  418. var pathStyle = pointer.style;
  419. pointer.useStyle(extend({
  420. image: pathStyle.image,
  421. x: pathStyle.x,
  422. y: pathStyle.y,
  423. width: pathStyle.width,
  424. height: pathStyle.height
  425. }, symbolStyle));
  426. } else {
  427. pointer.useStyle(symbolStyle);
  428. pointer.type !== 'pointer' && pointer.setColor(visualColor);
  429. }
  430. pointer.setStyle(itemModel.getModel(['pointer', 'itemStyle']).getItemStyle());
  431. if (pointer.style.fill === 'auto') {
  432. pointer.setStyle('fill', getColor(linearMap(data.get(valueDim, idx), valueExtent, [0, 1], true)));
  433. }
  434. pointer.z2EmphasisLift = 0;
  435. setStatesStylesFromModel(pointer, itemModel);
  436. toggleHoverEmphasis(pointer, focus, blurScope, emphasisDisabled);
  437. }
  438. if (showProgress) {
  439. var progress = progressList[idx];
  440. progress.useStyle(data.getItemVisual(idx, 'style'));
  441. progress.setStyle(itemModel.getModel(['progress', 'itemStyle']).getItemStyle());
  442. progress.z2EmphasisLift = 0;
  443. setStatesStylesFromModel(progress, itemModel);
  444. toggleHoverEmphasis(progress, focus, blurScope, emphasisDisabled);
  445. }
  446. });
  447. this._progressEls = progressList;
  448. }
  449. };
  450. GaugeView.prototype._renderAnchor = function (seriesModel, posInfo) {
  451. var anchorModel = seriesModel.getModel('anchor');
  452. var showAnchor = anchorModel.get('show');
  453. if (showAnchor) {
  454. var anchorSize = anchorModel.get('size');
  455. var anchorType = anchorModel.get('icon');
  456. var offsetCenter = anchorModel.get('offsetCenter');
  457. var anchorKeepAspect = anchorModel.get('keepAspect');
  458. var anchor = createSymbol(anchorType, posInfo.cx - anchorSize / 2 + parsePercent(offsetCenter[0], posInfo.r), posInfo.cy - anchorSize / 2 + parsePercent(offsetCenter[1], posInfo.r), anchorSize, anchorSize, null, anchorKeepAspect);
  459. anchor.z2 = anchorModel.get('showAbove') ? 1 : 0;
  460. anchor.setStyle(anchorModel.getModel('itemStyle').getItemStyle());
  461. this.group.add(anchor);
  462. }
  463. };
  464. GaugeView.prototype._renderTitleAndDetail = function (seriesModel, ecModel, api, getColor, posInfo) {
  465. var _this = this;
  466. var data = seriesModel.getData();
  467. var valueDim = data.mapDimension('value');
  468. var minVal = +seriesModel.get('min');
  469. var maxVal = +seriesModel.get('max');
  470. var contentGroup = new graphic.Group();
  471. var newTitleEls = [];
  472. var newDetailEls = [];
  473. var hasAnimation = seriesModel.isAnimationEnabled();
  474. var showPointerAbove = seriesModel.get(['pointer', 'showAbove']);
  475. data.diff(this._data).add(function (idx) {
  476. newTitleEls[idx] = new graphic.Text({
  477. silent: true
  478. });
  479. newDetailEls[idx] = new graphic.Text({
  480. silent: true
  481. });
  482. }).update(function (idx, oldIdx) {
  483. newTitleEls[idx] = _this._titleEls[oldIdx];
  484. newDetailEls[idx] = _this._detailEls[oldIdx];
  485. }).execute();
  486. data.each(function (idx) {
  487. var itemModel = data.getItemModel(idx);
  488. var value = data.get(valueDim, idx);
  489. var itemGroup = new graphic.Group();
  490. var autoColor = getColor(linearMap(value, [minVal, maxVal], [0, 1], true));
  491. var itemTitleModel = itemModel.getModel('title');
  492. if (itemTitleModel.get('show')) {
  493. var titleOffsetCenter = itemTitleModel.get('offsetCenter');
  494. var titleX = posInfo.cx + parsePercent(titleOffsetCenter[0], posInfo.r);
  495. var titleY = posInfo.cy + parsePercent(titleOffsetCenter[1], posInfo.r);
  496. var labelEl = newTitleEls[idx];
  497. labelEl.attr({
  498. z2: showPointerAbove ? 0 : 2,
  499. style: createTextStyle(itemTitleModel, {
  500. x: titleX,
  501. y: titleY,
  502. text: data.getName(idx),
  503. align: 'center',
  504. verticalAlign: 'middle'
  505. }, {
  506. inheritColor: autoColor
  507. })
  508. });
  509. itemGroup.add(labelEl);
  510. }
  511. var itemDetailModel = itemModel.getModel('detail');
  512. if (itemDetailModel.get('show')) {
  513. var detailOffsetCenter = itemDetailModel.get('offsetCenter');
  514. var detailX = posInfo.cx + parsePercent(detailOffsetCenter[0], posInfo.r);
  515. var detailY = posInfo.cy + parsePercent(detailOffsetCenter[1], posInfo.r);
  516. var width = parsePercent(itemDetailModel.get('width'), posInfo.r);
  517. var height = parsePercent(itemDetailModel.get('height'), posInfo.r);
  518. var detailColor = seriesModel.get(['progress', 'show']) ? data.getItemVisual(idx, 'style').fill : autoColor;
  519. var labelEl = newDetailEls[idx];
  520. var formatter_1 = itemDetailModel.get('formatter');
  521. labelEl.attr({
  522. z2: showPointerAbove ? 0 : 2,
  523. style: createTextStyle(itemDetailModel, {
  524. x: detailX,
  525. y: detailY,
  526. text: formatLabel(value, formatter_1),
  527. width: isNaN(width) ? null : width,
  528. height: isNaN(height) ? null : height,
  529. align: 'center',
  530. verticalAlign: 'middle'
  531. }, {
  532. inheritColor: detailColor
  533. })
  534. });
  535. setLabelValueAnimation(labelEl, {
  536. normal: itemDetailModel
  537. }, value, function (value) {
  538. return formatLabel(value, formatter_1);
  539. });
  540. hasAnimation && animateLabelValue(labelEl, idx, data, seriesModel, {
  541. getFormattedLabel: function (labelDataIndex, status, dataType, labelDimIndex, fmt, extendParams) {
  542. return formatLabel(extendParams ? extendParams.interpolatedValue : value, formatter_1);
  543. }
  544. });
  545. itemGroup.add(labelEl);
  546. }
  547. contentGroup.add(itemGroup);
  548. });
  549. this.group.add(contentGroup);
  550. this._titleEls = newTitleEls;
  551. this._detailEls = newDetailEls;
  552. };
  553. GaugeView.type = 'gauge';
  554. return GaugeView;
  555. }(ChartView);
  556. export default GaugeView;