| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- /**
- * DevExtreme (viz/sankey/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";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.setTooltipCustomOptions = setTooltipCustomOptions;
- var _extend = require("../../core/utils/extend").extend;
- var isFunction = require("../../core/utils/type").isFunction;
- var defaultCustomizeLinkTooltip = function(info) {
- return {
- html: "<strong>".concat(info.source, " > ").concat(info.target, "</strong><br/>Weight: ").concat(info.weight)
- }
- };
- var defaultCustomizeNodeTooltip = function(info) {
- return {
- html: "<strong>".concat(info.title, "</strong><br/>Incoming weight: ").concat(info.weightIn, "<br/>Outgoing weight: ").concat(info.weightOut)
- }
- };
- var generateCustomCallback = function(customCallback, defaultCallback) {
- return function(objectInfo) {
- var res = isFunction(customCallback) ? customCallback.call(objectInfo, objectInfo) : {};
- var hasOwnProperty = Object.prototype.hasOwnProperty.bind(res);
- if (!hasOwnProperty("html") && !hasOwnProperty("text")) {
- res = _extend(res, defaultCallback.call(objectInfo, objectInfo))
- }
- return res
- }
- };
- function setTooltipCustomOptions(sankey) {
- sankey.prototype._setTooltipOptions = function() {
- var tooltip = this._tooltip;
- var options = tooltip && this._getOption("tooltip");
- tooltip && tooltip.update(_extend({}, options, {
- customizeTooltip: function(args) {
- if ("node" === args.type) {
- return generateCustomCallback(options.customizeNodeTooltip, defaultCustomizeNodeTooltip)(args.info)
- } else {
- if ("link" === args.type) {
- return generateCustomCallback(options.customizeLinkTooltip, defaultCustomizeLinkTooltip)(args.info)
- }
- }
- return {}
- },
- enabled: options.enabled
- }))
- };
- sankey.prototype.hideTooltip = function() {
- this._tooltip && this._tooltip.hide()
- }
- }
|