bubble_point.js 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /**
  2. * DevExtreme (viz/series/points/bubble_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 symbolPoint = require("./symbol_point");
  12. var _extend = extend;
  13. var MIN_BUBBLE_HEIGHT = 20;
  14. module.exports = _extend({}, symbolPoint, {
  15. correctCoordinates: function(diameter) {
  16. this.bubbleSize = diameter / 2
  17. },
  18. _drawMarker: function(renderer, group, animationEnabled) {
  19. var that = this;
  20. var attr = _extend({
  21. translateX: that.x,
  22. translateY: that.y
  23. }, that._getStyle());
  24. that.graphic = renderer.circle(0, 0, animationEnabled ? 0 : that.bubbleSize).smartAttr(attr).data({
  25. "chart-data-point": that
  26. }).append(group)
  27. },
  28. getTooltipParams: function(location) {
  29. var that = this;
  30. var graphic = that.graphic;
  31. if (!graphic) {
  32. return
  33. }
  34. var height = graphic.getBBox().height;
  35. return {
  36. x: that.x,
  37. y: that.y,
  38. offset: height < MIN_BUBBLE_HEIGHT || "edge" === location ? height / 2 : 0
  39. }
  40. },
  41. _getLabelFormatObject: function() {
  42. var formatObject = symbolPoint._getLabelFormatObject.call(this);
  43. formatObject.size = this.initialSize;
  44. return formatObject
  45. },
  46. _updateData: function(data) {
  47. symbolPoint._updateData.call(this, data);
  48. this.size = this.initialSize = data.size
  49. },
  50. _getGraphicBBox: function() {
  51. var that = this;
  52. return that._getSymbolBBox(that.x, that.y, that.bubbleSize)
  53. },
  54. _updateMarker: function(animationEnabled, style) {
  55. var that = this;
  56. if (!animationEnabled) {
  57. style = _extend({
  58. r: that.bubbleSize,
  59. translateX: that.x,
  60. translateY: that.y
  61. }, style)
  62. }
  63. that.graphic.smartAttr(style)
  64. },
  65. _getFormatObject: function(tooltip) {
  66. var formatObject = symbolPoint._getFormatObject.call(this, tooltip);
  67. formatObject.sizeText = tooltip.formatValue(this.initialSize);
  68. return formatObject
  69. },
  70. _storeTrackerR: function() {
  71. return this.bubbleSize
  72. },
  73. _getLabelCoords: function(label) {
  74. var coords;
  75. if ("inside" === label.getLayoutOptions().position) {
  76. coords = this._getLabelCoordOfPosition(label, "inside")
  77. } else {
  78. coords = symbolPoint._getLabelCoords.call(this, label)
  79. }
  80. return coords
  81. }
  82. });