@visactor/vtable 0.12.1-alpha.1 → 0.12.1

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 (41) hide show
  1. package/cjs/components/tooltip/TooltipHandler.js +17 -8
  2. package/cjs/components/tooltip/TooltipHandler.js.map +1 -1
  3. package/cjs/core/BaseTable.js +1 -1
  4. package/cjs/core/BaseTable.js.map +1 -1
  5. package/cjs/dataset/dataset.d.ts +1 -0
  6. package/cjs/dataset/dataset.js +89 -58
  7. package/cjs/dataset/dataset.js.map +1 -1
  8. package/cjs/dataset/flatDataToObject.js +1 -2
  9. package/cjs/event/sparkline-event.js +2 -1
  10. package/cjs/index.d.ts +1 -1
  11. package/cjs/index.js +1 -1
  12. package/cjs/index.js.map +1 -1
  13. package/cjs/layout/chart-helper/get-axis-config.d.ts +11 -0
  14. package/cjs/layout/chart-helper/get-axis-config.js +65 -62
  15. package/cjs/layout/chart-helper/get-axis-config.js.map +1 -1
  16. package/cjs/layout/chart-helper/get-chart-spec.js +9 -24
  17. package/cjs/layout/chart-helper/get-chart-spec.js.map +1 -1
  18. package/cjs/layout/pivot-header-layout.js +2 -2
  19. package/cjs/layout/pivot-header-layout.js.map +1 -1
  20. package/dist/vtable.js +212 -184
  21. package/dist/vtable.min.js +2 -2
  22. package/es/components/tooltip/TooltipHandler.js +17 -8
  23. package/es/components/tooltip/TooltipHandler.js.map +1 -1
  24. package/es/core/BaseTable.js +1 -1
  25. package/es/core/BaseTable.js.map +1 -1
  26. package/es/dataset/dataset.d.ts +1 -0
  27. package/es/dataset/dataset.js +89 -58
  28. package/es/dataset/dataset.js.map +1 -1
  29. package/es/dataset/flatDataToObject.js +1 -2
  30. package/es/event/sparkline-event.js +2 -1
  31. package/es/index.d.ts +1 -1
  32. package/es/index.js +1 -1
  33. package/es/index.js.map +1 -1
  34. package/es/layout/chart-helper/get-axis-config.d.ts +11 -0
  35. package/es/layout/chart-helper/get-axis-config.js +61 -57
  36. package/es/layout/chart-helper/get-axis-config.js.map +1 -1
  37. package/es/layout/chart-helper/get-chart-spec.js +6 -21
  38. package/es/layout/chart-helper/get-chart-spec.js.map +1 -1
  39. package/es/layout/pivot-header-layout.js +2 -2
  40. package/es/layout/pivot-header-layout.js.map +1 -1
  41. package/package.json +3 -3
package/dist/vtable.js CHANGED
@@ -39785,35 +39785,14 @@
39785
39785
  row === layout.columnHeaderLevelCount - 1 &&
39786
39786
  col >= layout.rowHeaderLevelCount &&
