@visactor/vchart 1.12.0-alpha.6 → 1.12.0-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/es5/index.js +1 -1
- package/build/index.js +352 -478
- package/build/index.min.js +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/cjs/chart/stack.js +2 -1
- package/cjs/chart/word-cloud/word-cloud-transformer.js +1 -2
- package/cjs/chart/word-cloud/word-cloud-transformer.js.map +1 -1
- package/cjs/compile/grammar-item.js +1 -2
- package/cjs/core/index.d.ts +1 -1
- package/cjs/core/index.js +1 -1
- package/cjs/core/index.js.map +1 -1
- package/cjs/event/event-dispatcher.js +2 -1
- package/cjs/event/index.js +1 -2
- package/cjs/series/interface/type.d.ts +0 -1
- package/cjs/series/interface/type.js +6 -7
- package/cjs/series/interface/type.js.map +1 -1
- package/cjs/series/word-cloud/base.d.ts +12 -11
- package/cjs/series/word-cloud/base.js +117 -92
- package/cjs/series/word-cloud/base.js.map +1 -1
- package/cjs/series/word-cloud/constant.js +0 -4
- package/cjs/series/word-cloud/constant.js.map +1 -1
- package/cjs/series/word-cloud/interface.d.ts +2 -22
- package/cjs/series/word-cloud/interface.js.map +1 -1
- package/esm/chart/stack.js +2 -1
- package/esm/chart/word-cloud/word-cloud-transformer.js +1 -2
- package/esm/chart/word-cloud/word-cloud-transformer.js.map +1 -1
- package/esm/compile/grammar-item.js +1 -2
- package/esm/core/index.d.ts +1 -1
- package/esm/core/index.js +1 -1
- package/esm/core/index.js.map +1 -1
- package/esm/event/event-dispatcher.js +2 -1
- package/esm/event/index.js +1 -2
- package/esm/series/interface/type.d.ts +0 -1
- package/esm/series/interface/type.js +6 -7
- package/esm/series/interface/type.js.map +1 -1
- package/esm/series/word-cloud/base.d.ts +12 -11
- package/esm/series/word-cloud/base.js +122 -93
- package/esm/series/word-cloud/base.js.map +1 -1
- package/esm/series/word-cloud/constant.js +0 -4
- package/esm/series/word-cloud/constant.js.map +1 -1
- package/esm/series/word-cloud/interface.d.ts +2 -22
- package/esm/series/word-cloud/interface.js.map +1 -1
- package/package.json +4 -4
package/build/index.js
CHANGED
|
@@ -25532,219 +25532,6 @@
|
|
|
25532
25532
|
return "vertical" === direction;
|
|
25533
25533
|
}
|
|
25534
25534
|
|
|
25535
|
-
const shapes = {
|
|
25536
|
-
triangleForward: triangleForward,
|
|
25537
|
-
triangleUpright: triangle,
|
|
25538
|
-
triangle: triangle,
|
|
25539
|
-
diamond: diamond,
|
|
25540
|
-
square: square$1,
|
|
25541
|
-
star: star,
|
|
25542
|
-
cardioid: cardioid,
|
|
25543
|
-
circle: circle,
|
|
25544
|
-
pentagon: pentagon
|
|
25545
|
-
};
|
|
25546
|
-
function diamond() {
|
|
25547
|
-
return function (theta) {
|
|
25548
|
-
const thetaPrime = theta % (2 * Math.PI / 4);
|
|
25549
|
-
return 1 / (Math.cos(thetaPrime) + Math.sin(thetaPrime));
|
|
25550
|
-
};
|
|
25551
|
-
}
|
|
25552
|
-
function star() {
|
|
25553
|
-
return function (theta) {
|
|
25554
|
-
const thetaPrime = (theta + .955) % (2 * Math.PI / 10);
|
|
25555
|
-
return (theta + .955) % (2 * Math.PI / 5) - 2 * Math.PI / 10 >= 0 ? 1 / (Math.cos(2 * Math.PI / 10 - thetaPrime) + 3.07768 * Math.sin(2 * Math.PI / 10 - thetaPrime)) : 1 / (Math.cos(thetaPrime) + 3.07768 * Math.sin(thetaPrime));
|
|
25556
|
-
};
|
|
25557
|
-
}
|
|
25558
|
-
function square$1() {
|
|
25559
|
-
return function (theta) {
|
|
25560
|
-
return Math.min(1 / Math.abs(Math.cos(theta)), 1 / Math.abs(Math.sin(theta)));
|
|
25561
|
-
};
|
|
25562
|
-
}
|
|
25563
|
-
function triangle() {
|
|
25564
|
-
return function (theta) {
|
|
25565
|
-
const thetaPrime = (theta + 3 * Math.PI / 2) % (2 * Math.PI / 3);
|
|
25566
|
-
return 1 / (Math.cos(thetaPrime) + Math.sqrt(3) * Math.sin(thetaPrime));
|
|
25567
|
-
};
|
|
25568
|
-
}
|
|
25569
|
-
function triangleForward() {
|
|
25570
|
-
return function (theta) {
|
|
25571
|
-
const thetaPrime = theta % (2 * Math.PI / 3);
|
|
25572
|
-
return 1 / (Math.cos(thetaPrime) + Math.sqrt(3) * Math.sin(thetaPrime));
|
|
25573
|
-
};
|
|
25574
|
-
}
|
|
25575
|
-
function cardioid() {
|
|
25576
|
-
return function (theta) {
|
|
25577
|
-
return 1 + Math.sin(theta);
|
|
25578
|
-
};
|
|
25579
|
-
}
|
|
25580
|
-
function circle() {
|
|
25581
|
-
return function () {
|
|
25582
|
-
return 1;
|
|
25583
|
-
};
|
|
25584
|
-
}
|
|
25585
|
-
function pentagon() {
|
|
25586
|
-
return function (theta) {
|
|
25587
|
-
const thetaPrime = (theta + .955) % (2 * Math.PI / 5);
|
|
25588
|
-
return 1 / (Math.cos(thetaPrime) + .726543 * Math.sin(thetaPrime));
|
|
25589
|
-
};
|
|
25590
|
-
}
|
|
25591
|
-
function getMaxRadiusAndCenter(shape, size) {
|
|
25592
|
-
const w = size[0],
|
|
25593
|
-
h = size[1];
|
|
25594
|
-
let maxRadius = 1;
|
|
25595
|
-
const center = [size[0] >> 1, size[1] >> 1];
|
|
25596
|
-
switch (shape) {
|
|
25597
|
-
case "cardioid":
|
|
25598
|
-
center[1] = ~~(h / 2.7 * .4), maxRadius = Math.floor(Math.min(w / 2.3, h / 2.6));
|
|
25599
|
-
break;
|
|
25600
|
-
case "triangleForward":
|
|
25601
|
-
maxRadius = h / Math.sqrt(.75) > w ? Math.floor(w / 2) : Math.floor(h / (2 * Math.sqrt(.75)));
|
|
25602
|
-
break;
|
|
25603
|
-
case "triangle":
|
|
25604
|
-
case "triangleUpright":
|
|
25605
|
-
center[1] = ~~(h / 1.5), maxRadius = Math.floor(Math.min(h / 1.5, w / 2));
|
|
25606
|
-
break;
|
|
25607
|
-
case "circle":
|
|
25608
|
-
case "diamond":
|
|
25609
|
-
case "square":
|
|
25610
|
-
case "star":
|
|
25611
|
-
case "pentagon":
|
|
25612
|
-
maxRadius = Math.floor(Math.min(w / 2, h / 2));
|
|
25613
|
-
break;
|
|
25614
|
-
default:
|
|
25615
|
-
maxRadius = Math.floor(Math.max(w / 2, h / 2));
|
|
25616
|
-
}
|
|
25617
|
-
return {
|
|
25618
|
-
maxRadius: maxRadius,
|
|
25619
|
-
center: center
|
|
25620
|
-
};
|
|
25621
|
-
}
|
|
25622
|
-
const getShapeFunction = type => shapes[type] ? shapes[type]() : shapes.circle();
|
|
25623
|
-
|
|
25624
|
-
const generateIsEmptyPixel = backgroundColor => {
|
|
25625
|
-
if (!backgroundColor || "#fff" === backgroundColor) return (imageData, y, x) => {
|
|
25626
|
-
const width = imageData.width;
|
|
25627
|
-
return 0 === imageData.data[y * width * 4 + 4 * x + 3] || 255 === imageData.data[y * width * 4 + 4 * x + 0] && 255 === imageData.data[y * width * 4 + 4 * x + 1] && 255 === imageData.data[y * width * 4 + 4 * x + 2];
|
|
25628
|
-
};
|
|
25629
|
-
const bctx = vglobal.createCanvas({
|
|
25630
|
-
width: 1,
|
|
25631
|
-
height: 1
|
|
25632
|
-
}).getContext("2d");
|
|
25633
|
-
bctx.fillStyle = backgroundColor, bctx.fillRect(0, 0, 1, 1);
|
|
25634
|
-
const bgPixel = bctx.getImageData(0, 0, 1, 1).data;
|
|
25635
|
-
return (imageData, y, x) => {
|
|
25636
|
-
const width = imageData.width;
|
|
25637
|
-
return [0, 1, 2, 3].every(i => imageData.data[4 * (y * width + x) + i] === bgPixel[i]);
|
|
25638
|
-
};
|
|
25639
|
-
};
|
|
25640
|
-
const generateMaskCanvas = (shape, width, height, cacheCanvas) => {
|
|
25641
|
-
const {
|
|
25642
|
-
backgroundColor = "#fff"
|
|
25643
|
-
} = shape,
|
|
25644
|
-
maskCanvas = cacheCanvas || vglobal.createCanvas({
|
|
25645
|
-
width: width,
|
|
25646
|
-
height: height,
|
|
25647
|
-
dpr: 1
|
|
25648
|
-
}),
|
|
25649
|
-
tempContext = maskCanvas.getContext("2d");
|
|
25650
|
-
if (cacheCanvas) {
|
|
25651
|
-
const prevWidth = cacheCanvas.width,
|
|
25652
|
-
prevHeight = cacheCanvas.height;
|
|
25653
|
-
tempContext.clearRect(0, 0, prevWidth, prevHeight), cacheCanvas.style.width = `${width}px`, cacheCanvas.style.height = `${height}px`, cacheCanvas.width = width, cacheCanvas.height = height;
|
|
25654
|
-
}
|
|
25655
|
-
return tempContext.fillStyle = backgroundColor, tempContext.fillRect(0, 0, maskCanvas.width, maskCanvas.height), "text" === shape.type ? drawTextMask(shape, maskCanvas.width, maskCanvas.height, tempContext) : "geometric" === shape.type && drawGeometricMask(shape, maskCanvas.width, maskCanvas.height, tempContext), maskCanvas;
|
|
25656
|
-
};
|
|
25657
|
-
const drawTextMask = (shape, width, height, ctx) => {
|
|
25658
|
-
const {
|
|
25659
|
-
fontFamily = "sans-serif",
|
|
25660
|
-
fontWeight = "normal",
|
|
25661
|
-
fontStyle = "normal",
|
|
25662
|
-
fontVariant = "normal",
|
|
25663
|
-
fill: fill,
|
|
25664
|
-
text: text,
|
|
25665
|
-
hollow: hollow
|
|
25666
|
-
} = shape;
|
|
25667
|
-
let baseFontSize = 12;
|
|
25668
|
-
ctx.font = `${fontStyle} ${fontVariant} ${fontWeight} ${baseFontSize}px ${fontFamily}`, ctx.textAlign = "center", ctx.textBaseline = "middle", ctx.fillStyle = null != fill ? fill : "black";
|
|
25669
|
-
const textWidth = ctx.measureText(text).width;
|
|
25670
|
-
if (hollow && (ctx.globalCompositeOperation = "xor"), textWidth > width) {
|
|
25671
|
-
const scale = Math.min(width / textWidth, height / baseFontSize);
|
|
25672
|
-
ctx.fillText(text, width / 2, height / 2), ctx.scale(scale, scale);
|
|
25673
|
-
} else baseFontSize = Math.floor(baseFontSize * width / textWidth), baseFontSize = Math.min(baseFontSize, height), ctx.font = `${fontStyle} ${fontVariant} ${fontWeight} ${baseFontSize}px ${fontFamily}`, ctx.fillText(text, width / 2, height / 2);
|
|
25674
|
-
};
|
|
25675
|
-
const generatePoints = function (center, radius) {
|
|
25676
|
-
let startAngle = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
25677
|
-
let count = arguments.length > 3 ? arguments[3] : undefined;
|
|
25678
|
-
const angle = 2 * Math.PI / count;
|
|
25679
|
-
return new Array(count).fill(0).map((entry, index) => polarToCartesian$1(center, radius, startAngle + index * angle));
|
|
25680
|
-
};
|
|
25681
|
-
const generateCardioidPoints = function (center, radius) {
|
|
25682
|
-
let startAngle = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
25683
|
-
let count = arguments.length > 3 ? arguments[3] : undefined;
|
|
25684
|
-
const angle = 2 * Math.PI / count,
|
|
25685
|
-
func = getShapeFunction("cardioid");
|
|
25686
|
-
return new Array(count).fill(0).map((entry, index) => {
|
|
25687
|
-
const theta = startAngle + index * angle,
|
|
25688
|
-
r = radius * func(theta);
|
|
25689
|
-
return polarToCartesian$1(center, r, theta);
|
|
25690
|
-
});
|
|
25691
|
-
};
|
|
25692
|
-
const drawRegularPolygon = (ctx, points) => {
|
|
25693
|
-
ctx.beginPath(), points.forEach((p, index) => {
|
|
25694
|
-
0 === index ? ctx.moveTo(p.x, p.y) : ctx.lineTo(p.x, p.y);
|
|
25695
|
-
}), ctx.closePath(), ctx.fill();
|
|
25696
|
-
};
|
|
25697
|
-
const drawCardioid = (ctx, points) => {
|
|
25698
|
-
let prev;
|
|
25699
|
-
ctx.beginPath(), points.forEach((p, index) => {
|
|
25700
|
-
0 === index ? ctx.moveTo(p.x, p.y) : ctx.bezierCurveTo(p.x, p.y, prev.x, prev.y, p.x, p.y), prev = p;
|
|
25701
|
-
}), ctx.closePath(), ctx.fill();
|
|
25702
|
-
};
|
|
25703
|
-
const drawGeometricMask = (shape, width, height, ctx) => {
|
|
25704
|
-
const {
|
|
25705
|
-
fill: fill,
|
|
25706
|
-
hollow: hollow
|
|
25707
|
-
} = shape,
|
|
25708
|
-
{
|
|
25709
|
-
center: center,
|
|
25710
|
-
maxRadius: maxRadius
|
|
25711
|
-
} = getMaxRadiusAndCenter(shape.shape, [width, height]);
|
|
25712
|
-
ctx.fillStyle = null != fill ? fill : "black", hollow && (ctx.globalCompositeOperation = "xor");
|
|
25713
|
-
const cx = center[0],
|
|
25714
|
-
cy = center[1];
|
|
25715
|
-
if ("cardioid" === shape.shape) drawCardioid(ctx, generateCardioidPoints({
|
|
25716
|
-
x: cx,
|
|
25717
|
-
y: cy
|
|
25718
|
-
}, maxRadius, 0, 100));else if ("circle" === shape.shape) ctx.beginPath(), ctx.arc(cx, cy, maxRadius, 0, 2 * Math.PI, !0), ctx.fill();else if ("diamond" === shape.shape) drawRegularPolygon(ctx, generatePoints({
|
|
25719
|
-
x: cx,
|
|
25720
|
-
y: cy
|
|
25721
|
-
}, maxRadius, -Math.PI / 2, 4));else if ("square" === shape.shape) drawRegularPolygon(ctx, generatePoints({
|
|
25722
|
-
x: cx,
|
|
25723
|
-
y: cy
|
|
25724
|
-
}, maxRadius, -Math.PI / 4, 4));else if ("pentagon" === shape.shape) drawRegularPolygon(ctx, generatePoints({
|
|
25725
|
-
x: cx,
|
|
25726
|
-
y: cy
|
|
25727
|
-
}, maxRadius, Math.PI / 2, 5));else if ("triangle" === shape.shape || "triangleUpright" === shape.shape) drawRegularPolygon(ctx, generatePoints({
|
|
25728
|
-
x: cx,
|
|
25729
|
-
y: cy
|
|
25730
|
-
}, maxRadius, -Math.PI / 2, 3));else if ("triangleForward" === shape.shape) drawRegularPolygon(ctx, generatePoints({
|
|
25731
|
-
x: cx,
|
|
25732
|
-
y: cy
|
|
25733
|
-
}, maxRadius, 0, 3));else if ("star" === shape.shape) {
|
|
25734
|
-
const outterPoints = generatePoints({
|
|
25735
|
-
x: cx,
|
|
25736
|
-
y: cy
|
|
25737
|
-
}, maxRadius, -Math.PI / 2, 5),
|
|
25738
|
-
innerPoints = generatePoints({
|
|
25739
|
-
x: cx,
|
|
25740
|
-
y: cy
|
|
25741
|
-
}, maxRadius / (2 * Math.cos(Math.PI / 5)), -Math.PI / 2 + Math.PI / 5, 5),
|
|
25742
|
-
points = [];
|
|
25743
|
-
for (let i = 0; i < 5; i++) points.push(outterPoints[i]), points.push(innerPoints[i]);
|
|
25744
|
-
drawRegularPolygon(ctx, points);
|
|
25745
|
-
} else ctx.fillRect(0, 0, width, height);
|
|
25746
|
-
};
|
|
25747
|
-
|
|
25748
25535
|
const GROUP_ATTRIBUTES = ["x", "y", "dx", "dy", "scaleX", "scaleY", "angle", "anchor", "postMatrix", "visible", "clip", "pickable", "childrenPickable", "zIndex", "cursor"];
|
|
25749
25536
|
class AbstractComponent extends Group$1 {
|
|
25750
25537
|
constructor(attributes, options) {
|
|
@@ -35795,7 +35582,7 @@
|
|
|
35795
35582
|
return x;
|
|
35796
35583
|
}
|
|
35797
35584
|
const sqrt$1 = x => x < 0 ? -Math.sqrt(-x) : Math.sqrt(x);
|
|
35798
|
-
const square = x => x < 0 ? -x * x : x * x;
|
|
35585
|
+
const square$1 = x => x < 0 ? -x * x : x * x;
|
|
35799
35586
|
const logNegative = x => -Math.log(-x);
|
|
35800
35587
|
const expNegative = x => -Math.exp(-x);
|
|
35801
35588
|
const pow10 = x => isFinite(x) ? Math.pow(10, x) : x < 0 ? 0 : x;
|
|
@@ -36683,7 +36470,7 @@
|
|
|
36683
36470
|
|
|
36684
36471
|
class SqrtScale extends LinearScale {
|
|
36685
36472
|
constructor() {
|
|
36686
|
-
super(sqrt$1, square), this.type = ScaleEnum.Sqrt;
|
|
36473
|
+
super(sqrt$1, square$1), this.type = ScaleEnum.Sqrt;
|
|
36687
36474
|
}
|
|
36688
36475
|
clone() {
|
|
36689
36476
|
return new SqrtScale().domain(this._domain, !0).range(this._range, !0).unknown(this._unknown).clamp(this.clamp(), null, !0).interpolate(this._interpolate);
|
|
@@ -43946,7 +43733,6 @@
|
|
|
43946
43733
|
SeriesMarkNameEnum["stackLabel"] = "stackLabel";
|
|
43947
43734
|
SeriesMarkNameEnum["word"] = "word";
|
|
43948
43735
|
SeriesMarkNameEnum["fillingWord"] = "fillingWord";
|
|
43949
|
-
SeriesMarkNameEnum["wordMask"] = "wordMask";
|
|
43950
43736
|
SeriesMarkNameEnum["nodePoint"] = "nodePoint";
|
|
43951
43737
|
SeriesMarkNameEnum["ripplePoint"] = "ripplePoint";
|
|
43952
43738
|
SeriesMarkNameEnum["centerPoint"] = "centerPoint";
|
|
@@ -47722,12 +47508,7 @@
|
|
|
47722
47508
|
|
|
47723
47509
|
Animate$1.mode |= AnimateMode.SET_ATTR_IMMEDIATELY;
|
|
47724
47510
|
let GlobalAnimatorId = 0;
|
|
47725
|
-
const isCustomAnimateCtor = custom =>
|
|
47726
|
-
var _a;
|
|
47727
|
-
if (isNil$1(custom) || isNil$1(custom.prototype)) return !1;
|
|
47728
|
-
const prototype = null !== (_a = custom.prototype) && void 0 !== _a ? _a : {};
|
|
47729
|
-
return prototype instanceof ACustomAnimate || "onBind" in prototype && "onStart" in prototype && "onEnd" in prototype && "onUpdate" in prototype;
|
|
47730
|
-
};
|
|
47511
|
+
const isCustomAnimateCtor = custom => !isNil$1(custom) && !isNil$1(custom.prototype) && (custom.prototype instanceof ACustomAnimate || "onBind" in custom.prototype && "onStart" in custom.prototype && "onEnd" in custom.prototype && "onUpdate" in custom.prototype);
|
|
47731
47512
|
class Animator {
|
|
47732
47513
|
constructor(element, unit, animationOptions) {
|
|
47733
47514
|
this.id = GlobalAnimatorId++, this.isAnimating = !1, this.runnings = [], this.element = element, this.animationOptions = animationOptions, this.unit = unit;
|
|
@@ -49244,7 +49025,8 @@
|
|
|
49244
49025
|
const mark = grammar,
|
|
49245
49026
|
currentNode = this._markNodes.find(node => node.mark === mark);
|
|
49246
49027
|
this._markNodes.forEach(node => {
|
|
49247
|
-
|
|
49028
|
+
const targetMark = node.mark;
|
|
49029
|
+
targetMark.markType === GrammarMarkType.group && targetMark.includesChild(mark, !1) ? (node.children = node.children.filter(n => n !== currentNode), currentNode.parent = null) : mark.markType === GrammarMarkType.group && mark.includesChild(targetMark, !1) && (currentNode.children = currentNode.children.filter(n => n !== node), node.parent = null);
|
|
49248
49030
|
}), this._markNodes = this._markNodes.filter(n => n !== currentNode);
|
|
49249
49031
|
}
|
|
49250
49032
|
return this;
|
|
@@ -62365,7 +62147,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
|
|
|
62365
62147
|
};
|
|
62366
62148
|
registerVChartCore();
|
|
62367
62149
|
|
|
62368
|
-
const version = "1.12.0-alpha.
|
|
62150
|
+
const version = "1.12.0-alpha.7";
|
|
62369
62151
|
|
|
62370
62152
|
const addVChartProperty = (data, op) => {
|
|
62371
62153
|
const context = op.beforeCall();
|
|
@@ -81251,9 +81033,10 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
|
|
|
81251
81033
|
'rect'
|
|
81252
81034
|
];
|
|
81253
81035
|
|
|
81036
|
+
const WORD_CLOUD_WEIGHT = `${PREFIX}_WORD_CLOUD_WEIGHT`;
|
|
81254
81037
|
const WORD_CLOUD_TEXT = `${PREFIX}_WORD_CLOUD_TEXT`;
|
|
81255
81038
|
|
|
81256
|
-
const wordCloudSeriesMark = Object.assign(Object.assign({}, baseSeriesMark), { ["word"]: { name: "word", type: "text" }, ["fillingWord"]: { name: "fillingWord", type: "text" }
|
|
81039
|
+
const wordCloudSeriesMark = Object.assign(Object.assign({}, baseSeriesMark), { ["word"]: { name: "word", type: "text" }, ["fillingWord"]: { name: "fillingWord", type: "text" } });
|
|
81257
81040
|
|
|
81258
81041
|
class BaseWordCloudSeries extends BaseSeries {
|
|
81259
81042
|
constructor() {
|
|
@@ -81261,10 +81044,6 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
|
|
|
81261
81044
|
this._fontSizeRange = [DEFAULT_MIN_FONT_SIZE, DEFAULT_MIN_FONT_SIZE];
|
|
81262
81045
|
this._isWordCloudShape = false;
|
|
81263
81046
|
this._dataChange = true;
|
|
81264
|
-
this.handleMaskCanvasUpdate = (canvas, imageUrl) => {
|
|
81265
|
-
this._maskCanvas = canvas;
|
|
81266
|
-
document.body.appendChild(canvas);
|
|
81267
|
-
};
|
|
81268
81047
|
this.getWordColor = (datum) => {
|
|
81269
81048
|
if (datum.isFillingWord) {
|
|
81270
81049
|
if (!this._fillingColorCallback || this._dataChange) {
|
|
@@ -81275,22 +81054,12 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
|
|
|
81275
81054
|
return this._fillingColorCallback(datum);
|
|
81276
81055
|
}
|
|
81277
81056
|
if (!this._keyWordColorCallback || this._dataChange) {
|
|
81278
|
-
this._keyWordColorCallback = this.
|
|
81279
|
-
? datum => datum[this.
|
|
81057
|
+
this._keyWordColorCallback = this._colorHexField
|
|
81058
|
+
? datum => datum[this._colorHexField]
|
|
81280
81059
|
: this.initColorCallback(this._seriesField, false);
|
|
81281
81060
|
}
|
|
81282
81061
|
return this._keyWordColorCallback(datum);
|
|
81283
81062
|
};
|
|
81284
|
-
this._calculateFontWeight = (datum) => {
|
|
81285
|
-
const stats = this.getRawDataStatisticsByField(this._valueField, true);
|
|
81286
|
-
if (stats.min === stats.max) {
|
|
81287
|
-
return this._fontWeightRange[0];
|
|
81288
|
-
}
|
|
81289
|
-
return (this._fontWeightRange[0] +
|
|
81290
|
-
((this._fontWeightRange[this._fontWeightRange.length - 1] - this._fontWeightRange[0]) *
|
|
81291
|
-
(datum[this._valueField] - stats.min)) /
|
|
81292
|
-
(stats.max - stats.min));
|
|
81293
|
-
};
|
|
81294
81063
|
}
|
|
81295
81064
|
setValueField(field) {
|
|
81296
81065
|
if (isValid$1(field)) {
|
|
@@ -81306,10 +81075,14 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
|
|
|
81306
81075
|
}
|
|
81307
81076
|
}
|
|
81308
81077
|
setAttrFromSpec() {
|
|
81309
|
-
var _a, _b, _c, _d, _e;
|
|
81078
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
81310
81079
|
super.setAttrFromSpec();
|
|
81311
81080
|
this._padding = this._option.getChart().padding;
|
|
81312
81081
|
this._nameField = this._spec.nameField;
|
|
81082
|
+
this._fontFamilyField = this._spec.fontFamilyField;
|
|
81083
|
+
this._fontWeightField = this._spec.fontWeightField;
|
|
81084
|
+
this._fontStyleField = this._spec.fontStyleField;
|
|
81085
|
+
this._colorHexField = this._spec.colorHexField;
|
|
81313
81086
|
this._colorMode = (_a = this._spec.colorMode) !== null && _a !== void 0 ? _a : 'ordinal';
|
|
81314
81087
|
this._colorList = this._spec.colorList;
|
|
81315
81088
|
this.setValueField(this._spec.valueField);
|
|
@@ -81317,16 +81090,14 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
|
|
|
81317
81090
|
this._rotateAngles = (_c = this._spec.rotateAngles) !== null && _c !== void 0 ? _c : DEFAULT_ROTATE_ANGLES;
|
|
81318
81091
|
this.setFontSizeRange(this._spec.fontSizeRange);
|
|
81319
81092
|
this._maskShape = (_d = this._spec.maskShape) !== null && _d !== void 0 ? _d : DEFAULT_MASK_SHAPE;
|
|
81320
|
-
this.
|
|
81321
|
-
|
|
81093
|
+
this._keepAspect = this._spec.keepAspect;
|
|
81094
|
+
this._random = (_e = this._spec.random) !== null && _e !== void 0 ? _e : DEFAULT_RANDOM;
|
|
81095
|
+
this._fontPadding = (_g = (_f = this._spec.word) === null || _f === void 0 ? void 0 : _f.padding) !== null && _g !== void 0 ? _g : DEFAULT_FONT_PADDING;
|
|
81096
|
+
this._textField = ((_h = this._spec.word) === null || _h === void 0 ? void 0 : _h.formatMethod) ? WORD_CLOUD_TEXT : this._nameField;
|
|
81322
81097
|
this._wordCloudConfig = Object.assign({ drawOutOfBound: DEFAULT_DRAW_OUT_OF_BOUND, layoutMode: 'default', zoomToFit: DEFAULT_ZOOM_TO_FIT }, this._spec.wordCloudConfig);
|
|
81323
|
-
if ((!wordCloudConfig || isNil$1(wordCloudConfig.layoutMode)) && !isTrueBrowser(this._option.mode)) {
|
|
81324
|
-
this._wordCloudConfig.layoutMode = 'fast';
|
|
81325
|
-
}
|
|
81326
81098
|
this._wordCloudShapeConfig = Object.assign({ fillingSeriesField: this.getSeriesField(), fillingRotateAngles: DEFAULT_ROTATE_ANGLES, layoutMode: 'default' }, this._spec.wordCloudShapeConfig);
|
|
81327
|
-
this.
|
|
81328
|
-
|
|
81329
|
-
!['fast', 'grid', 'cloud'].includes(this._wordCloudConfig.layoutMode);
|
|
81099
|
+
this._fillingFontPadding = (_k = (_j = this._spec.fillingWord) === null || _j === void 0 ? void 0 : _j.padding) !== null && _k !== void 0 ? _k : DEFAULT_FONT_PADDING;
|
|
81100
|
+
this._isWordCloudShape = !SHAPE_TYPE.includes(this._maskShape);
|
|
81330
81101
|
this._defaultFontFamily = this._option.getTheme().fontFamily;
|
|
81331
81102
|
}
|
|
81332
81103
|
initData() {
|
|
@@ -81338,10 +81109,6 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
|
|
|
81338
81109
|
});
|
|
81339
81110
|
}
|
|
81340
81111
|
initMark() {
|
|
81341
|
-
var _a;
|
|
81342
|
-
if ((_a = this._spec.wordMask) === null || _a === void 0 ? void 0 : _a.visible) {
|
|
81343
|
-
this._maskMark = this._createMark(BaseWordCloudSeries.mark.wordMask, { dataView: false });
|
|
81344
|
-
}
|
|
81345
81112
|
this._wordMark = this._createMark(BaseWordCloudSeries.mark.word, {
|
|
81346
81113
|
key: DEFAULT_DATA_KEY,
|
|
81347
81114
|
defaultMorphElementKey: this._seriesField,
|
|
@@ -81350,61 +81117,41 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
|
|
|
81350
81117
|
});
|
|
81351
81118
|
}
|
|
81352
81119
|
initMarkStyle() {
|
|
81353
|
-
|
|
81354
|
-
|
|
81355
|
-
|
|
81356
|
-
|
|
81357
|
-
|
|
81358
|
-
|
|
81359
|
-
|
|
81360
|
-
|
|
81361
|
-
|
|
81362
|
-
|
|
81363
|
-
|
|
81364
|
-
|
|
81120
|
+
var _a, _b, _c;
|
|
81121
|
+
const wordMark = this._wordMark;
|
|
81122
|
+
const wordSpec = (_a = this._spec.word) !== null && _a !== void 0 ? _a : {};
|
|
81123
|
+
if (wordMark) {
|
|
81124
|
+
this.setMarkStyle(wordMark, {
|
|
81125
|
+
fill: this.getWordColor,
|
|
81126
|
+
text: (datum) => datum[this._textField],
|
|
81127
|
+
x: (datum) => datum.x,
|
|
81128
|
+
y: (datum) => datum.y,
|
|
81129
|
+
fontFamily: (datum) => datum.fontFamily,
|
|
81130
|
+
fontSize: (datum) => datum.fontSize,
|
|
81131
|
+
fontStyle: (datum) => datum.fontStyle,
|
|
81132
|
+
fontWeight: (datum) => datum.fontWeight,
|
|
81133
|
+
angle: (datum) => datum.angle,
|
|
81134
|
+
visible: (datum) => datum.visible
|
|
81365
81135
|
}, 'normal', exports.AttributeLevel.Series);
|
|
81136
|
+
this.setMarkStyle(wordMark, {
|
|
81137
|
+
fontFamily: (_c = (_b = wordSpec.style) === null || _b === void 0 ? void 0 : _b.fontFamily) !== null && _c !== void 0 ? _c : this._defaultFontFamily
|
|
81138
|
+
}, 'normal', exports.AttributeLevel.User_Mark);
|
|
81366
81139
|
}
|
|
81367
81140
|
}
|
|
81368
|
-
initMarkStyleOfWord(wordMark, wordSpec, colorHexField, seriesField, isFillingWord) {
|
|
81369
|
-
var _a, _b;
|
|
81370
|
-
if (!wordMark) {
|
|
81371
|
-
return;
|
|
81372
|
-
}
|
|
81373
|
-
this.setMarkStyle(wordMark, {
|
|
81374
|
-
fill: this.getWordColor,
|
|
81375
|
-
text: (wordSpec === null || wordSpec === void 0 ? void 0 : wordSpec.formatMethod)
|
|
81376
|
-
? (datum) => {
|
|
81377
|
-
return wordSpec.formatMethod(datum);
|
|
81378
|
-
}
|
|
81379
|
-
: (datum) => datum[this._textField],
|
|
81380
|
-
x: (datum) => datum.x,
|
|
81381
|
-
y: (datum) => datum.y,
|
|
81382
|
-
fontFamily: (datum) => datum.fontFamily,
|
|
81383
|
-
fontSize: (datum) => datum.fontSize,
|
|
81384
|
-
fontStyle: (datum) => datum.fontStyle,
|
|
81385
|
-
fontWeight: (datum) => datum.fontWeight,
|
|
81386
|
-
angle: (datum) => datum.angle,
|
|
81387
|
-
visible: datum => datum.visible
|
|
81388
|
-
}, 'normal', exports.AttributeLevel.Series);
|
|
81389
|
-
this.setMarkStyle(wordMark, {
|
|
81390
|
-
fontFamily: (_b = (_a = wordSpec === null || wordSpec === void 0 ? void 0 : wordSpec.style) === null || _a === void 0 ? void 0 : _a.fontFamily) !== null && _b !== void 0 ? _b : this._defaultFontFamily
|
|
81391
|
-
}, 'normal', exports.AttributeLevel.User_Mark);
|
|
81392
|
-
}
|
|
81393
81141
|
initTooltip() {
|
|
81394
81142
|
super.initTooltip();
|
|
81395
81143
|
this._wordMark && this._tooltipHelper.activeTriggerSet.mark.add(this._wordMark);
|
|
81396
81144
|
}
|
|
81397
81145
|
initAnimation() {
|
|
81398
|
-
|
|
81399
|
-
|
|
81400
|
-
|
|
81401
|
-
|
|
81402
|
-
|
|
81403
|
-
|
|
81404
|
-
|
|
81405
|
-
|
|
81406
|
-
|
|
81407
|
-
});
|
|
81146
|
+
var _a, _b;
|
|
81147
|
+
const mark = this._wordMark;
|
|
81148
|
+
if (mark) {
|
|
81149
|
+
const appearPreset = (_b = (_a = this._spec) === null || _a === void 0 ? void 0 : _a.animationAppear) === null || _b === void 0 ? void 0 : _b.preset;
|
|
81150
|
+
const params = {
|
|
81151
|
+
animationConfig: () => { var _a, _b; return (_b = (_a = mark.getAnimationConfig()) === null || _a === void 0 ? void 0 : _a.appear) === null || _b === void 0 ? void 0 : _b[0]; }
|
|
81152
|
+
};
|
|
81153
|
+
mark.setAnimationConfig(animationConfig(Factory.getAnimationInKey('wordCloud')(params, appearPreset), userAnimationConfig("word", this._spec, this._markAttributeContext)));
|
|
81154
|
+
}
|
|
81408
81155
|
}
|
|
81409
81156
|
getWordOrdinalColorScale(field, isFillingWord) {
|
|
81410
81157
|
var _a, _b, _c, _d, _e;
|
|
@@ -81414,39 +81161,53 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
|
|
|
81414
81161
|
return (_e = (_d = new ColorOrdinalScale().domain(colorDomain)).range) === null || _e === void 0 ? void 0 : _e.call(_d, colorRange);
|
|
81415
81162
|
}
|
|
81416
81163
|
initColorCallback(field, isFillingWord) {
|
|
81417
|
-
var _a
|
|
81164
|
+
var _a;
|
|
81418
81165
|
if (this._colorMode === 'ordinal') {
|
|
81419
81166
|
const scale = this.getWordOrdinalColorScale(field, isFillingWord);
|
|
81420
81167
|
return (datum) => {
|
|
81421
|
-
|
|
81168
|
+
var _a;
|
|
81169
|
+
return scale.scale(datum[(_a = this._seriesField) !== null && _a !== void 0 ? _a : DEFAULT_DATA_SERIES_FIELD]);
|
|
81422
81170
|
};
|
|
81423
81171
|
}
|
|
81424
|
-
|
|
81172
|
+
let colorList = (_a = (isFillingWord ? this._colorList : this._wordCloudShapeConfig.fillingColorList)) !== null && _a !== void 0 ? _a : this._option.globalScale.getScale('color').range();
|
|
81425
81173
|
if (colorList.length === 1) {
|
|
81426
|
-
|
|
81174
|
+
colorList = [colorList[0], colorList[0]];
|
|
81427
81175
|
}
|
|
81428
|
-
|
|
81429
|
-
const stats = this.getRawDataStatisticsByField(this._valueField, true);
|
|
81430
|
-
if (stats.min === stats.max) {
|
|
81431
|
-
return colorList[0];
|
|
81432
|
-
}
|
|
81433
|
-
const scale = new LinearScale().domain([stats.min, stats.max]).range(colorList);
|
|
81434
|
-
return (datum) => {
|
|
81435
|
-
return scale.scale(datum[this._valueField]);
|
|
81436
|
-
};
|
|
81437
|
-
}
|
|
81438
|
-
const scale = new LinearScale().domain([0, (_d = (_c = (_b = this.getViewData()) === null || _b === void 0 ? void 0 : _b.latestData) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 1]).range(colorList);
|
|
81439
|
-
return (datum) => {
|
|
81440
|
-
return scale.scale(datum[DEFAULT_DATA_INDEX]);
|
|
81441
|
-
};
|
|
81176
|
+
return (datum) => colorList[0];
|
|
81442
81177
|
}
|
|
81443
81178
|
compile() {
|
|
81179
|
+
var _a, _b;
|
|
81444
81180
|
super.compile();
|
|
81445
81181
|
const { width, height } = this._region.getLayoutRect();
|
|
81446
81182
|
if (!isValidNumber$1(width) || !isValidNumber$1(height) || !(height > 0 && width > 0)) {
|
|
81447
81183
|
return;
|
|
81448
81184
|
}
|
|
81449
81185
|
const wordCloudTransforms = [];
|
|
81186
|
+
const valueField = this._valueField;
|
|
81187
|
+
const valueScale = new LinearScale();
|
|
81188
|
+
const fontWeightRange = this._fontWeightRange;
|
|
81189
|
+
if (valueField) {
|
|
81190
|
+
const [minValue, maxValue] = extent$2((_a = this.getViewData()) === null || _a === void 0 ? void 0 : _a.latestData.map((datum) => +datum[valueField]));
|
|
81191
|
+
valueScale.domain([minValue, maxValue], true).range(fontWeightRange);
|
|
81192
|
+
wordCloudTransforms.push({
|
|
81193
|
+
type: 'map',
|
|
81194
|
+
as: WORD_CLOUD_WEIGHT,
|
|
81195
|
+
callback: (datum) => {
|
|
81196
|
+
if (minValue === maxValue) {
|
|
81197
|
+
return valueScale.scale(maxValue);
|
|
81198
|
+
}
|
|
81199
|
+
return valueScale.scale(datum[valueField]);
|
|
81200
|
+
}
|
|
81201
|
+
});
|
|
81202
|
+
}
|
|
81203
|
+
const wordSpec = (_b = this._spec.word) !== null && _b !== void 0 ? _b : {};
|
|
81204
|
+
if (wordSpec.formatMethod) {
|
|
81205
|
+
wordCloudTransforms.push({
|
|
81206
|
+
type: 'map',
|
|
81207
|
+
as: WORD_CLOUD_TEXT,
|
|
81208
|
+
callback: wordSpec.formatMethod
|
|
81209
|
+
});
|
|
81210
|
+
}
|
|
81450
81211
|
if (!this._isWordCloudShape) {
|
|
81451
81212
|
wordCloudTransforms.push(Object.assign({ type: 'wordcloud' }, this._wordCloudTransformOption()));
|
|
81452
81213
|
}
|
|
@@ -81455,43 +81216,84 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
|
|
|
81455
81216
|
}
|
|
81456
81217
|
this._wordMark.getProduct().transform(wordCloudTransforms);
|
|
81457
81218
|
}
|
|
81458
|
-
|
|
81459
|
-
var _a, _b, _c, _d, _e
|
|
81219
|
+
_wordCloudTransformOption() {
|
|
81220
|
+
var _a, _b, _c, _d, _e;
|
|
81460
81221
|
const { width, height } = this._region.getLayoutRect();
|
|
81461
|
-
const
|
|
81462
|
-
const wordStyleSpec = (_b = wordSpec.style) !== null && _b !== void 0 ? _b : {};
|
|
81222
|
+
const wordStyleSpec = (_b = (_a = this._spec.word) === null || _a === void 0 ? void 0 : _a.style) !== null && _b !== void 0 ? _b : {};
|
|
81463
81223
|
return {
|
|
81224
|
+
layoutType: !isTrueBrowser(this._option.mode) ? 'fast' : this._wordCloudConfig.layoutMode,
|
|
81464
81225
|
size: [width, height],
|
|
81465
|
-
shape:
|
|
81466
|
-
? Object.assign({ fontFamily: (_c = this._option.getTheme()) === null || _c === void 0 ? void 0 : _c.fontFamily }, this._maskShape) : this._maskShape,
|
|
81467
|
-
onUpdateMaskCanvas: isObject$2(this._maskShape) ? this.handleMaskCanvasUpdate : null,
|
|
81226
|
+
shape: this._maskShape,
|
|
81468
81227
|
dataIndexKey: DEFAULT_DATA_KEY,
|
|
81469
|
-
text:
|
|
81470
|
-
? (datum) => {
|
|
81471
|
-
return wordSpec.formatMethod(datum);
|
|
81472
|
-
}
|
|
81473
|
-
: { field: this._textField },
|
|
81228
|
+
text: { field: this._textField },
|
|
81474
81229
|
fontSize: this._valueField ? { field: this._valueField } : this._fontSizeRange[0],
|
|
81475
81230
|
fontSizeRange: this._fontSizeRange === 'auto' ? null : this._fontSizeRange,
|
|
81476
|
-
padding:
|
|
81477
|
-
|
|
81478
|
-
|
|
81479
|
-
|
|
81231
|
+
padding: this._fontPadding,
|
|
81232
|
+
rotate: this._rotateAngles,
|
|
81233
|
+
fontFamily: (_d = (_c = this._fontFamilyField) !== null && _c !== void 0 ? _c : wordStyleSpec.fontFamily) !== null && _d !== void 0 ? _d : this._defaultFontFamily,
|
|
81234
|
+
fontWeight: this._fontWeightField
|
|
81235
|
+
? { field: this._fontWeightField }
|
|
81480
81236
|
: this._valueField
|
|
81481
|
-
?
|
|
81237
|
+
? { field: WORD_CLOUD_WEIGHT }
|
|
81482
81238
|
: null,
|
|
81483
|
-
fontStyle: (
|
|
81239
|
+
fontStyle: (_e = this._fontStyleField) !== null && _e !== void 0 ? _e : wordStyleSpec.fontStyle,
|
|
81240
|
+
randomVisible: this._random,
|
|
81241
|
+
clip: this._wordCloudConfig.drawOutOfBound === 'clip',
|
|
81242
|
+
shrink: this._wordCloudConfig.zoomToFit.shrink,
|
|
81243
|
+
enlarge: this._wordCloudConfig.zoomToFit.enlarge,
|
|
81244
|
+
minFontSize: this._wordCloudConfig.zoomToFit.fontSizeLimitMin,
|
|
81245
|
+
progressiveTime: this._wordCloudConfig.progressiveTime,
|
|
81246
|
+
progressiveStep: this._wordCloudConfig.progressiveStep
|
|
81484
81247
|
};
|
|
81485
81248
|
}
|
|
81486
|
-
_wordCloudTransformOption() {
|
|
81487
|
-
var _a;
|
|
81488
|
-
return Object.assign(Object.assign({}, this._getCommonTransformOptions()), { layoutType: this._wordCloudConfig.layoutMode, rotate: this._rotateAngles, randomVisible: (_a = this._spec.random) !== null && _a !== void 0 ? _a : DEFAULT_RANDOM, clip: this._wordCloudConfig.drawOutOfBound === 'clip', shrink: this._wordCloudConfig.zoomToFit.shrink, enlarge: this._wordCloudConfig.zoomToFit.enlarge, minFontSize: this._wordCloudConfig.zoomToFit.fontSizeLimitMin, progressiveTime: this._wordCloudConfig.progressiveTime, progressiveStep: this._wordCloudConfig.progressiveStep, repeatFill: this._wordCloudConfig.zoomToFit.repeat });
|
|
81489
|
-
}
|
|
81490
81249
|
_wordCloudShapeTransformOption() {
|
|
81491
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
81250
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
81251
|
+
const { width, height } = this._region.getLayoutRect();
|
|
81492
81252
|
const wordStyleSpec = (_b = (_a = this._spec.word) === null || _a === void 0 ? void 0 : _a.style) !== null && _b !== void 0 ? _b : {};
|
|
81493
81253
|
const wordCloudShapeConfig = (_c = this._wordCloudShapeConfig) !== null && _c !== void 0 ? _c : {};
|
|
81494
|
-
|
|
81254
|
+
const fillingRotateAngles = this._wordCloudShapeConfig.fillingRotateAngles;
|
|
81255
|
+
return {
|
|
81256
|
+
dataIndexKey: DEFAULT_DATA_KEY,
|
|
81257
|
+
size: [width, height],
|
|
81258
|
+
shape: this._maskShape,
|
|
81259
|
+
text: { field: this._textField },
|
|
81260
|
+
fontSize: this._valueField ? { field: this._valueField } : this._fontSizeRange[0],
|
|
81261
|
+
fontSizeRange: this._fontSizeRange === 'auto' ? null : this._fontSizeRange,
|
|
81262
|
+
padding: this._fontPadding,
|
|
81263
|
+
rotateList: this._rotateAngles,
|
|
81264
|
+
fontFamily: (_e = (_d = this._fontFamilyField) !== null && _d !== void 0 ? _d : wordStyleSpec.fontFamily) !== null && _e !== void 0 ? _e : this._defaultFontFamily,
|
|
81265
|
+
fontWeight: this._fontWeightField
|
|
81266
|
+
? { field: this._fontWeightField }
|
|
81267
|
+
: this._valueField
|
|
81268
|
+
? { field: WORD_CLOUD_WEIGHT }
|
|
81269
|
+
: null,
|
|
81270
|
+
fontStyle: (_f = this._fontStyleField) !== null && _f !== void 0 ? _f : wordStyleSpec.fontStyle,
|
|
81271
|
+
fillingFontFamily: (_h = (_g = wordCloudShapeConfig.fillingFontFamilyField) !== null && _g !== void 0 ? _g : wordStyleSpec.fontFamily) !== null && _h !== void 0 ? _h : this._defaultFontFamily,
|
|
81272
|
+
fillingPadding: this._fillingFontPadding,
|
|
81273
|
+
fillingFontStyle: (_j = wordCloudShapeConfig.fillingFontStyleField) !== null && _j !== void 0 ? _j : wordStyleSpec.fontStyle,
|
|
81274
|
+
fillingFontWeight: (_k = wordCloudShapeConfig.fillingFontWeightField) !== null && _k !== void 0 ? _k : wordStyleSpec.fontWeight,
|
|
81275
|
+
fillingRotateList: fillingRotateAngles,
|
|
81276
|
+
fillingTimes: wordCloudShapeConfig.fillingTimes,
|
|
81277
|
+
fillingXStep: wordCloudShapeConfig.fillingXStep,
|
|
81278
|
+
fillingYStep: wordCloudShapeConfig.fillingYStep,
|
|
81279
|
+
fillingXRatioStep: wordCloudShapeConfig.fillingXRatioStep,
|
|
81280
|
+
fillingYRatioStep: wordCloudShapeConfig.fillingYRatioStep,
|
|
81281
|
+
fillingInitialOpacity: wordCloudShapeConfig.fillingInitialOpacity,
|
|
81282
|
+
fillingDeltaOpacity: wordCloudShapeConfig.fillingDeltaOpacity,
|
|
81283
|
+
fillingInitialFontSize: wordCloudShapeConfig.fillingInitialFontSize,
|
|
81284
|
+
fillingDeltaFontSize: wordCloudShapeConfig.fillingDeltaFontSize,
|
|
81285
|
+
ratio: wordCloudShapeConfig.ratio,
|
|
81286
|
+
fillingRatio: wordCloudShapeConfig.fillingRatio,
|
|
81287
|
+
removeWhiteBorder: wordCloudShapeConfig.removeWhiteBorder,
|
|
81288
|
+
textLayoutTimes: wordCloudShapeConfig.textLayoutTimes,
|
|
81289
|
+
fontSizeShrinkFactor: wordCloudShapeConfig.fontSizeShrinkFactor,
|
|
81290
|
+
stepFactor: wordCloudShapeConfig.stepFactor,
|
|
81291
|
+
layoutMode: wordCloudShapeConfig.layoutMode,
|
|
81292
|
+
importantWordCount: wordCloudShapeConfig.importantWordCount,
|
|
81293
|
+
globalShinkLimit: wordCloudShapeConfig.globalShinkLimit,
|
|
81294
|
+
fontSizeEnlargeFactor: wordCloudShapeConfig.fontSizeEnlargeFactor,
|
|
81295
|
+
fillingDeltaFontSizeFactor: wordCloudShapeConfig.fillingDeltaFontSizeFactor
|
|
81296
|
+
};
|
|
81495
81297
|
}
|
|
81496
81298
|
getStatisticFields() {
|
|
81497
81299
|
const fields = [];
|
|
@@ -81604,6 +81406,91 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
|
|
|
81604
81406
|
}));
|
|
81605
81407
|
};
|
|
81606
81408
|
|
|
81409
|
+
const shapes = {
|
|
81410
|
+
triangleForward: triangleForward,
|
|
81411
|
+
triangleUpright: triangle,
|
|
81412
|
+
triangle: triangle,
|
|
81413
|
+
diamond: diamond,
|
|
81414
|
+
square: square,
|
|
81415
|
+
star: star,
|
|
81416
|
+
cardioid: cardioid,
|
|
81417
|
+
circle: circle,
|
|
81418
|
+
pentagon: pentagon
|
|
81419
|
+
};
|
|
81420
|
+
function diamond() {
|
|
81421
|
+
return function (theta) {
|
|
81422
|
+
const thetaPrime = theta % (2 * Math.PI / 4);
|
|
81423
|
+
return 1 / (Math.cos(thetaPrime) + Math.sin(thetaPrime));
|
|
81424
|
+
};
|
|
81425
|
+
}
|
|
81426
|
+
function star() {
|
|
81427
|
+
return function (theta) {
|
|
81428
|
+
const thetaPrime = (theta + .955) % (2 * Math.PI / 10);
|
|
81429
|
+
return (theta + .955) % (2 * Math.PI / 5) - 2 * Math.PI / 10 >= 0 ? 1 / (Math.cos(2 * Math.PI / 10 - thetaPrime) + 3.07768 * Math.sin(2 * Math.PI / 10 - thetaPrime)) : 1 / (Math.cos(thetaPrime) + 3.07768 * Math.sin(thetaPrime));
|
|
81430
|
+
};
|
|
81431
|
+
}
|
|
81432
|
+
function square() {
|
|
81433
|
+
return function (theta) {
|
|
81434
|
+
return Math.min(1 / Math.abs(Math.cos(theta)), 1 / Math.abs(Math.sin(theta)));
|
|
81435
|
+
};
|
|
81436
|
+
}
|
|
81437
|
+
function triangle() {
|
|
81438
|
+
return function (theta) {
|
|
81439
|
+
const thetaPrime = (theta + 3 * Math.PI / 2) % (2 * Math.PI / 3);
|
|
81440
|
+
return 1 / (Math.cos(thetaPrime) + Math.sqrt(3) * Math.sin(thetaPrime));
|
|
81441
|
+
};
|
|
81442
|
+
}
|
|
81443
|
+
function triangleForward() {
|
|
81444
|
+
return function (theta) {
|
|
81445
|
+
const thetaPrime = theta % (2 * Math.PI / 3);
|
|
81446
|
+
return 1 / (Math.cos(thetaPrime) + Math.sqrt(3) * Math.sin(thetaPrime));
|
|
81447
|
+
};
|
|
81448
|
+
}
|
|
81449
|
+
function cardioid() {
|
|
81450
|
+
return function (theta) {
|
|
81451
|
+
return 1 - Math.sin(theta);
|
|
81452
|
+
};
|
|
81453
|
+
}
|
|
81454
|
+
function circle() {
|
|
81455
|
+
return function () {
|
|
81456
|
+
return 1;
|
|
81457
|
+
};
|
|
81458
|
+
}
|
|
81459
|
+
function pentagon() {
|
|
81460
|
+
return function (theta) {
|
|
81461
|
+
const thetaPrime = (theta + .955) % (2 * Math.PI / 5);
|
|
81462
|
+
return 1 / (Math.cos(thetaPrime) + .726543 * Math.sin(thetaPrime));
|
|
81463
|
+
};
|
|
81464
|
+
}
|
|
81465
|
+
function getMaxRadiusAndCenter(shape, size) {
|
|
81466
|
+
const w = size[0],
|
|
81467
|
+
h = size[1];
|
|
81468
|
+
let maxRadius = 1;
|
|
81469
|
+
const center = [size[0] >> 1, size[1] >> 1];
|
|
81470
|
+
switch (shape) {
|
|
81471
|
+
case "cardioid":
|
|
81472
|
+
center[1] = ~~(h / 2.7 * .6), maxRadius = Math.floor(Math.min(w / 2.3, h / 2.6));
|
|
81473
|
+
break;
|
|
81474
|
+
case "triangleForward":
|
|
81475
|
+
maxRadius = h / Math.sqrt(.75) > w ? Math.floor(w / 2) : Math.floor(h / (2 * Math.sqrt(.75)));
|
|
81476
|
+
break;
|
|
81477
|
+
case "triangle":
|
|
81478
|
+
case "triangleUpright":
|
|
81479
|
+
center[1] = ~~(h / 1.5), maxRadius = Math.floor(Math.min(h / 1.5, w / 2));
|
|
81480
|
+
break;
|
|
81481
|
+
case "rect":
|
|
81482
|
+
maxRadius = Math.floor(Math.max(h / 2, w / 2));
|
|
81483
|
+
break;
|
|
81484
|
+
default:
|
|
81485
|
+
maxRadius = Math.floor(Math.min(w / 2, h / 2));
|
|
81486
|
+
}
|
|
81487
|
+
return {
|
|
81488
|
+
maxRadius: maxRadius,
|
|
81489
|
+
center: center
|
|
81490
|
+
};
|
|
81491
|
+
}
|
|
81492
|
+
const getShapeFunction = type => shapes[type] ? shapes[type]() : shapes.circle();
|
|
81493
|
+
|
|
81607
81494
|
const randomHslColor = (min, max) => "hsl(" + (360 * Math.random()).toFixed() + "," + (30 * Math.random() + 70).toFixed() + "%," + (Math.random() * (max - min) + min).toFixed() + "%)";
|
|
81608
81495
|
function functor$1(d) {
|
|
81609
81496
|
return isFunction$1(d) ? d : function () {
|
|
@@ -81640,34 +81527,26 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
|
|
|
81640
81527
|
return degreeToRadian(rotates[Math.floor(random * rotates.length)]);
|
|
81641
81528
|
};
|
|
81642
81529
|
}
|
|
81643
|
-
canRepeat() {
|
|
81644
|
-
return !1;
|
|
81645
|
-
}
|
|
81646
81530
|
exceedTime() {
|
|
81647
81531
|
var _a;
|
|
81648
|
-
return this.options.progressiveStep > 0 ? this.progressiveIndex >= ((null !== (_a = this.currentStepIndex) && void 0 !== _a ? _a :
|
|
81532
|
+
return this.options.progressiveStep > 0 ? this.progressiveIndex >= ((null !== (_a = this.currentStepIndex) && void 0 !== _a ? _a : 0) + 1) * this.options.progressiveStep : this.options.progressiveTime > 0 && new Date().getTime() - this.escapeTime > this.options.progressiveTime;
|
|
81649
81533
|
}
|
|
81650
81534
|
progressiveRun() {
|
|
81651
81535
|
var _a;
|
|
81652
|
-
if (this.options.progressiveStep > 0 ? this.currentStepIndex = (null !== (_a = this.currentStepIndex) && void 0 !== _a ? _a :
|
|
81536
|
+
if (this.options.progressiveStep > 0 ? this.currentStepIndex = (null !== (_a = this.currentStepIndex) && void 0 !== _a ? _a : 0) + 1 : this.options.progressiveTime > 0 && (this.escapeTime = Date.now()), this.data && this.progressiveIndex && this.progressiveIndex < this.data.length) {
|
|
81653
81537
|
this.progressiveResult = [];
|
|
81654
|
-
|
|
81655
|
-
|
|
81656
|
-
|
|
81657
|
-
|
|
81658
|
-
|
|
81659
|
-
const drawn = this.layoutWord(i);
|
|
81660
|
-
if (curWordTryCount++, (drawn || curWordTryCount >= maxSingleWordTryCount) && (i++, curWordTryCount = 0, this.failCount = drawn ? 0 : this.failCount + 1), this.progressiveIndex = i, this.exceedTime()) break;
|
|
81661
|
-
i === this.data.length && this.failCount < maxFailCount && this.options.repeatFill && this.canRepeat() && (this.data = [...this.data, ...this.originalData.map(entry => Object.assign(Object.assign({}, entry), {
|
|
81662
|
-
isFill: !0
|
|
81663
|
-
}))], this.isTryRepeatFill = !0);
|
|
81538
|
+
const len = this.data.length;
|
|
81539
|
+
let i = this.progressiveIndex;
|
|
81540
|
+
for (; i < len;) {
|
|
81541
|
+
this.layoutWord(i);
|
|
81542
|
+
if (i++, this.progressiveIndex = i, this.exceedTime()) break;
|
|
81664
81543
|
}
|
|
81665
81544
|
return this.progressiveResult;
|
|
81666
81545
|
}
|
|
81667
81546
|
return this.result;
|
|
81668
81547
|
}
|
|
81669
81548
|
initProgressive() {
|
|
81670
|
-
this.
|
|
81549
|
+
this.progressiveIndex = -1, this.options.progressiveStep > 0 ? this.currentStepIndex = 0 : this.options.progressiveTime > 0 && (this.escapeTime = Date.now()), this.progressiveResult = [];
|
|
81671
81550
|
}
|
|
81672
81551
|
output() {
|
|
81673
81552
|
return this.result ? this.outputCallback(this.result) : null;
|
|
@@ -81698,9 +81577,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
|
|
|
81698
81577
|
shape: "circle",
|
|
81699
81578
|
progressiveTime: 0,
|
|
81700
81579
|
progressiveStep: 0,
|
|
81701
|
-
|
|
81702
|
-
fillTextFontSize: 12,
|
|
81703
|
-
maxFailCount: 20
|
|
81580
|
+
backgroundColor: "#fff"
|
|
81704
81581
|
};
|
|
81705
81582
|
|
|
81706
81583
|
const spirals = {
|
|
@@ -81779,7 +81656,8 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
|
|
|
81779
81656
|
height: 1
|
|
81780
81657
|
}));
|
|
81781
81658
|
this.contextAndRatio = contextAndRatio, this._board = new Array((this._size[0] >> 5) * this._size[1]).fill(0), this._bounds = null;
|
|
81782
|
-
words.length;
|
|
81659
|
+
const n = words.length;
|
|
81660
|
+
let i = 0;
|
|
81783
81661
|
this.result = [];
|
|
81784
81662
|
const data = words.map((d, i) => ({
|
|
81785
81663
|
text: this.getText(d),
|
|
@@ -81805,7 +81683,12 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
|
|
|
81805
81683
|
})).sort(function (a, b) {
|
|
81806
81684
|
return b.fontSize - a.fontSize;
|
|
81807
81685
|
});
|
|
81808
|
-
|
|
81686
|
+
this.data = data;
|
|
81687
|
+
let curWordTryCount = 0;
|
|
81688
|
+
for (; i < n;) {
|
|
81689
|
+
if (this.layoutWord(i) || curWordTryCount >= 2 ? (i++, curWordTryCount = 0) : curWordTryCount++, this.progressiveIndex = i, this.exceedTime()) break;
|
|
81690
|
+
}
|
|
81691
|
+
if (!this.options.clip && this.options.enlarge && this._bounds && this.shrinkBoard(this._bounds), this._bounds && ["cardioid", "triangle", "triangle-upright"].includes(this.options.shape)) {
|
|
81809
81692
|
const currentCenterY = (this._bounds[0].y + this._bounds[1].y) / 2;
|
|
81810
81693
|
this._dy = -(currentCenterY - this._size[1] / 2);
|
|
81811
81694
|
}
|
|
@@ -82038,8 +81921,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
|
|
|
82038
81921
|
}
|
|
82039
81922
|
CloudLayout.defaultOptions = {
|
|
82040
81923
|
enlarge: !1,
|
|
82041
|
-
minFontSize: 2
|
|
82042
|
-
maxSingleWordTryCount: 2
|
|
81924
|
+
minFontSize: 2
|
|
82043
81925
|
};
|
|
82044
81926
|
const isFullOutside = (tag, size) => tag.x + tag.x0 > size[0] || tag.y + tag.y0 > size[0] || tag.x + tag.x1 < 0 || tag.y + tag.y1 < 0,
|
|
82045
81927
|
isPartOutside = (tag, size) => tag.x + tag.x0 < 0 || tag.y + tag.y0 < 0 || tag.x + tag.x1 > size[0] || tag.y + tag.y1 > size[1];
|
|
@@ -82103,7 +81985,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
|
|
|
82103
81985
|
let index = arguments.length > 2 ? arguments[2] : undefined;
|
|
82104
81986
|
var _a;
|
|
82105
81987
|
const sizeShrinkRatio = this.options.clip ? 1 : shrinkRatio,
|
|
82106
|
-
fontSize = Math.max(Math.floor(
|
|
81988
|
+
fontSize = Math.max(Math.floor(this.getTextFontSize(item) * sizeShrinkRatio), this.options.minFontSize);
|
|
82107
81989
|
let word = this.getText(item) + "";
|
|
82108
81990
|
if (this.options.clip && (word = word.slice(0, Math.ceil(word.length * shrinkRatio))), !word) return null;
|
|
82109
81991
|
const fontWeight = this.getTextFontWeight(item),
|
|
@@ -82161,12 +82043,6 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
|
|
|
82161
82043
|
text: word
|
|
82162
82044
|
};
|
|
82163
82045
|
}
|
|
82164
|
-
calculateEmptyRate() {
|
|
82165
|
-
const totalCount = this.ngx * this.ngy;
|
|
82166
|
-
let emptyCount = 0;
|
|
82167
|
-
for (let gx = 0; gx < this.ngx; gx++) for (let gy = 0; gy < this.ngy; gy++) this.grid[gx][gy] && emptyCount++;
|
|
82168
|
-
return emptyCount / totalCount;
|
|
82169
|
-
}
|
|
82170
82046
|
canFitText(gx, gy, gw, gh, occupied) {
|
|
82171
82047
|
let i = occupied.length;
|
|
82172
82048
|
for (; i--;) {
|
|
@@ -82221,21 +82097,19 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
|
|
|
82221
82097
|
};
|
|
82222
82098
|
this.result.push(output), this.progressiveResult && this.progressiveResult.push(output);
|
|
82223
82099
|
}
|
|
82224
|
-
initGrid(
|
|
82225
|
-
|
|
82226
|
-
|
|
82227
|
-
|
|
82228
|
-
|
|
82229
|
-
let
|
|
82230
|
-
|
|
82231
|
-
let isEmptyPixel = generateIsEmptyPixel(shape.backgroundColor);
|
|
82100
|
+
initGrid(canvas) {
|
|
82101
|
+
let i;
|
|
82102
|
+
if (this.grid = [], canvas) {
|
|
82103
|
+
let bctx = document.createElement("canvas").getContext("2d");
|
|
82104
|
+
bctx.fillStyle = this.options.backgroundColor, bctx.fillRect(0, 0, 1, 1);
|
|
82105
|
+
let bgPixel = bctx.getImageData(0, 0, 1, 1).data,
|
|
82106
|
+
imageData = canvas.getContext("2d").getImageData(0, 0, this.ngx * this.gridSize, this.ngy * this.gridSize).data;
|
|
82232
82107
|
const singleGridLoop = (gx, gy) => {
|
|
82233
82108
|
let y = this.gridSize;
|
|
82234
82109
|
for (; y--;) {
|
|
82235
82110
|
let x = this.gridSize;
|
|
82236
|
-
for (; x--;) if (
|
|
82111
|
+
for (; x--;) for (i = 4; i--;) if (imageData[4 * ((gy * this.gridSize + y) * this.ngx * this.gridSize + (gx * this.gridSize + x)) + i] !== bgPixel[i]) return void (this.grid[gx][gy] = !1);
|
|
82237
82112
|
}
|
|
82238
|
-
this.grid[gx][gy] = !1;
|
|
82239
82113
|
};
|
|
82240
82114
|
let gx = this.ngx;
|
|
82241
82115
|
for (; gx--;) {
|
|
@@ -82243,7 +82117,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
|
|
|
82243
82117
|
let gy = this.ngy;
|
|
82244
82118
|
for (; gy--;) singleGridLoop(gx, gy), !1 !== this.grid[gx][gy] && (this.grid[gx][gy] = !0);
|
|
82245
82119
|
}
|
|
82246
|
-
imageData =
|
|
82120
|
+
imageData = bctx = bgPixel = void 0;
|
|
82247
82121
|
} else {
|
|
82248
82122
|
let gx = this.ngx;
|
|
82249
82123
|
for (; gx--;) {
|
|
@@ -82253,22 +82127,24 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
|
|
|
82253
82127
|
}
|
|
82254
82128
|
}
|
|
82255
82129
|
}
|
|
82256
|
-
canRepeat() {
|
|
82257
|
-
return this.calculateEmptyRate() > .001;
|
|
82258
|
-
}
|
|
82259
82130
|
layout(data, config) {
|
|
82260
|
-
this.initProgressive(), this.
|
|
82131
|
+
this.initProgressive(), this.data = data, this.pointsAtRadius = [], this.ngx = Math.floor(config.width / this.gridSize), this.ngy = Math.floor(config.height / this.gridSize);
|
|
82261
82132
|
const {
|
|
82262
82133
|
center: center,
|
|
82263
82134
|
maxRadius: maxRadius
|
|
82264
82135
|
} = getMaxRadiusAndCenter(this.options.shape, [config.width, config.height]);
|
|
82265
|
-
|
|
82136
|
+
this.center = config.origin ? [config.origin[0] / this.gridSize, config.origin[1] / this.gridSize] : [center[0] / this.gridSize, center[1] / this.gridSize], this.maxRadius = Math.floor(maxRadius / this.gridSize), this.initGrid(config.canvas), this.result = [];
|
|
82137
|
+
let i = 0;
|
|
82138
|
+
for (; i < data.length;) {
|
|
82139
|
+
this.layoutWord(i);
|
|
82140
|
+
if (i++, this.progressiveIndex = i, this.exceedTime()) break;
|
|
82141
|
+
}
|
|
82142
|
+
return this.result;
|
|
82266
82143
|
}
|
|
82267
82144
|
};
|
|
82268
82145
|
GridLayout$1.defaultOptions = {
|
|
82269
82146
|
gridSize: 8,
|
|
82270
|
-
ellipticity: 1
|
|
82271
|
-
maxSingleWordTryCount: 1
|
|
82147
|
+
ellipticity: 1
|
|
82272
82148
|
};
|
|
82273
82149
|
|
|
82274
82150
|
class FastLayout extends BaseLayout {
|
|
@@ -82356,19 +82232,19 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
|
|
|
82356
82232
|
clip = null !== (_f = options.clip) && void 0 !== _f && _f,
|
|
82357
82233
|
minFontSize = options.minFontSize,
|
|
82358
82234
|
randomVisible = options.randomVisible,
|
|
82359
|
-
as = options.as
|
|
82235
|
+
as = options.as || OUTPUT$1,
|
|
82360
82236
|
depth_3d = options.depth_3d,
|
|
82361
82237
|
postProjection = options.postProjection;
|
|
82362
82238
|
let fontSize = options.fontSize ? field$1(options.fontSize) : 14;
|
|
82363
82239
|
const fontSizeRange = options.fontSizeRange;
|
|
82364
82240
|
if (fontSizeRange && !isNumber$1(fontSize)) {
|
|
82365
82241
|
const fsize = fontSize,
|
|
82366
|
-
fontSizeSqrtScale =
|
|
82242
|
+
fontSizeSqrtScale = generateSqrtScale(extent$1(fsize, data), fontSizeRange);
|
|
82367
82243
|
fontSize = datum => fontSizeSqrtScale(fsize(datum));
|
|
82368
82244
|
}
|
|
82369
82245
|
let Layout = CloudLayout;
|
|
82370
82246
|
"fast" === options.layoutType ? Layout = FastLayout : "grid" === options.layoutType && (Layout = GridLayout$1);
|
|
82371
|
-
const layout = new Layout(
|
|
82247
|
+
const layout = new Layout({
|
|
82372
82248
|
text: text,
|
|
82373
82249
|
padding: padding,
|
|
82374
82250
|
spiral: spiral,
|
|
@@ -82383,13 +82259,15 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
|
|
|
82383
82259
|
enlarge: enlarge,
|
|
82384
82260
|
minFontSize: minFontSize,
|
|
82385
82261
|
random: randomVisible,
|
|
82262
|
+
progressiveStep: options.progressiveStep,
|
|
82263
|
+
progressiveTime: options.progressiveTime,
|
|
82386
82264
|
outputCallback: words => {
|
|
82387
82265
|
const res = [];
|
|
82388
82266
|
let t, w;
|
|
82389
|
-
for (let i = 0, len = words.length; i < len; i++) w = words[i], t = w.datum, t[as.x] = w.x, t[as.y] = w.y, t[as.fontFamily] = w.fontFamily, t[as.fontSize] = w.fontSize, t[as.fontStyle] = w.fontStyle, t[as.fontWeight] = w.fontWeight, t[as.angle] = w.angle, "StereographicProjection" === postProjection && stereographicProjection(canvasSize, w, t, as, depth_3d),
|
|
82267
|
+
for (let i = 0, len = words.length; i < len; i++) w = words[i], t = w.datum, t[as.x] = w.x, t[as.y] = w.y, t[as.fontFamily] = w.fontFamily, t[as.fontSize] = w.fontSize, t[as.fontStyle] = w.fontStyle, t[as.fontWeight] = w.fontWeight, t[as.angle] = w.angle, "StereographicProjection" === postProjection && stereographicProjection(canvasSize, w, t, as, depth_3d), res.push(t);
|
|
82390
82268
|
return res;
|
|
82391
82269
|
}
|
|
82392
|
-
})
|
|
82270
|
+
});
|
|
82393
82271
|
return layout.layout(data, {
|
|
82394
82272
|
width: canvasSize[0],
|
|
82395
82273
|
height: canvasSize[1]
|
|
@@ -82399,7 +82277,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
|
|
|
82399
82277
|
};
|
|
82400
82278
|
const field$1 = option => isString$1(option) || isNumber$1(option) || isFunction$1(option) || isArray$1(option) ? option : datum => datum[option.field],
|
|
82401
82279
|
sqrt = x => x < 0 ? -Math.sqrt(-x) : Math.sqrt(x),
|
|
82402
|
-
|
|
82280
|
+
generateSqrtScale = (domain, range) => {
|
|
82403
82281
|
if (domain[0] === domain[1]) return datum => range[0];
|
|
82404
82282
|
const s0 = sqrt(domain[0]),
|
|
82405
82283
|
s1 = sqrt(domain[1]),
|
|
@@ -82492,22 +82370,29 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
|
|
|
82492
82370
|
};
|
|
82493
82371
|
}
|
|
82494
82372
|
|
|
82495
|
-
function
|
|
82373
|
+
function loadAndHandleImage(segmentationInput) {
|
|
82374
|
+
const imagePromise = loadImage(segmentationInput.shapeUrl);
|
|
82375
|
+
return imagePromise ? imagePromise.then(shapeImage => segmentationInput && segmentationInput.removeWhiteBorder && shapeImage ? removeBorder(shapeImage, segmentationInput.tempCanvas, segmentationInput.tempCtx) : shapeImage) : null;
|
|
82376
|
+
}
|
|
82377
|
+
function segmentation(shapeImage, segmentationInput) {
|
|
82496
82378
|
const {
|
|
82497
82379
|
size: size,
|
|
82498
|
-
|
|
82380
|
+
tempCanvas: tempCanvas,
|
|
82381
|
+
tempCtx: ctx
|
|
82499
82382
|
} = segmentationInput,
|
|
82500
|
-
|
|
82383
|
+
shapeConfig = scaleAndMiddleShape(shapeImage, size);
|
|
82384
|
+
tempCanvas.width = size[0], tempCanvas.height = size[1], ctx.clearRect(0, 0, tempCanvas.width, tempCanvas.height), ctx.drawImage(shapeImage, shapeConfig.x, shapeConfig.y, shapeConfig.width, shapeConfig.height);
|
|
82385
|
+
const imageData = ctx.getImageData(0, 0, size[0], size[1]),
|
|
82501
82386
|
labels = new Array(size[0] * size[1]).fill(0);
|
|
82502
82387
|
let curLabel = 1;
|
|
82503
82388
|
const offset = [[0, 1], [1, 0], [-1, 0], [0, -1]];
|
|
82504
82389
|
let queue = [];
|
|
82505
|
-
for (let i = 0; i < size[1]; i++) for (let j = 0; j < size[0]; j++) if (0 === labels[i * size[0] + j] && !
|
|
82390
|
+
for (let i = 0; i < size[1]; i++) for (let j = 0; j < size[0]; j++) if (0 === labels[i * size[0] + j] && !isEmptyPixel(imageData, i, j)) {
|
|
82506
82391
|
labels[i * size[0] + j] = curLabel, queue.push([i, j]);
|
|
82507
82392
|
for (let k = 0; k < queue.length; k++) for (let m = 0; m < 4; m++) {
|
|
82508
82393
|
let row = queue[k][0] + offset[m][0],
|
|
82509
82394
|
col = queue[k][1] + offset[m][1];
|
|
82510
|
-
row = row < 0 ? 0 : row >= size[1] ? size[1] - 1 : row, col = col < 0 ? 0 : col >= size[0] ? size[0] - 1 : col, 0 !== labels[row * size[0] + col] ||
|
|
82395
|
+
row = row < 0 ? 0 : row >= size[1] ? size[1] - 1 : row, col = col < 0 ? 0 : col >= size[0] ? size[0] - 1 : col, 0 !== labels[row * size[0] + col] || isEmptyPixel(imageData, row, col) || (labels[row * size[0] + col] = curLabel, queue.push([row, col]));
|
|
82511
82396
|
}
|
|
82512
82397
|
curLabel++, queue = [];
|
|
82513
82398
|
}
|
|
@@ -82560,6 +82445,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
|
|
|
82560
82445
|
};
|
|
82561
82446
|
return Object.assign(segmentationInput, {
|
|
82562
82447
|
segmentation: segmentation,
|
|
82448
|
+
shapeConfig: shapeConfig,
|
|
82563
82449
|
shapeBounds: shapeBounds,
|
|
82564
82450
|
shapeMaxR: shapeMaxR,
|
|
82565
82451
|
shapeRatio: shapeRatio,
|
|
@@ -82577,31 +82463,33 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
|
|
|
82577
82463
|
return !1;
|
|
82578
82464
|
}
|
|
82579
82465
|
}
|
|
82580
|
-
function
|
|
82581
|
-
|
|
82582
|
-
|
|
82583
|
-
|
|
82466
|
+
function isEmptyPixel(imageData, i, j) {
|
|
82467
|
+
const width = imageData.width;
|
|
82468
|
+
return 0 === imageData.data[i * width * 4 + 4 * j + 3] || 255 === imageData.data[i * width * 4 + 4 * j + 0] && 255 === imageData.data[i * width * 4 + 4 * j + 1] && 255 === imageData.data[i * width * 4 + 4 * j + 2];
|
|
82469
|
+
}
|
|
82470
|
+
function removeBorder(image, canvas, ctx) {
|
|
82471
|
+
canvas.width = image.width, canvas.height = image.height, ctx.clearRect(0, 0, canvas.width, canvas.height), ctx.drawImage(image, 0, 0);
|
|
82584
82472
|
const width = canvas.width,
|
|
82585
82473
|
imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
|
|
82586
82474
|
let top = 0,
|
|
82587
82475
|
bottom = imageData.height,
|
|
82588
82476
|
left = 0,
|
|
82589
82477
|
right = imageData.width;
|
|
82590
|
-
|
|
82591
|
-
|
|
82592
|
-
|
|
82593
|
-
|
|
82594
|
-
columnBlank = (x, y0, y1) => {
|
|
82595
|
-
for (let y = y0; y < y1; ++y) if (!isEmptyPixel(imageData, y, x)) return !1;
|
|
82596
|
-
return !0;
|
|
82597
|
-
};
|
|
82598
|
-
for (; top < bottom && rowBlank(width, top);) ++top;
|
|
82599
|
-
for (; bottom - 1 > top && rowBlank(width, bottom - 1);) --bottom;
|
|
82600
|
-
for (; left < right && columnBlank(left, top, bottom);) ++left;
|
|
82601
|
-
for (; right - 1 > left && columnBlank(right - 1, top, bottom);) --right;
|
|
82478
|
+
for (; top < bottom && rowBlank(imageData, width, top);) ++top;
|
|
82479
|
+
for (; bottom - 1 > top && rowBlank(imageData, width, bottom - 1);) --bottom;
|
|
82480
|
+
for (; left < right && columnBlank(imageData, width, left, top, bottom);) ++left;
|
|
82481
|
+
for (; right - 1 > left && columnBlank(imageData, width, right - 1, top, bottom);) --right;
|
|
82602
82482
|
const trimmed = ctx.getImageData(left, top, right - left, bottom - top);
|
|
82603
82483
|
return canvas.width = trimmed.width, canvas.height = trimmed.height, ctx.clearRect(0, 0, canvas.width, canvas.height), ctx.putImageData(trimmed, 0, 0), canvas;
|
|
82604
82484
|
}
|
|
82485
|
+
function rowBlank(imageData, width, y) {
|
|
82486
|
+
for (let x = 0; x < width; ++x) if (!isEmptyPixel(imageData, y, x)) return !1;
|
|
82487
|
+
return !0;
|
|
82488
|
+
}
|
|
82489
|
+
function columnBlank(imageData, width, x, top, bottom) {
|
|
82490
|
+
for (let y = top; y < bottom; ++y) if (!isEmptyPixel(imageData, y, x)) return !1;
|
|
82491
|
+
return !0;
|
|
82492
|
+
}
|
|
82605
82493
|
function scaleAndMiddleShape(image, size) {
|
|
82606
82494
|
const width = image.width,
|
|
82607
82495
|
height = image.height;
|
|
@@ -82667,14 +82555,14 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
|
|
|
82667
82555
|
segmentation: {
|
|
82668
82556
|
regions: regions
|
|
82669
82557
|
},
|
|
82558
|
+
tempCtx: ctx,
|
|
82670
82559
|
tempCanvas: canvas,
|
|
82671
82560
|
boardSize: boardSize,
|
|
82672
82561
|
shapeCenter: shapeCenter,
|
|
82673
82562
|
shapeMaxR: shapeMaxR,
|
|
82674
82563
|
shapeRatio: shapeRatio
|
|
82675
82564
|
} = segmentationOutput,
|
|
82676
|
-
board = initBoardWithShape(segmentationOutput)
|
|
82677
|
-
ctx = canvas.getContext("2d");
|
|
82565
|
+
board = initBoardWithShape(segmentationOutput);
|
|
82678
82566
|
for (const region of regions) {
|
|
82679
82567
|
const {
|
|
82680
82568
|
words: regionWords,
|
|
@@ -82709,13 +82597,13 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
|
|
|
82709
82597
|
segmentation: {
|
|
82710
82598
|
regions: regions
|
|
82711
82599
|
},
|
|
82600
|
+
tempCtx: ctx,
|
|
82712
82601
|
tempCanvas: canvas,
|
|
82713
82602
|
boardSize: boardSize,
|
|
82714
82603
|
shapeCenter: shapeCenter,
|
|
82715
82604
|
shapeMaxR: shapeMaxR,
|
|
82716
82605
|
shapeRatio: shapeRatio
|
|
82717
82606
|
} = segmentationOutput,
|
|
82718
|
-
ctx = canvas.getContext("2d"),
|
|
82719
82607
|
boardOrigin = initBoardWithShape(segmentationOutput);
|
|
82720
82608
|
let board = boardOrigin.slice(0);
|
|
82721
82609
|
const fontFactor = layoutConfig.fontSizeShrinkFactor;
|
|
@@ -82777,13 +82665,13 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
|
|
|
82777
82665
|
segmentation: {
|
|
82778
82666
|
regions: regions
|
|
82779
82667
|
},
|
|
82668
|
+
tempCtx: ctx,
|
|
82780
82669
|
tempCanvas: canvas,
|
|
82781
82670
|
boardSize: boardSize,
|
|
82782
82671
|
shapeCenter: shapeCenter,
|
|
82783
82672
|
shapeMaxR: shapeMaxR,
|
|
82784
82673
|
shapeRatio: shapeRatio
|
|
82785
82674
|
} = segmentationOutput,
|
|
82786
|
-
ctx = canvas.getContext("2d"),
|
|
82787
82675
|
boardOrigin = initBoardWithShape(segmentationOutput);
|
|
82788
82676
|
let board = boardOrigin.slice(0);
|
|
82789
82677
|
const fontFactor = layoutConfig.fontSizeEnlargeFactor,
|
|
@@ -83024,19 +82912,19 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
|
|
|
83024
82912
|
getFillingPadding: getFillingPadding,
|
|
83025
82913
|
random: random,
|
|
83026
82914
|
board: board,
|
|
83027
|
-
|
|
82915
|
+
minFillFoontSize: minFillFoontSize
|
|
83028
82916
|
} = layoutConfig,
|
|
83029
82917
|
{
|
|
83030
82918
|
boardSize: boardSize,
|
|
83031
82919
|
shapeBounds: shapeBounds,
|
|
82920
|
+
tempCtx: ctx,
|
|
83032
82921
|
tempCanvas: canvas,
|
|
83033
82922
|
randomGenerator: randomGenerator
|
|
83034
|
-
} = segmentationOutput
|
|
83035
|
-
ctx = canvas.getContext("2d");
|
|
82923
|
+
} = segmentationOutput;
|
|
83036
82924
|
let fontSize = fillingInitialFontSize,
|
|
83037
82925
|
opacity = fillingInitialOpacity;
|
|
83038
82926
|
const placedFillingWords = [];
|
|
83039
|
-
for (let i = 0; i < fillingTimes; i++) filling1Time(fontSize, opacity), fontSize = Math.max(fontSize > fillingDeltaFontSize ? fontSize - fillingDeltaFontSize : fillingDeltaFontSize,
|
|
82927
|
+
for (let i = 0; i < fillingTimes; i++) filling1Time(fontSize, opacity), fontSize = Math.max(fontSize > fillingDeltaFontSize ? fontSize - fillingDeltaFontSize : fillingDeltaFontSize, minFillFoontSize), opacity = opacity > fillingDeltaOpacity ? opacity - fillingDeltaOpacity : fillingDeltaOpacity;
|
|
83040
82928
|
return placedFillingWords;
|
|
83041
82929
|
function filling1Time(fontSize, opacity) {
|
|
83042
82930
|
const fillingWords = words.map(word => {
|
|
@@ -83140,6 +83028,8 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
|
|
|
83140
83028
|
size: options.size,
|
|
83141
83029
|
ratio: options.ratio || .8,
|
|
83142
83030
|
tempCanvas: void 0,
|
|
83031
|
+
tempCtx: void 0,
|
|
83032
|
+
removeWhiteBorder: options.removeWhiteBorder || !1,
|
|
83143
83033
|
boardSize: [0, 0],
|
|
83144
83034
|
random: !1,
|
|
83145
83035
|
randomGenerator: void 0
|
|
@@ -83149,31 +83039,15 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
|
|
|
83149
83039
|
height: options.size[1]
|
|
83150
83040
|
}),
|
|
83151
83041
|
tempCtx = tempCanvas.getContext("2d");
|
|
83152
|
-
tempCtx.textAlign = "center", tempCtx.textBaseline = "middle", segmentationInput.tempCanvas = tempCanvas;
|
|
83042
|
+
tempCtx.textAlign = "center", tempCtx.textBaseline = "middle", segmentationInput.tempCanvas = tempCanvas, segmentationInput.tempCtx = tempCtx;
|
|
83153
83043
|
const boardW = options.size[0] + 31 >> 5 << 5;
|
|
83154
|
-
|
|
83155
|
-
|
|
83156
|
-
|
|
83157
|
-
|
|
83158
|
-
|
|
83159
|
-
|
|
83160
|
-
|
|
83161
|
-
height: options.size[1],
|
|
83162
|
-
dpr: 1
|
|
83163
|
-
});
|
|
83164
|
-
segmentationInput.maskCanvas = maskCanvas;
|
|
83165
|
-
const ctx = maskCanvas.getContext("2d");
|
|
83166
|
-
options.removeWhiteBorder && removeBorder(shapeImage, maskCanvas, segmentationInput.isEmptyPixel);
|
|
83167
|
-
const shapeConfig = scaleAndMiddleShape(shapeImage, options.size);
|
|
83168
|
-
ctx.clearRect(0, 0, options.size[0], options.size[1]), ctx.drawImage(shapeImage, shapeConfig.x, shapeConfig.y, shapeConfig.width, shapeConfig.height), this.options.onUpdateMaskCanvas && this.options.onUpdateMaskCanvas(segmentationInput.maskCanvas);
|
|
83169
|
-
}).catch(error => {
|
|
83170
|
-
this.isImageFinished = !0;
|
|
83171
|
-
})) : (this.isImageFinished = !0, this.isLayoutFinished = !0);
|
|
83172
|
-
} else if (segmentationInput.shapeUrl && ("text" === segmentationInput.shapeUrl.type || "geometric" === segmentationInput.shapeUrl.type)) {
|
|
83173
|
-
segmentationInput.isEmptyPixel = generateIsEmptyPixel(segmentationInput.shapeUrl.backgroundColor);
|
|
83174
|
-
const maskCanvas = generateMaskCanvas(segmentationInput.shapeUrl, options.size[0], options.size[1]);
|
|
83175
|
-
segmentationInput.maskCanvas = maskCanvas, this.options.onUpdateMaskCanvas && this.options.onUpdateMaskCanvas(maskCanvas), this.doLayout(), this.isImageFinished = !0, this.isLayoutFinished = !0;
|
|
83176
|
-
}
|
|
83044
|
+
segmentationInput.boardSize = [boardW, options.size[1]], segmentationInput.random ? segmentationInput.randomGenerator = Math.random : segmentationInput.randomGenerator = fakeRandom();
|
|
83045
|
+
const imagePromise = loadAndHandleImage(segmentationInput);
|
|
83046
|
+
imagePromise ? (this.segmentationInput = segmentationInput, this.isImageFinished = !1, this.isLayoutFinished = !1, imagePromise.then(shapeImage => {
|
|
83047
|
+
this.shapeImage = shapeImage, this.isImageFinished = !0;
|
|
83048
|
+
}).catch(error => {
|
|
83049
|
+
this.shapeImage = null, this.isImageFinished = !0;
|
|
83050
|
+
})) : (this.isImageFinished = !0, this.isLayoutFinished = !0);
|
|
83177
83051
|
}
|
|
83178
83052
|
unfinished() {
|
|
83179
83053
|
return !this.isLayoutFinished;
|
|
@@ -83182,15 +83056,15 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
|
|
|
83182
83056
|
return this.progressiveResult;
|
|
83183
83057
|
}
|
|
83184
83058
|
progressiveRun() {
|
|
83185
|
-
this.isImageFinished && !this.isLayoutFinished && (this.
|
|
83059
|
+
this.isImageFinished && !this.isLayoutFinished && (this.shapeImage && this.doLayout(), this.isLayoutFinished = !0);
|
|
83186
83060
|
}
|
|
83187
83061
|
progressiveOutput() {
|
|
83188
83062
|
return this.progressiveResult;
|
|
83189
83063
|
}
|
|
83190
83064
|
doLayout() {
|
|
83191
|
-
var _a, _b, _c
|
|
83065
|
+
var _a, _b, _c;
|
|
83192
83066
|
const segmentationInput = this.segmentationInput,
|
|
83193
|
-
segmentationOutput = segmentation(segmentationInput),
|
|
83067
|
+
segmentationOutput = segmentation(this.shapeImage, segmentationInput),
|
|
83194
83068
|
options = this.options,
|
|
83195
83069
|
data = this.data,
|
|
83196
83070
|
colorMode = options.colorMode || "ordinal",
|
|
@@ -83216,33 +83090,33 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
|
|
|
83216
83090
|
ratio: options.ratio || .8,
|
|
83217
83091
|
shapeUrl: options.shape,
|
|
83218
83092
|
random: void 0 === options.random || options.random,
|
|
83219
|
-
textLayoutTimes:
|
|
83220
|
-
removeWhiteBorder: options.removeWhiteBorder,
|
|
83221
|
-
layoutMode:
|
|
83222
|
-
fontSizeShrinkFactor:
|
|
83223
|
-
stepFactor:
|
|
83224
|
-
importantWordCount:
|
|
83093
|
+
textLayoutTimes: options.textLayoutTimes || 3,
|
|
83094
|
+
removeWhiteBorder: options.removeWhiteBorder || !1,
|
|
83095
|
+
layoutMode: options.layoutMode || "default",
|
|
83096
|
+
fontSizeShrinkFactor: options.fontSizeShrinkFactor || .8,
|
|
83097
|
+
stepFactor: options.stepFactor || 1,
|
|
83098
|
+
importantWordCount: options.importantWordCount || 10,
|
|
83225
83099
|
globalShinkLimit: options.globalShinkLimit || .2,
|
|
83226
|
-
fontSizeEnlargeFactor:
|
|
83227
|
-
fillingRatio:
|
|
83228
|
-
fillingTimes:
|
|
83229
|
-
fillingXStep: options.fillingXRatioStep ? Math.max(Math.floor(options.size[0] * options.fillingXRatioStep), 1) :
|
|
83230
|
-
fillingYStep: options.fillingYRatioStep ? Math.max(Math.floor(options.size[1] * options.fillingYRatioStep), 1) :
|
|
83100
|
+
fontSizeEnlargeFactor: options.fontSizeEnlargeFactor || 1.5,
|
|
83101
|
+
fillingRatio: options.fillingRatio || .7,
|
|
83102
|
+
fillingTimes: options.fillingTimes || 4,
|
|
83103
|
+
fillingXStep: options.fillingXRatioStep ? Math.max(Math.floor(options.size[0] * options.fillingXRatioStep), 1) : options.fillingXStep || 4,
|
|
83104
|
+
fillingYStep: options.fillingYRatioStep ? Math.max(Math.floor(options.size[1] * options.fillingYRatioStep), 1) : options.fillingYStep || 4,
|
|
83231
83105
|
fillingInitialFontSize: options.fillingInitialFontSize,
|
|
83232
83106
|
fillingDeltaFontSize: options.fillingDeltaFontSize,
|
|
83233
|
-
fillingInitialOpacity:
|
|
83234
|
-
fillingDeltaOpacity:
|
|
83107
|
+
fillingInitialOpacity: options.fillingInitialOpacity || .8,
|
|
83108
|
+
fillingDeltaOpacity: options.fillingDeltaOpacity || .05,
|
|
83235
83109
|
getFillingFontFamily: field(options.fillingFontFamily || "sans-serif"),
|
|
83236
83110
|
getFillingFontStyle: field(options.fillingFontStyle || "normal"),
|
|
83237
83111
|
getFillingFontWeight: field(options.fillingFontWeight || "normal"),
|
|
83238
|
-
getFillingPadding: field(
|
|
83239
|
-
fillingRotateList:
|
|
83240
|
-
fillingDeltaFontSizeFactor:
|
|
83112
|
+
getFillingPadding: field(options.fillingPadding || .4),
|
|
83113
|
+
fillingRotateList: options.fillingRotateList || [0, 90],
|
|
83114
|
+
fillingDeltaFontSizeFactor: options.fillingDeltaFontSizeFactor || .2,
|
|
83241
83115
|
fillingColorList: options.fillingColorList || ["#537EF5"],
|
|
83242
83116
|
sameColorList: !1,
|
|
83243
|
-
minInitFontSize:
|
|
83244
|
-
minFontSize:
|
|
83245
|
-
|
|
83117
|
+
minInitFontSize: options.minInitFontSize || 10,
|
|
83118
|
+
minFontSize: options.minFontSize || 4,
|
|
83119
|
+
minFillFoontSize: options.minFillFoontSize || 2
|
|
83246
83120
|
},
|
|
83247
83121
|
sameColorList = colorListEqual(wordsConfig.colorList, layoutConfig.fillingColorList);
|
|
83248
83122
|
layoutConfig.sameColorList = sameColorList, initColorScale(data, wordsConfig, layoutConfig, options), initFillingWordsFontSize(data, wordsConfig, layoutConfig, segmentationOutput);
|
|
@@ -83289,16 +83163,16 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
|
|
|
83289
83163
|
successedWords: successedWords,
|
|
83290
83164
|
failedWords: failedWords
|
|
83291
83165
|
} = cloud(words, layoutConfig, segmentationOutput),
|
|
83292
|
-
textKey = null !== (
|
|
83293
|
-
dataIndexKey = null !== (
|
|
83294
|
-
as = options.as
|
|
83166
|
+
textKey = null !== (_b = null === (_a = options.text) || void 0 === _a ? void 0 : _a.field) && void 0 !== _b ? _b : "textKey",
|
|
83167
|
+
dataIndexKey = null !== (_c = options.dataIndexKey) && void 0 !== _c ? _c : "defaultDataIndexKey",
|
|
83168
|
+
as = options.as || OUTPUT;
|
|
83295
83169
|
let w, t;
|
|
83296
83170
|
const modKeywords = [];
|
|
83297
83171
|
for (let i = 0; i < words.length; ++i) w = words[i], t = w.datum, t[as.x] = w.x, t[as.y] = w.y, t[as.fontFamily] = w.fontFamily, t[as.fontSize] = w.fontSize, t[as.fontStyle] = w.fontStyle, t[as.fontWeight] = w.fontWeight, t[as.angle] = degreeToRadian(w.rotate), t[as.opacity] = w.opacity, t[as.visible] = w.visible, t[as.isFillingWord] = !1, t[as.color] = w.color, t[dataIndexKey] = `${w.text}_${i}_keyword`, modKeywords.push(t);
|
|
83298
83172
|
const fillingWordsData = [];
|
|
83299
83173
|
fillingWords.forEach((word, index) => {
|
|
83300
83174
|
var _a, _b;
|
|
83301
|
-
const t =
|
|
83175
|
+
const t = {};
|
|
83302
83176
|
t[as.x] = word.x, t[as.y] = word.y, t[as.fontFamily] = word.fontFamily, t[as.fontSize] = word.fontSize, t[as.fontStyle] = word.fontStyle, t[as.fontWeight] = word.fontWeight, t[as.angle] = degreeToRadian(word.rotate), t[as.opacity] = word.opacity, t[as.visible] = word.visible, t[as.isFillingWord] = !0, t[as.color] = getFillingColor ? (null === (_a = options.colorField) || void 0 === _a ? void 0 : _a.field) === (null === (_b = options.fillingColorField) || void 0 === _b ? void 0 : _b.field) && sameColorList ? word.color : word.fillingColor : layoutConfig.fillingColorList[~~(segmentationInput.randomGenerator() * layoutConfig.fillingColorList.length)], t[textKey] = word.text, t[dataIndexKey] = `${word.text}_${index}_fillingWords`, fillingWordsData.push(t);
|
|
83303
83177
|
}), this.view && this.view.emit && this.view.emit(WORDCLOUD_SHAPE_HOOK_EVENT.AFTER_WORDCLOUD_SHAPE_LAYOUT, {
|
|
83304
83178
|
successedWords: successedWords,
|
|
@@ -83306,7 +83180,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
|
|
|
83306
83180
|
}), this.progressiveResult = modKeywords.concat(fillingWordsData);
|
|
83307
83181
|
}
|
|
83308
83182
|
release() {
|
|
83309
|
-
this.segmentationInput = null, this.data = null, this.progressiveResult = null, this.options = null;
|
|
83183
|
+
this.segmentationInput = null, this.data = null, this.shapeImage = null, this.progressiveResult = null, this.options = null;
|
|
83310
83184
|
}
|
|
83311
83185
|
}
|
|
83312
83186
|
const initColorScale = (data, wordsConfig, layoutConfig, options) => {
|
|
@@ -91477,7 +91351,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
|
|
|
91477
91351
|
|
|
91478
91352
|
class WordCloudChartSpecTransformer extends BaseWordCloudChartSpecTransformer {
|
|
91479
91353
|
_getDefaultSeriesSpec(spec) {
|
|
91480
|
-
const series = Object.assign(Object.assign({}, super._getDefaultSeriesSpec(spec)), { nameField: spec.nameField, valueField: spec.valueField, seriesField: spec.seriesField, fontFamilyField: spec.fontFamilyField, fontWeightField: spec.fontWeightField, fontStyleField: spec.fontStyleField, colorHexField: spec.colorHexField, colorMode: spec.colorMode, colorList: spec.colorList, rotateAngles: spec.rotateAngles, fontWeightRange: spec.fontWeightRange, fontSizeRange: spec.fontSizeRange, maskShape: spec.maskShape, keepAspect: spec.keepAspect, random: spec.random, wordCloudConfig: spec.wordCloudConfig, wordCloudShapeConfig: spec.wordCloudShapeConfig, word: spec.word, fillingWord: spec.fillingWord
|
|
91354
|
+
const series = Object.assign(Object.assign({}, super._getDefaultSeriesSpec(spec)), { nameField: spec.nameField, valueField: spec.valueField, seriesField: spec.seriesField, fontFamilyField: spec.fontFamilyField, fontWeightField: spec.fontWeightField, fontStyleField: spec.fontStyleField, colorHexField: spec.colorHexField, colorMode: spec.colorMode, colorList: spec.colorList, rotateAngles: spec.rotateAngles, fontWeightRange: spec.fontWeightRange, fontSizeRange: spec.fontSizeRange, maskShape: spec.maskShape, keepAspect: spec.keepAspect, random: spec.random, wordCloudConfig: spec.wordCloudConfig, wordCloudShapeConfig: spec.wordCloudShapeConfig, word: spec.word, fillingWord: spec.fillingWord });
|
|
91481
91355
|
const seriesType = this.seriesType;
|
|
91482
91356
|
if (seriesType) {
|
|
91483
91357
|
series.type = seriesType;
|