symbol_point.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  1. /**
  2. * DevExtreme (viz/series/points/symbol_point.js)
  3. * Version: 19.1.16
  4. * Build date: Tue Oct 18 2022
  5. *
  6. * Copyright (c) 2012 - 2022 Developer Express Inc. ALL RIGHTS RESERVED
  7. * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
  8. */
  9. "use strict";
  10. var extend = require("../../../core/utils/extend").extend;
  11. var each = require("../../../core/utils/iterator").each;
  12. var noop = require("../../../core/utils/common").noop;
  13. var windowUtils = require("../../../core/utils/window");
  14. var window = windowUtils.getWindow();
  15. var labelModule = require("./label");
  16. var _extend = extend;
  17. var _isDefined = require("../../../core/utils/type").isDefined;
  18. var _normalizeEnum = require("../../core/utils").normalizeEnum;
  19. var _math = Math;
  20. var _round = _math.round;
  21. var _floor = _math.floor;
  22. var _ceil = _math.ceil;
  23. var DEFAULT_IMAGE_WIDTH = 20;
  24. var DEFAULT_IMAGE_HEIGHT = 20;
  25. var LABEL_OFFSET = 10;
  26. var CANVAS_POSITION_DEFAULT = "canvas_position_default";
  27. function getSquareMarkerCoords(radius) {
  28. return [-radius, -radius, radius, -radius, radius, radius, -radius, radius, -radius, -radius]
  29. }
  30. function getPolygonMarkerCoords(radius) {
  31. var r = _ceil(radius);
  32. return [-r, 0, 0, -r, r, 0, 0, r, -r, 0]
  33. }
  34. function getCrossMarkerCoords(radius) {
  35. var r = _ceil(radius);
  36. var floorHalfRadius = _floor(r / 2);
  37. var ceilHalfRadius = _ceil(r / 2);
  38. return [-r, -floorHalfRadius, -floorHalfRadius, -r, 0, -ceilHalfRadius, floorHalfRadius, -r, r, -floorHalfRadius, ceilHalfRadius, 0, r, floorHalfRadius, floorHalfRadius, r, 0, ceilHalfRadius, -floorHalfRadius, r, -r, floorHalfRadius, -ceilHalfRadius, 0]
  39. }
  40. function getTriangleDownMarkerCoords(radius) {
  41. return [-radius, -radius, radius, -radius, 0, radius, -radius, -radius]
  42. }
  43. function getTriangleUpMarkerCoords(radius) {
  44. return [-radius, radius, radius, radius, 0, -radius, -radius, radius]
  45. }
  46. module.exports = {
  47. deleteLabel: function() {
  48. this._label.dispose();
  49. this._label = null
  50. },
  51. _hasGraphic: function() {
  52. return this.graphic
  53. },
  54. clearVisibility: function() {
  55. var that = this;
  56. var graphic = that.graphic;
  57. if (graphic && graphic.attr("visibility")) {
  58. graphic.attr({
  59. visibility: null
  60. })
  61. }
  62. },
  63. isVisible: function() {
  64. return this.inVisibleArea && this.series.isVisible()
  65. },
  66. setInvisibility: function() {
  67. var that = this;
  68. var graphic = that.graphic;
  69. if (graphic && "hidden" !== graphic.attr("visibility")) {
  70. graphic.attr({
  71. visibility: "hidden"
  72. })
  73. }
  74. that._errorBar && that._errorBar.attr({
  75. visibility: "hidden"
  76. });
  77. that._label.draw(false)
  78. },
  79. clearMarker: function() {
  80. var graphic = this.graphic;
  81. graphic && graphic.attr(this._emptySettings)
  82. },
  83. _createLabel: function() {
  84. this._label = new labelModule.Label({
  85. renderer: this.series._renderer,
  86. labelsGroup: this.series._labelsGroup,
  87. point: this
  88. })
  89. },
  90. _updateLabelData: function() {
  91. this._label.setData(this._getLabelFormatObject())
  92. },
  93. _updateLabelOptions: function() {
  94. !this._label && this._createLabel();
  95. this._label.setOptions(this._options.label)
  96. },
  97. _checkImage: function(image) {
  98. return _isDefined(image) && ("string" === typeof image || _isDefined(image.url))
  99. },
  100. _fillStyle: function() {
  101. this._styles = this._options.styles
  102. },
  103. _checkSymbol: function(oldOptions, newOptions) {
  104. var oldSymbol = oldOptions.symbol;
  105. var newSymbol = newOptions.symbol;
  106. var symbolChanged = "circle" === oldSymbol && "circle" !== newSymbol || "circle" !== oldSymbol && "circle" === newSymbol;
  107. var imageChanged = this._checkImage(oldOptions.image) !== this._checkImage(newOptions.image);
  108. return !!(symbolChanged || imageChanged)
  109. },
  110. _populatePointShape: function(symbol, radius) {
  111. switch (symbol) {
  112. case "square":
  113. return getSquareMarkerCoords(radius);
  114. case "polygon":
  115. return getPolygonMarkerCoords(radius);
  116. case "triangle":
  117. case "triangleDown":
  118. return getTriangleDownMarkerCoords(radius);
  119. case "triangleUp":
  120. return getTriangleUpMarkerCoords(radius);
  121. case "cross":
  122. return getCrossMarkerCoords(radius)
  123. }
  124. },
  125. hasCoords: function() {
  126. return null !== this.x && null !== this.y
  127. },
  128. correctValue: function(correction) {
  129. var that = this;
  130. var axis = that.series.getValueAxis();
  131. if (that.hasValue()) {
  132. that.value = that.properValue = axis.validateUnit(that.initialValue.valueOf() + correction.valueOf());
  133. that.minValue = axis.validateUnit(correction)
  134. }
  135. },
  136. resetCorrection: function() {
  137. this.value = this.properValue = this.initialValue;
  138. this.minValue = CANVAS_POSITION_DEFAULT
  139. },
  140. resetValue: function() {
  141. var that = this;
  142. if (that.hasValue()) {
  143. that.value = that.properValue = that.initialValue = 0;
  144. that.minValue = 0;
  145. that._label.setDataField("value", that.value)
  146. }
  147. },
  148. _getTranslates: function(animationEnabled) {
  149. var translateX = this.x;
  150. var translateY = this.y;
  151. if (animationEnabled) {
  152. if (this._options.rotated) {
  153. translateX = this.defaultX
  154. } else {
  155. translateY = this.defaultY
  156. }
  157. }
  158. return {
  159. x: translateX,
  160. y: translateY
  161. }
  162. },
  163. _createImageMarker: function(renderer, settings, options) {
  164. var width = options.width || DEFAULT_IMAGE_WIDTH;
  165. var height = options.height || DEFAULT_IMAGE_HEIGHT;
  166. return renderer.image(-_round(.5 * width), -_round(.5 * height), width, height, options.url ? options.url.toString() : options.toString(), "center").attr({
  167. translateX: settings.translateX,
  168. translateY: settings.translateY,
  169. visibility: settings.visibility
  170. })
  171. },
  172. _createSymbolMarker: function(renderer, pointSettings) {
  173. var marker;
  174. var symbol = this._options.symbol;
  175. if ("circle" === symbol) {
  176. delete pointSettings.points;
  177. marker = renderer.circle().attr(pointSettings)
  178. } else {
  179. if ("square" === symbol || "polygon" === symbol || "triangle" === symbol || "triangleDown" === symbol || "triangleUp" === symbol || "cross" === symbol) {
  180. marker = renderer.path([], "area").attr(pointSettings).sharp()
  181. }
  182. }
  183. return marker
  184. },
  185. _createMarker: function(renderer, group, image, settings) {
  186. var that = this;
  187. var marker = that._checkImage(image) ? that._createImageMarker(renderer, settings, image) : that._createSymbolMarker(renderer, settings);
  188. if (marker) {
  189. marker.data({
  190. "chart-data-point": that
  191. }).append(group)
  192. }
  193. return marker
  194. },
  195. _getSymbolBBox: function(x, y, r) {
  196. return {
  197. x: x - r,
  198. y: y - r,
  199. width: 2 * r,
  200. height: 2 * r
  201. }
  202. },
  203. _getImageBBox: function(x, y) {
  204. var image = this._options.image;
  205. var width = image.width || DEFAULT_IMAGE_WIDTH;
  206. var height = image.height || DEFAULT_IMAGE_HEIGHT;
  207. return {
  208. x: x - _round(width / 2),
  209. y: y - _round(height / 2),
  210. width: width,
  211. height: height
  212. }
  213. },
  214. _getGraphicBBox: function() {
  215. var that = this;
  216. var options = that._options;
  217. var x = that.x;
  218. var y = that.y;
  219. var bBox;
  220. if (options.visible) {
  221. bBox = that._checkImage(options.image) ? that._getImageBBox(x, y) : that._getSymbolBBox(x, y, options.styles.normal.r)
  222. } else {
  223. bBox = {
  224. x: x,
  225. y: y,
  226. width: 0,
  227. height: 0
  228. }
  229. }
  230. return bBox
  231. },
  232. hideInsideLabel: noop,
  233. _getShiftLabelCoords: function(label) {
  234. var coord = this._addLabelAlignmentAndOffset(label, this._getLabelCoords(label));
  235. return this._checkLabelPosition(label, coord)
  236. },
  237. _drawLabel: function() {
  238. var that = this;
  239. var customVisibility = that._getCustomLabelVisibility();
  240. var label = that._label;
  241. var isVisible = that._showForZeroValues() && that.hasValue() && false !== customVisibility && (that.series.getLabelVisibility() || customVisibility);
  242. label.draw(!!isVisible)
  243. },
  244. correctLabelPosition: function(label) {
  245. var that = this;
  246. var coord = that._getShiftLabelCoords(label);
  247. if (!that.hideInsideLabel(label, coord)) {
  248. label.setFigureToDrawConnector(that._getLabelConnector(label.pointPosition));
  249. label.shift(_round(coord.x), _round(coord.y))
  250. }
  251. },
  252. _showForZeroValues: function() {
  253. return true
  254. },
  255. _getLabelConnector: function(pointPosition) {
  256. var bBox = this._getGraphicBBox(pointPosition);
  257. var w2 = bBox.width / 2;
  258. var h2 = bBox.height / 2;
  259. return {
  260. x: bBox.x + w2,
  261. y: bBox.y + h2,
  262. r: this._options.visible ? Math.max(w2, h2) : 0
  263. }
  264. },
  265. _getPositionFromLocation: function() {
  266. return {
  267. x: this.x,
  268. y: this.y
  269. }
  270. },
  271. _isPointInVisibleArea: function(visibleArea, graphicBBox) {
  272. return visibleArea.minX <= graphicBBox.x + graphicBBox.width && visibleArea.maxX >= graphicBBox.x && visibleArea.minY <= graphicBBox.y + graphicBBox.height && visibleArea.maxY >= graphicBBox.y
  273. },
  274. _checkLabelPosition: function(label, coord) {
  275. var that = this;
  276. var visibleArea = that._getVisibleArea();
  277. var labelBBox = label.getBoundingRect();
  278. var graphicBBox = that._getGraphicBBox(label.pointPosition);
  279. var offset = LABEL_OFFSET;
  280. if (that._isPointInVisibleArea(visibleArea, graphicBBox)) {
  281. if (!that._options.rotated) {
  282. if (visibleArea.minX > coord.x) {
  283. coord.x = visibleArea.minX
  284. }
  285. if (visibleArea.maxX < coord.x + labelBBox.width) {
  286. coord.x = visibleArea.maxX - labelBBox.width
  287. }
  288. if (visibleArea.minY > coord.y) {
  289. coord.y = graphicBBox.y + graphicBBox.height + offset
  290. }
  291. if (visibleArea.maxY < coord.y + labelBBox.height) {
  292. coord.y = graphicBBox.y - labelBBox.height - offset
  293. }
  294. } else {
  295. if (visibleArea.minX > coord.x) {
  296. coord.x = graphicBBox.x + graphicBBox.width + offset
  297. }
  298. if (visibleArea.maxX < coord.x + labelBBox.width) {
  299. coord.x = graphicBBox.x - offset - labelBBox.width
  300. }
  301. if (visibleArea.minY > coord.y) {
  302. coord.y = visibleArea.minY
  303. }
  304. if (visibleArea.maxY < coord.y + labelBBox.height) {
  305. coord.y = visibleArea.maxY - labelBBox.height
  306. }
  307. }
  308. }
  309. return coord
  310. },
  311. _addLabelAlignmentAndOffset: function(label, coord) {
  312. var labelBBox = label.getBoundingRect();
  313. var labelOptions = label.getLayoutOptions();
  314. if (!this._options.rotated) {
  315. if ("left" === labelOptions.alignment) {
  316. coord.x += labelBBox.width / 2
  317. } else {
  318. if ("right" === labelOptions.alignment) {
  319. coord.x -= labelBBox.width / 2
  320. }
  321. }
  322. }
  323. coord.x += labelOptions.horizontalOffset;
  324. coord.y += labelOptions.verticalOffset;
  325. return coord
  326. },
  327. _getLabelCoords: function(label) {
  328. return this._getLabelCoordOfPosition(label, this._getLabelPosition(label.pointPosition))
  329. },
  330. _getLabelCoordOfPosition: function(label, position) {
  331. var that = this;
  332. var labelBBox = label.getBoundingRect();
  333. var graphicBBox = that._getGraphicBBox(label.pointPosition);
  334. var offset = LABEL_OFFSET;
  335. var centerY = graphicBBox.height / 2 - labelBBox.height / 2;
  336. var centerX = graphicBBox.width / 2 - labelBBox.width / 2;
  337. var x = graphicBBox.x;
  338. var y = graphicBBox.y;
  339. switch (position) {
  340. case "left":
  341. x -= labelBBox.width + offset;
  342. y += centerY;
  343. break;
  344. case "right":
  345. x += graphicBBox.width + offset;
  346. y += centerY;
  347. break;
  348. case "top":
  349. x += centerX;
  350. y -= labelBBox.height + offset;
  351. break;
  352. case "bottom":
  353. x += centerX;
  354. y += graphicBBox.height + offset;
  355. break;
  356. case "inside":
  357. x += centerX;
  358. y += centerY
  359. }
  360. return {
  361. x: x,
  362. y: y
  363. }
  364. },
  365. _drawMarker: function(renderer, group, animationEnabled) {
  366. var that = this;
  367. var options = that._options;
  368. var translates = that._getTranslates(animationEnabled);
  369. var style = that._getStyle();
  370. that.graphic = that._createMarker(renderer, group, options.image, _extend({
  371. translateX: translates.x,
  372. translateY: translates.y,
  373. points: that._populatePointShape(options.symbol, style.r)
  374. }, style))
  375. },
  376. _getErrorBarSettings: function() {
  377. return {
  378. visibility: "visible"
  379. }
  380. },
  381. _getErrorBarBaseEdgeLength: function() {
  382. return 2 * this.getPointRadius()
  383. },
  384. _drawErrorBar: function(renderer, group) {
  385. if (!this._options.errorBars) {
  386. return
  387. }
  388. var that = this;
  389. var options = that._options;
  390. var errorBarOptions = options.errorBars;
  391. var points = [];
  392. var settings;
  393. var pos = that._errorBarPos;
  394. var high = that._highErrorCoord;
  395. var low = that._lowErrorCoord;
  396. var displayMode = _normalizeEnum(errorBarOptions.displayMode);
  397. var isHighDisplayMode = "high" === displayMode;
  398. var isLowDisplayMode = "low" === displayMode;
  399. var highErrorOnly = (isHighDisplayMode || !_isDefined(low)) && _isDefined(high) && !isLowDisplayMode;
  400. var lowErrorOnly = (isLowDisplayMode || !_isDefined(high)) && _isDefined(low) && !isHighDisplayMode;
  401. var edgeLength = errorBarOptions.edgeLength;
  402. if (edgeLength <= 1 && edgeLength > 0) {
  403. edgeLength = this._getErrorBarBaseEdgeLength() * errorBarOptions.edgeLength
  404. }
  405. edgeLength = _floor(parseInt(edgeLength) / 2);
  406. highErrorOnly && (low = that._baseErrorBarPos);
  407. lowErrorOnly && (high = that._baseErrorBarPos);
  408. if ("none" !== displayMode && _isDefined(high) && _isDefined(low) && _isDefined(pos)) {
  409. !lowErrorOnly && points.push([pos - edgeLength, high, pos + edgeLength, high]);
  410. points.push([pos, high, pos, low]);
  411. !highErrorOnly && points.push([pos + edgeLength, low, pos - edgeLength, low]);
  412. options.rotated && each(points, function(_, p) {
  413. p.reverse()
  414. });
  415. settings = that._getErrorBarSettings(errorBarOptions);
  416. if (!that._errorBar) {
  417. that._errorBar = renderer.path(points, "line").attr(settings).append(group)
  418. } else {
  419. settings.points = points;
  420. that._errorBar.attr(settings)
  421. }
  422. } else {
  423. that._errorBar && that._errorBar.attr({
  424. visibility: "hidden"
  425. })
  426. }
  427. },
  428. getTooltipParams: function() {
  429. var that = this;
  430. var graphic = that.graphic;
  431. return {
  432. x: that.x,
  433. y: that.y,
  434. offset: graphic ? graphic.getBBox().height / 2 : 0
  435. }
  436. },
  437. setPercentValue: function(absTotal, total, leftHoleTotal, rightHoleTotal) {
  438. var that = this;
  439. var valuePercent = that.value / absTotal || 0;
  440. var minValuePercent = that.minValue / absTotal || 0;
  441. var percent = valuePercent - minValuePercent;
  442. that._label.setDataField("percent", percent);
  443. that._label.setDataField("total", total);
  444. if (that.series.isFullStackedSeries() && that.hasValue()) {
  445. if (that.leftHole) {
  446. that.leftHole /= absTotal - leftHoleTotal;
  447. that.minLeftHole /= absTotal - leftHoleTotal
  448. }
  449. if (that.rightHole) {
  450. that.rightHole /= absTotal - rightHoleTotal;
  451. that.minRightHole /= absTotal - rightHoleTotal
  452. }
  453. that.value = that.properValue = valuePercent;
  454. that.minValue = !minValuePercent ? that.minValue : minValuePercent
  455. }
  456. },
  457. _storeTrackerR: function() {
  458. var that = this;
  459. var navigator = window.navigator;
  460. var r = that._options.styles.normal.r;
  461. var minTrackerSize = windowUtils.hasProperty("ontouchstart") || navigator.msPointerEnabled && navigator.msMaxTouchPoints || navigator.pointerEnabled && navigator.maxTouchPoints ? 20 : 6;
  462. that._options.trackerR = r < minTrackerSize ? minTrackerSize : r;
  463. return that._options.trackerR
  464. },
  465. _translateErrorBars: function() {
  466. var that = this;
  467. var options = that._options;
  468. var rotated = options.rotated;
  469. var errorBars = options.errorBars;
  470. var translator = that._getValTranslator();
  471. if (!errorBars) {
  472. return
  473. }
  474. _isDefined(that.lowError) && (that._lowErrorCoord = translator.translate(that.lowError));
  475. _isDefined(that.highError) && (that._highErrorCoord = translator.translate(that.highError));
  476. that._errorBarPos = _floor(rotated ? that.vy : that.vx);
  477. that._baseErrorBarPos = "stdDeviation" === errorBars.type ? that._lowErrorCoord + (that._highErrorCoord - that._lowErrorCoord) / 2 : rotated ? that.vx : that.vy
  478. },
  479. _translate: function() {
  480. var that = this;
  481. var valTranslator = that._getValTranslator();
  482. var argTranslator = that._getArgTranslator();
  483. if (that._options.rotated) {
  484. that.vx = that.x = valTranslator.translate(that.value);
  485. that.vy = that.y = argTranslator.translate(that.argument);
  486. that.minX = valTranslator.translate(that.minValue);
  487. that.defaultX = valTranslator.translate(CANVAS_POSITION_DEFAULT)
  488. } else {
  489. that.vy = that.y = valTranslator.translate(that.value);
  490. that.vx = that.x = argTranslator.translate(that.argument);
  491. that.minY = valTranslator.translate(that.minValue);
  492. that.defaultY = valTranslator.translate(CANVAS_POSITION_DEFAULT)
  493. }
  494. that._translateErrorBars();
  495. that._calculateVisibility(that.x, that.y)
  496. },
  497. _updateData: function(data) {
  498. var that = this;
  499. that.value = that.properValue = that.initialValue = that.originalValue = data.value;
  500. that.minValue = that.initialMinValue = that.originalMinValue = _isDefined(data.minValue) ? data.minValue : CANVAS_POSITION_DEFAULT
  501. },
  502. _getImageSettings: function(image) {
  503. return {
  504. href: image.url || image.toString(),
  505. width: image.width || DEFAULT_IMAGE_WIDTH,
  506. height: image.height || DEFAULT_IMAGE_HEIGHT
  507. }
  508. },
  509. getCrosshairData: function() {
  510. var that = this;
  511. var r = that._options.rotated;
  512. var value = that.properValue;
  513. var argument = that.argument;
  514. return {
  515. x: that.vx,
  516. y: that.vy,
  517. xValue: r ? value : argument,
  518. yValue: r ? argument : value,
  519. axis: that.series.axis
  520. }
  521. },
  522. getPointRadius: function() {
  523. var style = this._getStyle();
  524. var options = this._options;
  525. var r = style.r;
  526. var extraSpace;
  527. var symbol = options.symbol;
  528. var isSquare = "square" === symbol;
  529. var isTriangle = "triangle" === symbol || "triangleDown" === symbol || "triangleUp" === symbol;
  530. if (options.visible && !options.image && r) {
  531. extraSpace = style["stroke-width"] / 2;
  532. return (isSquare || isTriangle ? 1.4 * r : r) + extraSpace
  533. }
  534. return 0
  535. },
  536. _updateMarker: function(animationEnabled, style) {
  537. var that = this;
  538. var options = that._options;
  539. var settings;
  540. var image = options.image;
  541. var visibility = !that.isVisible() ? {
  542. visibility: "hidden"
  543. } : {};
  544. if (that._checkImage(image)) {
  545. settings = _extend({}, {
  546. visibility: style.visibility
  547. }, visibility, that._getImageSettings(image))
  548. } else {
  549. settings = _extend({}, style, visibility, {
  550. points: that._populatePointShape(options.symbol, style.r)
  551. })
  552. }
  553. if (!animationEnabled) {
  554. settings.translateX = that.x;
  555. settings.translateY = that.y
  556. }
  557. that.graphic.attr(settings).sharp()
  558. },
  559. _getLabelFormatObject: function() {
  560. var that = this;
  561. return {
  562. argument: that.initialArgument,
  563. value: that.initialValue,
  564. originalArgument: that.originalArgument,
  565. originalValue: that.originalValue,
  566. seriesName: that.series.name,
  567. lowErrorValue: that.lowError,
  568. highErrorValue: that.highError,
  569. point: that
  570. }
  571. },
  572. _getLabelPosition: function() {
  573. var rotated = this._options.rotated;
  574. if (this.initialValue > 0) {
  575. return rotated ? "right" : "top"
  576. } else {
  577. return rotated ? "left" : "bottom"
  578. }
  579. },
  580. _getFormatObject: function(tooltip) {
  581. var that = this;
  582. var labelFormatObject = that._label.getData();
  583. return _extend({}, labelFormatObject, {
  584. argumentText: tooltip.formatValue(that.initialArgument, "argument"),
  585. valueText: tooltip.formatValue(that.initialValue)
  586. }, _isDefined(labelFormatObject.percent) ? {
  587. percentText: tooltip.formatValue(labelFormatObject.percent, "percent")
  588. } : {}, _isDefined(labelFormatObject.total) ? {
  589. totalText: tooltip.formatValue(labelFormatObject.total)
  590. } : {})
  591. },
  592. getMarkerVisibility: function() {
  593. return this._options.visible
  594. },
  595. coordsIn: function(x, y) {
  596. var trackerRadius = this._storeTrackerR();
  597. return x >= this.x - trackerRadius && x <= this.x + trackerRadius && y >= this.y - trackerRadius && y <= this.y + trackerRadius
  598. },
  599. getMinValue: function(noErrorBar) {
  600. var errorBarOptions = this._options.errorBars;
  601. if (errorBarOptions && !noErrorBar) {
  602. var displayMode = errorBarOptions.displayMode;
  603. var lowValue = "high" !== displayMode && _isDefined(this.lowError) ? this.lowError : this.value;
  604. var highValue = "low" !== displayMode && _isDefined(this.highError) ? this.highError : this.value;
  605. return lowValue < highValue ? lowValue : highValue
  606. } else {
  607. return this.value
  608. }
  609. },
  610. getMaxValue: function(noErrorBar) {
  611. var errorBarOptions = this._options.errorBars;
  612. if (errorBarOptions && !noErrorBar) {
  613. var displayMode = errorBarOptions.displayMode;
  614. var lowValue = "high" !== displayMode && _isDefined(this.lowError) ? this.lowError : this.value;
  615. var highValue = "low" !== displayMode && _isDefined(this.highError) ? this.highError : this.value;
  616. return lowValue > highValue ? lowValue : highValue
  617. } else {
  618. return this.value
  619. }
  620. }
  621. };