GaugeView.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  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 =
  79. /** @class */
  80. function (_super) {
  81. __extends(GaugeView, _super);
  82. function GaugeView() {
  83. var _this = _super !== null && _super.apply(this, arguments) || this;
  84. _this.type = GaugeView.type;
  85. return _this;
  86. }
  87. GaugeView.prototype.render = function (seriesModel, ecModel, api) {
  88. this.group.removeAll();
  89. var colorList = seriesModel.get(['axisLine', 'lineStyle', 'color']);
  90. var posInfo = parsePosition(seriesModel, api);
  91. this._renderMain(seriesModel, ecModel, api, colorList, posInfo);
  92. this._data = seriesModel.getData();
  93. };
  94. GaugeView.prototype.dispose = function () {};
  95. GaugeView.prototype._renderMain = function (seriesModel, ecModel, api, colorList, posInfo) {
  96. var group = this.group;
  97. var clockwise = seriesModel.get('clockwise');
  98. var startAngle = -seriesModel.get('startAngle') / 180 * Math.PI;
  99. var endAngle = -seriesModel.get('endAngle') / 180 * Math.PI;
  100. var axisLineModel = seriesModel.getModel('axisLine');
  101. var roundCap = axisLineModel.get('roundCap');
  102. var MainPath = roundCap ? Sausage : graphic.Sector;
  103. var showAxis = axisLineModel.get('show');
  104. var lineStyleModel = axisLineModel.getModel('lineStyle');
  105. var axisLineWidth = lineStyleModel.get('width');
  106. var angles = [startAngle, endAngle];
  107. normalizeArcAngles(angles, !clockwise);
  108. startAngle = angles[0];
  109. endAngle = angles[1];
  110. var angleRangeSpan = endAngle - startAngle;
  111. var prevEndAngle = startAngle;
  112. var sectors = [];
  113. for (var i = 0; showAxis && i < colorList.length; i++) {
  114. // Clamp
  115. var percent = Math.min(Math.max(colorList[i][0], 0), 1);
  116. endAngle = startAngle + angleRangeSpan * percent;
  117. var sector = new MainPath({
  118. shape: {
  119. startAngle: prevEndAngle,
  120. endAngle: endAngle,
  121. cx: posInfo.cx,
  122. cy: posInfo.cy,
  123. clockwise: clockwise,
  124. r0: posInfo.r - axisLineWidth,
  125. r: posInfo.r
  126. },
  127. silent: true
  128. });
  129. sector.setStyle({
  130. fill: colorList[i][1]
  131. });
  132. sector.setStyle(lineStyleModel.getLineStyle( // Because we use sector to simulate arc
  133. // so the properties for stroking are useless
  134. ['color', 'width']));
  135. sectors.push(sector);
  136. prevEndAngle = endAngle;
  137. }
  138. sectors.reverse();
  139. each(sectors, function (sector) {
  140. return group.add(sector);
  141. });
  142. var getColor = function (percent) {
  143. // Less than 0
  144. if (percent <= 0) {
  145. return colorList[0][1];
  146. }
  147. var i;
  148. for (i = 0; i < colorList.length; i++) {
  149. if (colorList[i][0] >= percent && (i === 0 ? 0 : colorList[i - 1][0]) < percent) {
  150. return colorList[i][1];
  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); // Split line
  185. if (splitLineModel.get('show')) {
  186. var distance = splitLineDistance ? splitLineDistance + axisLineWidth : axisLineWidth;
  187. var splitLine = new graphic.Line({
  188. shape: {
  189. x1: unitX * (r - distance) + cx,
  190. y1: unitY * (r - distance) + cy,
  191. x2: unitX * (r - splitLineLen - distance) + cx,
  192. y2: unitY * (r - splitLineLen - distance) + cy
  193. },
  194. style: splitLineStyle,
  195. silent: true
  196. });
  197. if (splitLineStyle.stroke === 'auto') {
  198. splitLine.setStyle({
  199. stroke: getColor(i / splitNumber)
  200. });
  201. }
  202. group.add(splitLine);
  203. } // Label
  204. if (labelModel.get('show')) {
  205. var distance = labelModel.get('distance') + splitLineDistance;
  206. var label = formatLabel(round(i / splitNumber * (maxVal - minVal) + minVal), labelModel.get('formatter'));
  207. var autoColor = getColor(i / splitNumber);
  208. var textStyleX = unitX * (r - splitLineLen - distance) + cx;
  209. var textStyleY = unitY * (r - splitLineLen - distance) + cy;
  210. var rotateType = labelModel.get('rotate');
  211. var rotate = 0;
  212. if (rotateType === 'radial') {
  213. rotate = -angle + 2 * Math.PI;
  214. if (rotate > Math.PI / 2) {
  215. rotate += Math.PI;
  216. }
  217. } else if (rotateType === 'tangential') {
  218. rotate = -angle - Math.PI / 2;
  219. } else if (isNumber(rotateType)) {
  220. rotate = rotateType * Math.PI / 180;
  221. }
  222. if (rotate === 0) {
  223. group.add(new graphic.Text({
  224. style: createTextStyle(labelModel, {
  225. text: label,
  226. x: textStyleX,
  227. y: textStyleY,
  228. verticalAlign: unitY < -0.8 ? 'top' : unitY > 0.8 ? 'bottom' : 'middle',
  229. align: unitX < -0.4 ? 'left' : unitX > 0.4 ? 'right' : 'center'
  230. }, {
  231. inheritColor: autoColor
  232. }),
  233. silent: true
  234. }));
  235. } else {
  236. group.add(new graphic.Text({
  237. style: createTextStyle(labelModel, {
  238. text: label,
  239. x: textStyleX,
  240. y: textStyleY,
  241. verticalAlign: 'middle',
  242. align: 'center'
  243. }, {
  244. inheritColor: autoColor
  245. }),
  246. silent: true,
  247. originX: textStyleX,
  248. originY: textStyleY,
  249. rotation: rotate
  250. }));
  251. }
  252. } // Axis tick
  253. if (tickModel.get('show') && i !== splitNumber) {
  254. var distance = tickModel.get('distance');
  255. distance = distance ? distance + axisLineWidth : axisLineWidth;
  256. for (var j = 0; j <= subSplitNumber; j++) {
  257. unitX = Math.cos(angle);
  258. unitY = Math.sin(angle);
  259. var tickLine = new graphic.Line({
  260. shape: {
  261. x1: unitX * (r - distance) + cx,
  262. y1: unitY * (r - distance) + cy,
  263. x2: unitX * (r - tickLen - distance) + cx,
  264. y2: unitY * (r - tickLen - distance) + cy
  265. },
  266. silent: true,
  267. style: tickLineStyle
  268. });
  269. if (tickLineStyle.stroke === 'auto') {
  270. tickLine.setStyle({
  271. stroke: getColor((i + j / subSplitNumber) / splitNumber)
  272. });
  273. }
  274. group.add(tickLine);
  275. angle += subStep;
  276. }
  277. angle -= subStep;
  278. } else {
  279. angle += step;
  280. }
  281. }
  282. };
  283. GaugeView.prototype._renderPointer = function (seriesModel, ecModel, api, getColor, posInfo, startAngle, endAngle, clockwise, axisLineWidth) {
  284. var group = this.group;
  285. var oldData = this._data;
  286. var oldProgressData = this._progressEls;
  287. var progressList = [];
  288. var showPointer = seriesModel.get(['pointer', 'show']);
  289. var progressModel = seriesModel.getModel('progress');
  290. var showProgress = progressModel.get('show');
  291. var data = seriesModel.getData();
  292. var valueDim = data.mapDimension('value');
  293. var minVal = +seriesModel.get('min');
  294. var maxVal = +seriesModel.get('max');
  295. var valueExtent = [minVal, maxVal];
  296. var angleExtent = [startAngle, endAngle];
  297. function createPointer(idx, angle) {
  298. var itemModel = data.getItemModel(idx);
  299. var pointerModel = itemModel.getModel('pointer');
  300. var pointerWidth = parsePercent(pointerModel.get('width'), posInfo.r);
  301. var pointerLength = parsePercent(pointerModel.get('length'), posInfo.r);
  302. var pointerStr = seriesModel.get(['pointer', 'icon']);
  303. var pointerOffset = pointerModel.get('offsetCenter');
  304. var pointerOffsetX = parsePercent(pointerOffset[0], posInfo.r);
  305. var pointerOffsetY = parsePercent(pointerOffset[1], posInfo.r);
  306. var pointerKeepAspect = pointerModel.get('keepAspect');
  307. var pointer; // not exist icon type will be set 'rect'
  308. if (pointerStr) {
  309. pointer = createSymbol(pointerStr, pointerOffsetX - pointerWidth / 2, pointerOffsetY - pointerLength, pointerWidth, pointerLength, null, pointerKeepAspect);
  310. } else {
  311. pointer = new PointerPath({
  312. shape: {
  313. angle: -Math.PI / 2,
  314. width: pointerWidth,
  315. r: pointerLength,
  316. x: pointerOffsetX,
  317. y: pointerOffsetY
  318. }
  319. });
  320. }
  321. pointer.rotation = -(angle + Math.PI / 2);
  322. pointer.x = posInfo.cx;
  323. pointer.y = posInfo.cy;
  324. return pointer;
  325. }
  326. function createProgress(idx, endAngle) {
  327. var roundCap = progressModel.get('roundCap');
  328. var ProgressPath = roundCap ? Sausage : graphic.Sector;
  329. var isOverlap = progressModel.get('overlap');
  330. var progressWidth = isOverlap ? progressModel.get('width') : axisLineWidth / data.count();
  331. var r0 = isOverlap ? posInfo.r - progressWidth : posInfo.r - (idx + 1) * progressWidth;
  332. var r = isOverlap ? posInfo.r : posInfo.r - idx * progressWidth;
  333. var progress = new ProgressPath({
  334. shape: {
  335. startAngle: startAngle,
  336. endAngle: endAngle,
  337. cx: posInfo.cx,
  338. cy: posInfo.cy,
  339. clockwise: clockwise,
  340. r0: r0,
  341. r: r
  342. }
  343. });
  344. isOverlap && (progress.z2 = maxVal - data.get(valueDim, idx) % maxVal);
  345. return progress;
  346. }
  347. if (showProgress || showPointer) {
  348. data.diff(oldData).add(function (idx) {
  349. var val = data.get(valueDim, idx);
  350. if (showPointer) {
  351. var pointer = createPointer(idx, startAngle); // TODO hide pointer on NaN value?
  352. graphic.initProps(pointer, {
  353. rotation: -((isNaN(+val) ? angleExtent[0] : linearMap(val, valueExtent, angleExtent, true)) + Math.PI / 2)
  354. }, seriesModel);
  355. group.add(pointer);
  356. data.setItemGraphicEl(idx, pointer);
  357. }
  358. if (showProgress) {
  359. var progress = createProgress(idx, startAngle);
  360. var isClip = progressModel.get('clip');
  361. graphic.initProps(progress, {
  362. shape: {
  363. endAngle: linearMap(val, valueExtent, angleExtent, isClip)
  364. }
  365. }, seriesModel);
  366. group.add(progress); // Add data index and series index for indexing the data by element
  367. // Useful in tooltip
  368. setCommonECData(seriesModel.seriesIndex, data.dataType, idx, progress);
  369. progressList[idx] = progress;
  370. }
  371. }).update(function (newIdx, oldIdx) {
  372. var val = data.get(valueDim, newIdx);
  373. if (showPointer) {
  374. var previousPointer = oldData.getItemGraphicEl(oldIdx);
  375. var previousRotate = previousPointer ? previousPointer.rotation : startAngle;
  376. var pointer = createPointer(newIdx, previousRotate);
  377. pointer.rotation = previousRotate;
  378. graphic.updateProps(pointer, {
  379. rotation: -((isNaN(+val) ? angleExtent[0] : linearMap(val, valueExtent, angleExtent, true)) + Math.PI / 2)
  380. }, seriesModel);
  381. group.add(pointer);
  382. data.setItemGraphicEl(newIdx, pointer);
  383. }
  384. if (showProgress) {
  385. var previousProgress = oldProgressData[oldIdx];
  386. var previousEndAngle = previousProgress ? previousProgress.shape.endAngle : startAngle;
  387. var progress = createProgress(newIdx, previousEndAngle);
  388. var isClip = progressModel.get('clip');
  389. graphic.updateProps(progress, {
  390. shape: {
  391. endAngle: linearMap(val, valueExtent, angleExtent, isClip)
  392. }
  393. }, seriesModel);
  394. group.add(progress); // Add data index and series index for indexing the data by element
  395. // Useful in tooltip
  396. setCommonECData(seriesModel.seriesIndex, data.dataType, newIdx, progress);
  397. progressList[newIdx] = progress;
  398. }
  399. }).execute();
  400. data.each(function (idx) {
  401. var itemModel = data.getItemModel(idx);
  402. var emphasisModel = itemModel.getModel('emphasis');
  403. var focus = emphasisModel.get('focus');
  404. var blurScope = emphasisModel.get('blurScope');
  405. var emphasisDisabled = emphasisModel.get('disabled');
  406. if (showPointer) {
  407. var pointer = data.getItemGraphicEl(idx);
  408. var symbolStyle = data.getItemVisual(idx, 'style');
  409. var visualColor = symbolStyle.fill;
  410. if (pointer instanceof ZRImage) {
  411. var pathStyle = pointer.style;
  412. pointer.useStyle(extend({
  413. image: pathStyle.image,
  414. x: pathStyle.x,
  415. y: pathStyle.y,
  416. width: pathStyle.width,
  417. height: pathStyle.height
  418. }, symbolStyle));
  419. } else {
  420. pointer.useStyle(symbolStyle);
  421. pointer.type !== 'pointer' && pointer.setColor(visualColor);
  422. }
  423. pointer.setStyle(itemModel.getModel(['pointer', 'itemStyle']).getItemStyle());
  424. if (pointer.style.fill === 'auto') {
  425. pointer.setStyle('fill', getColor(linearMap(data.get(valueDim, idx), valueExtent, [0, 1], true)));
  426. }
  427. pointer.z2EmphasisLift = 0;
  428. setStatesStylesFromModel(pointer, itemModel);
  429. toggleHoverEmphasis(pointer, focus, blurScope, emphasisDisabled);
  430. }
  431. if (showProgress) {
  432. var progress = progressList[idx];
  433. progress.useStyle(data.getItemVisual(idx, 'style'));
  434. progress.setStyle(itemModel.getModel(['progress', 'itemStyle']).getItemStyle());
  435. progress.z2EmphasisLift = 0;
  436. setStatesStylesFromModel(progress, itemModel);
  437. toggleHoverEmphasis(progress, focus, blurScope, emphasisDisabled);
  438. }
  439. });
  440. this._progressEls = progressList;
  441. }
  442. };
  443. GaugeView.prototype._renderAnchor = function (seriesModel, posInfo) {
  444. var anchorModel = seriesModel.getModel('anchor');
  445. var showAnchor = anchorModel.get('show');
  446. if (showAnchor) {
  447. var anchorSize = anchorModel.get('size');
  448. var anchorType = anchorModel.get('icon');
  449. var offsetCenter = anchorModel.get('offsetCenter');
  450. var anchorKeepAspect = anchorModel.get('keepAspect');
  451. 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);
  452. anchor.z2 = anchorModel.get('showAbove') ? 1 : 0;
  453. anchor.setStyle(anchorModel.getModel('itemStyle').getItemStyle());
  454. this.group.add(anchor);
  455. }
  456. };
  457. GaugeView.prototype._renderTitleAndDetail = function (seriesModel, ecModel, api, getColor, posInfo) {
  458. var _this = this;
  459. var data = seriesModel.getData();
  460. var valueDim = data.mapDimension('value');
  461. var minVal = +seriesModel.get('min');
  462. var maxVal = +seriesModel.get('max');
  463. var contentGroup = new graphic.Group();
  464. var newTitleEls = [];
  465. var newDetailEls = [];
  466. var hasAnimation = seriesModel.isAnimationEnabled();
  467. var showPointerAbove = seriesModel.get(['pointer', 'showAbove']);
  468. data.diff(this._data).add(function (idx) {
  469. newTitleEls[idx] = new graphic.Text({
  470. silent: true
  471. });
  472. newDetailEls[idx] = new graphic.Text({
  473. silent: true
  474. });
  475. }).update(function (idx, oldIdx) {
  476. newTitleEls[idx] = _this._titleEls[oldIdx];
  477. newDetailEls[idx] = _this._detailEls[oldIdx];
  478. }).execute();
  479. data.each(function (idx) {
  480. var itemModel = data.getItemModel(idx);
  481. var value = data.get(valueDim, idx);
  482. var itemGroup = new graphic.Group();
  483. var autoColor = getColor(linearMap(value, [minVal, maxVal], [0, 1], true));
  484. var itemTitleModel = itemModel.getModel('title');
  485. if (itemTitleModel.get('show')) {
  486. var titleOffsetCenter = itemTitleModel.get('offsetCenter');
  487. var titleX = posInfo.cx + parsePercent(titleOffsetCenter[0], posInfo.r);
  488. var titleY = posInfo.cy + parsePercent(titleOffsetCenter[1], posInfo.r);
  489. var labelEl = newTitleEls[idx];
  490. labelEl.attr({
  491. z2: showPointerAbove ? 0 : 2,
  492. style: createTextStyle(itemTitleModel, {
  493. x: titleX,
  494. y: titleY,
  495. text: data.getName(idx),
  496. align: 'center',
  497. verticalAlign: 'middle'
  498. }, {
  499. inheritColor: autoColor
  500. })
  501. });
  502. itemGroup.add(labelEl);
  503. }
  504. var itemDetailModel = itemModel.getModel('detail');
  505. if (itemDetailModel.get('show')) {
  506. var detailOffsetCenter = itemDetailModel.get('offsetCenter');
  507. var detailX = posInfo.cx + parsePercent(detailOffsetCenter[0], posInfo.r);
  508. var detailY = posInfo.cy + parsePercent(detailOffsetCenter[1], posInfo.r);
  509. var width = parsePercent(itemDetailModel.get('width'), posInfo.r);
  510. var height = parsePercent(itemDetailModel.get('height'), posInfo.r);
  511. var detailColor = seriesModel.get(['progress', 'show']) ? data.getItemVisual(idx, 'style').fill : autoColor;
  512. var labelEl = newDetailEls[idx];
  513. var formatter_1 = itemDetailModel.get('formatter');
  514. labelEl.attr({
  515. z2: showPointerAbove ? 0 : 2,
  516. style: createTextStyle(itemDetailModel, {
  517. x: detailX,
  518. y: detailY,
  519. text: formatLabel(value, formatter_1),
  520. width: isNaN(width) ? null : width,
  521. height: isNaN(height) ? null : height,
  522. align: 'center',
  523. verticalAlign: 'middle'
  524. }, {
  525. inheritColor: detailColor
  526. })
  527. });
  528. setLabelValueAnimation(labelEl, {
  529. normal: itemDetailModel
  530. }, value, function (value) {
  531. return formatLabel(value, formatter_1);
  532. });
  533. hasAnimation && animateLabelValue(labelEl, idx, data, seriesModel, {
  534. getFormattedLabel: function (labelDataIndex, status, dataType, labelDimIndex, fmt, extendParams) {
  535. return formatLabel(extendParams ? extendParams.interpolatedValue : value, formatter_1);
  536. }
  537. });
  538. itemGroup.add(labelEl);
  539. }
  540. contentGroup.add(itemGroup);
  541. });
  542. this.group.add(contentGroup);
  543. this._titleEls = newTitleEls;
  544. this._detailEls = newDetailEls;
  545. };
  546. GaugeView.type = 'gauge';
  547. return GaugeView;
  548. }(ChartView);
  549. export default GaugeView;