@visactor/vtable 0.19.2-alpha.3 → 0.20.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.
Files changed (203) hide show
  1. package/cjs/ListTable.d.ts +12 -2
  2. package/cjs/ListTable.js +80 -23
  3. package/cjs/ListTable.js.map +1 -1
  4. package/cjs/PivotChart.d.ts +2 -1
  5. package/cjs/PivotChart.js +5 -1
  6. package/cjs/PivotChart.js.map +1 -1
  7. package/cjs/PivotTable.d.ts +5 -2
  8. package/cjs/PivotTable.js +13 -5
  9. package/cjs/PivotTable.js.map +1 -1
  10. package/cjs/core/BaseTable.d.ts +2 -2
  11. package/cjs/core/BaseTable.js +7 -8
  12. package/cjs/core/BaseTable.js.map +1 -1
  13. package/cjs/core/tableHelper.d.ts +2 -2
  14. package/cjs/core/tableHelper.js +4 -6
  15. package/cjs/core/tableHelper.js.map +1 -1
  16. package/cjs/data/CachedDataSource.d.ts +4 -3
  17. package/cjs/data/CachedDataSource.js +5 -4
  18. package/cjs/data/CachedDataSource.js.map +1 -1
  19. package/cjs/data/DataSource.d.ts +22 -3
  20. package/cjs/data/DataSource.js +93 -7
  21. package/cjs/data/DataSource.js.map +1 -1
  22. package/cjs/dataset/dataset-pivot-table.d.ts +3 -3
  23. package/cjs/dataset/dataset-pivot-table.js +1 -0
  24. package/cjs/dataset/dataset-pivot-table.js.map +1 -1
  25. package/cjs/dataset/dataset.d.ts +3 -3
  26. package/cjs/dataset/dataset.js +3 -0
  27. package/cjs/dataset/dataset.js.map +1 -1
  28. package/cjs/dataset/statistics-helper.d.ts +24 -3
  29. package/cjs/dataset/statistics-helper.js +75 -9
  30. package/cjs/dataset/statistics-helper.js.map +1 -1
  31. package/cjs/edit/edit-manager.js +5 -4
  32. package/cjs/edit/edit-manager.js.map +1 -1
  33. package/cjs/event/media-click.js +2 -1
  34. package/cjs/event/scroll.js +0 -1
  35. package/cjs/index.d.ts +1 -1
  36. package/cjs/index.js +1 -1
  37. package/cjs/index.js.map +1 -1
  38. package/cjs/layout/chart-helper/get-chart-spec.d.ts +1 -0
  39. package/cjs/layout/chart-helper/get-chart-spec.js +34 -9
  40. package/cjs/layout/chart-helper/get-chart-spec.js.map +1 -1
  41. package/cjs/layout/layout-helper.d.ts +4 -63
  42. package/cjs/layout/layout-helper.js +25 -247
  43. package/cjs/layout/layout-helper.js.map +1 -1
  44. package/cjs/layout/pivot-header-layout.d.ts +6 -3
  45. package/cjs/layout/pivot-header-layout.js +26 -15
  46. package/cjs/layout/pivot-header-layout.js.map +1 -1
  47. package/cjs/layout/row-height-map.js +2 -1
  48. package/cjs/layout/row-height-map.js.map +1 -1
  49. package/cjs/layout/simple-header-layout.d.ts +25 -2
  50. package/cjs/layout/simple-header-layout.js +130 -18
  51. package/cjs/layout/simple-header-layout.js.map +1 -1
  52. package/cjs/layout/tree-helper.d.ts +63 -0
  53. package/cjs/layout/tree-helper.js +259 -0
  54. package/cjs/layout/tree-helper.js.map +1 -0
  55. package/cjs/scenegraph/graphic/chart.d.ts +2 -1
  56. package/cjs/scenegraph/graphic/chart.js +21 -18
  57. package/cjs/scenegraph/graphic/chart.js.map +1 -1
  58. package/cjs/scenegraph/graphic/contributions/chart-render-helper.js +4 -1
  59. package/cjs/scenegraph/graphic/contributions/chart-render-helper.js.map +1 -1
  60. package/cjs/scenegraph/graphic/contributions/chart-render.js +2 -2
  61. package/cjs/scenegraph/graphic/contributions/chart-render.js.map +1 -1
  62. package/cjs/scenegraph/group-creater/cell-helper.js +19 -8
  63. package/cjs/scenegraph/group-creater/cell-helper.js.map +1 -1
  64. package/cjs/scenegraph/group-creater/cell-type/chart-cell.d.ts +1 -1
  65. package/cjs/scenegraph/group-creater/cell-type/chart-cell.js +2 -2
  66. package/cjs/scenegraph/group-creater/cell-type/chart-cell.js.map +1 -1
  67. package/cjs/scenegraph/group-creater/cell-type/image-cell.d.ts +1 -1
  68. package/cjs/scenegraph/group-creater/cell-type/image-cell.js +9 -5
  69. package/cjs/scenegraph/group-creater/cell-type/image-cell.js.map +1 -1
  70. package/cjs/scenegraph/group-creater/cell-type/video-cell.js +1 -1
  71. package/cjs/scenegraph/group-creater/cell-type/video-cell.js.map +1 -1
  72. package/cjs/scenegraph/group-creater/column-helper.js +5 -5
  73. package/cjs/scenegraph/group-creater/column-helper.js.map +1 -1
  74. package/cjs/scenegraph/group-creater/progress/update-position/sort-vertical.js +5 -2
  75. package/cjs/scenegraph/group-creater/progress/update-position/sort-vertical.js.map +1 -1
  76. package/cjs/scenegraph/scenegraph.js +4 -6
  77. package/cjs/scenegraph/scenegraph.js.map +1 -1
  78. package/cjs/state/sort/index.js +2 -5
  79. package/cjs/state/sort/index.js.map +1 -1
  80. package/cjs/state/state.d.ts +0 -1
  81. package/cjs/state/state.js +1 -2
  82. package/cjs/state/state.js.map +1 -1
  83. package/cjs/tools/get-data-path/create-dataset.js.map +1 -1
  84. package/cjs/tools/isx.d.ts +1 -1
  85. package/cjs/tools/util.d.ts +1 -1
  86. package/cjs/ts-types/base-table.d.ts +6 -5
  87. package/cjs/ts-types/base-table.js.map +1 -1
  88. package/cjs/ts-types/list-table/define/basic-define.d.ts +2 -0
  89. package/cjs/ts-types/list-table/define/basic-define.js.map +1 -1
  90. package/cjs/ts-types/list-table/layout-map/api.d.ts +4 -3
  91. package/cjs/ts-types/list-table/layout-map/api.js.map +1 -1
  92. package/cjs/ts-types/new-data-set.d.ts +27 -6
  93. package/cjs/ts-types/new-data-set.js +1 -1
  94. package/cjs/ts-types/new-data-set.js.map +1 -1
  95. package/cjs/ts-types/table-engine.d.ts +17 -5
  96. package/cjs/ts-types/table-engine.js.map +1 -1
  97. package/cjs/vrender.js.map +1 -1
  98. package/dist/vtable.js +1175 -498
  99. package/dist/vtable.min.js +2 -2
  100. package/es/ListTable.d.ts +12 -2
  101. package/es/ListTable.js +80 -23
  102. package/es/ListTable.js.map +1 -1
  103. package/es/PivotChart.d.ts +2 -1
  104. package/es/PivotChart.js +5 -1
  105. package/es/PivotChart.js.map +1 -1
  106. package/es/PivotTable.d.ts +5 -2
  107. package/es/PivotTable.js +13 -5
  108. package/es/PivotTable.js.map +1 -1
  109. package/es/core/BaseTable.d.ts +2 -2
  110. package/es/core/BaseTable.js +7 -8
  111. package/es/core/BaseTable.js.map +1 -1
  112. package/es/core/tableHelper.d.ts +2 -2
  113. package/es/core/tableHelper.js +4 -6
  114. package/es/core/tableHelper.js.map +1 -1
  115. package/es/data/CachedDataSource.d.ts +4 -3
  116. package/es/data/CachedDataSource.js +5 -4
  117. package/es/data/CachedDataSource.js.map +1 -1
  118. package/es/data/DataSource.d.ts +22 -3
  119. package/es/data/DataSource.js +91 -7
  120. package/es/data/DataSource.js.map +1 -1
  121. package/es/dataset/dataset-pivot-table.d.ts +3 -3
  122. package/es/dataset/dataset-pivot-table.js +1 -0
  123. package/es/dataset/dataset-pivot-table.js.map +1 -1
  124. package/es/dataset/dataset.d.ts +3 -3
  125. package/es/dataset/dataset.js +3 -0
  126. package/es/dataset/dataset.js.map +1 -1
  127. package/es/dataset/statistics-helper.d.ts +24 -3
  128. package/es/dataset/statistics-helper.js +72 -8
  129. package/es/dataset/statistics-helper.js.map +1 -1
  130. package/es/edit/edit-manager.js +5 -4
  131. package/es/edit/edit-manager.js.map +1 -1
  132. package/es/event/media-click.js +2 -1
  133. package/es/event/scroll.js +1 -2
  134. package/es/index.d.ts +1 -1
  135. package/es/index.js +1 -1
  136. package/es/index.js.map +1 -1
  137. package/es/layout/chart-helper/get-chart-spec.d.ts +1 -0
  138. package/es/layout/chart-helper/get-chart-spec.js +29 -4
  139. package/es/layout/chart-helper/get-chart-spec.js.map +1 -1
  140. package/es/layout/layout-helper.d.ts +4 -63
  141. package/es/layout/layout-helper.js +19 -246
  142. package/es/layout/layout-helper.js.map +1 -1
  143. package/es/layout/pivot-header-layout.d.ts +6 -3
  144. package/es/layout/pivot-header-layout.js +17 -6
  145. package/es/layout/pivot-header-layout.js.map +1 -1
  146. package/es/layout/row-height-map.js +2 -1
  147. package/es/layout/row-height-map.js.map +1 -1
  148. package/es/layout/simple-header-layout.d.ts +25 -2
  149. package/es/layout/simple-header-layout.js +130 -17
  150. package/es/layout/simple-header-layout.js.map +1 -1
  151. package/es/layout/tree-helper.d.ts +63 -0
  152. package/es/layout/tree-helper.js +256 -0
  153. package/es/layout/tree-helper.js.map +1 -0
  154. package/es/scenegraph/graphic/chart.d.ts +2 -1
  155. package/es/scenegraph/graphic/chart.js +21 -17
  156. package/es/scenegraph/graphic/chart.js.map +1 -1
  157. package/es/scenegraph/graphic/contributions/chart-render-helper.js +4 -1
  158. package/es/scenegraph/graphic/contributions/chart-render-helper.js.map +1 -1
  159. package/es/scenegraph/graphic/contributions/chart-render.js +2 -2
  160. package/es/scenegraph/graphic/contributions/chart-render.js.map +1 -1
  161. package/es/scenegraph/group-creater/cell-helper.js +20 -7
  162. package/es/scenegraph/group-creater/cell-helper.js.map +1 -1
  163. package/es/scenegraph/group-creater/cell-type/chart-cell.d.ts +1 -1
  164. package/es/scenegraph/group-creater/cell-type/chart-cell.js +2 -2
  165. package/es/scenegraph/group-creater/cell-type/chart-cell.js.map +1 -1
  166. package/es/scenegraph/group-creater/cell-type/image-cell.d.ts +1 -1
  167. package/es/scenegraph/group-creater/cell-type/image-cell.js +9 -5
  168. package/es/scenegraph/group-creater/cell-type/image-cell.js.map +1 -1
  169. package/es/scenegraph/group-creater/cell-type/video-cell.js +1 -1
  170. package/es/scenegraph/group-creater/cell-type/video-cell.js.map +1 -1
  171. package/es/scenegraph/group-creater/column-helper.js +5 -5
  172. package/es/scenegraph/group-creater/column-helper.js.map +1 -1
  173. package/es/scenegraph/group-creater/progress/update-position/sort-vertical.js +6 -3
  174. package/es/scenegraph/group-creater/progress/update-position/sort-vertical.js.map +1 -1
  175. package/es/scenegraph/scenegraph.js +4 -6
  176. package/es/scenegraph/scenegraph.js.map +1 -1
  177. package/es/state/sort/index.js +2 -5
  178. package/es/state/sort/index.js.map +1 -1
  179. package/es/state/state.d.ts +0 -1
  180. package/es/state/state.js +1 -2
  181. package/es/state/state.js.map +1 -1
  182. package/es/tools/get-data-path/create-dataset.js.map +1 -1
  183. package/es/tools/isx.d.ts +1 -1
  184. package/es/tools/util.d.ts +1 -1
  185. package/es/ts-types/base-table.d.ts +6 -5
  186. package/es/ts-types/base-table.js.map +1 -1
  187. package/es/ts-types/list-table/define/basic-define.d.ts +2 -0
  188. package/es/ts-types/list-table/define/basic-define.js.map +1 -1
  189. package/es/ts-types/list-table/layout-map/api.d.ts +4 -3
  190. package/es/ts-types/list-table/layout-map/api.js.map +1 -1
  191. package/es/ts-types/new-data-set.d.ts +27 -6
  192. package/es/ts-types/new-data-set.js +1 -1
  193. package/es/ts-types/new-data-set.js.map +1 -1
  194. package/es/ts-types/table-engine.d.ts +17 -5
  195. package/es/ts-types/table-engine.js.map +1 -1
  196. package/es/vrender.js.map +1 -1
  197. package/package.json +3 -3
  198. package/cjs/data/FilterDataSource.d.ts +0 -1
  199. package/cjs/data/FilterDataSource.js +0 -1
  200. package/cjs/data/FilterDataSource.js.map +0 -1
  201. package/es/data/FilterDataSource.d.ts +0 -1
  202. package/es/data/FilterDataSource.js +0 -1
  203. package/es/data/FilterDataSource.js.map +0 -1
package/dist/vtable.js CHANGED
@@ -21455,6 +21455,7 @@
21455
21455
  AggregationType["MAX"] = "MAX";
21456
21456
  AggregationType["AVG"] = "AVG";
21457
21457
  AggregationType["COUNT"] = "COUNT";
21458
+ AggregationType["CUSTOM"] = "CUSTOM";
21458
21459
  })(AggregationType || (AggregationType = {}));
21459
21460
  var SortType;