39787
39787
  col < layout.colCount - layout.rightFrozenColCount) {
39788
- const indicatorKeys = layout.getIndicatorKeyInChartSpec(col, layout.columnHeaderLevelCount - 1);
39789
- let defaultKey = indicatorKeys?.[1];
39790
- if (isArray$5(defaultKey)) {
39791
- defaultKey = defaultKey[0];
39792
- }
39793
- if (!defaultKey) {
39794
- return undefined;
39788
+ const { axisOption, isPercent, isZeroAlign, seriesIndice } = getAxisOption(col, row + 1, 'top', layout);
39789
+ if (axisOption?.visible === false) {
39790
+ return;
39795
39791
  }
39796
- const { axisOption, isPercent, isZeroAlign } = getAxisOption(col, row + 1, 'top', layout);
39797
- const data = layout.dataset.collectedValues[defaultKey + (isZeroAlign ? '_align' : '')]
39798
- ? layout.dataset.collectedValues[defaultKey + (isZeroAlign ? '_align' : '')]
39799
- : layout.dataset.collectedValues[defaultKey];
39792
+ const indicatorKeys = layout.getIndicatorKeyInChartSpec(col, layout.columnHeaderLevelCount - 1);
39800
39793
  const colPath = layout.getColKeysPath(col, row);
39801
- const range = merge$1({}, data?.[colPath ?? ''] ?? { min: 0, max: 1 });
39802
- if (range.positiveMax && range.positiveMax > range.max) {
39803
- range.max = range.positiveMax;
39804
- }
39805
- if (range.negativeMin && range.negativeMin < range.min) {
39806
- range.min = range.negativeMin;
39807
- }
39808
- if (range.min === range.max) {
39809
- if (range.min > 0) {
39810
- range.min = 0;
39811
- }
39812
- else {
39813
- range.max = 0;
39814
- }
39815
- }
39816
- if (axisOption?.visible === false) {
39794
+ const range = getAxisRange(layout.dataset.collectedValues, indicatorKeys, isZeroAlign, colPath, seriesIndice ?? 1);
39795
+ if (!range) {
39817
39796
  return;
39818
39797
  }
39819
39798
  if (isPercent) {
@@ -39843,30 +39822,15 @@
39843
39822
  else if (row === layout.rowCount - layout.bottomFrozenRowCount &&
39844
39823
  col >= layout.rowHeaderLevelCount &&
39845
39824
  col < layout.colCount - layout.rightFrozenColCount) {
39825
+ const { axisOption, isPercent, isZeroAlign, seriesIndice } = getAxisOption(col, row - 1, 'bottom', layout);
39826
+ if (axisOption?.visible === false) {
39827
+ return;
39828
+ }
39846
39829
  const indicatorKeys = layout.getIndicatorKeyInChartSpec(col, row);
39847
- let defaultKey = indicatorKeys?.[0];
39848
- if (isArray$5(defaultKey)) {
39849
- defaultKey = defaultKey[0];
39850
- }
39851
- const { axisOption, isPercent, isZeroAlign } = getAxisOption(col, row - 1, 'bottom', layout);
39852
- const data = layout.dataset.collectedValues[defaultKey + (isZeroAlign ? '_align' : '')]
39853
- ? layout.dataset.collectedValues[defaultKey + (isZeroAlign ? '_align' : '')]
39854
- : layout.dataset.collectedValues[defaultKey];
39855
39830
  const colPath = layout.getColKeysPath(col, row);
39856
- const range = merge$1({}, data?.[colPath ?? ''] ?? { min: 0, max: 1 });
39857
- if (range.positiveMax && range.positiveMax > range.max) {
39858
- range.max = range.positiveMax;
39859
- }
39860
- if (range.negativeMin && range.negativeMin < range.min) {
39861
- range.min = range.negativeMin;
39862
- }
39863
- if (range.min === range.max) {
39864
- if (range.min > 0) {
39865
- range.min = 0;
39866
- }
39867
- else {
39868
- range.max = 0;
39869
- }
39831
+ const range = getAxisRange(layout.dataset.collectedValues, indicatorKeys, isZeroAlign, colPath, seriesIndice ?? 0);
39832
+ if (!range) {
39833
+ return;
39870
39834
  }
39871
39835
  let indicatorInfo = null;
39872
39836
  indicatorKeys?.forEach(key => {
@@ -39875,9 +39839,6 @@
39875
39839
  indicatorInfo = info;
39876
39840
  }
39877
39841
  });
39878
- if (axisOption?.visible === false) {
39879
- return;
39880
- }
39881
39842
  if (isPercent) {
39882
39843
  range.min = range.min < 0 ? -1 : 0;
39883
39844
  range.max = range.max > 0 ? 1 : 0;
@@ -39935,30 +39896,15 @@
39935
39896
  if (col === layout.rowHeaderLevelCount - 1 &&
39936
39897
  row >= layout.columnHeaderLevelCount &&
39937
39898
  row < layout.rowCount - layout.bottomFrozenRowCount) {
39899
+ const { axisOption, isPercent, isZeroAlign, seriesIndice } = getAxisOption(col + 1, row, 'left', layout);
39900
+ if (axisOption?.visible === false) {
39901
+ return;
39902
+ }
39938
39903
  const indicatorKeys = layout.getIndicatorKeyInChartSpec(col, row);
39939
- let defaultKey = indicatorKeys?.[0];
39940
- if (isArray$5(defaultKey)) {
39941
- defaultKey = defaultKey[0];
39942
- }
39943
- const { axisOption, isPercent, isZeroAlign } = getAxisOption(col + 1, row, 'left', layout);
39944
- const data = layout.dataset.collectedValues[defaultKey + (isZeroAlign ? '_align' : '')]
39945
- ? layout.dataset.collectedValues[defaultKey + (isZeroAlign ? '_align' : '')]
39946
- : layout.dataset.collectedValues[defaultKey];
39947
39904
  const rowPath = layout.getRowKeysPath(col, row);
39948
- const range = merge$1({}, data?.[rowPath ?? ''] ?? { min: 0, max: 1 });
39949
- if (range.positiveMax && range.positiveMax > range.max) {
39950
- range.max = range.positiveMax;
39951
- }
39952
- if (range.negativeMin && range.negativeMin < range.min) {
39953
- range.min = range.negativeMin;
39954
- }
39955
- if (range.min === range.max) {
39956
- if (range.min > 0) {
39957
- range.min = 0;
39958
- }
39959
- else {
39960
- range.max = 0;
39961
- }
39905
+ const range = getAxisRange(layout.dataset.collectedValues, indicatorKeys, isZeroAlign, rowPath, seriesIndice ?? 0);
39906
+ if (!range) {
39907
+ return;
39962
39908
  }
39963
39909
  let indicatorInfo = null;
39964
39910
  indicatorKeys?.forEach(key => {
@@ -39967,9 +39913,6 @@
39967
39913
  indicatorInfo = info;
39968
39914
  }
39969
39915
  });
39970
- if (axisOption?.visible === false) {
39971
- return;
39972
- }
39973
39916
  if (isPercent) {
39974
39917
  range.min = range.min < 0 ? -1 : 0;
39975
39918
  range.max = range.max > 0 ? 1 : 0;
@@ -40002,35 +39945,14 @@
40002
39945
  else if (col === layout.colCount - layout.rightFrozenColCount &&
40003
39946
  row >= layout.columnHeaderLevelCount &&
40004
39947
  row < layout.rowCount - layout.bottomFrozenRowCount) {
40005
- const indicatorKeys = layout.getIndicatorKeyInChartSpec(layout.rowHeaderLevelCount - 1, row);
40006
- let defaultKey = indicatorKeys?.[1];
40007
- if (isArray$5(defaultKey)) {
40008
- defaultKey = defaultKey[0];
40009
- }
40010
- if (!defaultKey) {
40011
- return undefined;
39948
+ const { axisOption, isPercent, isZeroAlign, seriesIndice } = getAxisOption(col - 1, row, 'right', layout);
39949
+ if (axisOption?.visible === false) {
39950
+ return;
40012
39951
  }
40013
- const { axisOption, isPercent, isZeroAlign } = getAxisOption(col - 1, row, 'right', layout);
40014
- const data = layout.dataset.collectedValues[defaultKey + (isZeroAlign ? '_align' : '')]
40015
- ? layout.dataset.collectedValues[defaultKey + (isZeroAlign ? '_align' : '')]
40016
- : layout.dataset.collectedValues[defaultKey];
39952
+ const indicatorKeys = layout.getIndicatorKeyInChartSpec(layout.rowHeaderLevelCount - 1, row);
40017
39953
  const rowPath = layout.getRowKeysPath(col, row);
40018
- const range = merge$1({}, data?.[rowPath ?? ''] ?? { min: 0, max: 1 });
40019
- if (range.positiveMax && range.positiveMax > range.max) {
40020
- range.max = range.positiveMax;
40021
- }
40022
- if (range.negativeMin && range.negativeMin < range.min) {
40023
- range.min = range.negativeMin;
40024
- }
40025
- if (range.min === range.max) {
40026
- if (range.min > 0) {
40027
- range.min = 0;
40028
- }
40029
- else {
40030
- range.max = 0;
40031
- }
40032
- }
40033
- if (axisOption?.visible === false) {
39954
+ const range = getAxisRange(layout.dataset.collectedValues, indicatorKeys, isZeroAlign, rowPath, seriesIndice ?? 1);
39955
+ if (!range) {
40034
39956
  return;
40035
39957
  }
40036
39958
  if (isPercent) {
@@ -40091,10 +40013,19 @@
40091
40013
  return axis.orient === orient;
40092
40014
  });
40093
40015
  if (axisOption) {
40016
+ const { seriesIndex, seriesId } = axisOption;
40017
+ let seriesIndice;
40018
+ if (isValid$5(seriesId) && isArray$5(spec.series)) {
40019
+ seriesIndice = (isArray$5(seriesId) ? seriesId : [seriesId]).map(id => spec.series.findIndex((s) => s.id === id));
40020
+ }
40021
+ else if (isValid$5(seriesIndex) && isArray$5(spec.series)) {
40022
+ seriesIndice = seriesIndex;
40023
+ }
40094
40024
  return {
40095
40025
  axisOption,
40096
40026
  isPercent: spec.percent,
40097
- isZeroAlign: checkZeroAlign(spec, orient, layout)
40027
+ isZeroAlign: checkZeroAlign(spec, orient, layout),
40028
+ seriesIndice
40098
40029
  };
40099
40030
  }
40100
40031
  }
@@ -40143,6 +40074,48 @@
40143
40074
  }
40144
40075
  return false;
40145
40076
  }
40077
+ function getAxisRange(collectedValues, indicatorKeys, isZeroAlign, colPath, seriesId) {
40078
+ if (isArray$5(seriesId)) {
40079
+ const range = { min: Infinity, max: -Infinity };
40080
+ for (let i = 0; i < seriesId.length; i++) {
40081
+ const singleRange = getAxisRange(collectedValues, indicatorKeys, isZeroAlign, colPath, seriesId[i]);
40082
+ if (singleRange) {
40083
+ range.min = Math.min(range.min, singleRange.min);
40084
+ range.max = Math.max(range.max, singleRange.max);
40085
+ }
40086
+ }
40087
+ if (isFinite(range.min) && isFinite(range.max)) {
40088
+ return range;
40089
+ }
40090
+ return null;
40091
+ }
40092
+ let defaultKey = indicatorKeys?.[seriesId];
40093
+ if (isArray$5(defaultKey)) {
40094
+ defaultKey = defaultKey[0];
40095
+ }
40096
+ if (!defaultKey) {
40097
+ return null;
40098
+ }
40099
+ const data = collectedValues[defaultKey + (isZeroAlign ? '_align' : '')]
40100
+ ? collectedValues[defaultKey + (isZeroAlign ? '_align' : '')]
40101
+ : collectedValues[defaultKey];
40102
+ const range = merge$1({}, data?.[colPath ?? ''] ?? { min: 0, max: 1 });
40103
+ if (range.positiveMax && range.positiveMax > range.max) {
40104
+ range.max = range.positiveMax;
40105
+ }
40106
+ if (range.negativeMin && range.negativeMin < range.min) {
40107
+ range.min = range.negativeMin;
40108
+ }
40109
+ if (range.min === range.max) {
40110
+ if (range.min > 0) {
40111
+ range.min = 0;
40112
+ }
40113
+ else {
40114
+ range.max = 0;
40115
+ }
40116
+ }
40117
+ return range;
40118
+ }
40146
40119
 
40147
40120
  function computeAxisComponentWidth(config, table) {
40148
40121
  const attribute = merge$1({}, commonAxis, config);
@@ -51620,16 +51593,27 @@
51620
51593
  return;
51621
51594
  }
51622
51595
  }
51623
- if (table.internalProps.tooltip?.isShowOverflowTextTooltip) {
51596
+ let tooltipOption;
51597
+ const headerDescription = table.getHeaderDescription(col, row);
51598
+ if (headerDescription) {
51599
+ const rect = table.getCellRangeRelativeRect({ col, row });
51600
+ tooltipOption = {
51601
+ content: headerDescription,
51602
+ referencePosition: {
51603
+ placement: Placement.bottom,
51604
+ rect
51605
+ },
51606
+ style: { arrowMark: false }
51607
+ };
51608
+ }
51609
+ else if (table.internalProps.tooltip?.isShowOverflowTextTooltip) {
51624
51610
  const overflowText = table.getCellOverflowText(col, row);
51625
- const headerDescription = table.getHeaderDescription(col, row);
51626
51611
  const rect = table.getCellRangeRelativeRect({ col, row });
51627
- let tooltipOption;
51628
51612
  if (overflowText) {
51629
51613
  tooltipOption = {
51630
51614
  content: headerDescription
51631
51615
  ? `${headerDescription}
51632
- ${overflowText}`
51616
+ ${overflowText}`
51633
51617
  : overflowText,
51634
51618
  referencePosition: {
51635
51619
  placement: Placement.bottom,
@@ -51638,19 +51622,9 @@
51638
51622
  style: { arrowMark: false }
51639
51623
  };
51640
51624
  }
51641
- if (headerDescription) {
51642
- tooltipOption = {
51643
- content: headerDescription,
51644
- referencePosition: {
51645
- placement: Placement.bottom,
51646
- rect
51647
- },
51648
- style: { arrowMark: false }
51649
- };
51650
- }
51651
- if (tooltipOption) {
51652
- this._bindToCell(e.col, e.row, tooltipOption);
51653
- }
51625
+ }
51626
+ if (tooltipOption) {
51627
+ this._bindToCell(e.col, e.row, tooltipOption);
51654
51628
  }
51655
51629
  });
51656
51630
  table.on(TABLE_EVENT_TYPE.MOUSEMOVE_CELL, e => {
@@ -52746,7 +52720,7 @@
52746
52720
  return TABLE_EVENT_TYPE;
52747
52721
  }
52748
52722
  options;
52749
- version = "0.12.1-alpha.1";
52723
+ version = "0.12.1";
52750
52724
  pagination;
52751
52725
  id = `VTable${Date.now()}`;
52752
52726
  headerStyleCache;
@@ -54968,23 +54942,10 @@
54968
54942
  const axes = [];
54969
54943
  if (layout.indicatorsAsCol) {
54970
54944
  const indicatorKeys = layout.getIndicatorKeyInChartSpec(col, row);
54971
- layout.getRecordIndexByCol(col);
54945
+ const colPath = layout.getColKeysPath(col, row);
54972
54946
  indicatorKeys.forEach((key, index) => {
54973
- if (isArray$5(key)) {
54974
- key = key[0];
54975
- }
54976
- const { axisOption, isPercent, isZeroAlign } = getAxisOption(col, row, index === 0 ? 'bottom' : 'top', layout);
54977
- const data = layout.dataset.collectedValues[key + (isZeroAlign ? '_align' : '')]
54978
- ? layout.dataset.collectedValues[key + (isZeroAlign ? '_align' : '')]
54979
- : layout.dataset.collectedValues[key];
54980
- const colPath = layout.getColKeysPath(col, row);
54981
- const range = merge$1({}, data?.[colPath ?? ''] ?? { min: 0, max: 1 });
54982
- if (range.positiveMax && range.positiveMax > range.max) {
54983
- range.max = range.positiveMax;
54984
- }
54985
- if (range.negativeMin && range.negativeMin < range.min) {
54986
- range.min = range.negativeMin;
54987
- }
54947
+ const { axisOption, isPercent, isZeroAlign, seriesIndice } = getAxisOption(col, row, index === 0 ? 'bottom' : 'top', layout);
54948
+ const range = getAxisRange(layout.dataset.collectedValues, indicatorKeys, isZeroAlign, colPath, seriesIndice ?? index);
54988
54949
  if (isPercent) {
54989
54950
  range.min = range.min < 0 ? -1 : 0;
54990
54951
  range.max = range.max > 0 ? 1 : 0;
@@ -55044,20 +55005,8 @@
55044
55005
  const indicatorKeys = layout.getIndicatorKeyInChartSpec(col, row);
55045
55006
  const rowPath = layout.getRowKeysPath(col, row);
55046
55007
  indicatorKeys.forEach((key, index) => {
55047
- if (isArray$5(key)) {
55048
- key = key[0];
55049
- }
55050
- const { axisOption, isPercent, isZeroAlign } = getAxisOption(col, row, index === 0 ? 'left' : 'right', layout);
55051
- const data = layout.dataset.collectedValues[key + (isZeroAlign ? '_align' : '')]
55052
- ? layout.dataset.collectedValues[key + (isZeroAlign ? '_align' : '')]
55053
- : layout.dataset.collectedValues[key];
55054
- const range = merge$1({}, data?.[rowPath ?? ''] ?? { min: 0, max: 1 });
55055
- if (range.positiveMax && range.positiveMax > range.max) {
55056
- range.max = range.positiveMax;
55057
- }
55058
- if (range.negativeMin && range.negativeMin < range.min) {
55059
- range.min = range.negativeMin;
55060
- }
55008
+ const { axisOption, isPercent, isZeroAlign, seriesIndice } = getAxisOption(col, row, index === 0 ? 'left' : 'right', layout);
55009
+ const range = getAxisRange(layout.dataset.collectedValues, indicatorKeys, isZeroAlign, rowPath, seriesIndice ?? index);
55061
55010
  if (isPercent) {
55062
55011
  range.min = range.min < 0 ? -1 : 0;
55063
55012
  range.max = range.max > 0 ? 1 : 0;
@@ -56919,7 +56868,7 @@
56919
56868
  });
56920
56869
  const cell = {
56921
56870
  id,
56922
- title: hd.value ?? indicatorInfo.title,
56871
+ title: hd.value ?? indicatorInfo?.title,
56923
56872
  field: hd.dimensionKey,
56924
56873
  style: typeof (indicatorInfo ?? dimensionInfo)?.headerStyle === 'function'
56925
56874
  ? (indicatorInfo ?? dimensionInfo)?.headerStyle
@@ -57631,7 +57580,7 @@
57631
57580
  }
57632
57581
  getCellRange(col, row) {
57633
57582
  const result = { start: { col, row }, end: { col, row } };
57634
- if (!this.isHeader(col, row) || col === -1 || row === -1 || this.isIndicatorHeader(col, row)) {
57583
+ if (!this.isHeader(col, row) || col === -1 || row === -1) {
57635
57584
  return result;
57636
57585
  }
57637
57586
  if (this.isRightFrozenColumn(col, row) || this.isBottomFrozenRow(col, row)) {
@@ -59380,6 +59329,7 @@
59380
59329
  rowHierarchyType;
59381
59330
  indicators;
59382
59331
  indicatorsAsCol;
59332
+ totalRecordsTree = {};
59383
59333
  constructor(dataConfig, rows, columns, indicatorKeys, indicators, indicatorsAsCol, records, rowHierarchyType, customColTree, customRowTree, needSplitPositiveAndNegative) {
59384
59334
  this.registerAggregators();
59385
59335
  this.dataConfig = dataConfig;
@@ -59434,7 +59384,9 @@
59434
59384
  }
59435
59385
  else {
59436
59386
  if (this.rowHierarchyType === 'tree') {
59437
- this.rowHeaderTree = this.ArrToTree1(this.rowKeys, this.rows, indicatorsAsCol ? undefined : indicators);
59387
+ this.rowHeaderTree = this.ArrToTree1(this.rowKeys, this.rows, indicatorsAsCol ? undefined : indicators, this?.totals?.row?.showGrandTotals ||
59388
+ (!indicatorsAsCol && this.columns.length === 0) ||
59389
+ (indicatorsAsCol && this.rows.length === 0), this.rowGrandTotalLabel);
59438
59390
  }
59439
59391
  else {
59440
59392
  this.rowHeaderTree = this.ArrToTree(this.rowKeys, this.rows, indicatorsAsCol ? undefined : indicators, this.rowsIsTotal, this?.totals?.row?.showGrandTotals ||
@@ -59560,16 +59512,6 @@
59560
59512
  this.derivedFieldRules?.forEach((derivedFieldRule, i) => {
59561
59513
  record[derivedFieldRule.fieldName] = derivedFieldRule.derivedFunc(record);
59562
59514
  });
59563
- const colKey = [];
59564
- const rowKey = [];
59565
- for (let l = 0, len1 = this.rows.length; l < len1; l++) {
59566
- const rowAttr = this.rows[l];
59567
- rowKey.push(record[rowAttr]);
59568
- }
59569
- for (let n = 0, len2 = this.columns.length; n < len2; n++) {
59570
- const colAttr = this.columns[n];
59571
- colKey.push(record[colAttr]);
59572
- }
59573
59515
  for (const field in this.collectValuesBy) {
59574
59516
  if (record[field]) {
59575
59517
  if (!this.collectedValues[field]) {
@@ -59610,8 +59552,81 @@
59610
59552
  }
59611
59553
  }
59612
59554
  }
59555
+ const colKey = [];
59556
+ const rowKey = [];
59557
+ let isToTalRecord = false;
59558
+ for (let l = 0, len1 = this.rows.length; l < len1; l++) {
59559
+ const rowAttr = this.rows[l];
59560
+ if (rowAttr in record) {
59561
+ rowKey.push(record[rowAttr]);
59562
+ }
59563
+ else {
59564
+ if (this.dataConfig?.totals?.row?.showGrandTotals &&
59565
+ l === 0 &&
59566
+ !this.rows.find((rk) => {
59567
+ return rk in record;
59568
+ })) {
59569
+ rowKey.push(this.rowGrandTotalLabel);
59570
+ isToTalRecord = true;
59571
+ break;
59572
+ }
59573
+ else if (this.dataConfig?.totals?.row?.showSubTotals &&
59574
+ this.dataConfig?.totals?.row?.subTotalsDimensions.indexOf(this.rows[l - 1]) >= 0) {
59575
+ if (this.rowHierarchyType === 'grid') {
59576
+ rowKey.push(this.rowSubTotalLabel);
59577
+ }
59578
+ isToTalRecord = true;
59579
+ break;
59580
+ }
59581
+ }
59582
+ }
59583
+ for (let n = 0, len2 = this.columns.length; n < len2; n++) {
59584
+ const colAttr = this.columns[n];
59585
+ if (colAttr in record) {
59586
+ colKey.push(record[colAttr]);
59587
+ }
59588
+ else {
59589
+ if (this.dataConfig?.totals?.column?.showGrandTotals &&
59590
+ n === 0 &&
59591
+ !this.columns.find((ck) => {
59592
+ return ck in record;
59593
+ })) {
59594
+ colKey.push(this.colGrandTotalLabel);
59595
+ isToTalRecord = true;
59596
+ break;
59597
+ }
59598
+ else if (this.dataConfig?.totals?.column?.showSubTotals &&
59599
+ this.dataConfig?.totals?.column?.subTotalsDimensions.indexOf(this.columns[n - 1]) >= 0) {
59600
+ colKey.push(this.colSubTotalLabel);
59601
+ isToTalRecord = true;
59602
+ break;
59603
+ }
59604
+ }
59605
+ }
59613
59606
  const flatRowKey = rowKey.join(this.stringJoinChar);
59614
59607
  const flatColKey = colKey.join(this.stringJoinChar);
59608
+ if (isToTalRecord) {
59609
+ if (!this.totalRecordsTree[flatRowKey]) {
59610
+ this.totalRecordsTree[flatRowKey] = {};
59611
+ }
59612
+ if (!this.totalRecordsTree[flatRowKey][flatColKey]) {
59613
+ this.totalRecordsTree[flatRowKey][flatColKey] = [];
59614
+ }
59615
+ for (let i = 0; i < this.indicatorKeys.length; i++) {
59616
+ const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
59617
+ if (!this.totalRecordsTree[flatRowKey]?.[flatColKey]?.[i]) {
59618
+ this.totalRecordsTree[flatRowKey][flatColKey][i] = new this.aggregators[aggRule?.aggregationType ?? AggregationType.SUM](aggRule?.field ?? this.indicatorKeys[i], aggRule?.formatFun ??
59619
+ this.indicators?.find((indicator) => {
59620
+ if (typeof indicator !== 'string') {
59621
+ return indicator.indicatorKey === this.indicatorKeys[i];
59622
+ }
59623
+ return false;
59624
+ })?.format);
59625
+ }
59626
+ this.indicatorKeys[i] in record && this.totalRecordsTree[flatRowKey]?.[flatColKey]?.[i].push(record);
59627
+ }
59628
+ return;
59629
+ }
59615
59630
  if (rowKey.length !== 0) {
59616
59631
  if (!this.rowFlatKeys[flatRowKey]) {
59617
59632
  this.rowKeys.push(rowKey);
@@ -59884,16 +59899,22 @@
59884
59899
  that?.totals?.row?.showGrandTotals) {
59885
59900
  const rowTotalKeys = [];
59886
59901
  const colCompute = (flatRowKey, flatColKey) => {
59902
+ if (this.totalRecordsTree?.[flatRowKey]?.[flatColKey]) {
59903
+ this.tree[flatRowKey][flatColKey] = this.totalRecordsTree?.[flatRowKey]?.[flatColKey];
59904
+ return;
59905
+ }
59887
59906
  const colKey = flatColKey.split(this.stringJoinChar);
59888
59907
  for (let i = 0, len = that.totals?.column?.subTotalsDimensions?.length; i < len; i++) {
59889
59908
  const dimension = that.totals.column.subTotalsDimensions[i];
59890
59909
  const dimensionIndex = that.columns.indexOf(dimension);
59891
59910
  if (dimensionIndex >= 0) {
59892
59911
  const colTotalKey = colKey.slice(0, dimensionIndex + 1);
59893
- if (this.rowHierarchyType === 'grid') {
59894
- colTotalKey.push(that.totals?.column?.subTotalLabel ?? '小计');
59895
- }
59912
+ colTotalKey.push(that.totals?.column?.subTotalLabel ?? '小计');
59896
59913
  const flatColTotalKey = colTotalKey.join(this.stringJoinChar);
59914
+ if (this.totalRecordsTree?.[flatRowKey]?.[flatColTotalKey]) {
59915
+ this.tree[flatRowKey][flatColTotalKey] = this.totalRecordsTree?.[flatRowKey]?.[flatColTotalKey];
59916
+ return;
59917
+ }
59897
59918
  if (!this.tree[flatRowKey][flatColTotalKey]) {
59898
59919
  this.tree[flatRowKey][flatColTotalKey] = [];
59899
59920
  }
@@ -59914,6 +59935,10 @@
59914
59935
  }
59915
59936
  if (that.totals?.column?.showGrandTotals || this.rows.length === 0) {
59916
59937
  const flatColTotalKey = that.colGrandTotalLabel;
59938
+ if (this.totalRecordsTree?.[flatRowKey]?.[flatColTotalKey]) {
59939
+ this.tree[flatRowKey][flatColTotalKey] = this.totalRecordsTree?.[flatRowKey]?.[flatColTotalKey];
59940
+ return;
59941
+ }
59917
59942
  if (!this.tree[flatRowKey][flatColTotalKey]) {
59918
59943
  this.tree[flatRowKey][flatColTotalKey] = [];
59919
59944
  }
@@ -59938,7 +59963,7 @@
59938
59963
  for (let i = 0, len = that.totals?.row?.subTotalsDimensions?.length; i < len; i++) {
59939
59964
  const dimension = that.totals.row.subTotalsDimensions[i];
59940
59965
  const dimensionIndex = that.rows.indexOf(dimension);
59941
- if (dimensionIndex >= 0) {
59966
+ if (dimensionIndex >= 0 && dimensionIndex < that.rows.length - 1) {
59942
59967
  const rowTotalKey = rowKey.slice(0, dimensionIndex + 1);
59943
59968
  if (this.rowHierarchyType === 'grid') {
59944
59969
  rowTotalKey.push(that.totals?.row?.subTotalLabel ?? '小计');
@@ -59950,19 +59975,19 @@
59950
59975
  }
59951
59976
  if (!this.tree[flatRowTotalKey][flatColKey]) {
59952
59977
  this.tree[flatRowTotalKey][flatColKey] = [];
59953
- for (let i = 0; i < this.indicatorKeys.length; i++) {
59954
- if (!this.tree[flatRowTotalKey][flatColKey][i]) {
59955
- const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
59956
- this.tree[flatRowTotalKey][flatColKey][i] = new this.aggregators[aggRule?.aggregationType ?? AggregationType.SUM](aggRule?.field ?? this.indicatorKeys[i], aggRule?.formatFun ??
59957
- this.indicators?.find((indicator) => {
59958
- if (typeof indicator !== 'string') {
59959
- return indicator.indicatorKey === this.indicatorKeys[i];
59960
- }
59961
- return false;
59962
- })?.format);
59963
- }
59964
- this.tree[flatRowTotalKey][flatColKey][i].push(that.tree[flatRowKey]?.[flatColKey]?.[i]);
59978
+ }
59979
+ for (let i = 0; i < this.indicatorKeys.length; i++) {
59980
+ if (!this.tree[flatRowTotalKey][flatColKey][i]) {
59981
+ const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
59982
+ this.tree[flatRowTotalKey][flatColKey][i] = new this.aggregators[aggRule?.aggregationType ?? AggregationType.SUM](aggRule?.field ?? this.indicatorKeys[i], aggRule?.formatFun ??
59983
+ this.indicators?.find((indicator) => {
59984
+ if (typeof indicator !== 'string') {
59985
+ return indicator.indicatorKey === this.indicatorKeys[i];
59986
+ }
59987
+ return false;
59988
+ })?.format);
59965
59989
  }
59990
+ this.tree[flatRowTotalKey][flatColKey][i].push(that.tree[flatRowKey]?.[flatColKey]?.[i]);
59966
59991
  }
59967
59992
  }
59968
59993
  }
@@ -59999,7 +60024,7 @@
59999
60024
  });
60000
60025
  }
60001
60026
  }
60002
- ArrToTree1(arr, rows, indicators) {
60027
+ ArrToTree1(arr, rows, indicators, isGrandTotal, grandTotalLabel) {
60003
60028
  const result = [];
60004
60029
  const concatStr = this.stringJoinChar;
60005
60030
  const map = new Map();
@@ -60041,6 +60066,9 @@
60041
60066
  });
60042
60067
  }
60043
60068
  arr.forEach(item => addList(item));
60069
+ if (isGrandTotal) {
60070
+ addList([grandTotalLabel]);
60071
+ }
60044
60072
  return result;
60045
60073
  }
60046
60074
  ArrToTree(arr, rows, indicators, subTotalFlags, isGrandTotal, grandTotalLabel, subTotalLabel) {
@@ -62393,7 +62421,7 @@
62393
62421
  return new Tag(params ? params.attribute : {});
62394
62422
  }
62395
62423
 
62396
- const version = "0.12.1-alpha.1";
62424
+ const version = "0.12.1";
62397
62425
  function getIcons() {
62398
62426
  return get$1();
62399
62427
  }