| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- /**
- * DevExtreme (viz/tree_map/tooltip.js)
- * Version: 19.1.16
- * Build date: Tue Oct 18 2022
- *
- * Copyright (c) 2012 - 2022 Developer Express Inc. ALL RIGHTS RESERVED
- * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
- */
- "use strict";
- var proto = require("./tree_map.base").prototype;
- var expand = require("../core/helpers").expand;
- require("./api");
- expand(proto, "_extendProxyType", function(proto) {
- var that = this;
- proto.showTooltip = function(coords) {
- that._showTooltip(this._id, coords)
- }
- });
- expand(proto, "_onNodesCreated", function() {
- if (this._tooltipIndex >= 0) {
- this._tooltip.hide()
- }
- this._tooltipIndex = -1
- });
- expand(proto, "_onTilingPerformed", function() {
- if (this._tooltipIndex >= 0) {
- this._moveTooltip(this._nodes[this._tooltipIndex])
- }
- });
- function getCoords(rect, renderer) {
- var offset = renderer.getRootOffset();
- return [(rect[0] + rect[2]) / 2 + offset.left, (rect[1] + rect[3]) / 2 + offset.top]
- }
- proto._showTooltip = function(index, coords) {
- var that = this;
- var tooltip = that._tooltip;
- var node = that._nodes[index];
- var state = that._tooltipIndex === index || tooltip.show({
- value: node.value,
- valueText: tooltip.formatValue(node.value),
- node: node.proxy
- }, {
- x: 0,
- y: 0,
- offset: 0
- }, {
- node: node.proxy
- });
- if (state) {
- that._moveTooltip(node, coords)
- } else {
- tooltip.hide()
- }
- that._tooltipIndex = state ? index : -1
- };
- proto._moveTooltip = function(node, coords) {
- var xy = coords || node.rect && getCoords(node.rect, this._renderer) || [-1e3, -1e3];
- this._tooltip.move(xy[0], xy[1], 0)
- };
- proto.hideTooltip = function() {
- if (this._tooltipIndex >= 0) {
- this._tooltipIndex = -1;
- this._tooltip.hide()
- }
- };
- require("./tree_map.base").addPlugin(require("../core/tooltip").plugin);
|