@visactor/vchart
Version:
charts lib based @visactor/VGrammar
43 lines (34 loc) • 2.85 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;
};
import { ColorContinuousLegend, SizeContinuousLegend } from "@visactor/vrender-components";
import { isEmpty, isValid } from "@visactor/vutils";
import { mergeSpec } from "@visactor/vutils-extension";
import { transformComponentStyle, transformToGraphic } from "../../../util/style";
import { transformLegendTitleAttributes } from "../util";
export function getContinuousLegendAttributes(spec) {
const _a = 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 = transformLegendTitleAttributes(title) : attrs.title = {
visible: !1
}, attrs.showHandler = !1 !== handler.visible, isEmpty(handler.style) || (attrs.handlerStyle = transformToGraphic(handler.style)),
isValid(rail.width) && (attrs.railWidth = rail.width), isValid(rail.height) && (attrs.railHeight = rail.height),
isEmpty(rail.style) || (attrs.railStyle = transformToGraphic(rail.style)), isEmpty(track.style) || (attrs.trackStyle = transformToGraphic(track.style)),
attrs.startText = transformComponentStyle(startText), attrs.endText = transformComponentStyle(endText),
attrs.handlerText = transformComponentStyle(handlerText), isEmpty(sizeBackground) || (attrs.sizeBackground = transformToGraphic(sizeBackground)),
background.visible && !isEmpty(background.style) && (mergeSpec(attrs, background.style),
isValid(background.padding) && (attrs.padding = background.padding)), attrs;
}
export function isContinuousLegend(type) {
return "color" === type || "size" === type;
}
export const ContinuousLegendMap = {
color: ColorContinuousLegend,
size: SizeContinuousLegend
};
//# sourceMappingURL=util.js.map