21460
21461
  (function (SortType) {
@@ -30945,6 +30946,506 @@
30945
30946
  return true;
30946
30947
  }
30947
30948
 
30949
+ class Aggregator {
30950
+ className = 'Aggregator';
30951
+ isRecord = true;
30952
+ records = [];
30953
+ type;
30954
+ field;
30955
+ formatFun;
30956
+ _formatedValue;
30957
+ constructor(dimension, formatFun, isRecord) {
30958
+ this.field = dimension;
30959
+ this.formatFun = formatFun;
30960
+ this.isRecord = isRecord ?? this.isRecord;
30961
+ }
30962
+ clearCacheValue() {
30963
+ this._formatedValue = undefined;
30964
+ }
30965
+ formatValue(col, row, table) {
30966
+ if (!this._formatedValue) {
30967
+ if (this.formatFun) {
30968
+ this._formatedValue = this.formatFun(this.value(), col, row, table);
30969
+ }
30970
+ else {
30971
+ this._formatedValue = this.value();
30972
+ }
30973
+ }
30974
+ return this._formatedValue;
30975
+ }
30976
+ reset() {
30977
+ this.records = [];
30978
+ }
30979
+ }
30980
+ class RecordAggregator extends Aggregator {
30981
+ type = AggregationType.RECORD;
30982
+ isRecord = true;
30983
+ push(record) {
30984
+ if (this.isRecord) {
30985
+ if (record.className === 'Aggregator') {
30986
+ this.records.push(...record.records);
30987
+ }
30988
+ else {
30989
+ this.records.push(record);
30990
+ }
30991
+ }
30992
+ }
30993
+ value() {
30994
+ return this.records;
30995
+ }
30996
+ reset() {
30997
+ this.records = [];
30998
+ }
30999
+ recalculate() {
31000
+ }
31001
+ }
31002
+ class NoneAggregator extends Aggregator {
31003
+ type = AggregationType.NONE;
31004
+ isRecord = true;
31005
+ fieldValue;
31006
+ push(record) {
31007
+ if (this.isRecord) {
31008
+ this.records = [record];
31009
+ }
31010
+ this.fieldValue = record[this.field];
31011
+ }
31012
+ value() {
31013
+ return this.fieldValue;
31014
+ }
31015
+ reset() {
31016
+ this.records = [];
31017
+ this.fieldValue = undefined;
31018
+ }
31019
+ recalculate() {
31020
+ }
31021
+ }
31022
+ class CustomAggregator extends Aggregator {
31023
+ type = AggregationType.CUSTOM;
31024
+ isRecord = true;
31025
+ aggregationFun;
31026
+ values = [];
31027
+ fieldValue;
31028
+ constructor(dimension, formatFun, isRecord, aggregationFun) {
31029
+ super(dimension, formatFun, isRecord);
31030
+ this.aggregationFun = aggregationFun;
31031
+ }
31032
+ push(record) {
31033
+ if (this.isRecord) {
31034
+ if (record.className === 'Aggregator') {
31035
+ this.records.push(...record.records);
31036
+ }
31037
+ else {
31038
+ this.records.push(record);
31039
+ }
31040
+ }
31041
+ this.values.push(record[this.field]);
31042
+ }
31043
+ value() {
31044
+ if (!this.fieldValue) {
31045
+ this.fieldValue = this.aggregationFun?.(this.values, this.records, this.field);
31046
+ }
31047
+ return this.fieldValue;
31048
+ }
31049
+ reset() {
31050
+ this.records = [];
31051
+ this.fieldValue = undefined;
31052
+ }
31053
+ recalculate() {
31054
+ }
31055
+ }
31056
+ class SumAggregator extends Aggregator {
31057
+ type = AggregationType.SUM;
31058
+ sum = 0;
31059
+ positiveSum = 0;
31060
+ nagetiveSum = 0;
31061
+ needSplitPositiveAndNegativeForSum = false;
31062
+ constructor(dimension, formatFun, isRecord, needSplitPositiveAndNegative) {
31063
+ super(dimension, formatFun, isRecord);
31064
+ this.needSplitPositiveAndNegativeForSum = needSplitPositiveAndNegative ?? false;
31065
+ }
31066
+ push(record) {
31067
+ if (this.isRecord) {
31068
+ if (record.className === 'Aggregator') {
31069
+ this.records.push(...record.records);
31070
+ }
31071
+ else {
31072
+ this.records.push(record);
31073
+ }
31074
+ }
31075
+ if (record.className === 'Aggregator') {
31076
+ const value = record.value();
31077
+ this.sum += value;
31078
+ if (this.needSplitPositiveAndNegativeForSum) {
31079
+ if (value > 0) {
31080
+ this.positiveSum += value;
31081
+ }
31082
+ else if (value < 0) {
31083
+ this.nagetiveSum += value;
31084
+ }
31085
+ }
31086
+ }
31087
+ else if (!isNaN(parseFloat(record[this.field]))) {
31088
+ const value = parseFloat(record[this.field]);
31089
+ this.sum += value;
31090
+ if (this.needSplitPositiveAndNegativeForSum) {
31091
+ if (value > 0) {
31092
+ this.positiveSum += value;
31093
+ }
31094
+ else if (value < 0) {
31095
+ this.nagetiveSum += value;
31096
+ }
31097
+ }
31098
+ }
31099
+ }
31100
+ value() {
31101
+ return this.sum;
31102
+ }
31103
+ positiveValue() {
31104
+ return this.positiveSum;
31105
+ }
31106
+ negativeValue() {
31107
+ return this.nagetiveSum;
31108
+ }
31109
+ reset() {
31110
+ this.records = [];
31111
+ this.sum = 0;
31112
+ }
31113
+ recalculate() {
31114
+ this.sum = 0;
31115
+ this._formatedValue = undefined;
31116
+ for (let i = 0; i < this.records.length; i++) {
31117
+ const record = this.records[i];
31118
+ if (record.className === 'Aggregator') {
31119
+ const value = record.value();
31120
+ this.sum += value;
31121
+ if (this.needSplitPositiveAndNegativeForSum) {
31122
+ if (value > 0) {
31123
+ this.positiveSum += value;
31124
+ }
31125
+ else if (value < 0) {
31126
+ this.nagetiveSum += value;
31127
+ }
31128
+ }
31129
+ }
31130
+ else if (!isNaN(parseFloat(record[this.field]))) {
31131
+ const value = parseFloat(record[this.field]);
31132
+ this.sum += value;
31133
+ if (this.needSplitPositiveAndNegativeForSum) {
31134
+ if (value > 0) {
31135
+ this.positiveSum += value;
31136
+ }
31137
+ else if (value < 0) {
31138
+ this.nagetiveSum += value;
31139
+ }
31140
+ }
31141
+ }
31142
+ }
31143
+ }
31144
+ }
31145
+ class CountAggregator extends Aggregator {
31146
+ type = AggregationType.COUNT;
31147
+ count = 0;
31148
+ push(record) {
31149
+ if (this.isRecord) {
31150
+ if (record.className === 'Aggregator') {
31151
+ this.records.push(...record.records);
31152
+ }
31153
+ else {
31154
+ this.records.push(record);
31155
+ }
31156
+ }
31157
+ if (record.className === 'Aggregator') {
31158
+ this.count += record.value();
31159
+ }
31160
+ else {
31161
+ this.count++;
31162
+ }
31163
+ }
31164
+ value() {
31165
+ return this.count;
31166
+ }
31167
+ reset() {
31168
+ this.records = [];
31169
+ this.count = 0;
31170
+ }
31171
+ recalculate() {
31172
+ this.count = 0;
31173
+ this._formatedValue = undefined;
31174
+ for (let i = 0; i < this.records.length; i++) {
31175
+ const record = this.records[i];
31176
+ if (record.className === 'Aggregator') {
31177
+ this.count += record.value();
31178
+ }
31179
+ else {
31180
+ this.count++;
31181
+ }
31182
+ }
31183
+ }
31184
+ }
31185
+ class AvgAggregator extends Aggregator {
31186
+ type = AggregationType.AVG;
31187
+ sum = 0;
31188
+ count = 0;
31189
+ push(record) {
31190
+ if (this.isRecord) {
31191
+ if (record.className === 'Aggregator') {
31192
+ this.records.push(...record.records);
31193
+ }
31194
+ else {
31195
+ this.records.push(record);
31196
+ }
31197
+ }
31198
+ if (record.className === 'Aggregator' && record.type === AggregationType.AVG) {
31199
+ this.sum += record.sum;
31200
+ this.count += record.count;
31201
+ }
31202
+ else if (!isNaN(parseFloat(record[this.field]))) {
31203
+ this.sum += parseFloat(record[this.field]);
31204
+ this.count++;
31205
+ }
31206
+ }
31207
+ value() {
31208
+ return this.sum / this.count;
31209
+ }
31210
+ reset() {
31211
+ this.records = [];
31212
+ this.sum = 0;
31213
+ this.count = 0;
31214
+ }
31215
+ recalculate() {
31216
+ this.sum = 0;
31217
+ this.count = 0;
31218
+ this._formatedValue = undefined;
31219
+ for (let i = 0; i < this.records.length; i++) {
31220
+ const record = this.records[i];
31221
+ if (record.className === 'Aggregator' && record.type === AggregationType.AVG) {
31222
+ this.sum += record.sum;
31223
+ this.count += record.count;
31224
+ }
31225
+ else if (!isNaN(parseFloat(record[this.field]))) {
31226
+ this.sum += parseFloat(record[this.field]);
31227
+ this.count++;
31228
+ }
31229
+ }
31230
+ }
31231
+ }
31232
+ class MaxAggregator extends Aggregator {
31233
+ type = AggregationType.MAX;
31234
+ max = Number.MIN_SAFE_INTEGER;
31235
+ push(record) {
31236
+ if (this.isRecord) {
31237
+ if (record.className === 'Aggregator') {
31238
+ this.records.push(...record.records);
31239
+ }
31240
+ else {
31241
+ this.records.push(record);
31242
+ }
31243
+ }
31244
+ if (record.className === 'Aggregator') {
31245
+ this.max = record.max > this.max ? record.max : this.max;
31246
+ }
31247
+ else if (typeof record === 'number') {
31248
+ this.max = record > this.max ? record : this.max;
31249
+ }
31250
+ else if (typeof record[this.field] === 'number') {
31251
+ this.max = record[this.field] > this.max ? record[this.field] : this.max;
31252
+ }
31253
+ else if (!isNaN(record[this.field])) {
31254
+ this.max = parseFloat(record[this.field]) > this.max ? parseFloat(record[this.field]) : this.max;
31255
+ }
31256
+ }
31257
+ value() {
31258
+ return this.max;
31259
+ }
31260
+ reset() {
31261
+ this.records = [];
31262
+ this.max = Number.MIN_SAFE_INTEGER;
31263
+ }
31264
+ recalculate() {
31265
+ this.max = Number.MIN_SAFE_INTEGER;
31266
+ this._formatedValue = undefined;
31267
+ for (let i = 0; i < this.records.length; i++) {
31268
+ const record = this.records[i];
31269
+ if (record.className === 'Aggregator') {
31270
+ this.max = record.max > this.max ? record.max : this.max;
31271
+ }
31272
+ else if (typeof record === 'number') {
31273
+ this.max = record > this.max ? record : this.max;
31274
+ }
31275
+ else if (typeof record[this.field] === 'number') {
31276
+ this.max = record[this.field] > this.max ? record[this.field] : this.max;
31277
+ }
31278
+ else if (!isNaN(record[this.field])) {
31279
+ this.max = parseFloat(record[this.field]) > this.max ? parseFloat(record[this.field]) : this.max;
31280
+ }
31281
+ }
31282
+ }
31283
+ }
31284
+ class MinAggregator extends Aggregator {
31285
+ type = AggregationType.MIN;
31286
+ min = Number.MAX_SAFE_INTEGER;
31287
+ push(record) {
31288
+ if (this.isRecord) {
31289
+ if (record.className === 'Aggregator') {
31290
+ this.records.push(...record.records);
31291
+ }
31292
+ else {
31293
+ this.records.push(record);
31294
+ }
31295
+ }
31296
+ if (record.className === 'Aggregator') {
31297
+ this.min = record.min < this.min ? record.min : this.min;
31298
+ }
31299
+ else if (typeof record === 'number') {
31300
+ this.min = record < this.min ? record : this.min;
31301
+ }
31302
+ else if (typeof record[this.field] === 'number') {
31303
+ this.min = record[this.field] < this.min ? record[this.field] : this.min;
31304
+ }
31305
+ }
31306
+ value() {
31307
+ return this.min;
31308
+ }
31309
+ reset() {
31310
+ this.records = [];
31311
+ this.min = Number.MAX_SAFE_INTEGER;
31312
+ }
31313
+ recalculate() {
31314
+ this.min = Number.MAX_SAFE_INTEGER;
31315
+ this._formatedValue = undefined;
31316
+ for (let i = 0; i < this.records.length; i++) {
31317
+ const record = this.records[i];
31318
+ if (record.className === 'Aggregator') {
31319
+ this.min = record.min < this.min ? record.min : this.min;
31320
+ }
31321
+ else if (typeof record === 'number') {
31322
+ this.min = record < this.min ? record : this.min;
31323
+ }
31324
+ else if (typeof record[this.field] === 'number') {
31325
+ this.min = record[this.field] < this.min ? record[this.field] : this.min;
31326
+ }
31327
+ }
31328
+ }
31329
+ }
31330
+ function typeSort(a, b) {
31331
+ if (a && b) {
31332
+ return a.toString().localeCompare(b.toString(), 'zh');
31333
+ }
31334
+ if (a) {
31335
+ return 1;
31336
+ }
31337
+ return -1;
31338
+ }
31339
+ function naturalSort(as, bs) {
31340
+ const rx = /(\d+)|(\D+)/g;
31341
+ const rd = /\d/;
31342
+ const rz = /^0/;
31343
+ let a;
31344
+ let a1;
31345
+ let b;
31346
+ let b1;
31347
+ let nas = 0;
31348
+ let nbs = 0;
31349
+ if (bs !== null && as === null) {
31350
+ return -1;
31351
+ }
31352
+ if (as !== null && bs === null) {
31353
+ return 1;
31354
+ }
31355
+ if (typeof as === 'number' && isNaN(as)) {
31356
+ return -1;
31357
+ }
31358
+ if (typeof bs === 'number' && isNaN(bs)) {
31359
+ return 1;
31360
+ }
31361
+ nas = +as;
31362
+ nbs = +bs;
31363
+ if (nas < nbs) {
31364
+ return -1;
31365
+ }
31366
+ if (nas > nbs) {
31367
+ return 1;
31368
+ }
31369
+ if (typeof as === 'number' && typeof bs !== 'number') {
31370
+ return -1;
31371
+ }
31372
+ if (typeof bs === 'number' && typeof as !== 'number') {
31373
+ return 1;
31374
+ }
31375
+ if (typeof as === 'number' && typeof bs === 'number') {
31376
+ return 0;
31377
+ }
31378
+ if (isNaN(nbs) && !isNaN(nas)) {
31379
+ return -1;
31380
+ }
31381
+ if (isNaN(nas) && !isNaN(nbs)) {
31382
+ return 1;
31383
+ }
31384
+ a = String(as);
31385
+ b = String(bs);
31386
+ if (a === b) {
31387
+ return 0;
31388
+ }
31389
+ if (!(rd.test(a) && rd.test(b))) {
31390
+ return a > b ? 1 : -1;
31391
+ }
31392
+ a = a.match(rx);
31393
+ b = b.match(rx);
31394
+ while (a.length && b.length) {
31395
+ a1 = a.shift();
31396
+ b1 = b.shift();
31397
+ if (a1 !== b1) {
31398
+ if (rd.test(a1) && rd.test(b1)) {
31399
+ return a1.replace(rz, '.0') - b1.replace(rz, '.0');
31400
+ }
31401
+ return a1 > b1 ? 1 : -1;
31402
+ }
31403
+ }
31404
+ return a.length - b.length;
31405
+ }
31406
+ function sortBy(order) {
31407
+ let x;
31408
+ const mapping = {};
31409
+ const lowercase_mapping = {};
31410
+ for (let i = 0; i < order.length; i++) {
31411
+ x = order[i];
31412
+ mapping[x] = i;
31413
+ if (typeof x === 'string') {
31414
+ lowercase_mapping[x.toLowerCase()] = i;
31415
+ }
31416
+ }
31417
+ return function (a, b) {
31418
+ if (mapping[a] !== null && mapping[a] !== undefined && mapping[b] !== null && mapping[b] !== undefined) {
31419
+ return mapping[a] - mapping[b];
31420
+ }
31421
+ else if (mapping[a] !== null && mapping[a] !== undefined) {
31422
+ return -1;
31423
+ }
31424
+ else if (mapping[b] !== null && mapping[b] !== undefined) {
31425
+ return 1;
31426
+ }
31427
+ else if (lowercase_mapping[a] !== null &&
31428
+ mapping[a] !== undefined &&
31429
+ lowercase_mapping[b] !== null &&
31430
+ mapping[b] !== undefined) {
31431
+ return lowercase_mapping[a] - lowercase_mapping[b];
31432
+ }
31433
+ else if (lowercase_mapping[a] === null ||
31434
+ mapping[a] === undefined ||
31435
+ lowercase_mapping[b] === null ||
31436
+ mapping[b] === undefined) {
31437
+ return 0;
31438
+ }
31439
+ else if (lowercase_mapping[a] !== null && mapping[a] !== undefined) {
31440
+ return -1;
31441
+ }
31442
+ else if (lowercase_mapping[b] !== null && mapping[b] !== undefined) {
31443
+ return 1;
31444
+ }
31445
+ return naturalSort(a, b);
31446
+ };
31447
+ }
31448
+
30948
31449
  function isFieldAssessor(field) {
30949
31450
  if (obj.isObject(field)) {
30950
31451
  const a = field;
@@ -31006,6 +31507,8 @@
31006
31507
  return isValid$1(mapIndex) ? mapIndex : index;
31007
31508
  }
31008
31509
  class DataSource extends EventTarget$1 {
31510
+ dataConfig;
31511
+ dataSourceObj;
31009
31512
  _get;
31010
31513
  _sourceLength;
31011
31514
  _source;
@@ -31023,11 +31526,18 @@
31023
31526
  }
31024
31527
  treeDataHierarchyState = new Map();
31025
31528
  beforeChangedRecordsMap = [];
31026
- constructor(obj, pagination, hierarchyExpandLevel) {
31529
+ registedAggregators = {};
31530
+ fieldAggregators = [];
31531
+ layoutColumnObjects = [];
31532
+ constructor(dataSourceObj, dataConfig, pagination, columnObjs, hierarchyExpandLevel) {
31027
31533
  super();
31028
- this._get = obj?.get.bind(obj) || undefined;
31029
- this._sourceLength = obj?.length || 0;
31030
- this._source = obj?.source ?? obj;
31534
+ this.registerAggregators();
31535
+ this.dataSourceObj = dataSourceObj;
31536
+ this.dataConfig = dataConfig;
31537
+ this._get = dataSourceObj?.get.bind(dataSourceObj) || undefined;
31538
+ this.layoutColumnObjects = columnObjs;
31539
+ this._source = this.processRecords(dataSourceObj?.source ?? dataSourceObj);
31540
+ this._sourceLength = this._source?.length || 0;
31031
31541
  this.sortedIndexMap = new Map();
31032
31542
  this._currentPagerIndexedData = [];
31033
31543
  this.userPagination = pagination;
@@ -31061,6 +31571,76 @@
31061
31571
  }
31062
31572
  this.updatePagerData();
31063
31573
  }
31574
+ registerAggregator(type, aggregator) {
31575
+ this.registedAggregators[type] = aggregator;
31576
+ }
31577
+ registerAggregators() {
31578
+ this.registerAggregator(AggregationType.RECORD, RecordAggregator);
31579
+ this.registerAggregator(AggregationType.SUM, SumAggregator);
31580
+ this.registerAggregator(AggregationType.COUNT, CountAggregator);
31581
+ this.registerAggregator(AggregationType.MAX, MaxAggregator);
31582
+ this.registerAggregator(AggregationType.MIN, MinAggregator);
31583
+ this.registerAggregator(AggregationType.AVG, AvgAggregator);
31584
+ this.registerAggregator(AggregationType.NONE, NoneAggregator);
31585
+ this.registerAggregator(AggregationType.CUSTOM, CustomAggregator);
31586
+ }
31587
+ _generateFieldAggragations() {
31588
+ const columnObjs = this.layoutColumnObjects;
31589
+ for (let i = 0; i < columnObjs?.length; i++) {
31590
+ columnObjs[i].aggregator = null;
31591
+ const field = columnObjs[i].field;
31592
+ const aggragation = columnObjs[i].aggregation;
31593
+ if (!aggragation) {
31594
+ continue;
31595
+ }
31596
+ if (Array.isArray(aggragation)) {
31597
+ for (let j = 0; j < aggragation.length; j++) {
31598
+ const item = aggragation[j];
31599
+ const aggregator = new this.registedAggregators[item.aggregationType](field, item.formatFun, true, item.aggregationFun);
31600
+ this.fieldAggregators.push(aggregator);
31601
+ if (!columnObjs[i].aggregator) {
31602
+ columnObjs[i].aggregator = [];
31603
+ }
31604
+ columnObjs[i].aggregator.push(aggregator);
31605
+ }
31606
+ }
31607
+ else {
31608
+ const aggregator = new this.registedAggregators[aggragation.aggregationType](field, aggragation.formatFun, true, aggragation.aggregationFun);
31609
+ this.fieldAggregators.push(aggregator);
31610
+ columnObjs[i].aggregator = aggregator;
31611
+ }
31612
+ }
31613
+ }
31614
+ processRecords(records) {
31615
+ this._generateFieldAggragations();
31616
+ const filteredRecords = [];
31617
+ const isHasAggregation = this.fieldAggregators.length >= 1;
31618
+ const isHasFilterRule = this.dataConfig?.filterRules?.length >= 1;
31619
+ if (isHasFilterRule || isHasAggregation) {
31620
+ for (let i = 0, len = records.length; i < len; i++) {
31621
+ const record = records[i];
31622
+ if (isHasFilterRule) {
31623
+ if (this.filterRecord(record)) {
31624
+ filteredRecords.push(record);
31625
+ isHasAggregation && this.processRecord(record);
31626
+ }
31627
+ }
31628
+ else if (isHasAggregation) {
31629
+ this.processRecord(record);
31630
+ }
31631
+ }
31632
+ if (isHasFilterRule) {
31633
+ return filteredRecords;
31634
+ }
31635
+ }
31636
+ return records;
31637
+ }
31638
+ processRecord(record) {
31639
+ for (let i = 0; i < this.fieldAggregators.length; i++) {
31640
+ const aggregator = this.fieldAggregators[i];
31641
+ aggregator.push(record);
31642
+ }
31643
+ }
31064
31644
  initChildrenNodeHierarchy(indexKey, hierarchyExpandLevel, currentLevel, nodeData) {
31065
31645
  if (currentLevel > hierarchyExpandLevel) {
31066
31646
  return 0;
@@ -31422,6 +32002,49 @@
31422
32002
  this.updatePagerData();
31423
32003
  this.fireListeners(EVENT_TYPE.CHANGE_ORDER, null);
31424
32004
  }
32005
+ filterRecord(record) {
32006
+ let isReserved = true;
32007
+ for (let i = 0; i < this.dataConfig.filterRules.length; i++) {
32008
+ const filterRule = this.dataConfig?.filterRules[i];
32009
+ if (filterRule.filterKey) {
32010
+ const filterValue = record[filterRule.filterKey];
32011
+ if (filterRule.filteredValues.indexOf(filterValue) === -1) {
32012
+ isReserved = false;
32013
+ break;
32014
+ }
32015
+ }
32016
+ else if (!filterRule.filterFunc?.(record)) {
32017
+ isReserved = false;
32018
+ break;
32019
+ }
32020
+ }
32021
+ return isReserved;
32022
+ }
32023
+ updateFilterRulesForSorted(filterRules) {
32024
+ this.dataConfig.filterRules = filterRules;
32025
+ this._source = this.processRecords(this.dataSourceObj?.source ?? this.dataSourceObj);
32026
+ this._sourceLength = this._source?.length || 0;
32027
+ this.sortedIndexMap.clear();
32028
+ this.currentIndexedData = Array.from({ length: this._sourceLength }, (_, i) => i);
32029
+ if (!this.userPagination) {
32030
+ this.pagination.perPageCount = this._sourceLength;
32031
+ this.pagination.totalCount = this._sourceLength;
32032
+ }
32033
+ }
32034
+ updateFilterRules(filterRules) {
32035
+ this.dataConfig.filterRules = filterRules;
32036
+ this._source = this.processRecords(this.dataSourceObj?.source ?? this.dataSourceObj);
32037
+ this._sourceLength = this._source?.length || 0;
32038
+ this.currentIndexedData = Array.from({ length: this._sourceLength }, (_, i) => i);
32039
+ if (this.userPagination) {
32040
+ this.updatePagerData();
32041
+ }
32042
+ else {
32043
+ this.pagination.perPageCount = this._sourceLength;
32044
+ this.pagination.totalCount = this._sourceLength;
32045
+ this.updatePagerData();
32046
+ }
32047
+ }
31425
32048
  clearSortedIndexMap() {
31426
32049
  if (this.lastOrderField && this.lastOrder) {
31427
32050
  this.sortedIndexMap.forEach((sortMap, key) => {
@@ -31482,6 +32105,9 @@
31482
32105
  this.currentPagerIndexedData.length = 0;
31483
32106
  }
31484
32107
  getOriginalRecord(dataIndex) {
32108
+ if (this.dataConfig?.filterRules) {
32109
+ return this.source[dataIndex];
32110
+ }
31485
32111
  return getValue(this._get(dataIndex), (val) => {
31486
32112
  this.recordPromiseCallBack(dataIndex, val);
31487
32113
  });
@@ -31543,7 +32169,7 @@
31543
32169
  static get EVENT_TYPE() {
31544
32170
  return DataSource.EVENT_TYPE;
31545
32171
  }
31546
- static ofArray(array, pagination, hierarchyExpandLevel) {
32172
+ static ofArray(array, dataConfig, pagination, columnObjs, hierarchyExpandLevel) {
31547
32173
  return new CachedDataSource({
31548
32174
  get: (index) => {
31549
32175
  if (Array.isArray(index)) {
@@ -31553,10 +32179,10 @@
31553
32179
  },
31554
32180
  length: array.length,
31555
32181
  source: array
31556
- }, pagination, hierarchyExpandLevel);
32182
+ }, dataConfig, pagination, columnObjs, hierarchyExpandLevel);
31557
32183
  }
31558
- constructor(opt, pagination, hierarchyExpandLevel) {
31559
- super(opt, pagination, hierarchyExpandLevel);
32184
+ constructor(opt, dataConfig, pagination, columnObjs, hierarchyExpandLevel) {
32185
+ super(opt, dataConfig, pagination, columnObjs, hierarchyExpandLevel);
31560
32186
  this._recordCache = {};
31561
32187
  this._fieldCache = {};
31562
32188
  }
@@ -32076,7 +32702,7 @@
32076
32702
  _dealWithUpdateDataSource(table, () => {
32077
32703
  const data = records;
32078
32704
  table.internalProps.records = records;
32079
- const newDataSource = (table.internalProps.dataSource = CachedDataSource.ofArray(data, table.pagination, table.options.hierarchyExpandLevel ?? (table._hasHierarchyTreeHeader?.() ? 1 : undefined)));
32705
+ const newDataSource = (table.internalProps.dataSource = CachedDataSource.ofArray(data, table.internalProps.dataConfig, table.pagination, table.internalProps.layoutMap.columnObjects, table.options.hierarchyExpandLevel ?? (table._hasHierarchyTreeHeader?.() ? 1 : undefined)));
32080
32706
  table.addReleaseObj(newDataSource);
32081
32707
  });
32082
32708
  }
@@ -32266,24 +32892,17 @@
32266
32892
  if (table.sortState) {
32267
32893
  let order;
32268
32894
  let field;
32269
- let fieldKey;
32270
32895
  if (Array.isArray(table.sortState)) {
32271
32896
  if (table.sortState.length !== 0) {
32272
- ({ order, field, fieldKey } = table.sortState?.[0]);
32897
+ ({ order, field } = table.sortState?.[0]);
32273
32898
  }
32274
32899
  }
32275
32900
  else {
32276
- ({ order, field, fieldKey } = table.sortState);
32901
+ ({ order, field } = table.sortState);
32277
32902
  }
32278
32903
  if (order && field && order !== 'normal') {
32279
- const sortFunc = table._getSortFuncFromHeaderOption(undefined, field, fieldKey);
32280
- let hd;
32281
- if (fieldKey) {
32282
- hd = table.internalProps.layoutMap.headerObjects.find((col) => col && col.fieldKey === fieldKey);
32283
- }
32284
- else {
32285
- hd = table.internalProps.layoutMap.headerObjects.find((col) => col && col.field === field);
32286
- }
32904
+ const sortFunc = table._getSortFuncFromHeaderOption(undefined, field);
32905
+ const hd = table.internalProps.layoutMap.headerObjects.find((col) => col && col.field === field);
32287
32906
  table.dataSource.sort(hd.field, order, sortFunc ?? defaultOrderFn);
32288
32907
  }
32289
32908
  }
@@ -32602,11 +33221,13 @@
32602
33221
  activeChartInstance;
32603
33222
  active;
32604
33223
  cacheCanvas;
32605
- constructor(params) {
33224
+ isShareChartSpec;
33225
+ constructor(isShareChartSpec, params) {
32606
33226
  super(params);
32607
33227
  this.numberType = CHART_NUMBER_TYPE;
33228
+ this.isShareChartSpec = isShareChartSpec;
32608
33229
  if (!params.chartInstance) {
32609
- params.chartInstance = this.chartInstance = new params.ClassType(params.spec, {
33230
+ const chartInstance = new params.ClassType(params.spec, {
32610
33231
  renderCanvas: params.canvas,
32611
33232
  mode: this.attribute.mode === 'node' ? 'node' : 'desktop-browser',
32612
33233
  modeParams: this.attribute.modeParams,
@@ -32617,7 +33238,8 @@
32617
33238
  animation: false,
32618
33239
  autoFit: false
32619
33240
  });
32620
- this.chartInstance.renderSync();
33241
+ chartInstance.renderSync();
33242
+ params.chartInstance = this.chartInstance = chartInstance;
32621
33243
  }
32622
33244
  else {
32623
33245
  this.chartInstance = params.chartInstance;
@@ -32742,7 +33364,7 @@
32742
33364
  return extend(builtin, chartTypes);
32743
33365
  }
32744
33366
 
32745
- function createChartCellGroup(cellGroup, columnGroup, xOrigin, yOrigin, col, row, width, height, padding, dataValue, chartModule, chartSpec, chartInstance, dataId, table, cellTheme) {
33367
+ function createChartCellGroup(cellGroup, columnGroup, xOrigin, yOrigin, col, row, width, height, padding, dataValue, chartModule, chartSpec, chartInstance, dataId, table, cellTheme, isShareChartSpec) {
32746
33368
  const registerCharts = get$2();
32747
33369
  const ClassType = registerCharts[chartModule];
32748
33370
  const headerStyle = table._getCellStyle(col, row);
@@ -32773,7 +33395,7 @@
32773
33395
  columnGroup?.addCellGroup(cellGroup);
32774
33396
  }
32775
33397
  cellGroup.AABBBounds.width();
32776
- const chartGroup = new Chart({
33398
+ const chartGroup = new Chart(isShareChartSpec, {
32777
33399
  stroke: false,
32778
33400
  x: padding[3],
32779
33401
  y: padding[0],
@@ -33177,7 +33799,9 @@
33177
33799
  if (image.resources &&
33178
33800
  image.resources.has(image.attribute.image) &&
33179
33801
  image.resources.get(image.attribute.image).state === 'success') {
33180
- updateAutoSizingAndKeepAspectRatio(imageAutoSizing, keepAspectRatio, padding, textAlign, textBaseline, image, cellGroup, table);
33802
+ setTimeout(() => {
33803
+ updateAutoSizingAndKeepAspectRatio(imageAutoSizing, keepAspectRatio, padding, textAlign, textBaseline, image, cellGroup, table);
33804
+ }, 0);
33181
33805
  }
33182
33806
  else {
33183
33807
  image.successCallback = () => {
@@ -33205,11 +33829,10 @@
33205
33829
  cellGroup.appendChild(image);
33206
33830
  return cellGroup;
33207
33831
  }
33208
- function _adjustWidthHeight(col, row, width, height, scene, padding) {
33832
+ function _adjustWidthHeight(col, row, width, height, scene, padding, cellGroup) {
33209
33833
  let needInvalidate = false;
33210
33834
  let targetWidth = null;
33211
33835
  let targetHeight = null;
33212
- const cellGroup = scene.getCell(col, row, true);
33213
33836
  const { width: cellWidth, height: cellHeight, isMerge } = getCellRange(cellGroup, scene.table);
33214
33837
  if (cellWidth < width + padding[1] + padding[3]) {
33215
33838
  targetWidth = width + padding[1] + padding[3];
@@ -33247,6 +33870,9 @@
33247
33870
  }
33248
33871
  function updateImageCellContentWhileResize(cellGroup, col, row, table) {
33249
33872
  const image = cellGroup.getChildByName('image');
33873
+ if (!image) {
33874
+ return;
33875
+ }
33250
33876
  const originImage = (typeof image.attribute.image !== 'string' && image.attribute.image) ||
33251
33877
  image.resources?.get(image.attribute.image).data;
33252
33878
  if (!originImage) {
@@ -33329,7 +33955,7 @@
33329
33955
  const originImage = image.resources.get(image.attribute.image).data;
33330
33956
  const { col, row } = cellGroup;
33331
33957
  if (imageAutoSizing && !isDamagePic(image)) {
33332
- _adjustWidthHeight(col, row, originImage.width, originImage.height, table.scenegraph, padding);
33958
+ _adjustWidthHeight(col, row, originImage.width, originImage.height, table.scenegraph, padding, cellGroup);
33333
33959
  }
33334
33960
  if (keepAspectRatio || isDamagePic(image)) {
33335
33961
  const { width: cellWidth, height: cellHeight, isMerge } = getCellRange(cellGroup, table);
@@ -34797,7 +35423,7 @@
34797
35423
  const video = document.createElement('video');
34798
35424
  video.addEventListener('loadeddata', () => {
34799
35425
  if (imageAutoSizing) {
34800
- _adjustWidthHeight(col, row, video.videoWidth, video.videoHeight, table.scenegraph, padding);
35426
+ _adjustWidthHeight(col, row, video.videoWidth, video.videoHeight, table.scenegraph, padding, cellGroup);
34801
35427
  }
34802
35428
  const width = cellGroup.attribute.width;
34803
35429
  const height = cellGroup.attribute.height;
@@ -35123,9 +35749,7 @@
35123
35749
  }
35124
35750
  else if (type === 'chart') {
35125
35751
  const chartInstance = table.internalProps.layoutMap.getChartInstance(col, row);
35126
- cellGroup = createChartCellGroup(null, columnGroup, 0, y, col, row, cellWidth, cellHeight, padding, value, define.chartModule, table.isPivotChart()
35127
- ? table.internalProps.layoutMap.getChartSpec(col, row)
35128
- : define.chartSpec, chartInstance, table.internalProps.layoutMap?.getChartDataId(col, row) ?? 'data', table, cellTheme);
35752
+ cellGroup = createChartCellGroup(null, columnGroup, 0, y, col, row, cellWidth, cellHeight, padding, value, define.chartModule, table.internalProps.layoutMap.getChartSpec(col, row), chartInstance, table.internalProps.layoutMap.getChartDataId(col, row) ?? 'data', table, cellTheme, table.internalProps.layoutMap.isShareChartSpec(col, row));
35129
35753
  }
35130
35754
  else if (type === 'progressbar') {
35131
35755
  const style = table._getCellStyle(col, row);
@@ -35243,9 +35867,8 @@
35243
35867
  dx: hierarchyOffset,
35244
35868
  x
35245
35869
  };
35246
- const oldText = textMark.attribute.text;
35247
35870
  textMark.setAttributes(cellTheme.text ? Object.assign({}, cellTheme.text, attribute) : attribute);
35248
- if (!oldText && textMark.attribute.text) {
35871
+ if (textMark.attribute.text) {
35249
35872
  const textBaseline = cellTheme.text.textBaseline;
35250
35873
  const height = cellHeight - (padding[0] + padding[2]);
35251
35874
  let y = 0;
@@ -35273,8 +35896,8 @@
35273
35896
  : table.getBodyColumnType(col, row);
35274
35897
  const mayHaveIcon = cellLocation !== 'body' ? true : !!define?.icon || !!define?.tree;
35275
35898
  const padding = cellTheme._vtable.padding;
35276
- const textAlign = cellTheme._vtable.textAlign;
35277
- const textBaseline = cellTheme._vtable.textBaseline;
35899
+ const textAlign = cellTheme.text.textAlign;
35900
+ const textBaseline = cellTheme.text.textBaseline;
35278
35901
  let newCellGroup;
35279
35902
  let bgColorFunc;
35280
35903
  if (table.internalProps?.dataConfig?.mappingRules && !table.isHeader(col, row)) {
@@ -35304,13 +35927,11 @@
35304
35927
  newCellGroup = updateCellContent(type, value, define, table, col, row, bgColorFunc, cellWidth, cellHeight, oldCellGroup, padding, textAlign, textBaseline, mayHaveIcon, addNew, cellTheme, range, customResult);
35305
35928
  }
35306
35929
  if (isMerge) {
35307
- const rangeHeight = table.getRowHeight(row);
35308
- const rangeWidth = table.getColWidth(col);
35309
35930
  const { width: contentWidth } = newCellGroup.attribute;
35310
35931
  const { height: contentHeight } = newCellGroup.attribute;
35311
35932
  newCellGroup.contentWidth = contentWidth;
35312
35933
  newCellGroup.contentHeight = contentHeight;
35313
- resizeCellGroup(newCellGroup, rangeWidth, rangeHeight, range, table);
35934
+ dealWithMergeCellSize(range, cellWidth, cellHeight, padding, textAlign, textBaseline, table);
35314
35935
  }
35315
35936
  return newCellGroup;
35316
35937
  }
@@ -35349,6 +35970,24 @@
35349
35970
  }
35350
35971
  return false;
35351
35972
  }
35973
+ function dealWithMergeCellSize(range, cellWidth, cellHeight, padding, textAlign, textBaseline, table) {
35974
+ for (let col = range.start.col; col <= range.end.col; col++) {
35975
+ for (let row = range.start.row; row <= range.end.row; row++) {
35976
+ const cellGroup = table.scenegraph.getCell(col, row, true);
35977
+ if (range.start.row !== range.end.row) {
35978
+ updateCellContentHeight(cellGroup, cellHeight, cellHeight, table.heightMode === 'autoHeight', padding, textAlign, textBaseline);
35979
+ }
35980
+ if (range.start.col !== range.end.col) {
35981
+ updateCellContentWidth(cellGroup, cellWidth, cellHeight, 0, table.heightMode === 'autoHeight', padding, textAlign, textBaseline, table.scenegraph);
35982
+ }
35983
+ cellGroup.contentWidth = cellWidth;
35984
+ cellGroup.contentHeight = cellHeight;
35985
+ const rangeHeight = table.getRowHeight(row);
35986
+ const rangeWidth = table.getColWidth(col);
35987
+ resizeCellGroup(cellGroup, rangeWidth, rangeHeight, range, table);
35988
+ }
35989
+ }
35990
+ }
35352
35991
 
35353
35992
  function createComplexColumn(columnGroup, col, colWidth, rowStart, rowEnd, mergeMap, defaultRowHeight, table, cellLocation, rowLimit) {
35354
35993
  let padding;
@@ -35377,7 +36016,8 @@
35377
36016
  range = customMergeRange;
35378
36017
  isMerge = range.start.col !== range.end.col || range.start.row !== range.end.row;
35379
36018
  if (isMerge) {
35380
- const mergeSize = dealMerge(range, mergeMap, table);
36019
+ const needUpdateRange = rowStart > range.start.row;
36020
+ const mergeSize = dealMerge(range, mergeMap, table, needUpdateRange);
35381
36021
  cellWidth = mergeSize.cellWidth;
35382
36022
  cellHeight = mergeSize.cellHeight;
35383
36023
  }
@@ -35402,7 +36042,8 @@
35402
36042
  range = table.getCellRange(col, row);
35403
36043
  isMerge = range.start.col !== range.end.col || range.start.row !== range.end.row;
35404
36044
  if (isMerge) {
35405
- const mergeSize = dealMerge(range, mergeMap, table);
36045
+ const needUpdateRange = rowStart > range.start.row;
36046
+ const mergeSize = dealMerge(range, mergeMap, table, needUpdateRange);
35406
36047
  cellWidth = mergeSize.cellWidth;
35407
36048
  cellHeight = mergeSize.cellHeight;
35408
36049
  }
@@ -35503,11 +36144,11 @@
35503
36144
  heightChange
35504
36145
  };
35505
36146
  }
35506
- function dealMerge(range, mergeMap, table) {
36147
+ function dealMerge(range, mergeMap, table, forceUpdate) {
35507
36148
  let cellWidth = 0;
35508
36149
  let cellHeight = 0;
35509
36150
  const mergeResult = mergeMap.get(`${range.start.col},${range.start.row};${range.end.col},${range.end.row}`);
35510
- if (!mergeResult) {
36151
+ if (!mergeResult || forceUpdate) {
35511
36152
  for (let col = range.start.col; col <= range.end.col; col++) {
35512
36153
  cellWidth += table.getColWidth(col);
35513
36154
  }
@@ -39221,6 +39862,11 @@
39221
39862
  const { viewWidth, viewHeight } = stage;
39222
39863
  if (viewWidth < cacheCanvasSizeLimit && viewHeight < cacheCanvasSizeLimit) {
39223
39864
  chart.cacheCanvas = stage.toCanvas();
39865
+ if (!chart.isShareChartSpec) {
39866
+ chart.chartInstance?.release();
39867
+ chart.chartInstance = null;
39868
+ chart.setAttribute('chartInstance', null);
39869
+ }
39224
39870
  return;
39225
39871
  }
39226
39872
  const rows = Math.ceil(viewHeight / cacheCanvasSizeLimit);
@@ -39258,7 +39904,7 @@
39258
39904
  const { dataId, data, spec } = chart.attribute;
39259
39905
  chart.getViewBox();
39260
39906
  const { width = groupAttribute.width, height = groupAttribute.height } = chart.attribute;
39261
- const { chartInstance, active, cacheCanvas, activeChartInstance } = chart;
39907
+ const { active, cacheCanvas, activeChartInstance } = chart;
39262
39908
  if (!active && cacheCanvas) {
39263
39909
  if (isArray$1(cacheCanvas)) {
39264
39910
  cacheCanvas.forEach(singleCacheCanvas => {
@@ -39288,7 +39934,7 @@
39288
39934
  : data ?? [],
39289
39935
  fields: series?.data?.fields
39290
39936
  });
39291
- if (!chartInstance.updateFullDataSync) {
39937
+ if (!activeChartInstance.updateFullDataSync) {
39292
39938
  activeChartInstance.updateDataSync(dataIdStr, dataIdAndField
39293
39939
  ? data?.filter((item) => {
39294
39940
  return item.hasOwnProperty(dataIdAndField);
@@ -41249,7 +41895,12 @@
41249
41895
  syncTopRow = Math.max(proxy.bodyTopRow, proxy.screenTopRow - proxy.screenRowCount * 1);
41250
41896
  syncBottomRow = Math.min(proxy.bodyBottomRow, proxy.screenTopRow + proxy.screenRowCount * 2);
41251
41897
  }
41898
+ const oldBodyHeight = proxy.table.getAllRowsHeight();
41252
41899
  computeRowsHeight(proxy.table, syncTopRow, syncBottomRow);
41900
+ const newBodyHeight = proxy.table.getAllRowsHeight();
41901
+ if (oldBodyHeight !== newBodyHeight) {
41902
+ proxy.table.scenegraph.updateContainerHeight(proxy.table.frozenRowCount, newBodyHeight - oldBodyHeight);
41903
+ }
41253
41904
  updateRowContent(syncTopRow, syncBottomRow, proxy);
41254
41905
  if (proxy.table.heightMode === 'autoHeight') {
41255
41906
  updateAutoRow(proxy.bodyLeftCol, proxy.bodyRightCol, syncTopRow, syncBottomRow, proxy.table, proxy.rowEnd > proxy.bodyBottomRow - (proxy.rowEnd - proxy.rowStart + 1) ? 'down' : 'up');
@@ -44248,7 +44899,7 @@
44248
44899
  initSceneGraph(this);
44249
44900
  }
44250
44901
  clearCells() {
44251
- if (this.table.isPivotChart() || this.table.hasCustomRenderOrLayout()) {
44902
+ if (this.table.isPivotChart() || this.table._hasCustomRenderOrLayout()) {
44252
44903
  this.stage.pluginService.findPluginsByName('poptipForText').forEach(plugin => {
44253
44904
  plugin.deactivate(this.stage.pluginService);
44254
44905
  });
@@ -44348,7 +44999,7 @@
44348
44999
  this.component.updateStyle();
44349
45000
  }
44350
45001
  createSceneGraph() {
44351
- if (this.table.isPivotChart() || this.table.hasCustomRenderOrLayout()) {
45002
+ if (this.table.isPivotChart() || this.table._hasCustomRenderOrLayout()) {
44352
45003
  this.stage.pluginService.autoEnablePlugins.getContributions().forEach((p) => {
44353
45004
  if (p.name === 'poptipForText') {
44354
45005
  this.stage.pluginService.register(p);
@@ -45088,11 +45739,7 @@
45088
45739
  updateContainer() {
45089
45740
  this.updateContainerAttrWidthAndX();
45090
45741
  this.updateTableSize();
45091
- const oldHorizontalBarPos = this.table.stateManager.scroll.horizontalBarPos;
45092
- const oldVerticalBarPos = this.table.stateManager.scroll.verticalBarPos;
45093
45742
  this.component.updateScrollBar();
45094
- this.table.stateManager.setScrollLeft(oldHorizontalBarPos);
45095
- this.table.stateManager.setScrollTop(oldVerticalBarPos);
45096
45743
  this.updateNextFrame();
45097
45744
  }
45098
45745
  updateCellContentWhileResize(col, row) {
@@ -45540,7 +46187,6 @@
45540
46187
  }
45541
46188
  else if (headerC?.sort) {
45542
46189
  tableState = {
45543
- fieldKey: table.getHeaderFieldKey(col, row),
45544
46190
  field: table.getHeaderField(col, row),
45545
46191
  order: 'asc'
45546
46192
  };
@@ -45548,7 +46194,6 @@
45548
46194
  else if (isTargetCell && headerC?.showSort) ;
45549
46195
  else {
45550
46196
  tableState = {
45551
- fieldKey: table.getHeaderFieldKey(col, row),
45552
46197
  field: table.getHeaderField(col, row),
45553
46198
  order: 'normal'
45554
46199
  };
@@ -45567,13 +46212,7 @@
45567
46212
  table.stateManager.updateSelectPos(-1, -1);
45568
46213
  }
45569
46214
  function executeSort(newState, table, headerDefine) {
45570
- let hd;
45571
- if (newState.fieldKey) {
45572
- hd = table.internalProps.layoutMap.headerObjects.find((col) => col && col.fieldKey === newState.fieldKey);
45573
- }
45574
- else {
45575
- hd = table.internalProps.layoutMap.headerObjects.find((col) => col && col.field === newState.field);
45576
- }
46215
+ const hd = table.internalProps.layoutMap.headerObjects.find((col) => col && col.field === newState.field);
45577
46216
  if (!hd) {
45578
46217
  return;
45579
46218
  }
@@ -46462,7 +47101,6 @@
46462
47101
  }
46463
47102
  setSortState(sortState) {
46464
47103
  this.sort.field = sortState?.field;
46465
- this.sort.fieldKey = sortState?.fieldKey;
46466
47104
  this.sort.order = sortState?.order;
46467
47105
  }
46468
47106
  setFrozenState() {
@@ -51570,6 +52208,7 @@
51570
52208
  return this.data.size;
51571
52209
  }
51572
52210
  clear() {
52211
+ this._keys = [];
51573
52212
  this.data.clear();
51574
52213
  this.cumulativeSum.clear();
51575
52214
  this.difference.clear();
@@ -51814,7 +52453,7 @@
51814
52453
  return TABLE_EVENT_TYPE;
51815
52454
  }
51816
52455
  options;
51817
- version = "0.19.2-alpha.3";
52456
+ version = "0.20.0";
51818
52457
  pagination;
51819
52458
  id = `VTable${Date.now()}`;
51820
52459
  headerStyleCache;
@@ -53214,6 +53853,9 @@
53214
53853
  this.setScrollTop(scrollTop);
53215
53854
  this.setScrollLeft(scrollLeft);
53216
53855
  }
53856
+ get recordsCount() {
53857
+ return this.records?.length;
53858
+ }
53217
53859
  get allowFrozenColCount() {
53218
53860
  return this.internalProps.allowFrozenColCount;
53219
53861
  }
@@ -53297,9 +53939,6 @@
53297
53939
  getHeaderField(col, row) {
53298
53940
  return this.internalProps.layoutMap.getHeaderField(col, row);
53299
53941
  }
53300
- getHeaderFieldKey(col, row) {
53301
- return this.internalProps.layoutMap.getHeaderFieldKey(col, row);
53302
- }
53303
53942
  getHeaderDefine(col, row) {
53304
53943
  const hd = this.internalProps.layoutMap.getHeader(col, row);
53305
53944
  return hd?.define;
@@ -53349,13 +53988,7 @@
53349
53988
  }
53350
53989
  _getHeaderCellBySortState(sortState) {
53351
53990
  const { layoutMap } = this.internalProps;
53352
- let hd;
53353
- if (sortState.fieldKey) {
53354
- hd = layoutMap.headerObjects.find((col) => col && col.fieldKey === sortState.fieldKey);
53355
- }
53356
- else {
53357
- hd = layoutMap.headerObjects.find((col) => col && col.field === sortState.field);
53358
- }
53991
+ const hd = layoutMap.headerObjects.find((col) => col && col.field === sortState.field);
53359
53992
  if (hd) {
53360
53993
  const headercell = layoutMap.getHeaderCellAdressById(hd.id);
53361
53994
  return headercell;
@@ -54333,8 +54966,36 @@
54333
54966
  indicatorObj = layout.columnObjects.find(indicator => indicator.indicatorKey === indicatorKey);
54334
54967
  }
54335
54968
  const chartSpec = indicatorObj?.chartSpec;
54969
+ if (typeof chartSpec === 'function') {
54970
+ const arg = {
54971
+ col,
54972
+ row,
54973
+ dataValue: layout._table.getCellOriginValue(col, row) || '',
54974
+ value: layout._table.getCellValue(col, row) || '',
54975
+ rect: layout._table.getCellRangeRelativeRect(layout._table.getCellRange(col, row)),
54976
+ table: layout._table
54977
+ };
54978
+ return chartSpec(arg);
54979
+ }
54336
54980
  return chartSpec;
54337
54981
  }
54982
+ function isShareChartSpec(col, row, layout) {
54983
+ const paths = layout.getCellHeaderPaths(col, row);
54984
+ let indicatorObj;
54985
+ if (layout.indicatorsAsCol) {
54986
+ const indicatorKey = paths.colHeaderPaths.find(colPath => colPath.indicatorKey)?.indicatorKey;
54987
+ indicatorObj = layout.columnObjects.find(indicator => indicator.indicatorKey === indicatorKey);
54988
+ }
54989
+ else {
54990
+ const indicatorKey = paths.rowHeaderPaths.find(rowPath => rowPath.indicatorKey)?.indicatorKey;
54991
+ indicatorObj = layout.columnObjects.find(indicator => indicator.indicatorKey === indicatorKey);
54992
+ }
54993
+ const chartSpec = indicatorObj?.chartSpec;
54994
+ if (typeof chartSpec === 'function') {
54995
+ return false;
54996
+ }
54997
+ return true;
54998
+ }
54338
54999
  function checkHasCartesianChart(layout) {
54339
55000
  let isHasCartesianChart = false;
54340
55001
  for (let i = 0; i < layout.indicatorsDefine.length; i++) {
@@ -54394,16 +55055,19 @@
54394
55055
  function getChartSpec(col, row, layout) {
54395
55056
  let chartSpec = layout.getRawChartSpec(col, row);
54396
55057
  if (chartSpec) {
54397
- chartSpec = cloneDeep(chartSpec);
54398
- chartSpec.sortDataByAxis = true;
54399
- if (isArray$1(chartSpec.series)) {
54400
- chartSpec.series.forEach((serie) => {
54401
- serie.sortDataByAxis = true;
54402
- });
55058
+ if (layout._table.isPivotChart()) {
55059
+ chartSpec = cloneDeep(chartSpec);
55060
+ chartSpec.sortDataByAxis = true;
55061
+ if (isArray$1(chartSpec.series)) {
55062
+ chartSpec.series.forEach((serie) => {
55063
+ serie.sortDataByAxis = true;
55064
+ });
55065
+ }
55066
+ chartSpec.axes = layout.getChartAxes(col, row);
55067
+ chartSpec.padding = 0;
55068
+ chartSpec.dataZoom = [];
55069
+ return chartSpec;
54403
55070
  }
54404
- chartSpec.axes = layout.getChartAxes(col, row);
54405
- chartSpec.padding = 0;
54406
- chartSpec.dataZoom = [];
54407
55071
  return chartSpec;
54408
55072
  }
54409
55073
  return null;
@@ -54589,6 +55253,49 @@
54589
55253
  return isHasChart;
54590
55254
  }
54591
55255
 
55256
+ function checkHasAggregation(layoutMap) {
55257
+ const columnObjects = layoutMap.columnObjects;
55258
+ for (let i = 0; i < columnObjects.length; i++) {
55259
+ const column = columnObjects[i];
55260
+ if (column?.aggregation) {
55261
+ return true;
55262
+ }
55263
+ }
55264
+ return false;
55265
+ }
55266
+ function checkHasAggregationOnTop(layoutMap) {
55267
+ const columnObjects = layoutMap.columnObjects;
55268
+ let count = 0;
55269
+ for (let i = 0; i < columnObjects.length; i++) {
55270
+ const column = columnObjects[i];
55271
+ if (column?.aggregation) {
55272
+ if (Array.isArray(column?.aggregation)) {
55273
+ count = Math.max(count, column.aggregation.filter(item => item.showOnTop === true).length);
55274
+ }
55275
+ else if (column.aggregation.showOnTop === true) {
55276
+ count = Math.max(count, 1);
55277
+ }
55278
+ }
55279
+ }
55280
+ return count;
55281
+ }
55282
+ function checkHasAggregationOnBottom(layoutMap) {
55283
+ const columnObjects = layoutMap.columnObjects;
55284
+ let count = 0;
55285
+ for (let i = 0; i < columnObjects.length; i++) {
55286
+ const column = columnObjects[i];
55287
+ if (column?.aggregation) {
55288
+ if (Array.isArray(column?.aggregation)) {
55289
+ count = Math.max(count, column.aggregation.filter(item => item.showOnTop === false).length);
55290
+ }
55291
+ else if (column.aggregation.showOnTop === false) {
55292
+ count = Math.max(count, 1);
55293
+ }
55294
+ }
55295
+ }
55296
+ return count;
55297
+ }
55298
+
54592
55299
  class DimensionTree {
54593
55300
  sharedVar;
54594
55301
  sizeIncludeParent = false;
@@ -55014,6 +55721,9 @@
55014
55721
  _showHeader = true;
55015
55722
  _recordsCount = 0;
55016
55723
  _table;
55724
+ _hasAggregation = false;
55725
+ _hasAggregationOnTopCount = 0;
55726
+ _hasAggregationOnBottomCount = 0;
55017
55727
  _cellRangeMap;
55018
55728
  constructor(table, columns, showHeader, hierarchyIndent) {
55019
55729
  this._cellRangeMap = new Map();
@@ -55028,6 +55738,9 @@
55028
55738
  o[e.id] = e;
55029
55739
  return o;
55030
55740
  }, {});
55741
+ this._hasAggregation = checkHasAggregation(this);
55742
+ this._hasAggregationOnBottomCount = checkHasAggregationOnBottom(this);
55743
+ this._hasAggregationOnTopCount = checkHasAggregationOnTop(this);
55031
55744
  }
55032
55745
  get transpose() {
55033
55746
  return this._transpose;
@@ -55050,6 +55763,153 @@
55050
55763
  }
55051
55764
  return false;
55052
55765
  }
55766
+ isAggregation(col, row) {
55767
+ if (this.hasAggregation) {
55768
+ if (this.hasAggregationOnBottomCount) {
55769
+ if (this.transpose) {
55770
+ if (col >= this.colCount - this.hasAggregationOnBottomCount) {
55771
+ return true;
55772
+ }
55773
+ }
55774
+ else {
55775
+ if (row >= this.rowCount - this.hasAggregationOnBottomCount) {
55776
+ return true;
55777
+ }
55778
+ }
55779
+ }
55780
+ if (this.hasAggregationOnTopCount) {
55781
+ if (this.transpose) {
55782
+ if (col >= this.rowHeaderLevelCount && col < this.rowHeaderLevelCount + this.hasAggregationOnTopCount) {
55783
+ return true;
55784
+ }
55785
+ }
55786
+ else {
55787
+ if (row >= this.columnHeaderLevelCount && row < this.columnHeaderLevelCount + this.hasAggregationOnTopCount) {
55788
+ return true;
55789
+ }
55790
+ }
55791
+ }
55792
+ }
55793
+ return false;
55794
+ }
55795
+ isTopAggregation(col, row) {
55796
+ if (this.hasAggregationOnTopCount) {
55797
+ if (this.transpose) {
55798
+ if (col >= this.rowHeaderLevelCount && col < this.rowHeaderLevelCount + this.hasAggregationOnTopCount) {
55799
+ return true;
55800
+ }
55801
+ }
55802
+ else {
55803
+ if (row >= this.columnHeaderLevelCount && row < this.columnHeaderLevelCount + this.hasAggregationOnTopCount) {
55804
+ return true;
55805
+ }
55806
+ }
55807
+ }
55808
+ return false;
55809
+ }
55810
+ isBottomAggregation(col, row) {
55811
+ if (this.hasAggregationOnBottomCount) {
55812
+ if (this.transpose) {
55813
+ if (col >= this.colCount - this.hasAggregationOnBottomCount) {
55814
+ return true;
55815
+ }
55816
+ }
55817
+ else {
55818
+ if (row >= this.rowCount - this.hasAggregationOnBottomCount) {
55819
+ return true;
55820
+ }
55821
+ }
55822
+ }
55823
+ return false;
55824
+ }
55825
+ get hasAggregation() {
55826
+ return this._hasAggregation;
55827
+ }
55828
+ get hasAggregationOnTopCount() {
55829
+ return this._hasAggregationOnTopCount;
55830
+ }
55831
+ get hasAggregationOnBottomCount() {
55832
+ return this._hasAggregationOnBottomCount;
55833
+ }
55834
+ getAggregators(col, row) {
55835
+ const column = this.getBody(col, row);
55836
+ const aggregators = column.aggregator;
55837
+ return aggregators;
55838
+ }
55839
+ getAggregatorOnTop(col, row) {
55840
+ const column = this.getBody(col, row);
55841
+ const aggregators = column.aggregator;
55842
+ const aggregation = column.aggregation;
55843
+ if (Array.isArray(aggregation)) {
55844
+ const topAggregationIndexs = aggregation.reduce((indexs, agg, index) => {
55845
+ if (agg.showOnTop) {
55846
+ indexs.push(index);
55847
+ }
55848
+ return indexs;
55849
+ }, []);
55850
+ const topAggregators = topAggregationIndexs.map(index => aggregators[index]);
55851
+ if (this.transpose) {
55852
+ return topAggregators[col - this.rowHeaderLevelCount];
55853
+ }
55854
+ return topAggregators[row - this.columnHeaderLevelCount];
55855
+ }
55856
+ if (this.transpose && col - this.rowHeaderLevelCount === 0) {
55857
+ return aggregation?.showOnTop ? aggregators : null;
55858
+ }
55859
+ else if (!this.transpose && row - this.columnHeaderLevelCount === 0) {
55860
+ return aggregation?.showOnTop ? aggregators : null;
55861
+ }
55862
+ return null;
55863
+ }
55864
+ getAggregatorOnBottom(col, row) {
55865
+ const column = this.getBody(col, row);
55866
+ const aggregators = column.aggregator;
55867
+ const aggregation = column.aggregation;
55868
+ if (Array.isArray(aggregation)) {
55869
+ const bottomAggregationIndexs = aggregation.reduce((indexs, agg, index) => {
55870
+ if (agg.showOnTop === false) {
55871
+ indexs.push(index);
55872
+ }
55873
+ return indexs;
55874
+ }, []);
55875
+ const bottomAggregators = bottomAggregationIndexs.map(index => aggregators[index]);
55876
+ if (this.transpose) {
55877
+ return bottomAggregators[col - (this.colCount - this.hasAggregationOnBottomCount)];
55878
+ }
55879
+ return bottomAggregators[row - (this.rowCount - this.hasAggregationOnBottomCount)];
55880
+ }
55881
+ if (this.transpose && col - (this.colCount - this.hasAggregationOnBottomCount) === 0) {
55882
+ return aggregation?.showOnTop === false ? aggregators : null;
55883
+ }
55884
+ else if (!this.transpose && row - (this.rowCount - this.hasAggregationOnBottomCount) === 0) {
55885
+ return aggregation?.showOnTop === false ? aggregators : null;
55886
+ }
55887
+ return null;
55888
+ }
55889
+ getCellAddressHasAggregator(col, row) {
55890
+ const cellAddrs = [];
55891
+ if (this.transpose) {
55892
+ const topCount = this.hasAggregationOnTopCount;
55893
+ for (let i = 0; i < topCount; i++) {
55894
+ cellAddrs.push({ col: this.headerLevelCount + i, row });
55895
+ }
55896
+ const bottomCount = this.hasAggregationOnBottomCount;
55897
+ for (let i = 0; i < bottomCount; i++) {
55898
+ cellAddrs.push({ col: this.rowCount - bottomCount + i, row });
55899
+ }
55900
+ }
55901
+ else {
55902
+ const topCount = this.hasAggregationOnTopCount;
55903
+ for (let i = 0; i < topCount; i++) {
55904
+ cellAddrs.push({ col, row: this.headerLevelCount + i });
55905
+ }
55906
+ const bottomCount = this.hasAggregationOnBottomCount;
55907
+ for (let i = 0; i < bottomCount; i++) {
55908
+ cellAddrs.push({ col, row: this.rowCount - bottomCount + i });
55909
+ }
55910
+ }
55911
+ return cellAddrs;
55912
+ }
55053
55913
  getCellLocation(col, row) {
55054
55914
  if (this.isHeader(col, row)) {
55055
55915
  if (this.transpose) {
@@ -55319,11 +56179,6 @@
55319
56179
  const id = this.getCellId(col, row);
55320
56180
  return this._headerObjectMap[id];
55321
56181
  }
55322
- getHeaderFieldKey(col, row) {
55323
- const id = this.getCellId(col, row);
55324
- return (this._headerObjectMap[id]?.fieldKey ||
55325
- (this.transpose ? this._columns[row]?.fieldKey : this._columns[col]?.fieldKey));
55326
- }
55327
56182
  getHeaderField(col, row) {
55328
56183
  const id = this.getCellId(col, row);
55329
56184
  return (this._headerObjectMap[id]?.field ||
@@ -55531,19 +56386,21 @@
55531
56386
  range1.end.row === range2.end.row);
55532
56387
  }
55533
56388
  getRecordIndexByCell(col, row) {
56389
+ const skipRowCount = this.hasAggregationOnTopCount ? this.headerLevelCount + 1 : this.headerLevelCount;
55534
56390
  if (this.transpose) {
55535
- if (col < this.headerLevelCount) {
56391
+ if (col < skipRowCount) {
55536
56392
  return -1;
55537
56393
  }
55538
- return col - this.headerLevelCount;
56394
+ return col - skipRowCount;
55539
56395
  }
55540
- if (row < this.headerLevelCount) {
56396
+ if (row < skipRowCount) {
55541
56397
  return -1;
55542
56398
  }
55543
- return row - this.headerLevelCount;
56399
+ return row - skipRowCount;
55544
56400
  }
55545
56401
  getRecordStartRowByRecordIndex(index) {
55546
- return this.headerLevelCount + index;
56402
+ const skipRowCount = this.hasAggregationOnTopCount ? this.headerLevelCount + 1 : this.headerLevelCount;
56403
+ return skipRowCount + index;
55547
56404
  }
55548
56405
  _addHeaders(row, column, roots, hideColumnsSubHeader) {
55549
56406
  const results = [];
@@ -55556,8 +56413,6 @@
55556
56413
  title: hd.title ?? hd.caption,
55557
56414
  headerIcon: hd.headerIcon,
55558
56415
  field: hd.field,
55559
- fieldKey: hd?.fieldKey,
55560
- fieldFormat: hd.fieldFormat,
55561
56416
  style: hd.headerStyle,
55562
56417
  headerType: hd.headerType ?? 'text',
55563
56418
  dropDownMenu: hd.dropDownMenu,
@@ -55582,7 +56437,6 @@
55582
56437
  this._columns.push({
55583
56438
  id: this.seqId++,
55584
56439
  field: colDef.field,
55585
- fieldKey: colDef.fieldKey,
55586
56440
  fieldFormat: colDef.fieldFormat,
55587
56441
  width: colDef.width,
55588
56442
  minWidth: colDef.minWidth,
@@ -55595,7 +56449,8 @@
55595
56449
  style: colDef.style,
55596
56450
  define: colDef,
55597
56451
  columnWidthComputeMode: colDef.columnWidthComputeMode,
55598
- disableColumnResize: colDef?.disableColumnResize
56452
+ disableColumnResize: colDef?.disableColumnResize,
56453
+ aggregation: this._getAggregationForColumn(colDef, col)
55599
56454
  });
55600
56455
  for (let r = row + 1; r < this._headerCellIds.length; r++) {
55601
56456
  this._headerCellIds[r][col] = id;
@@ -55604,6 +56459,35 @@
55604
56459
  });
55605
56460
  return results;
55606
56461
  }
56462
+ _getAggregationForColumn(colDef, col) {
56463
+ let aggregation;
56464
+ if (colDef.aggregation) {
56465
+ aggregation = colDef.aggregation;
56466
+ }
56467
+ else if (this._table.options.aggregation) {
56468
+ if (typeof this._table.options.aggregation === 'function') {
56469
+ aggregation = this._table.options.aggregation({
56470
+ col: col,
56471
+ field: colDef.field
56472
+ });
56473
+ }
56474
+ else {
56475
+ aggregation = this._table.options.aggregation;
56476
+ }
56477
+ }
56478
+ if (aggregation) {
56479
+ if (Array.isArray(aggregation)) {
56480
+ return aggregation.map(item => {
56481
+ if (!isValid$1(item.showOnTop)) {
56482
+ item.showOnTop = false;
56483
+ }
56484
+ return item;
56485
+ });
56486
+ }
56487
+ return Object.assign({ showOnTop: false }, aggregation);
56488
+ }
56489
+ return null;
56490
+ }
55607
56491
  _newRow(row, hideColumnsSubHeader = false) {
55608
56492
  if (this._headerCellIds[row]) {
55609
56493
  const prev = this._headerCellIds[row - 1];
@@ -55764,6 +56648,9 @@
55764
56648
  }
55765
56649
  setChartInstance(_col, _row, chartInstance) {
55766
56650
  const columnObj = this.transpose ? this._columns[_row] : this._columns[_col];
56651
+ if (typeof columnObj.chartSpec === 'function') {
56652
+ return;
56653
+ }
55767
56654
  columnObj.chartInstance = chartInstance;
55768
56655
  }
55769
56656
  getChartInstance(_col, _row) {
@@ -55785,9 +56672,32 @@
55785
56672
  getChartAxes(col, row) {
55786
56673
  return [];
55787
56674
  }
56675
+ isShareChartSpec(col, row) {
56676
+ const body = this.getBody(col, row);
56677
+ const chartSpec = body?.chartSpec;
56678
+ if (typeof chartSpec === 'function') {
56679
+ return false;
56680
+ }
56681
+ return true;
56682
+ }
56683
+ getChartSpec(col, row) {
56684
+ return this.getRawChartSpec(col, row);
56685
+ }
55788
56686
  getRawChartSpec(col, row) {
55789
56687
  const body = this.getBody(col, row);
55790
- return body?.chartSpec;
56688
+ const chartSpec = body?.chartSpec;
56689
+ if (typeof chartSpec === 'function') {
56690
+ const arg = {
56691
+ col,
56692
+ row,
56693
+ dataValue: this._table.getCellOriginValue(col, row) || '',
56694
+ value: this._table.getCellValue(col, row) || '',
56695
+ rect: this._table.getCellRangeRelativeRect(this._table.getCellRange(col, row)),
56696
+ table: this._table
56697
+ };
56698
+ return chartSpec(arg);
56699
+ }
56700
+ return chartSpec;
55791
56701
  }
55792
56702
  getChartDataId(col, row) {
55793
56703
  return getChartDataId(col, row, this);
@@ -55807,6 +56717,15 @@
55807
56717
  define.title = title;
55808
56718
  define.define.title = title;
55809
56719
  }
56720
+ getColumnByField(field) {
56721
+ const result = this.columnObjects?.reduce((pre, cur, index) => {
56722
+ if (cur.field === field) {
56723
+ pre.push({ col: index, columnDefine: cur });
56724
+ }
56725
+ return pre;
56726
+ }, []);
56727
+ return result;
56728
+ }
55810
56729
  }
55811
56730
 
55812
56731
  class Title {
@@ -55993,6 +56912,9 @@
55993
56912
  return;
55994
56913
  }
55995
56914
  }
56915
+ if (this.table.internalProps.layoutMap?.isAggregation?.(col, row)) {
56916
+ return;
56917
+ }
55996
56918
  this.editingEditor = editor;
55997
56919
  this.editCell = { col, row };
55998
56920
  const dataValue = this.table.getCellOriginValue(col, row);
@@ -56069,6 +56991,7 @@
56069
56991
  internalProps.frozenColDragHeaderMode = options.frozenColDragHeaderMode;
56070
56992
  this.pagination = options.pagination;
56071
56993
  internalProps.sortState = options.sortState;
56994
+ internalProps.dataConfig = {};
56072
56995
  internalProps.columns = options.columns
56073
56996
  ? cloneDeep(options.columns)
56074
56997
  : options.header
@@ -56114,6 +57037,12 @@
56114
57037
  get sortState() {
56115
57038
  return this.internalProps.sortState;
56116
57039
  }
57040
+ get records() {
57041
+ return this.dataSource.source;
57042
+ }
57043
+ get recordsCount() {
57044
+ return this.dataSource.source.length;
57045
+ }
56117
57046
  updateColumns(columns) {
56118
57047
  const oldHoverState = { col: this.stateManager.hover.cellPos.col, row: this.stateManager.hover.cellPos.row };
56119
57048
  this.internalProps.columns = cloneDeep(columns);
@@ -56174,6 +57103,16 @@
56174
57103
  const { title } = table.internalProps.layoutMap.getHeader(col, row);
56175
57104
  return typeof title === 'function' ? title() : title;
56176
57105
  }
57106
+ else if (table.internalProps.layoutMap.isAggregation(col, row)) {
57107
+ if (table.internalProps.layoutMap.isTopAggregation(col, row)) {
57108
+ const aggregator = table.internalProps.layoutMap.getAggregatorOnTop(col, row);
57109
+ return aggregator?.formatValue ? aggregator.formatValue(col, row, this) : '';
57110
+ }
57111
+ else if (table.internalProps.layoutMap.isBottomAggregation(col, row)) {
57112
+ const aggregator = table.internalProps.layoutMap.getAggregatorOnBottom(col, row);
57113
+ return aggregator?.formatValue ? aggregator.formatValue(col, row, this) : '';
57114
+ }
57115
+ }
56177
57116
  const { field, fieldFormat } = table.internalProps.layoutMap.getBody(col, row);
56178
57117
  return table.getFieldData(fieldFormat || field, col, row);
56179
57118
  }
@@ -56186,6 +57125,16 @@
56186
57125
  const { title } = table.internalProps.layoutMap.getHeader(col, row);
56187
57126
  return typeof title === 'function' ? title() : title;
56188
57127
  }
57128
+ else if (table.internalProps.layoutMap.isAggregation(col, row)) {
57129
+ if (table.internalProps.layoutMap.isTopAggregation(col, row)) {
57130
+ const aggregator = table.internalProps.layoutMap.getAggregatorOnTop(col, row);
57131
+ return aggregator?.value();
57132
+ }
57133
+ else if (table.internalProps.layoutMap.isBottomAggregation(col, row)) {
57134
+ const aggregator = table.internalProps.layoutMap.getAggregatorOnBottom(col, row);
57135
+ return aggregator?.value();
57136
+ }
57137
+ }
56189
57138
  const { field } = table.internalProps.layoutMap.getBody(col, row);
56190
57139
  return table.getFieldData(field, col, row);
56191
57140
  }
@@ -56258,6 +57207,7 @@
56258
57207
  super.updateOption(options);
56259
57208
  internalProps.frozenColDragHeaderMode = options.frozenColDragHeaderMode;
56260
57209
  this.pagination = options.pagination;
57210
+ internalProps.dataConfig = {};
56261
57211
  this.showHeader = options.showHeader ?? true;
56262
57212
  internalProps.columns = options.columns
56263
57213
  ? cloneDeep(options.columns)
@@ -56337,11 +57287,13 @@
56337
57287
  if (!layoutMap) {
56338
57288
  return;
56339
57289
  }
56340
- layoutMap.recordsCount = table.internalProps.dataSource?.length ?? 0;
57290
+ layoutMap.recordsCount =
57291
+ (table.internalProps.dataSource?.length ?? 0) +
57292
+ layoutMap.hasAggregationOnTopCount +
57293
+ layoutMap.hasAggregationOnBottomCount;
56341
57294
  if (table.transpose) {
56342
57295
  table.rowCount = layoutMap.rowCount ?? 0;
56343
- table.colCount =
56344
- (table.internalProps.dataSource?.length ?? 0) * layoutMap.bodyRowSpanCount + layoutMap.headerLevelCount;
57296
+ table.colCount = layoutMap.recordsCount * layoutMap.bodyRowSpanCount + layoutMap.headerLevelCount;
56345
57297
  table.frozenRowCount = 0;
56346
57298
  this.internalProps.frozenColCount = layoutMap.headerLevelCount ?? 0;
56347
57299
  if (table.bottomFrozenRowCount !== (this.options.bottomFrozenRowCount ?? 0)) {
@@ -56353,8 +57305,7 @@
56353
57305
  }
56354
57306
  else {
56355
57307
  table.colCount = layoutMap.colCount ?? 0;
56356
- table.rowCount =
56357
- (table.internalProps.dataSource?.length ?? 0) * layoutMap.bodyRowSpanCount + layoutMap.headerLevelCount;
57308
+ table.rowCount = layoutMap.recordsCount * layoutMap.bodyRowSpanCount + layoutMap.headerLevelCount;
56358
57309
  this.internalProps.frozenColCount = this.options.frozenColCount ?? 0;
56359
57310
  table.frozenRowCount = layoutMap.headerLevelCount;
56360
57311
  if (table.bottomFrozenRowCount !== (this.options.bottomFrozenRowCount ?? 0)) {
@@ -56602,22 +57553,15 @@
56602
57553
  }
56603
57554
  let order;
56604
57555
  let field;
56605
- let fieldKey;
56606
57556
  if (Array.isArray(this.internalProps.sortState)) {
56607
- ({ order, field, fieldKey } = this.internalProps.sortState?.[0]);
57557
+ ({ order, field } = this.internalProps.sortState?.[0]);
56608
57558
  }
56609
57559
  else {
56610
- ({ order, field, fieldKey } = this.internalProps.sortState);
57560
+ ({ order, field } = this.internalProps.sortState);
56611
57561
  }
56612
57562
  if (field && executeSort) {
56613
- const sortFunc = this._getSortFuncFromHeaderOption(this.internalProps.columns, field, fieldKey);
56614
- let hd;
56615
- if (fieldKey) {
56616
- hd = this.internalProps.layoutMap.headerObjects.find((col) => col && col.fieldKey === fieldKey);
56617
- }
56618
- else {
56619
- hd = this.internalProps.layoutMap.headerObjects.find((col) => col && col.field === field);
56620
- }
57563
+ const sortFunc = this._getSortFuncFromHeaderOption(this.internalProps.columns, field);
57564
+ const hd = this.internalProps.layoutMap.headerObjects.find((col) => col && col.field === field);
56621
57565
  if (hd.define.sort !== false) {
56622
57566
  this.dataSource.sort(hd.field, order, sortFunc);
56623
57567
  this.internalProps.layoutMap.clearCellRangeMap();
@@ -56626,6 +57570,19 @@
56626
57570
  }
56627
57571
  this.stateManager.updateSortState(sortState);
56628
57572
  }
57573
+ updateFilterRules(filterRules) {
57574
+ this.scenegraph.clearCells();
57575
+ this.internalProps.dataConfig.filterRules = filterRules;
57576
+ if (this.sortState) {
57577
+ this.dataSource.updateFilterRulesForSorted(filterRules);
57578
+ sortRecords(this);
57579
+ }
57580
+ else {
57581
+ this.dataSource.updateFilterRules(filterRules);
57582
+ }
57583
+ this.refreshRowColCount();
57584
+ this.scenegraph.createSceneGraph();
57585
+ }
56629
57586
  getCheckboxState(field) {
56630
57587
  if (this.stateManager.checkedState.length < this.rowCount - this.columnHeaderLevelCount) {
56631
57588
  this.stateManager.initLeftRecordsCheckState(this.records);
@@ -56660,24 +57617,17 @@
56660
57617
  if (this.sortState) {
56661
57618
  let order;
56662
57619
  let field;
56663
- let fieldKey;
56664
57620
  if (Array.isArray(this.sortState)) {
56665
57621
  if (this.sortState.length !== 0) {
56666
- ({ order, field, fieldKey } = this.sortState?.[0]);
57622
+ ({ order, field } = this.sortState?.[0]);
56667
57623
  }
56668
57624
  }
56669
57625
  else {
56670
- ({ order, field, fieldKey } = this.sortState);
57626
+ ({ order, field } = this.sortState);
56671
57627
  }
56672
57628
  if (order && field && order !== 'normal') {
56673
- const sortFunc = this._getSortFuncFromHeaderOption(undefined, field, fieldKey);
56674
- let hd;
56675
- if (fieldKey) {
56676
- hd = this.internalProps.layoutMap.headerObjects.find((col) => col && col.fieldKey === fieldKey);
56677
- }
56678
- else {
56679
- hd = this.internalProps.layoutMap.headerObjects.find((col) => col && col.field === field);
56680
- }
57629
+ const sortFunc = this._getSortFuncFromHeaderOption(undefined, field);
57630
+ const hd = this.internalProps.layoutMap.headerObjects.find((col) => col && col.field === field);
56681
57631
  if (hd.define.sort !== false) {
56682
57632
  this.dataSource.sort(hd.field, order, sortFunc ?? defaultOrderFn);
56683
57633
  }
@@ -56751,6 +57701,26 @@
56751
57701
  else {
56752
57702
  this.dataSource.changeFieldValue(value, recordIndex, field, col, row, this);
56753
57703
  }
57704
+ const aggregators = this.internalProps.layoutMap.getAggregators(col, row);
57705
+ if (aggregators) {
57706
+ if (Array.isArray(aggregators)) {
57707
+ for (let i = 0; i < aggregators?.length; i++) {
57708
+ aggregators[i].recalculate();
57709
+ }
57710
+ }
57711
+ else {
57712
+ aggregators.recalculate();
57713
+ }
57714
+ const aggregatorCells = this.internalProps.layoutMap.getCellAddressHasAggregator(col, row);
57715
+ for (let i = 0; i < aggregatorCells.length; i++) {
57716
+ const range = this.getCellRange(aggregatorCells[i].col, aggregatorCells[i].row);
57717
+ for (let sCol = range.start.col; sCol <= range.end.col; sCol++) {
57718
+ for (let sRow = range.start.row; sRow <= range.end.row; sRow++) {
57719
+ this.scenegraph.updateCellContent(sCol, sRow);
57720
+ }
57721
+ }
57722
+ }
57723
+ }
56754
57724
  const range = this.getCellRange(col, row);
56755
57725
  for (let sCol = range.start.col; sCol <= range.end.col; sCol++) {
56756
57726
  for (let sRow = range.start.row; sRow <= range.end.row; sRow++) {
@@ -57154,7 +58124,7 @@
57154
58124
  }
57155
58125
  }
57156
58126
  }
57157
- hasCustomRenderOrLayout() {
58127
+ _hasCustomRenderOrLayout() {
57158
58128
  const { headerObjects } = this.internalProps.layoutMap;
57159
58129
  if (this.options.customRender) {
57160
58130
  return true;
@@ -57170,6 +58140,37 @@
57170
58140
  }
57171
58141
  return false;
57172
58142
  }
58143
+ getAggregateValuesByField(field) {
58144
+ const columns = this.internalProps.layoutMap.getColumnByField(field);
58145
+ const results = [];
58146
+ for (let i = 0; i < columns.length; i++) {
58147
+ const aggregator = columns[i].columnDefine.aggregator;
58148
+ delete columns[i].columnDefine;
58149
+ if (aggregator) {
58150
+ const columnAggregateValue = {
58151
+ col: columns[i].col,
58152
+ aggregateValue: null
58153
+ };
58154
+ columnAggregateValue.aggregateValue = [];
58155
+ if (Array.isArray(aggregator)) {
58156
+ for (let j = 0; j < aggregator.length; j++) {
58157
+ columnAggregateValue.aggregateValue.push({
58158
+ aggregationType: aggregator[j].type,
58159
+ value: aggregator[j].value()
58160
+ });
58161
+ }
58162
+ }
58163
+ else {
58164
+ columnAggregateValue.aggregateValue.push({
58165
+ aggregationType: aggregator.type,
58166
+ value: aggregator.value()
58167
+ });
58168
+ }
58169
+ results.push(columnAggregateValue);
58170
+ }
58171
+ }
58172
+ return results;
58173
+ }
57173
58174
  }
57174
58175
 
57175
58176
  const defaultDimension = { startInTotal: 0, level: 0 };
@@ -58887,6 +59888,9 @@
58887
59888
  const indicatorKey = paths.rowHeaderPaths.find(rowPath => rowPath.indicatorKey)?.indicatorKey;
58888
59889
  indicatorObj = this._indicators?.find(indicator => indicator.indicatorKey === indicatorKey);
58889
59890
  }
59891
+ if (typeof indicatorObj?.chartSpec === 'function') {
59892
+ return;
59893
+ }
58890
59894
  indicatorObj && (indicatorObj.chartInstance = chartInstance);
58891
59895
  }
58892
59896
  getChartInstance(_col, _row) {
@@ -58969,6 +59973,12 @@
58969
59973
  getRawChartSpec(col, row) {
58970
59974
  return getRawChartSpec(col, row, this);
58971
59975
  }
59976
+ getChartSpec(col, row) {
59977
+ return getChartSpec(col, row, this);
59978
+ }
59979
+ isShareChartSpec(col, row) {
59980
+ return isShareChartSpec(col, row, this);
59981
+ }
58972
59982
  getChartDataId(col, row) {
58973
59983
  return getChartDataId(col, row, this);
58974
59984
  }
@@ -59079,9 +60089,6 @@
59079
60089
  }
59080
60090
  return null;
59081
60091
  }
59082
- getChartSpec(col, row) {
59083
- return getChartSpec(col, row, this);
59084
- }
59085
60092
  _generateChartState() {
59086
60093
  const state = {
59087
60094
  vtable_selected: {
@@ -59318,12 +60325,23 @@
59318
60325
  });
59319
60326
  return indicatorInfo;
59320
60327
  }
60328
+ getLayoutColumnTree() {
60329
+ const tree = [];
60330
+ const children = this.columnDimensionTree.tree.children;
60331
+ generateLayoutTree(tree, children);
60332
+ return tree;
60333
+ }
59321
60334
  getLayoutRowTree() {
59322
60335
  const tree = [];
59323
60336
  const children = this.rowDimensionTree.tree.children;
59324
60337
  generateLayoutTree(tree, children);
59325
60338
  return tree;
59326
60339
  }
60340
+ getLayoutColumnTreeCount() {
60341
+ const children = this.columnDimensionTree.tree.children;
60342
+ const mainTreeCount = countLayoutTree(children, this.rowHierarchyType === 'tree');
60343
+ return mainTreeCount;
60344
+ }
59327
60345
  getLayoutRowTreeCount() {
59328
60346
  const children = this.rowDimensionTree.tree.children;
59329
60347
  const mainTreeCount = countLayoutTree(children, this.rowHierarchyType === 'tree');
@@ -59542,371 +60560,6 @@
59542
60560
  }
59543
60561
  }
59544
60562
 
59545
- class Aggregator {
59546
- className = 'Aggregator';
59547
- isRecord = true;
59548
- records = [];
59549
- type;
59550
- field;
59551
- formatFun;
59552
- _formatedValue;
59553
- needSplitPositiveAndNegativeForSum = false;
59554
- constructor(dimension, formatFun, isRecord, needSplitPositiveAndNegative) {
59555
- this.field = dimension;
59556
- this.needSplitPositiveAndNegativeForSum = needSplitPositiveAndNegative ?? false;
59557
- this.formatFun = formatFun;
59558
- this.isRecord = isRecord ?? this.isRecord;
59559
- }
59560
- clearCacheValue() {
59561
- this._formatedValue = undefined;
59562
- }
59563
- formatValue(col, row, table) {
59564
- if (!this._formatedValue) {
59565
- if (this.formatFun) {
59566
- this._formatedValue = this.formatFun(this.value(), col, row, table);
59567
- }
59568
- else {
59569
- this._formatedValue = this.value();
59570
- }
59571
- }
59572
- return this._formatedValue;
59573
- }
59574
- reset() {
59575
- this.records = [];
59576
- }
59577
- }
59578
- class RecordAggregator extends Aggregator {
59579
- type = AggregationType.RECORD;
59580
- isRecord = true;
59581
- push(record) {
59582
- if (this.isRecord) {
59583
- if (record.className === 'Aggregator') {
59584
- this.records.push(...record.records);
59585
- }
59586
- else {
59587
- this.records.push(record);
59588
- }
59589
- }
59590
- }
59591
- value() {
59592
- return this.records;
59593
- }
59594
- reset() {
59595
- this.records = [];
59596
- }
59597
- }
59598
- class NoneAggregator extends Aggregator {
59599
- type = AggregationType.NONE;
59600
- isRecord = true;
59601
- fieldValue;
59602
- push(record) {
59603
- if (this.isRecord) {
59604
- this.records = [record];
59605
- }
59606
- this.fieldValue = record[this.field];
59607
- }
59608
- value() {
59609
- return this.fieldValue;
59610
- }
59611
- reset() {
59612
- this.records = [];
59613
- this.fieldValue = undefined;
59614
- }
59615
- }
59616
- class SumAggregator extends Aggregator {
59617
- type = AggregationType.SUM;
59618
- sum = 0;
59619
- positiveSum = 0;
59620
- nagetiveSum = 0;
59621
- push(record) {
59622
- if (this.isRecord) {
59623
- if (record.className === 'Aggregator') {
59624
- this.records.push(...record.records);
59625
- }
59626
- else {
59627
- this.records.push(record);
59628
- }
59629
- }
59630
- if (record.className === 'Aggregator') {
59631
- const value = record.value();
59632
- this.sum += value;
59633
- if (this.needSplitPositiveAndNegativeForSum) {
59634
- if (value > 0) {
59635
- this.positiveSum += value;
59636
- }
59637
- else if (value < 0) {
59638
- this.nagetiveSum += value;
59639
- }
59640
- }
59641
- }
59642
- else if (!isNaN(parseFloat(record[this.field]))) {
59643
- const value = parseFloat(record[this.field]);
59644
- this.sum += value;
59645
- if (this.needSplitPositiveAndNegativeForSum) {
59646
- if (value > 0) {
59647
- this.positiveSum += value;
59648
- }
59649
- else if (value < 0) {
59650
- this.nagetiveSum += value;
59651
- }
59652
- }
59653
- }
59654
- }
59655
- value() {
59656
- return this.sum;
59657
- }
59658
- positiveValue() {
59659
- return this.positiveSum;
59660
- }
59661
- negativeValue() {
59662
- return this.nagetiveSum;
59663
- }
59664
- reset() {
59665
- this.records = [];
59666
- this.sum = 0;
59667
- }
59668
- }
59669
- class CountAggregator extends Aggregator {
59670
- type = AggregationType.COUNT;
59671
- count = 0;
59672
- push(record) {
59673
- if (this.isRecord) {
59674
- if (record.className === 'Aggregator') {
59675
- this.records.push(...record.records);
59676
- }
59677
- else {
59678
- this.records.push(record);
59679
- }
59680
- }
59681
- if (record.className === 'Aggregator') {
59682
- this.count += record.value();
59683
- }
59684
- else {
59685
- this.count++;
59686
- }
59687
- }
59688
- value() {
59689
- return this.count;
59690
- }
59691
- reset() {
59692
- this.records = [];
59693
- this.count = 0;
59694
- }
59695
- }
59696
- class AvgAggregator extends Aggregator {
59697
- type = AggregationType.AVG;
59698
- sum = 0;
59699
- count = 0;
59700
- push(record) {
59701
- if (this.isRecord) {
59702
- if (record.className === 'Aggregator') {
59703
- this.records.push(...record.records);
59704
- }
59705
- else {
59706
- this.records.push(record);
59707
- }
59708
- }
59709
- if (record.className === 'Aggregator' && record.type === AggregationType.AVG) {
59710
- this.sum += record.sum;
59711
- this.count += record.count;
59712
- }
59713
- else if (!isNaN(parseFloat(record[this.field]))) {
59714
- this.sum += parseFloat(record[this.field]);
59715
- this.count++;
59716
- }
59717
- }
59718
- value() {
59719
- return this.sum / this.count;
59720
- }
59721
- reset() {
59722
- this.records = [];
59723
- this.sum = 0;
59724
- this.count = 0;
59725
- }
59726
- }
59727
- class MaxAggregator extends Aggregator {
59728
- type = AggregationType.MAX;
59729
- max = Number.MIN_SAFE_INTEGER;
59730
- push(record) {
59731
- if (this.isRecord) {
59732
- if (record.className === 'Aggregator') {
59733
- this.records.push(...record.records);
59734
- }
59735
- else {
59736
- this.records.push(record);
59737
- }
59738
- }
59739
- if (record.className === 'Aggregator') {
59740
- this.max = record.max > this.max ? record.max : this.max;
59741
- }
59742
- else if (typeof record === 'number') {
59743
- this.max = record > this.max ? record : this.max;
59744
- }
59745
- else if (typeof record[this.field] === 'number') {
59746
- this.max = record[this.field] > this.max ? record[this.field] : this.max;
59747
- }
59748
- else if (!isNaN(record[this.field])) {
59749
- this.max = parseFloat(record[this.field]) > this.max ? parseFloat(record[this.field]) : this.max;
59750
- }
59751
- }
59752
- value() {
59753
- return this.max;
59754
- }
59755
- reset() {
59756
- this.records = [];
59757
- this.max = Number.MIN_SAFE_INTEGER;
59758
- }
59759
- }
59760
- class MinAggregator extends Aggregator {
59761
- type = AggregationType.MIN;
59762
- min = Number.MAX_SAFE_INTEGER;
59763
- isRecord = false;
59764
- push(record) {
59765
- if (this.isRecord) {
59766
- if (record.className === 'Aggregator') {
59767
- this.records.push(...record.records);
59768
- }
59769
- else {
59770
- this.records.push(record);
59771
- }
59772
- }
59773
- if (record.className === 'Aggregator') {
59774
- this.min = record.min < this.min ? record.min : this.min;
59775
- }
59776
- else if (typeof record === 'number') {
59777
- this.min = record < this.min ? record : this.min;
59778
- }
59779
- else if (typeof record[this.field] === 'number') {
59780
- this.min = record[this.field] < this.min ? record[this.field] : this.min;
59781
- }
59782
- }
59783
- value() {
59784
- return this.min;
59785
- }
59786
- reset() {
59787
- this.records = [];
59788
- this.min = Number.MAX_SAFE_INTEGER;
59789
- }
59790
- }
59791
- function typeSort(a, b) {
59792
- if (a && b) {
59793
- return a.toString().localeCompare(b.toString(), 'zh');
59794
- }
59795
- if (a) {
59796
- return 1;
59797
- }
59798
- return -1;
59799
- }
59800
- function naturalSort(as, bs) {
59801
- const rx = /(\d+)|(\D+)/g;
59802
- const rd = /\d/;
59803
- const rz = /^0/;
59804
- let a;
59805
- let a1;
59806
- let b;
59807
- let b1;
59808
- let nas = 0;
59809
- let nbs = 0;
59810
- if (bs !== null && as === null) {
59811
- return -1;
59812
- }
59813
- if (as !== null && bs === null) {
59814
- return 1;
59815
- }
59816
- if (typeof as === 'number' && isNaN(as)) {
59817
- return -1;
59818
- }
59819
- if (typeof bs === 'number' && isNaN(bs)) {
59820
- return 1;
59821
- }
59822
- nas = +as;
59823
- nbs = +bs;
59824
- if (nas < nbs) {
59825
- return -1;
59826
- }
59827
- if (nas > nbs) {
59828
- return 1;
59829
- }
59830
- if (typeof as === 'number' && typeof bs !== 'number') {
59831
- return -1;
59832
- }
59833
- if (typeof bs === 'number' && typeof as !== 'number') {
59834
- return 1;
59835
- }
59836
- if (typeof as === 'number' && typeof bs === 'number') {
59837
- return 0;
59838
- }
59839
- if (isNaN(nbs) && !isNaN(nas)) {
59840
- return -1;
59841
- }
59842
- if (isNaN(nas) && !isNaN(nbs)) {
59843
- return 1;
59844
- }
59845
- a = String(as);
59846
- b = String(bs);
59847
- if (a === b) {
59848
- return 0;
59849
- }
59850
- if (!(rd.test(a) && rd.test(b))) {
59851
- return a > b ? 1 : -1;
59852
- }
59853
- a = a.match(rx);
59854
- b = b.match(rx);
59855
- while (a.length && b.length) {
59856
- a1 = a.shift();
59857
- b1 = b.shift();
59858
- if (a1 !== b1) {
59859
- if (rd.test(a1) && rd.test(b1)) {
59860
- return a1.replace(rz, '.0') - b1.replace(rz, '.0');
59861
- }
59862
- return a1 > b1 ? 1 : -1;
59863
- }
59864
- }
59865
- return a.length - b.length;
59866
- }
59867
- function sortBy(order) {
59868
- let x;
59869
- const mapping = {};
59870
- const lowercase_mapping = {};
59871
- for (let i = 0; i < order.length; i++) {
59872
- x = order[i];
59873
- mapping[x] = i;
59874
- if (typeof x === 'string') {
59875
- lowercase_mapping[x.toLowerCase()] = i;
59876
- }
59877
- }
59878
- return function (a, b) {
59879
- if (mapping[a] !== null && mapping[a] !== undefined && mapping[b] !== null && mapping[b] !== undefined) {
59880
- return mapping[a] - mapping[b];
59881
- }
59882
- else if (mapping[a] !== null && mapping[a] !== undefined) {
59883
- return -1;
59884
- }
59885
- else if (mapping[b] !== null && mapping[b] !== undefined) {
59886
- return 1;
59887
- }
59888
- else if (lowercase_mapping[a] !== null &&
59889
- mapping[a] !== undefined &&
59890
- lowercase_mapping[b] !== null &&
59891
- mapping[b] !== undefined) {
59892
- return lowercase_mapping[a] - lowercase_mapping[b];
59893
- }
59894
- else if (lowercase_mapping[a] === null ||
59895
- mapping[a] === undefined ||
59896
- lowercase_mapping[b] === null ||
59897
- mapping[b] === undefined) {
59898
- return 0;
59899
- }
59900
- else if (lowercase_mapping[a] !== null && mapping[a] !== undefined) {
59901
- return -1;
59902
- }
59903
- else if (lowercase_mapping[b] !== null && mapping[b] !== undefined) {
59904
- return 1;
59905
- }
59906
- return naturalSort(a, b);
59907
- };
59908
- }
59909
-
59910
60563
  class Dataset {
59911
60564
  dataConfig;
59912
60565
  records;
@@ -60422,6 +61075,8 @@
60422
61075
  formatFun: agg.formatFun,
60423
61076
  records: agg.records,
60424
61077
  className: '',
61078
+ recalculate() {
61079
+ },
60425
61080
  push() {
60426
61081
  },
60427
61082
  clearCacheValue() {
@@ -60437,6 +61092,8 @@
60437
61092
  className: '',
60438
61093
  push() {
60439
61094
  },
61095
+ recalculate() {
61096
+ },
60440
61097
  formatValue() {
60441
61098
  return changeValue;
60442
61099
  },
@@ -60452,6 +61109,8 @@
60452
61109
  className: '',
60453
61110
  push() {
60454
61111
  },
61112
+ recalculate() {
61113
+ },
60455
61114
  value() {
60456
61115
  return null;
60457
61116
  },
@@ -61001,10 +61660,12 @@
61001
61660
  this.pagination = options.pagination;
61002
61661
  this.internalProps.columnResizeType = options.columnResizeType ?? 'column';
61003
61662
  this.internalProps.dataConfig = cloneDeep(options.dataConfig);
61004
- this.internalProps.enableDataAnalysis = options.enableDataAnalysis;
61005
61663
  if (!options.rowTree && !options.columnTree) {
61006
61664
  this.internalProps.enableDataAnalysis = true;
61007
61665
  }
61666
+ else {
61667
+ this.internalProps.enableDataAnalysis = false;
61668
+ }
61008
61669
  const records = this.internalProps.records;
61009
61670
  if (this.internalProps.enableDataAnalysis && (options.rows || options.columns)) {
61010
61671
  const rowKeys = options.rows?.reduce((keys, rowObj) => {
@@ -61082,6 +61743,9 @@
61082
61743
  isPivotChart() {
61083
61744
  return false;
61084
61745
  }
61746
+ get recordsCount() {
61747
+ return this.records?.length;
61748
+ }
61085
61749
  _canResizeColumn(col, row) {
61086
61750
  const ifCan = super._canResizeColumn(col, row);
61087
61751
  if (ifCan) {
@@ -61114,10 +61778,12 @@
61114
61778
  this.pagination = options.pagination;
61115
61779
  internalProps.columnResizeType = options.columnResizeType ?? 'column';
61116
61780
  internalProps.dataConfig = cloneDeep(options.dataConfig);
61117
- internalProps.enableDataAnalysis = options.enableDataAnalysis;
61118
61781
  if (!options.rowTree && !options.columnTree) {
61119
61782
  internalProps.enableDataAnalysis = true;
61120
61783
  }
61784
+ else {
61785
+ internalProps.enableDataAnalysis = false;
61786
+ }
61121
61787
  if (options?.rowHierarchyType === 'tree' &&
61122
61788
  this.internalProps.layoutMap.rowHierarchyType === 'tree' &&
61123
61789
  this.internalProps.layoutMap.rowExpandLevel === options?.rowExpandLevel) {
@@ -61611,6 +62277,14 @@
61611
62277
  getHierarchyState(col, row) {
61612
62278
  return this._getHeaderLayoutMap(col, row)?.hierarchyState;
61613
62279
  }
62280
+ getLayoutColumnTree() {
62281
+ const layoutMap = this.internalProps.layoutMap;
62282
+ return layoutMap.getLayoutColumnTree();
62283
+ }
62284
+ getLayoutColumnTreeCount() {
62285
+ const layoutMap = this.internalProps.layoutMap;
62286
+ return layoutMap.getLayoutColumnTreeCount();
62287
+ }
61614
62288
  getLayoutRowTree() {
61615
62289
  const layoutMap = this.internalProps.layoutMap;
61616
62290
  return layoutMap.getLayoutRowTree();
@@ -61829,7 +62503,7 @@
61829
62503
  this.records[rowIndex][colIndex] = newValue;
61830
62504
  }
61831
62505
  }
61832
- hasCustomRenderOrLayout() {
62506
+ _hasCustomRenderOrLayout() {
61833
62507
  if (this.options.customRender) {
61834
62508
  return true;
61835
62509
  }
@@ -61945,6 +62619,9 @@
61945
62619
  get pivotChartAxes() {
61946
62620
  return this._axes;
61947
62621
  }
62622
+ get recordsCount() {
62623
+ return this.records?.length;
62624
+ }
61948
62625
  isListTable() {
61949
62626
  return false;
61950
62627
  }
@@ -62716,7 +63393,7 @@
62716
63393
  }
62717
63394
  this.eventManager.updateEventBinder();
62718
63395
  }
62719
- hasCustomRenderOrLayout() {
63396
+ _hasCustomRenderOrLayout() {
62720
63397
  if (this.options.customRender) {
62721
63398
  return true;
62722
63399
  }
@@ -63254,7 +63931,7 @@
63254
63931
  }
63255
63932
 
63256
63933
  registerForVrender();
63257
- const version = "0.19.2-alpha.3";
63934
+ const version = "0.20.0";
63258
63935
  function getIcons() {
63259
63936
  return get$1();
63260
63937
  }