UNPKG

@visactor/vtable

Version:

canvas table width high performance

85 lines (79 loc) 3.54 kB
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; }; import { isEmpty, isValid, merge } from "@visactor/vutils"; import { isPercent } from "../../../tools/calc"; import { transformComponentStyle, transformLegendTitleAttributes, transformToGraphic } from "../../util/transform"; const defaultLegendSpec = { orient: "bottom", position: "middle", padding: 30, title: { visible: !1, padding: 0, textStyle: { fontSize: 14, fill: "#000000", fontWeight: "normal" }, space: 12 }, item: { visible: !0, spaceCol: 10, spaceRow: 10, padding: 2, background: { state: { selectedHover: { fill: "gray", fillOpacity: .7 }, unSelectedHover: { fill: "gray", fillOpacity: .2 } } }, shape: { space: 4, state: { unSelected: { fillOpacity: .5 } } }, label: { space: 4, style: { fill: "#89909D", fontSize: 14 }, state: { unSelected: { fillOpacity: .5 } } } }, allowAllCanceled: !0, visible: !0 }; export function getLegendAttributes(spec, rect) { const _a = merge({}, defaultLegendSpec, spec), {title: title = {}, item: item = {}, pager: pager = {}, background: background = {}, type: type, id: id, visible: visible, orient: orient, position: position, data: data, filter: filter, regionId: regionId, regionIndex: regionIndex, seriesIndex: seriesIndex, seriesId: seriesId, padding: padding} = _a, attrs = __rest(_a, [ "title", "item", "pager", "background", "type", "id", "visible", "orient", "position", "data", "filter", "regionId", "regionIndex", "seriesIndex", "seriesId", "padding" ]); return title.visible && (attrs.title = transformLegendTitleAttributes(title)), isEmpty(item.focusIconStyle) || transformToGraphic(item.focusIconStyle), transformComponentStyle(item.shape), transformComponentStyle(item.label), transformComponentStyle(item.value), transformComponentStyle(item.background), isPercent(item.maxWidth) && (item.maxWidth = Number(item.maxWidth.substring(0, item.maxWidth.length - 1)) * rect.width / 100), isPercent(item.width) && (item.width = Number(item.width.substring(0, item.width.length - 1)) * rect.width / 100), isPercent(item.height) && (item.height = Number(item.height.substring(0, item.height.length - 1)) * rect.width / 100), attrs.item = item, isEmpty(pager.textStyle) || transformToGraphic(pager.textStyle), transformComponentStyle(pager.handler), attrs.pager = pager, background.visible && !isEmpty(background.style) && (merge(attrs, background.style), isValid(background.padding) && (attrs.padding = background.padding)), attrs; } //# sourceMappingURL=get-discrete-legend-attributes.js.map