@visactor/vtable-calendar 1.26.0 → 1.26.1-alpha.0
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/vtable-calendar.js +79 -27
- package/dist/vtable-calendar.min.js +1 -1
- package/package.json +6 -5
package/dist/vtable-calendar.js
CHANGED
|
@@ -1789,6 +1789,20 @@
|
|
|
1789
1789
|
function crossProduct(dir1, dir2) {
|
|
1790
1790
|
return dir1[0] * dir2[1] - dir1[1] * dir2[0];
|
|
1791
1791
|
}
|
|
1792
|
+
function fixPrecision$1(num, precision = 10) {
|
|
1793
|
+
return Math.round(num * precision) / precision;
|
|
1794
|
+
}
|
|
1795
|
+
function getDecimalPlaces(n) {
|
|
1796
|
+
const dStr = n.toString().split(/[eE]/),
|
|
1797
|
+
s = (dStr[0].split(".")[1] || "").length - (+dStr[1] || 0);
|
|
1798
|
+
return s > 0 ? s : 0;
|
|
1799
|
+
}
|
|
1800
|
+
function precisionAdd(a, b) {
|
|
1801
|
+
return fixPrecision$1(a + b, 10 ** Math.max(getDecimalPlaces(a), getDecimalPlaces(b)));
|
|
1802
|
+
}
|
|
1803
|
+
function precisionSub(a, b) {
|
|
1804
|
+
return fixPrecision$1(a - b, 10 ** Math.max(getDecimalPlaces(a), getDecimalPlaces(b)));
|
|
1805
|
+
}
|
|
1792
1806
|
|
|
1793
1807
|
class Point {
|
|
1794
1808
|
constructor(x = 0, y = 0, x1, y1) {
|
|
@@ -33714,42 +33728,54 @@
|
|
|
33714
33728
|
if (record) if (this.isRecord && this.records && (record.isAggregator ? this.records.push(...record.records) : this.records.push(record)), record.isAggregator && this.children) {
|
|
33715
33729
|
this.children.push(record);
|
|
33716
33730
|
const value = record.value();
|
|
33717
|
-
this.sum
|
|
33731
|
+
this.sum = precisionAdd(this.sum, null != value ? value : 0), this.needSplitPositiveAndNegativeForSum && (value > 0 ? this.positiveSum = precisionAdd(this.positiveSum, value) : value < 0 && (this.nagetiveSum = precisionAdd(this.nagetiveSum, value)));
|
|
33718
33732
|
} else if (this.field && !isNaN(parseFloat(record[this.field]))) {
|
|
33719
33733
|
const value = parseFloat(record[this.field]);
|
|
33720
|
-
this.sum
|
|
33734
|
+
this.sum = precisionAdd(this.sum, value), this.needSplitPositiveAndNegativeForSum && (value > 0 ? this.positiveSum = precisionAdd(this.positiveSum, value) : value < 0 && (this.nagetiveSum = precisionAdd(this.nagetiveSum, value)));
|
|
33721
33735
|
}
|
|
33722
33736
|
this.clearCacheValue();
|
|
33723
33737
|
}
|
|
33724
33738
|
deleteRecord(record) {
|
|
33725
|
-
if (record)
|
|
33726
|
-
this.
|
|
33727
|
-
|
|
33728
|
-
|
|
33729
|
-
|
|
33730
|
-
|
|
33731
|
-
|
|
33739
|
+
if (record) {
|
|
33740
|
+
if (this.isRecord && this.records) {
|
|
33741
|
+
const index = this.records.indexOf(record);
|
|
33742
|
+
-1 !== index && this.records.splice(index, 1);
|
|
33743
|
+
}
|
|
33744
|
+
if (record.isAggregator && this.children) {
|
|
33745
|
+
const index = this.children.indexOf(record);
|
|
33746
|
+
-1 !== index && this.children.splice(index, 1);
|
|
33747
|
+
const value = record.value();
|
|
33748
|
+
this.sum = precisionSub(this.sum, null != value ? value : 0), this.needSplitPositiveAndNegativeForSum && (value > 0 ? this.positiveSum = precisionSub(this.positiveSum, value) : value < 0 && (this.nagetiveSum = precisionSub(this.nagetiveSum, value)));
|
|
33749
|
+
} else if (this.field && !isNaN(parseFloat(record[this.field]))) {
|
|
33750
|
+
const value = parseFloat(record[this.field]);
|
|
33751
|
+
this.sum = precisionSub(this.sum, value), this.needSplitPositiveAndNegativeForSum && (value > 0 ? this.positiveSum = precisionSub(this.positiveSum, value) : value < 0 && (this.nagetiveSum = precisionSub(this.nagetiveSum, value)));
|
|
33752
|
+
}
|
|
33732
33753
|
}
|
|
33733
33754
|
this.clearCacheValue();
|
|
33734
33755
|
}
|
|
33735
33756
|
updateRecord(oldRecord, newRecord) {
|
|
33736
33757
|
if (oldRecord && newRecord) {
|
|
33737
|
-
if (this.isRecord && this.records
|
|
33738
|
-
const
|
|
33739
|
-
|
|
33758
|
+
if (this.isRecord && this.records) {
|
|
33759
|
+
const index = this.records.indexOf(oldRecord);
|
|
33760
|
+
-1 !== index && (this.records[index] = newRecord);
|
|
33761
|
+
}
|
|
33762
|
+
if (oldRecord.isAggregator && this.children) {
|
|
33763
|
+
const oldValue = oldRecord.value(),
|
|
33764
|
+
index = this.children.indexOf(oldRecord);
|
|
33765
|
+
-1 !== index && (this.children[index] = newRecord);
|
|
33740
33766
|
const newValue = newRecord.value();
|
|
33741
|
-
this.
|
|
33767
|
+
this.sum = precisionAdd(this.sum, precisionSub(newValue, oldValue)), this.needSplitPositiveAndNegativeForSum && (oldValue > 0 ? this.positiveSum = precisionSub(this.positiveSum, oldValue) : oldValue < 0 && (this.nagetiveSum = precisionSub(this.nagetiveSum, oldValue)), newValue > 0 ? this.positiveSum = precisionAdd(this.positiveSum, newValue) : newValue < 0 && (this.nagetiveSum = precisionAdd(this.nagetiveSum, newValue)));
|
|
33742
33768
|
} else if (this.field && !isNaN(parseFloat(oldRecord[this.field]))) {
|
|
33743
33769
|
const oldValue = parseFloat(oldRecord[this.field]),
|
|
33744
33770
|
newValue = parseFloat(newRecord[this.field]);
|
|
33745
|
-
this.sum
|
|
33771
|
+
this.sum = precisionAdd(this.sum, precisionSub(newValue, oldValue)), this.needSplitPositiveAndNegativeForSum && (oldValue > 0 ? this.positiveSum = precisionSub(this.positiveSum, oldValue) : oldValue < 0 && (this.nagetiveSum = precisionSub(this.nagetiveSum, oldValue)), newValue > 0 ? this.positiveSum = precisionAdd(this.positiveSum, newValue) : newValue < 0 && (this.nagetiveSum = precisionAdd(this.nagetiveSum, newValue)));
|
|
33746
33772
|
}
|
|
33747
33773
|
this.clearCacheValue();
|
|
33748
33774
|
}
|
|
33749
33775
|
}
|
|
33750
33776
|
value() {
|
|
33751
|
-
var _a
|
|
33752
|
-
return null !== (_a = this.changedValue) && void 0 !== _a ? _a :
|
|
33777
|
+
var _a;
|
|
33778
|
+
return null !== (_a = this.changedValue) && void 0 !== _a ? _a : this.records && this.records.length >= 1 || !1 === this.isRecord ? this.sum : void 0;
|
|
33753
33779
|
}
|
|
33754
33780
|
positiveValue() {
|
|
33755
33781
|
return this.positiveSum;
|
|
@@ -33765,16 +33791,16 @@
|
|
|
33765
33791
|
const child = this.children[i];
|
|
33766
33792
|
if (child.isAggregator) {
|
|
33767
33793
|
const value = child.value();
|
|
33768
|
-
this.sum
|
|
33794
|
+
this.sum = precisionAdd(this.sum, null != value ? value : 0), this.needSplitPositiveAndNegativeForSum && (value > 0 ? this.positiveSum = precisionAdd(this.positiveSum, value) : value < 0 && (this.nagetiveSum = precisionAdd(this.nagetiveSum, value)));
|
|
33769
33795
|
}
|
|
33770
33796
|
} else if (this.records) for (let i = 0; i < this.records.length; i++) {
|
|
33771
33797
|
const record = this.records[i];
|
|
33772
33798
|
if (record.isAggregator) {
|
|
33773
33799
|
const value = record.value();
|
|
33774
|
-
this.sum
|
|
33800
|
+
this.sum = precisionAdd(this.sum, null != value ? value : 0), this.needSplitPositiveAndNegativeForSum && (value > 0 ? this.positiveSum = precisionAdd(this.positiveSum, value) : value < 0 && (this.nagetiveSum = precisionAdd(this.nagetiveSum, value)));
|
|
33775
33801
|
} else if (this.field && !isNaN(parseFloat(record[this.field]))) {
|
|
33776
33802
|
const value = parseFloat(record[this.field]);
|
|
33777
|
-
this.sum
|
|
33803
|
+
this.sum = precisionAdd(this.sum, value), this.needSplitPositiveAndNegativeForSum && (value > 0 ? this.positiveSum = precisionAdd(this.positiveSum, value) : value < 0 && (this.nagetiveSum = precisionAdd(this.nagetiveSum, value)));
|
|
33778
33804
|
}
|
|
33779
33805
|
}
|
|
33780
33806
|
}
|
|
@@ -33817,17 +33843,43 @@
|
|
|
33817
33843
|
super(...arguments), this.type = AggregationType.AVG, this.sum = 0, this.count = 0;
|
|
33818
33844
|
}
|
|
33819
33845
|
push(record) {
|
|
33820
|
-
record && (this.isRecord && this.records && (record.isAggregator ? this.records.push(...record.records) : this.records.push(record)), record.isAggregator && record.type === AggregationType.AVG ? (this.children && this.children.push(record), this.sum
|
|
33846
|
+
record && (this.isRecord && this.records && (record.isAggregator ? this.records.push(...record.records) : this.records.push(record)), record.isAggregator && record.type === AggregationType.AVG ? (this.children && this.children.push(record), this.sum = precisionAdd(this.sum, record.sum), this.count += record.count) : this.field && !isNaN(parseFloat(record[this.field])) && (this.sum = precisionAdd(this.sum, parseFloat(record[this.field])), this.count++)), this.clearCacheValue();
|
|
33821
33847
|
}
|
|
33822
33848
|
deleteRecord(record) {
|
|
33823
|
-
|
|
33849
|
+
if (record) {
|
|
33850
|
+
if (this.isRecord && this.records) {
|
|
33851
|
+
const index = this.records.indexOf(record);
|
|
33852
|
+
-1 !== index && this.records.splice(index, 1);
|
|
33853
|
+
}
|
|
33854
|
+
if (record.isAggregator && record.type === AggregationType.AVG) {
|
|
33855
|
+
if (this.children) {
|
|
33856
|
+
const index = this.children.indexOf(record);
|
|
33857
|
+
-1 !== index && this.children.splice(index, 1);
|
|
33858
|
+
}
|
|
33859
|
+
this.sum = precisionSub(this.sum, record.sum), this.count -= record.count;
|
|
33860
|
+
} else this.field && !isNaN(parseFloat(record[this.field])) && (this.sum = precisionSub(this.sum, parseFloat(record[this.field])), this.count--);
|
|
33861
|
+
}
|
|
33862
|
+
this.clearCacheValue();
|
|
33824
33863
|
}
|
|
33825
33864
|
updateRecord(oldRecord, newRecord) {
|
|
33826
|
-
|
|
33865
|
+
if (oldRecord && newRecord) {
|
|
33866
|
+
if (this.isRecord && this.records) {
|
|
33867
|
+
const index = this.records.indexOf(oldRecord);
|
|
33868
|
+
-1 !== index && (this.records[index] = newRecord);
|
|
33869
|
+
}
|
|
33870
|
+
if (oldRecord.isAggregator && oldRecord.type === AggregationType.AVG) {
|
|
33871
|
+
if (this.children && newRecord.isAggregator) {
|
|
33872
|
+
const index = this.children.indexOf(oldRecord);
|
|
33873
|
+
-1 !== index && (this.children[index] = newRecord);
|
|
33874
|
+
}
|
|
33875
|
+
this.sum = precisionAdd(this.sum, precisionSub(newRecord.sum, oldRecord.sum)), this.count += newRecord.count - oldRecord.count;
|
|
33876
|
+
} else this.field && !isNaN(parseFloat(oldRecord[this.field])) && (this.sum = precisionAdd(this.sum, precisionSub(parseFloat(newRecord[this.field]), parseFloat(oldRecord[this.field]))));
|
|
33877
|
+
this.clearCacheValue();
|
|
33878
|
+
}
|
|
33827
33879
|
}
|
|
33828
33880
|
value() {
|
|
33829
|
-
var _a
|
|
33830
|
-
return null !== (_a = this.changedValue) && void 0 !== _a ? _a :
|
|
33881
|
+
var _a;
|
|
33882
|
+
return null !== (_a = this.changedValue) && void 0 !== _a ? _a : this.records && this.records.length >= 1 || !1 === this.isRecord && this.count > 0 ? this.sum / this.count : void 0;
|
|
33831
33883
|
}
|
|
33832
33884
|
reset() {
|
|
33833
33885
|
this.changedValue = void 0, this.children = [], this.records = [], this.sum = 0, this.count = 0;
|
|
@@ -33837,11 +33889,11 @@
|
|
|
33837
33889
|
const child = this.children[i];
|
|
33838
33890
|
if (child.isAggregator && child.type === AggregationType.AVG) {
|
|
33839
33891
|
const childValue = child.value();
|
|
33840
|
-
this.sum
|
|
33892
|
+
this.sum = precisionAdd(this.sum, childValue * child.count), this.count += child.count;
|
|
33841
33893
|
}
|
|
33842
33894
|
} else if (this.records) for (let i = 0; i < this.records.length; i++) {
|
|
33843
33895
|
const record = this.records[i];
|
|
33844
|
-
record.isAggregator && record.type === AggregationType.AVG ? (this.sum
|
|
33896
|
+
record.isAggregator && record.type === AggregationType.AVG ? (this.sum = precisionAdd(this.sum, record.sum), this.count += record.count) : this.field && !isNaN(parseFloat(record[this.field])) && (this.sum = precisionAdd(this.sum, parseFloat(record[this.field])), this.count++);
|
|
33845
33897
|
}
|
|
33846
33898
|
}
|
|
33847
33899
|
}
|
|
@@ -57069,7 +57121,7 @@
|
|
|
57069
57121
|
}
|
|
57070
57122
|
constructor(container, options = {}) {
|
|
57071
57123
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
|
|
57072
|
-
if (super(), this.showFrozenIcon = !0, this._scrollToRowCorrectTimer = null, this._tableBorderWidth_left = 0, this._tableBorderWidth_right = 0, this._tableBorderWidth_top = 0, this._tableBorderWidth_bottom = 0, this.version = "1.26.0", this.id = `VTable${Date.now()}`, this.isReleased = !1, this._chartEventMap = {}, this.throttleInvalidate = throttle2(this.render.bind(this), 200), "undefined" != typeof window) {
|
|
57124
|
+
if (super(), this.showFrozenIcon = !0, this._scrollToRowCorrectTimer = null, this._tableBorderWidth_left = 0, this._tableBorderWidth_right = 0, this._tableBorderWidth_top = 0, this._tableBorderWidth_bottom = 0, this.version = "1.26.1-alpha.0", this.id = `VTable${Date.now()}`, this.isReleased = !1, this._chartEventMap = {}, this.throttleInvalidate = throttle2(this.render.bind(this), 200), "undefined" != typeof window) {
|
|
57073
57125
|
const g = window;
|
|
57074
57126
|
g[this.id] = this;
|
|
57075
57127
|
const registry = g.__vtable__ || (g.__vtable__ = {
|