UNPKG

@visactor/vtable

Version:

canvas table width high performance

140 lines (134 loc) 5.38 kB
"use strict"; 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.getContinuousLegendAttributes = void 0; const vutils_1 = require("@visactor/vutils"), transform_1 = require("../../util/transform"), defaultContinueLegendSpec = { orient: "right", position: "middle", padding: 30, title: { visible: !1, padding: 0, textStyle: { fontSize: 14, fontWeight: "normal", fill: { type: "palette", key: "titleFontColor" } }, space: 12 }, handler: { visible: !0 }, startText: { style: { fontSize: 14, fontWeight: "normal", fill: { type: "palette", key: "labelFontColor" } } }, endText: { style: { fontSize: 14, fontWeight: "normal", fill: { type: "palette", key: "labelFontColor" } } }, handlerText: { style: { fontSize: 14, fontWeight: "normal", fill: { type: "palette", key: "labelFontColor" } } } }, defaultColorLegendSpec = { horizontal: Object.assign(Object.assign({}, defaultContinueLegendSpec), { rail: { width: 200, height: 8, style: { fill: "rgba(0,0,0,0.04)" } } }), vertical: Object.assign(Object.assign({}, defaultContinueLegendSpec), { rail: { width: 8, height: 200, style: { fill: "rgba(0,0,0,0.04)" } } }) }, defaultSizeLegendSpec = { horizontal: Object.assign({ sizeBackground: { fill: "#cdcdcd" }, track: { style: { fill: "rgba(20,20,20,0.1)" } }, rail: { width: 200, height: 4, style: { fill: "rgba(0,0,0,0.04)" } } }, defaultContinueLegendSpec), vertical: Object.assign({ sizeBackground: { fill: "#cdcdcd" }, track: { style: { fill: "rgba(20,20,20,0.1)" } }, rail: { width: 4, height: 200, style: { fill: "rgba(0,0,0,0.04)" } } }, defaultContinueLegendSpec) }; function getContinuousLegendAttributes(spec, rect) { const _a = (0, vutils_1.merge)({}, ("color" === spec.type ? defaultColorLegendSpec : defaultSizeLegendSpec)["bottom" === spec.orient || "top" === spec.orient ? "horizontal" : "vertical"], 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, transform_1.transformLegendTitleAttributes)(title)), attrs.showHandler = !1 !== handler.visible, (0, vutils_1.isEmpty)(handler.style) || (attrs.handlerStyle = (0, transform_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, transform_1.transformToGraphic)(rail.style)), (0, vutils_1.isEmpty)(track.style) || (attrs.trackStyle = (0, transform_1.transformToGraphic)(track.style)), attrs.startText = (0, transform_1.transformComponentStyle)(startText), attrs.endText = (0, transform_1.transformComponentStyle)(endText), attrs.handlerText = (0, transform_1.transformComponentStyle)(handlerText), (0, vutils_1.isEmpty)(sizeBackground) || (attrs.sizeBackground = (0, transform_1.transformToGraphic)(sizeBackground)), background.visible && !(0, vutils_1.isEmpty)(background.style) && ((0, vutils_1.merge)(attrs, background.style), (0, vutils_1.isValid)(background.padding) && (attrs.padding = background.padding)), attrs; } exports.getContinuousLegendAttributes = getContinuousLegendAttributes; //# sourceMappingURL=get-continue-legend-attributes.js.map