@visactor/vtable
Version:
canvas table width high performance
67 lines (65 loc) • 3.25 kB
JavaScript
import { createRect, createArc, createPolygon } from "./../../vrender";
export function createMark(marked, cellGroup, table) {
if ("boolean" == typeof marked) {
const mark = createArc({
x: cellGroup.attribute.width,
y: 0,
startAngle: Math.PI / 2,
endAngle: Math.PI,
outerRadius: 6,
fill: "#3073F2",
pickable: !1
});
mark.name = "mark", cellGroup.appendChild(mark);
} else {
const {bgColor: bgColor = "#3073F2", shape: shape = "sector", position: position = "right-top", size: size = 10, offset: offset = 0} = marked;
let x, y, startAngle, endAngle, fill, mark;
if ("sector" === shape) "right-top" === position ? (x = cellGroup.attribute.width - offset,
y = offset, startAngle = Math.PI / 2, endAngle = Math.PI) : "left-top" === position ? (x = offset,
y = offset, startAngle = 0, endAngle = Math.PI / 2) : "right-bottom" === position ? (x = cellGroup.attribute.width - offset,
y = cellGroup.attribute.height - offset, startAngle = Math.PI, endAngle = Math.PI / 2 * 3) : "left-bottom" === position && (x = offset,
y = cellGroup.attribute.height - offset, startAngle = Math.PI / 2 * 3, endAngle = 2 * Math.PI),
fill = bgColor, mark = createArc({
x: x,
y: y,
startAngle: startAngle,
endAngle: endAngle,
outerRadius: size,
fill: fill,
pickable: !1
}); else if ("triangle" === shape) {
let x2, y2, x3, y3;
"right-top" === position ? (x = cellGroup.attribute.width - offset, y = offset,
x2 = x - size, y2 = y, x3 = x, y3 = y + size) : "left-top" === position ? (x = offset,
y = offset, x2 = x + size, y2 = y, x3 = x, y3 = y + size) : "right-bottom" === position ? (x = cellGroup.attribute.width - offset,
y = cellGroup.attribute.height - offset, x2 = x - size, y2 = y, x3 = x, y3 = y - size) : "left-bottom" === position && (x = offset,
y = cellGroup.attribute.height - offset, x2 = x + size, y2 = y, x3 = x, y3 = y - size),
fill = bgColor, mark = createPolygon({
points: [ {
x: x,
y: y
}, {
x: x2,
y: y2
}, {
x: x3,
y: y3
} ],
fill: fill,
pickable: !1
});
} else "rect" === shape && ("right-top" === position ? (x = cellGroup.attribute.width - size - offset,
y = offset) : "left-top" === position ? (x = offset, y = offset) : "right-bottom" === position ? (x = cellGroup.attribute.width - size - offset,
y = cellGroup.attribute.height - size - offset) : "left-bottom" === position && (x = offset,
y = cellGroup.attribute.height - size - offset), fill = bgColor, mark = createRect({
x: x,
y: y,
width: size,
height: size,
fill: fill,
pickable: !1
}));
mark.name = "mark", cellGroup.appendChild(mark);
}
}
//# sourceMappingURL=mark.js.map