cx 24.10.4 → 24.10.5
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 +103 -20
- package/dist/manifest.js +690 -690
- package/package.json +1 -1
- package/src/charts/axis/Axis.d.ts +113 -110
- package/src/charts/axis/Axis.js +30 -10
- package/src/charts/axis/CategoryAxis.d.ts +27 -24
- package/src/charts/axis/CategoryAxis.js +235 -212
package/dist/charts.js
CHANGED
|
@@ -37,6 +37,32 @@ import {
|
|
|
37
37
|
getCursorPos,
|
|
38
38
|
} from "cx/widgets";
|
|
39
39
|
|
|
40
|
+
function _arrayLikeToArray(r, a) {
|
|
41
|
+
(null == a || a > r.length) && (a = r.length);
|
|
42
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
43
|
+
return n;
|
|
44
|
+
}
|
|
45
|
+
function _createForOfIteratorHelperLoose(r, e) {
|
|
46
|
+
var t = ("undefined" != typeof Symbol && r[Symbol.iterator]) || r["@@iterator"];
|
|
47
|
+
if (t) return (t = t.call(r)).next.bind(t);
|
|
48
|
+
if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) {
|
|
49
|
+
t && (r = t);
|
|
50
|
+
var o = 0;
|
|
51
|
+
return function () {
|
|
52
|
+
return o >= r.length
|
|
53
|
+
? {
|
|
54
|
+
done: !0,
|
|
55
|
+
}
|
|
56
|
+
: {
|
|
57
|
+
done: !1,
|
|
58
|
+
value: r[o++],
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
throw new TypeError(
|
|
63
|
+
"Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.",
|
|
64
|
+
);
|
|
65
|
+
}
|
|
40
66
|
function _extends() {
|
|
41
67
|
return (
|
|
42
68
|
(_extends = Object.assign
|
|
@@ -64,6 +90,20 @@ function _setPrototypeOf(t, e) {
|
|
|
64
90
|
_setPrototypeOf(t, e)
|
|
65
91
|
);
|
|
66
92
|
}
|
|
93
|
+
function _unsupportedIterableToArray(r, a) {
|
|
94
|
+
if (r) {
|
|
95
|
+
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
96
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
97
|
+
return (
|
|
98
|
+
"Object" === t && r.constructor && (t = r.constructor.name),
|
|
99
|
+
"Map" === t || "Set" === t
|
|
100
|
+
? Array.from(r)
|
|
101
|
+
: "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)
|
|
102
|
+
? _arrayLikeToArray(r, a)
|
|
103
|
+
: void 0
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
67
107
|
|
|
68
108
|
var Rect = /*#__PURE__*/ (function () {
|
|
69
109
|
function Rect(config) {
|
|
@@ -286,7 +326,8 @@ var Axis = /*#__PURE__*/ (function (_BoundedObject) {
|
|
|
286
326
|
y1,
|
|
287
327
|
x2,
|
|
288
328
|
y2,
|
|
289
|
-
tickSize = this.tickSize
|
|
329
|
+
tickSize = this.tickSize,
|
|
330
|
+
tickOffset = this.tickOffset;
|
|
290
331
|
if (this.vertical) {
|
|
291
332
|
x1 = x2 = this.secondary ? bounds.r : bounds.l;
|
|
292
333
|
y1 = bounds.b;
|
|
@@ -318,17 +359,17 @@ var Axis = /*#__PURE__*/ (function (_BoundedObject) {
|
|
|
318
359
|
serie.forEach(function (v, i) {
|
|
319
360
|
var s = calculator.map(v);
|
|
320
361
|
if (_this.secondary) {
|
|
321
|
-
x1 = _this.vertical ? bounds.r : s;
|
|
322
|
-
y1 = _this.vertical ? s : bounds.t;
|
|
323
|
-
x2 = _this.vertical ? bounds.r + tickSize : s;
|
|
324
|
-
y2 = _this.vertical ? s : bounds.t - tickSize;
|
|
362
|
+
x1 = _this.vertical ? bounds.r + tickOffset : s;
|
|
363
|
+
y1 = _this.vertical ? s : bounds.t - tickOffset;
|
|
364
|
+
x2 = _this.vertical ? bounds.r + tickOffset + tickSize : s;
|
|
365
|
+
y2 = _this.vertical ? s : bounds.t - tickOffset - tickSize;
|
|
325
366
|
} else {
|
|
326
|
-
x1 = _this.vertical ? bounds.l : s;
|
|
327
|
-
y1 = _this.vertical ? s : bounds.b;
|
|
328
|
-
x2 = _this.vertical ? bounds.l - tickSize : s;
|
|
329
|
-
y2 = _this.vertical ? s : bounds.b + tickSize;
|
|
367
|
+
x1 = _this.vertical ? bounds.l - tickOffset : s;
|
|
368
|
+
y1 = _this.vertical ? s : bounds.b + tickOffset;
|
|
369
|
+
x2 = _this.vertical ? bounds.l - tickOffset - tickSize : s;
|
|
370
|
+
y2 = _this.vertical ? s : bounds.b + tickOffset + tickSize;
|
|
330
371
|
}
|
|
331
|
-
t.push("M " + x1 + " " + y1 + " L " + x2 + " " + y2);
|
|
372
|
+
if (!_this.useGridlineTicks) t.push("M " + x1 + " " + y1 + " L " + x2 + " " + y2);
|
|
332
373
|
var x, y;
|
|
333
374
|
var labelOffset =
|
|
334
375
|
_this.alternateLabelOffset != null && i % 2 == 1 ? _this.alternateLabelOffset : _this.labelOffset;
|
|
@@ -366,6 +407,23 @@ var Axis = /*#__PURE__*/ (function (_BoundedObject) {
|
|
|
366
407
|
});
|
|
367
408
|
}
|
|
368
409
|
if (!data.hideTicks) {
|
|
410
|
+
if (this.useGridlineTicks) {
|
|
411
|
+
var gridlines = calculator.mapGridlines();
|
|
412
|
+
gridlines.forEach(function (s, i) {
|
|
413
|
+
if (_this.secondary) {
|
|
414
|
+
x1 = _this.vertical ? bounds.r + tickOffset : s;
|
|
415
|
+
y1 = _this.vertical ? s : bounds.t - tickOffset;
|
|
416
|
+
x2 = _this.vertical ? bounds.r + tickOffset + tickSize : s;
|
|
417
|
+
y2 = _this.vertical ? s : bounds.t - tickOffset - tickSize;
|
|
418
|
+
} else {
|
|
419
|
+
x1 = _this.vertical ? bounds.l - tickOffset : s;
|
|
420
|
+
y1 = _this.vertical ? s : bounds.b + tickOffset;
|
|
421
|
+
x2 = _this.vertical ? bounds.l - tickOffset - tickSize : s;
|
|
422
|
+
y2 = _this.vertical ? s : bounds.b + tickOffset + tickSize;
|
|
423
|
+
}
|
|
424
|
+
t.push("M " + x1 + " " + y1 + " L " + x2 + " " + y2);
|
|
425
|
+
});
|
|
426
|
+
}
|
|
369
427
|
res[1] = /*#__PURE__*/ jsx(
|
|
370
428
|
"path",
|
|
371
429
|
{
|
|
@@ -466,6 +524,7 @@ Axis.prototype.hideLabels = false;
|
|
|
466
524
|
Axis.prototype.hideTicks = false;
|
|
467
525
|
Axis.prototype.hideLine = false;
|
|
468
526
|
Axis.prototype.tickSize = 3;
|
|
527
|
+
Axis.prototype.tickOffset = 0;
|
|
469
528
|
Axis.prototype.minTickDistance = 25;
|
|
470
529
|
Axis.prototype.minLabelDistanceVertical = 40;
|
|
471
530
|
Axis.prototype.minLabelDistanceHorizontal = 50;
|
|
@@ -4566,7 +4625,7 @@ var CategoryAxis = /*#__PURE__*/ (function (_Axis) {
|
|
|
4566
4625
|
inverted = _instance$data.inverted,
|
|
4567
4626
|
uniform = _instance$data.uniform,
|
|
4568
4627
|
minSize = _instance$data.minSize;
|
|
4569
|
-
instance.calculator.reset(inverted, uniform, values, names, minSize);
|
|
4628
|
+
instance.calculator.reset(inverted, uniform, values, names, minSize, this.minTickDistance, this.minLabelDistance);
|
|
4570
4629
|
};
|
|
4571
4630
|
_proto.reportData = function reportData(context, instance) {
|
|
4572
4631
|
instance.set("categoryCount", instance.calculator.valueList.length);
|
|
@@ -4601,11 +4660,14 @@ CategoryAxis.prototype.labelAnchor = "auto";
|
|
|
4601
4660
|
CategoryAxis.prototype.labelDx = "auto";
|
|
4602
4661
|
CategoryAxis.prototype.labelDy = "auto";
|
|
4603
4662
|
CategoryAxis.prototype.minSize = 1;
|
|
4663
|
+
CategoryAxis.prototype.minLabelDistanceHorizontal = 0;
|
|
4664
|
+
CategoryAxis.prototype.minLabelDistanceVertical = 0;
|
|
4665
|
+
CategoryAxis.prototype.minTickDistance = 0;
|
|
4604
4666
|
Axis.alias("category", CategoryAxis);
|
|
4605
4667
|
var CategoryScale = /*#__PURE__*/ (function () {
|
|
4606
4668
|
function CategoryScale() {}
|
|
4607
4669
|
var _proto2 = CategoryScale.prototype;
|
|
4608
|
-
_proto2.reset = function reset(inverted, uniform, values, names, minSize) {
|
|
4670
|
+
_proto2.reset = function reset(inverted, uniform, values, names, minSize, minTickDistance, minLabelDistance) {
|
|
4609
4671
|
var _this = this;
|
|
4610
4672
|
this.padding = 0.5;
|
|
4611
4673
|
delete this.min;
|
|
@@ -4619,6 +4681,8 @@ var CategoryScale = /*#__PURE__*/ (function () {
|
|
|
4619
4681
|
this.uniform = uniform;
|
|
4620
4682
|
this.valueStacks = {};
|
|
4621
4683
|
this.names = {};
|
|
4684
|
+
this.minTickDistance = minTickDistance;
|
|
4685
|
+
this.minLabelDistance = minLabelDistance;
|
|
4622
4686
|
if (values) {
|
|
4623
4687
|
if (isArray(values))
|
|
4624
4688
|
values.forEach(function (v) {
|
|
@@ -4666,6 +4730,19 @@ var CategoryScale = /*#__PURE__*/ (function () {
|
|
|
4666
4730
|
this.factor = (sign * (this.b - this.a)) / (this.max - this.min + 2 * this.padding);
|
|
4667
4731
|
this.origin = (this.a * (1 + sign)) / 2 + (this.b * (1 - sign)) / 2; //a || b
|
|
4668
4732
|
}
|
|
4733
|
+
this.tickSizes = [];
|
|
4734
|
+
var tickMultiplier = [1, 2, 5];
|
|
4735
|
+
var absFactor = Math.abs(this.factor);
|
|
4736
|
+
for (var base = 1; base < 10000 && this.tickSizes.length < 2; base *= 10) {
|
|
4737
|
+
for (var _iterator = _createForOfIteratorHelperLoose(tickMultiplier), _step; !(_step = _iterator()).done; ) {
|
|
4738
|
+
var m = _step.value;
|
|
4739
|
+
if (base * m * absFactor >= this.minTickDistance && this.tickSizes.length == 0) this.tickSizes.push(base * m);
|
|
4740
|
+
if (base * m * absFactor >= this.minLabelDistance) {
|
|
4741
|
+
this.tickSizes.push(base * m);
|
|
4742
|
+
break;
|
|
4743
|
+
}
|
|
4744
|
+
}
|
|
4745
|
+
}
|
|
4669
4746
|
};
|
|
4670
4747
|
_proto2.hash = function hash() {
|
|
4671
4748
|
return {
|
|
@@ -4736,24 +4813,30 @@ var CategoryScale = /*#__PURE__*/ (function () {
|
|
|
4736
4813
|
return this.valueList[index];
|
|
4737
4814
|
};
|
|
4738
4815
|
_proto2.findTickSize = function findTickSize(minPxDist) {
|
|
4816
|
+
for (var _iterator2 = _createForOfIteratorHelperLoose(this.tickSizes), _step2; !(_step2 = _iterator2()).done; ) {
|
|
4817
|
+
var tickSize = _step2.value;
|
|
4818
|
+
if (tickSize * Math.abs(this.factor) >= minPxDist) return tickSize;
|
|
4819
|
+
}
|
|
4739
4820
|
return 1;
|
|
4740
4821
|
};
|
|
4741
4822
|
_proto2.getTickSizes = function getTickSizes() {
|
|
4742
|
-
return
|
|
4823
|
+
return this.tickSizes;
|
|
4743
4824
|
};
|
|
4744
4825
|
_proto2.getTicks = function getTicks(tickSizes) {
|
|
4745
4826
|
var _this2 = this;
|
|
4746
4827
|
return tickSizes.map(function (size) {
|
|
4747
|
-
return _this2.valueList
|
|
4828
|
+
return _this2.valueList.filter(function (_, i) {
|
|
4829
|
+
return i % size == 0;
|
|
4830
|
+
});
|
|
4748
4831
|
});
|
|
4749
4832
|
};
|
|
4750
4833
|
_proto2.mapGridlines = function mapGridlines() {
|
|
4751
|
-
var
|
|
4752
|
-
return
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
|
|
4834
|
+
var result = [];
|
|
4835
|
+
if (this.tickSizes.length == 0) return result;
|
|
4836
|
+
var step = this.tickSizes[0];
|
|
4837
|
+
for (var index = this.min; index <= this.max + 1; index += step)
|
|
4838
|
+
result.push(this.origin + (index - 0.5 - this.min + this.padding) * this.factor);
|
|
4839
|
+
return result;
|
|
4757
4840
|
};
|
|
4758
4841
|
return CategoryScale;
|
|
4759
4842
|
})();
|