cx 25.6.0 → 25.6.2
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/dist/charts.js +99 -8
- package/dist/manifest.js +709 -709
- package/package.json +2 -2
- package/src/charts/LineGraph.d.ts +9 -0
- package/src/charts/LineGraph.js +77 -7
package/dist/charts.js
CHANGED
|
@@ -3330,6 +3330,8 @@ var LineGraph = /*#__PURE__*/ (function (_Widget) {
|
|
|
3330
3330
|
active: true,
|
|
3331
3331
|
stack: undefined,
|
|
3332
3332
|
stacked: undefined,
|
|
3333
|
+
smooth: undefined,
|
|
3334
|
+
smoothingRatio: undefined,
|
|
3333
3335
|
},
|
|
3334
3336
|
]),
|
|
3335
3337
|
);
|
|
@@ -3337,6 +3339,10 @@ var LineGraph = /*#__PURE__*/ (function (_Widget) {
|
|
|
3337
3339
|
_proto.prepareData = function prepareData(context, instance) {
|
|
3338
3340
|
var data = instance.data;
|
|
3339
3341
|
if (data.name && !data.colorName) data.colorName = data.name;
|
|
3342
|
+
if (data.smooth && data.smoothingRatio != null) {
|
|
3343
|
+
if (data.smoothingRatio < 0) data.smoothingRatio = 0;
|
|
3344
|
+
if (data.smoothingRatio > 0.4) data.smoothingRatio = 0.4;
|
|
3345
|
+
}
|
|
3340
3346
|
_Widget.prototype.prepareData.call(this, context, instance);
|
|
3341
3347
|
};
|
|
3342
3348
|
_proto.explore = function explore(context, instance) {
|
|
@@ -3443,18 +3449,24 @@ var LineGraph = /*#__PURE__*/ (function (_Widget) {
|
|
|
3443
3449
|
return spans;
|
|
3444
3450
|
};
|
|
3445
3451
|
_proto.render = function render(context, instance, key) {
|
|
3446
|
-
var _stateMods
|
|
3452
|
+
var _stateMods,
|
|
3453
|
+
_this4 = this;
|
|
3447
3454
|
var data = instance.data,
|
|
3448
3455
|
lineSpans = instance.lineSpans;
|
|
3449
3456
|
if (!lineSpans) return null;
|
|
3450
3457
|
var stateMods = ((_stateMods = {}), (_stateMods["color-" + data.colorIndex] = data.colorIndex != null), _stateMods);
|
|
3451
3458
|
var line, area;
|
|
3459
|
+
var r = data.smoothingRatio;
|
|
3460
|
+
var linePath = "";
|
|
3452
3461
|
if (data.line) {
|
|
3453
|
-
var linePath = "";
|
|
3454
3462
|
lineSpans.forEach(function (span) {
|
|
3455
3463
|
span.forEach(function (p, i) {
|
|
3456
|
-
linePath +=
|
|
3457
|
-
|
|
3464
|
+
linePath +=
|
|
3465
|
+
i == 0
|
|
3466
|
+
? "M " + p.x + " " + p.y
|
|
3467
|
+
: !data.smooth || span.length < 2
|
|
3468
|
+
? "L " + p.x + " " + p.y
|
|
3469
|
+
: _this4.getCurvedPathSegment(p, span, i - 1, i - 2, i - 1, i + 1, r);
|
|
3458
3470
|
});
|
|
3459
3471
|
});
|
|
3460
3472
|
line = /*#__PURE__*/ jsx("path", {
|
|
@@ -3468,12 +3480,32 @@ var LineGraph = /*#__PURE__*/ (function (_Widget) {
|
|
|
3468
3480
|
lineSpans.forEach(function (span) {
|
|
3469
3481
|
var closePath = "";
|
|
3470
3482
|
span.forEach(function (p, i) {
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3483
|
+
var segment = "";
|
|
3484
|
+
if (i == 0) {
|
|
3485
|
+
segment = "M " + p.x + " " + p.y;
|
|
3486
|
+
|
|
3487
|
+
// closing point
|
|
3488
|
+
closePath =
|
|
3489
|
+
!data.smooth || span.length < 2
|
|
3490
|
+
? "L " + p.x + " " + p.y0
|
|
3491
|
+
: _this4.getCurvedPathSegment(p, span, i + 1, i + 2, i + 1, i - 1, r, "y0");
|
|
3492
|
+
} else {
|
|
3493
|
+
if (!data.smooth) {
|
|
3494
|
+
segment = "L " + p.x + " " + p.y;
|
|
3495
|
+
closePath = "L " + p.x + " " + p.y0 + closePath;
|
|
3496
|
+
} else {
|
|
3497
|
+
segment = _this4.getCurvedPathSegment(p, span, i - 1, i - 2, i - 1, i + 1, r, "y");
|
|
3498
|
+
|
|
3499
|
+
// closing point
|
|
3500
|
+
if (i < span.length - 1)
|
|
3501
|
+
closePath = _this4.getCurvedPathSegment(p, span, i + 1, i + 2, i + 1, i - 1, r, "y0") + closePath;
|
|
3502
|
+
}
|
|
3503
|
+
}
|
|
3504
|
+
areaPath += segment;
|
|
3474
3505
|
});
|
|
3506
|
+
areaPath += "L " + span[span.length - 1].x + " " + span[span.length - 1].y0;
|
|
3475
3507
|
areaPath += closePath;
|
|
3476
|
-
areaPath += "
|
|
3508
|
+
areaPath += "Z";
|
|
3477
3509
|
});
|
|
3478
3510
|
area = /*#__PURE__*/ jsx("path", {
|
|
3479
3511
|
className: this.CSS.element(this.baseClass, "area", stateMods),
|
|
@@ -3490,6 +3522,63 @@ var LineGraph = /*#__PURE__*/ (function (_Widget) {
|
|
|
3490
3522
|
key,
|
|
3491
3523
|
);
|
|
3492
3524
|
};
|
|
3525
|
+
_proto.getCurvedPathSegment = function getCurvedPathSegment(p, points, i1, i2, j1, j2, r, yField) {
|
|
3526
|
+
if (yField === void 0) {
|
|
3527
|
+
yField = "y";
|
|
3528
|
+
}
|
|
3529
|
+
var _this$getControlPoint = this.getControlPoint({
|
|
3530
|
+
cp: points[i1],
|
|
3531
|
+
pp: points[i2],
|
|
3532
|
+
r: r,
|
|
3533
|
+
np: p,
|
|
3534
|
+
yField: yField,
|
|
3535
|
+
}),
|
|
3536
|
+
sx = _this$getControlPoint[0],
|
|
3537
|
+
sy = _this$getControlPoint[1];
|
|
3538
|
+
var _this$getControlPoint2 = this.getControlPoint({
|
|
3539
|
+
cp: p,
|
|
3540
|
+
pp: points[j1],
|
|
3541
|
+
np: points[j2],
|
|
3542
|
+
r: r,
|
|
3543
|
+
reverse: true,
|
|
3544
|
+
yField: yField,
|
|
3545
|
+
}),
|
|
3546
|
+
ex = _this$getControlPoint2[0],
|
|
3547
|
+
ey = _this$getControlPoint2[1];
|
|
3548
|
+
return "C " + sx + " " + sy + ", " + ex + " " + ey + ", " + p.x + " " + p[yField];
|
|
3549
|
+
};
|
|
3550
|
+
_proto.getControlPoint = function getControlPoint(_ref) {
|
|
3551
|
+
var cp = _ref.cp,
|
|
3552
|
+
pp = _ref.pp,
|
|
3553
|
+
np = _ref.np,
|
|
3554
|
+
r = _ref.r,
|
|
3555
|
+
reverse = _ref.reverse,
|
|
3556
|
+
_ref$yField = _ref.yField,
|
|
3557
|
+
yField = _ref$yField === void 0 ? "y" : _ref$yField;
|
|
3558
|
+
// When 'current' is the first or last point of the array 'previous' or 'next' don't exist. Replace with 'current'.
|
|
3559
|
+
var p = pp || cp;
|
|
3560
|
+
var n = np || cp;
|
|
3561
|
+
|
|
3562
|
+
// Properties of the opposed-line
|
|
3563
|
+
var _this$getLineInfo = this.getLineInfo(p.x, p[yField], n.x, n[yField]),
|
|
3564
|
+
angle = _this$getLineInfo.angle,
|
|
3565
|
+
length = _this$getLineInfo.length;
|
|
3566
|
+
// If it is end-control-point, add PI to the angle to go backward
|
|
3567
|
+
angle = angle + (reverse ? Math.PI : 0);
|
|
3568
|
+
length = length * r;
|
|
3569
|
+
// The control point position is relative to the current point
|
|
3570
|
+
var x = cp.x + Math.cos(angle) * length;
|
|
3571
|
+
var y = cp[yField] + Math.sin(angle) * length;
|
|
3572
|
+
return [x, y];
|
|
3573
|
+
};
|
|
3574
|
+
_proto.getLineInfo = function getLineInfo(p1x, p1y, p2x, p2y) {
|
|
3575
|
+
var lengthX = p2x - p1x;
|
|
3576
|
+
var lengthY = p2y - p1y;
|
|
3577
|
+
return {
|
|
3578
|
+
length: Math.sqrt(Math.pow(lengthX, 2) + Math.pow(lengthY, 2)),
|
|
3579
|
+
angle: Math.atan2(lengthY, lengthX),
|
|
3580
|
+
};
|
|
3581
|
+
};
|
|
3493
3582
|
return LineGraph;
|
|
3494
3583
|
})(Widget);
|
|
3495
3584
|
LineGraph.prototype.xAxis = "x";
|
|
@@ -3507,6 +3596,8 @@ LineGraph.prototype.legendAction = "auto";
|
|
|
3507
3596
|
LineGraph.prototype.legendShape = "rect";
|
|
3508
3597
|
LineGraph.prototype.stack = "stack";
|
|
3509
3598
|
LineGraph.prototype.hiddenBase = false;
|
|
3599
|
+
LineGraph.prototype.smooth = false;
|
|
3600
|
+
LineGraph.prototype.smoothingRatio = 0.05;
|
|
3510
3601
|
Widget.alias("line-graph", LineGraph);
|
|
3511
3602
|
|
|
3512
3603
|
var ColumnBarGraphBase = /*#__PURE__*/ (function (_Widget) {
|