devextreme
Version:
HTML5 JavaScript Component Suite for Responsive Web Development
58 lines (56 loc) • 2.31 kB
JavaScript
/**
* DevExtreme (viz/sankey/tooltip.js)
* Version: 18.2.18
* 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/
*/
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.setTooltipCustomOptions = setTooltipCustomOptions;
var _extend = require("../../core/utils/extend").extend,
isFunction = require("../../core/utils/type").isFunction,
defaultCustomizeLinkTooltip = function(info) {
return {
html: "<strong>" + info.source + " > " + info.target + "</strong><br/>Weight: " + info.weight
}
},
defaultCustomizeNodeTooltip = function(info) {
return {
html: "<strong>" + info.title + "</strong><br/>Incoming weight: " + info.weightIn + "<br/>Outgoing weight: " + info.weightOut
}
},
generateCustomCallback = function(customCallback, defaultCallback) {
return function(objectInfo) {
var res = isFunction(customCallback) ? customCallback.call(objectInfo, objectInfo) : {};
if (!res.hasOwnProperty("html") && !res.hasOwnProperty("text")) {
res = _extend(res, defaultCallback.call(objectInfo, objectInfo))
}
return res
}
};
function setTooltipCustomOptions(sankey) {
sankey.prototype._setTooltipOptions = function() {
var tooltip = this._tooltip,
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()
}
}