Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_chart() {
const Shape = G2.Shape
const Util = G2.Util
Shape.registerShape('polygon', 'boundary-polygon', {
draw(cfg, container) {
if (!Util.isEmpty(cfg.points)) {
const attrs = {
stroke: '#fff',
lineWidth: 1,
fill: cfg.color,
fillOpacity: cfg.opacity
}
const points = cfg.points
const path = [
['M', points[0].x, points[0].y],
['L', points[1].x, points[1].y],
['L', points[2].x, points[2].y],
['L', points[3].x, points[3].y],
['Z']
function getFillAttrs(cfg: any) {
const defaultAttrs = G2.Global.shape.interval;
const attrs = G2.Util.mix({}, defaultAttrs, {
fill: cfg.color,
stroke: cfg.color,
fillOpacity: cfg.opacity,
}, cfg.style);
return attrs;
}
drawShape(cfg: any, group: any) {
const attrs = getFillAttrs(cfg);
let rectPath = getRectPath(cfg.points);
rectPath = this.parsePath(rectPath);
const interval = group.addShape('path', {
attrs: G2.Util.mix(attrs, {
path: rectPath,
}),
});
if (cfg.nextPoints) {
let linkPath = [
['M', cfg.points[2].x, cfg.points[2].y],
['L', cfg.nextPoints[0].x, cfg.nextPoints[0].y],
];
if (cfg.nextPoints[0].y === 0) {
linkPath[1] = ['L', cfg.nextPoints[1].x, cfg.nextPoints[1].y];
}
linkPath = this.parsePath(linkPath);
group.addShape('path', {