@visactor/vtable
Version:
canvas table width high performance
133 lines (128 loc) • 4.99 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 { isEmpty, isValid, merge } from "@visactor/vutils";
import { transformComponentStyle, transformLegendTitleAttributes, transformToGraphic } from "../../util/transform";
const 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)
};
export function getContinuousLegendAttributes(spec, rect) {
const _a = 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 = transformLegendTitleAttributes(title)), 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) && (merge(attrs, background.style),
isValid(background.padding) && (attrs.padding = background.padding)), attrs;
}
//# sourceMappingURL=get-continue-legend-attributes.js.map