@visactor/vchart
Version:
charts lib based @visactor/VGrammar
45 lines (38 loc) • 3.36 kB
JavaScript
;
var __rest = this && this.__rest || function(s, e) {
var t = {};
for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0 && (t[p] = s[p]);
if (null != s && "function" == typeof Object.getOwnPropertySymbols) {
var i = 0;
for (p = Object.getOwnPropertySymbols(s); i < p.length; i++) e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]) && (t[p[i]] = s[p[i]]);
}
return t;
};
Object.defineProperty(exports, "__esModule", {
value: !0
}), exports.ContinuousLegendMap = exports.isContinuousLegend = exports.getContinuousLegendAttributes = void 0;
const vrender_components_1 = require("@visactor/vrender-components"), vutils_1 = require("@visactor/vutils"), vutils_extension_1 = require("@visactor/vutils-extension"), style_1 = require("../../../util/style"), util_1 = require("../util");
function getContinuousLegendAttributes(spec) {
const _a = (0, vutils_extension_1.mergeSpec)({}, spec), {title: title = {}, handler: handler = {}, rail: rail = {}, track: track = {}, startText: startText, endText: endText, handlerText: handlerText, sizeBackground: sizeBackground, background: background = {}, type: type, id: id, visible: visible, orient: orient, position: position, data: data, defaultSelected: defaultSelected, field: field, filter: filter, regionId: regionId, regionIndex: regionIndex, seriesIndex: seriesIndex, seriesId: seriesId, padding: padding} = _a, attrs = __rest(_a, [ "title", "handler", "rail", "track", "startText", "endText", "handlerText", "sizeBackground", "background", "type", "id", "visible", "orient", "position", "data", "defaultSelected", "field", "filter", "regionId", "regionIndex", "seriesIndex", "seriesId", "padding" ]);
return title.visible ? attrs.title = (0, util_1.transformLegendTitleAttributes)(title) : attrs.title = {
visible: !1
}, attrs.showHandler = !1 !== handler.visible, (0, vutils_1.isEmpty)(handler.style) || (attrs.handlerStyle = (0,
style_1.transformToGraphic)(handler.style)), (0, vutils_1.isValid)(rail.width) && (attrs.railWidth = rail.width),
(0, vutils_1.isValid)(rail.height) && (attrs.railHeight = rail.height), (0, vutils_1.isEmpty)(rail.style) || (attrs.railStyle = (0,
style_1.transformToGraphic)(rail.style)), (0, vutils_1.isEmpty)(track.style) || (attrs.trackStyle = (0,
style_1.transformToGraphic)(track.style)), attrs.startText = (0, style_1.transformComponentStyle)(startText),
attrs.endText = (0, style_1.transformComponentStyle)(endText), attrs.handlerText = (0,
style_1.transformComponentStyle)(handlerText), (0, vutils_1.isEmpty)(sizeBackground) || (attrs.sizeBackground = (0,
style_1.transformToGraphic)(sizeBackground)), background.visible && !(0, vutils_1.isEmpty)(background.style) && ((0,
vutils_extension_1.mergeSpec)(attrs, background.style), (0, vutils_1.isValid)(background.padding) && (attrs.padding = background.padding)),
attrs;
}
function isContinuousLegend(type) {
return "color" === type || "size" === type;
}
exports.getContinuousLegendAttributes = getContinuousLegendAttributes, exports.isContinuousLegend = isContinuousLegend,
exports.ContinuousLegendMap = {
color: vrender_components_1.ColorContinuousLegend,
size: vrender_components_1.SizeContinuousLegend
};
//# sourceMappingURL=util.js.map