@visactor/vtable 0.17.3-alpha.0 → 0.17.3-alpha.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 (69) hide show
  1. package/cjs/PivotTable.d.ts +1 -0
  2. package/cjs/PivotTable.js +28 -0
  3. package/cjs/PivotTable.js.map +1 -1
  4. package/cjs/body-helper/body-helper.js +2 -1
  5. package/cjs/body-helper/body-helper.js.map +1 -1
  6. package/cjs/core/BaseTable.js +3 -2
  7. package/cjs/core/BaseTable.js.map +1 -1
  8. package/cjs/index.d.ts +1 -1
  9. package/cjs/index.js +1 -1
  10. package/cjs/index.js.map +1 -1
  11. package/cjs/scenegraph/component/cell-content.d.ts +1 -0
  12. package/cjs/scenegraph/component/cell-content.js +4 -3
  13. package/cjs/scenegraph/component/cell-content.js.map +1 -1
  14. package/cjs/scenegraph/graphic/contributions/chart-render-helper.js +5 -5
  15. package/cjs/scenegraph/graphic/contributions/chart-render-helper.js.map +1 -1
  16. package/cjs/scenegraph/graphic/group.d.ts +2 -0
  17. package/cjs/scenegraph/graphic/group.js.map +1 -1
  18. package/cjs/scenegraph/group-creater/column-helper.d.ts +4 -1
  19. package/cjs/scenegraph/group-creater/column-helper.js +7 -3
  20. package/cjs/scenegraph/group-creater/column-helper.js.map +1 -1
  21. package/cjs/scenegraph/layout/compute-col-width.js +6 -2
  22. package/cjs/scenegraph/layout/compute-col-width.js.map +1 -1
  23. package/cjs/scenegraph/layout/compute-row-height.js +14 -9
  24. package/cjs/scenegraph/layout/compute-row-height.js.map +1 -1
  25. package/cjs/scenegraph/layout/update-height.d.ts +1 -1
  26. package/cjs/scenegraph/layout/update-height.js +7 -5
  27. package/cjs/scenegraph/layout/update-height.js.map +1 -1
  28. package/cjs/scenegraph/layout/update-width.d.ts +1 -1
  29. package/cjs/scenegraph/layout/update-width.js +8 -6
  30. package/cjs/scenegraph/layout/update-width.js.map +1 -1
  31. package/cjs/scenegraph/scenegraph.d.ts +2 -2
  32. package/cjs/scenegraph/scenegraph.js +5 -4
  33. package/cjs/scenegraph/scenegraph.js.map +1 -1
  34. package/dist/vtable.js +103 -28
  35. package/dist/vtable.min.js +2 -2
  36. package/es/PivotTable.d.ts +1 -0
  37. package/es/PivotTable.js +28 -0
  38. package/es/PivotTable.js.map +1 -1
  39. package/es/body-helper/body-helper.js +2 -1
  40. package/es/body-helper/body-helper.js.map +1 -1
  41. package/es/core/BaseTable.js +3 -2
  42. package/es/core/BaseTable.js.map +1 -1
  43. package/es/index.d.ts +1 -1
  44. package/es/index.js +1 -1
  45. package/es/index.js.map +1 -1
  46. package/es/scenegraph/component/cell-content.d.ts +1 -0
  47. package/es/scenegraph/component/cell-content.js +4 -3
  48. package/es/scenegraph/component/cell-content.js.map +1 -1
  49. package/es/scenegraph/graphic/contributions/chart-render-helper.js +5 -5
  50. package/es/scenegraph/graphic/contributions/chart-render-helper.js.map +1 -1
  51. package/es/scenegraph/graphic/group.d.ts +2 -0
  52. package/es/scenegraph/graphic/group.js.map +1 -1
  53. package/es/scenegraph/group-creater/column-helper.d.ts +4 -1
  54. package/es/scenegraph/group-creater/column-helper.js +7 -3
  55. package/es/scenegraph/group-creater/column-helper.js.map +1 -1
  56. package/es/scenegraph/layout/compute-col-width.js +6 -2
  57. package/es/scenegraph/layout/compute-col-width.js.map +1 -1
  58. package/es/scenegraph/layout/compute-row-height.js +14 -9
  59. package/es/scenegraph/layout/compute-row-height.js.map +1 -1
  60. package/es/scenegraph/layout/update-height.d.ts +1 -1
  61. package/es/scenegraph/layout/update-height.js +7 -5
  62. package/es/scenegraph/layout/update-height.js.map +1 -1
  63. package/es/scenegraph/layout/update-width.d.ts +1 -1
  64. package/es/scenegraph/layout/update-width.js +8 -6
  65. package/es/scenegraph/layout/update-width.js.map +1 -1
  66. package/es/scenegraph/scenegraph.d.ts +2 -2
  67. package/es/scenegraph/scenegraph.js +5 -4
  68. package/es/scenegraph/scenegraph.js.map +1 -1
  69. package/package.json +2 -2
package/dist/vtable.js CHANGED
@@ -49120,6 +49120,8 @@
49120
49120
  colHeight;
49121
49121
  border;
49122
49122
  needUpdate;
49123
+ needUpdateWidth;
49124
+ needUpdateHeight;
49123
49125
  clear() {
49124
49126
  this.removeAllChild();
49125
49127
  }
@@ -50366,6 +50368,7 @@
50366
50368
  _autoWidth = false;
50367
50369
  _autoHeight = false;
50368
50370
  _cellWidth;
50371
+ _originCellWidth;
50369
50372
  _cellHeight;
50370
50373
  _align;
50371
50374
  _baseline;
@@ -50397,6 +50400,7 @@
50397
50400
  this._autoWidth = option.autoWidth;
50398
50401
  this._autoHeight = option.autoHeight;
50399
50402
  this._cellWidth = option.cellWidth;
50403
+ this._originCellWidth = option.cellWidth;
50400
50404
  this._cellHeight = option.cellHeight;
50401
50405
  this._align = option.align;
50402
50406
  this._baseline = option.baseline;
@@ -50518,10 +50522,12 @@
50518
50522
  }
50519
50523
  updateWidth(width) {
50520
50524
  this._cellWidth = width;
50525
+ this._originCellWidth = width;
50521
50526
  this.layout();
50522
50527
  }
50523
50528
  updateHeight(height) {
50524
50529
  this._cellHeight = height;
50530
+ this._cellWidth = this._originCellWidth;
50525
50531
  this.layout();
50526
50532
  }
50527
50533
  }
@@ -51774,6 +51780,8 @@
51774
51780
  if (row === range.end.row) {
51775
51781
  newLineWidth[2] = isLineWidthArray ? lineWidth[2] : lineWidth;
51776
51782
  }
51783
+ const widthChange = rangeWidth !== cellGroup.attribute.width;
51784
+ const heightChange = rangeHeight !== cellGroup.attribute.height;
51777
51785
  cellGroup.setAttributes({
51778
51786
  width: rangeWidth,
51779
51787
  height: rangeHeight,
@@ -51783,6 +51791,10 @@
51783
51791
  cellGroup.mergeStartRow = range.start.row;
51784
51792
  cellGroup.mergeEndCol = range.end.col;
51785
51793
  cellGroup.mergeEndRow = range.end.row;
51794
+ return {
51795
+ widthChange,
51796
+ heightChange
51797
+ };
51786
51798
  }
51787
51799
  function dealMerge(range, mergeMap, table) {
51788
51800
  let cellWidth = 0;
@@ -52781,7 +52793,7 @@
52781
52793
  if (isAllRowsAuto || table.getDefaultRowHeight(row) === 'auto') {
52782
52794
  const height = computeRowHeight(row, startCol, endCol, table);
52783
52795
  if (update) {
52784
- newHeights[row] = height;
52796
+ newHeights[row] = Math.round(height);
52785
52797
  }
52786
52798
  else {
52787
52799
  table._setRowHeight(row, height);
@@ -52792,7 +52804,7 @@
52792
52804
  if (isAllRowsAuto || table.getDefaultRowHeight(row) === 'auto') {
52793
52805
  const height = computeRowHeight(row, 0, table.colCount - 1, table);
52794
52806
  if (update) {
52795
- newHeights[row] = height;
52807
+ newHeights[row] = Math.round(height);
52796
52808
  }
52797
52809
  else {
52798
52810
  table._setRowHeight(row, height);
@@ -52809,7 +52821,7 @@
52809
52821
  for (let row = table.rowCount - table.bottomFrozenRowCount; row <= rowEnd; row++) {
52810
52822
  const height = computeRowHeight(row, 0, table.colCount - 1, table);
52811
52823
  if (update) {
52812
- newHeights[row] = height;
52824
+ newHeights[row] = Math.round(height);
52813
52825
  }
52814
52826
  else {
52815
52827
  table._setRowHeight(row, height);
@@ -52827,7 +52839,7 @@
52827
52839
  height = computeRowHeight(row, 0, table.colCount - 1, table);
52828
52840
  }
52829
52841
  if (update) {
52830
- newHeights[row] = height;
52842
+ newHeights[row] = Math.round(height);
52831
52843
  }
52832
52844
  else {
52833
52845
  table._setRowHeight(row, height);
@@ -52838,7 +52850,7 @@
52838
52850
  for (let row = Math.max(rowStart, table.columnHeaderLevelCount); row <= rowEnd; row++) {
52839
52851
  const height = computeRowHeight(row, 0, table.colCount - 1, table);
52840
52852
  if (update) {
52841
- newHeights[row] = height;
52853
+ newHeights[row] = Math.round(height);
52842
52854
  }
52843
52855
  else {
52844
52856
  table._setRowHeight(row, height);
@@ -52939,10 +52951,15 @@
52939
52951
  for (let row = 0; row < table.rowCount; row++) {
52940
52952
  const newRowHeight = newHeights[row] ?? table.getRowHeight(row);
52941
52953
  if (newRowHeight !== oldRowHeights[row]) {
52942
- table.scenegraph.updateRowHeight(row, newRowHeight - oldRowHeights[row]);
52943
52954
  table._setRowHeight(row, newRowHeight);
52944
52955
  }
52945
52956
  }
52957
+ for (let row = 0; row < table.rowCount; row++) {
52958
+ const newRowHeight = table.getRowHeight(row);
52959
+ if (newRowHeight !== oldRowHeights[row]) {
52960
+ table.scenegraph.updateRowHeight(row, newRowHeight - oldRowHeights[row], true);
52961
+ }
52962
+ }
52946
52963
  }
52947
52964
  }
52948
52965
  function computeRowHeight(row, startCol, endCol, table) {
@@ -53279,8 +53296,10 @@
53279
53296
  };
53280
53297
  }
53281
53298
 
53282
- function updateRowHeight(scene, row, detaY) {
53283
- scene.table._setRowHeight(row, scene.table.getRowHeight(row) + detaY, true);
53299
+ function updateRowHeight(scene, row, detaY, skipTableHeightMap) {
53300
+ if (!skipTableHeightMap) {
53301
+ scene.table._setRowHeight(row, scene.table.getRowHeight(row) + detaY, true);
53302
+ }
53284
53303
  for (let col = 0; col < scene.table.colCount; col++) {
53285
53304
  const cell = scene.getCell(col, row);
53286
53305
  const mergeInfo = getCellMergeInfo(scene.table, col, row);
@@ -53311,7 +53330,6 @@
53311
53330
  }
53312
53331
  }
53313
53332
  function updateCellHeightForRow(scene, cell, col, row, height, detaY, isHeader) {
53314
- cell.setAttribute('height', height);
53315
53333
  const cellGroup = cell;
53316
53334
  const distHeight = height;
53317
53335
  if (!cellGroup) {
@@ -53320,6 +53338,11 @@
53320
53338
  updateCellHeight(scene, cellGroup, col, row, distHeight, detaY);
53321
53339
  }
53322
53340
  function updateCellHeight(scene, cell, col, row, distHeight, detaY, isHeader) {
53341
+ if (cell.attribute.height === distHeight && !cell.needUpdateHeight) {
53342
+ return;
53343
+ }
53344
+ cell.needUpdateHeight = false;
53345
+ cell.setAttribute('height', distHeight);
53323
53346
  const type = scene.table.isHeader(col, row)
53324
53347
  ? scene.table._getHeaderLayoutMap(col, row).headerType
53325
53348
  : scene.table.getBodyColumnType(col, row);
@@ -53407,7 +53430,7 @@
53407
53430
  const rangeHeight = table.getRowHeight(row);
53408
53431
  const rangeWidth = table.getColWidth(col);
53409
53432
  singleCellGroup.contentHeight = distHeight;
53410
- resizeCellGroup(singleCellGroup, rangeWidth, rangeHeight, {
53433
+ const { widthChange } = resizeCellGroup(singleCellGroup, rangeWidth, rangeHeight, {
53411
53434
  start: {
53412
53435
  col: cellGroup.mergeStartCol,
53413
53436
  row: cellGroup.mergeStartRow
@@ -53417,6 +53440,9 @@
53417
53440
  row: cellGroup.mergeEndRow
53418
53441
  }
53419
53442
  }, table);
53443
+ if (widthChange) {
53444
+ singleCellGroup.needUpdateWidth = true;
53445
+ }
53420
53446
  }
53421
53447
  }
53422
53448
  }
@@ -53425,8 +53451,10 @@
53425
53451
  }
53426
53452
  }
53427
53453
 
53428
- function updateColWidth(scene, col, detaX) {
53429
- scene.table._setColWidth(col, scene.table.getColWidth(col) + detaX, true);
53454
+ function updateColWidth(scene, col, detaX, skipTableWidthMap) {
53455
+ if (!skipTableWidthMap) {
53456
+ scene.table._setColWidth(col, scene.table.getColWidth(col) + detaX, true);
53457
+ }
53430
53458
  const autoRowHeight = scene.table.heightMode === 'autoHeight';
53431
53459
  const colOrCornerHeaderColumn = scene.getColGroup(col, true);
53432
53460
  if (colOrCornerHeaderColumn) {
@@ -53567,9 +53595,10 @@
53567
53595
  }
53568
53596
  }
53569
53597
  function updateCellWidth(scene, cell, col, row, oldWidth, distWidth, detaX, isHeader, autoRowHeight) {
53570
- if (cell.attribute.width === distWidth) {
53598
+ if (cell.attribute.width === distWidth && !cell.needUpdateWidth) {
53571
53599
  return false;
53572
53600
  }
53601
+ cell.needUpdateWidth = false;
53573
53602
  cell.setAttribute('width', distWidth);
53574
53603
  const cellGroup = cell;
53575
53604
  if (!cellGroup) {
@@ -53689,7 +53718,7 @@
53689
53718
  const rangeHeight = table.getRowHeight(row);
53690
53719
  const rangeWidth = table.getColWidth(col);
53691
53720
  singleCellGroup.contentWidth = distWidth;
53692
- resizeCellGroup(singleCellGroup, rangeWidth, rangeHeight, {
53721
+ const { heightChange } = resizeCellGroup(singleCellGroup, rangeWidth, rangeHeight, {
53693
53722
  start: {
53694
53723
  col: cellGroup.mergeStartCol,
53695
53724
  row: cellGroup.mergeStartRow
@@ -53699,6 +53728,9 @@
53699
53728
  row: cellGroup.mergeEndRow
53700
53729
  }
53701
53730
  }, table);
53731
+ if (heightChange) {
53732
+ singleCellGroup.needUpdateHeight = true;
53733
+ }
53702
53734
  isHeightChange = isHeightChange || changed;
53703
53735
  }
53704
53736
  }
@@ -54765,12 +54797,12 @@
54765
54797
  viewBox.y2 = viewBox.y1 + 1;
54766
54798
  }
54767
54799
  axes.forEach((axis, index) => {
54768
- if (axis.type === 'linear') {
54769
- chartInstance.updateModelSpecSync({ type: 'axes', index }, { min: axis.range?.min ?? 0, max: axis.range?.max ?? 0 }, true);
54770
- }
54771
- else if (axis.type === 'band') {
54800
+ if (axis.type === 'band') {
54772
54801
  chartInstance.updateModelSpec({ type: 'axes', index }, { domain: axis.domain.slice(0) }, true);
54773
54802
  }
54803
+ else {
54804
+ chartInstance.updateModelSpecSync({ type: 'axes', index }, { min: axis.range?.min ?? 0, max: axis.range?.max ?? 0 }, true);
54805
+ }
54774
54806
  });
54775
54807
  chartInstance.updateViewBox({
54776
54808
  x1: viewBox.x1 - chart.getRootNode().table.scrollLeft,
@@ -55592,7 +55624,7 @@
55592
55624
  table._clearColRangeWidthsMap(col);
55593
55625
  }
55594
55626
  if (update) {
55595
- newWidths[col] = table._adjustColWidth(col, maxWidth);
55627
+ newWidths[col] = Math.round(table._adjustColWidth(col, maxWidth));
55596
55628
  }
55597
55629
  else {
55598
55630
  table._setColWidth(col, table._adjustColWidth(col, maxWidth), false, true);
@@ -55637,7 +55669,13 @@
55637
55669
  for (let col = 0; col < table.colCount; col++) {
55638
55670
  const newColWidth = newWidths[col] ?? table.getColWidth(col);
55639
55671
  if (newColWidth !== oldColWidths[col]) {
55640
- table.scenegraph.updateColWidth(col, newColWidth - oldColWidths[col], true);
55672
+ table._setColWidth(col, newColWidth);
55673
+ }
55674
+ }
55675
+ for (let col = 0; col < table.colCount; col++) {
55676
+ const newColWidth = table.getColWidth(col);
55677
+ if (newColWidth !== oldColWidths[col]) {
55678
+ table.scenegraph.updateColWidth(col, newColWidth - oldColWidths[col], true, true);
55641
55679
  }
55642
55680
  }
55643
55681
  table.scenegraph.updateContainer();
@@ -59782,8 +59820,8 @@
59782
59820
  });
59783
59821
  moveSelectingRangeComponentsToSelectedRangeComponents(this);
59784
59822
  }
59785
- updateColWidth(col, detaX, skipUpdateContainer) {
59786
- updateColWidth(this, col, Math.round(detaX));
59823
+ updateColWidth(col, detaX, skipUpdateContainer, skipTableWidthMap) {
59824
+ updateColWidth(this, col, Math.round(detaX), skipTableWidthMap);
59787
59825
  if (!skipUpdateContainer) {
59788
59826
  this.updateContainer();
59789
59827
  }
@@ -59961,9 +59999,9 @@
59961
59999
  });
59962
60000
  }
59963
60001
  }
59964
- updateRowHeight(row, detaY) {
60002
+ updateRowHeight(row, detaY, skipTableHeightMap) {
59965
60003
  detaY = Math.round(detaY);
59966
- updateRowHeight(this, row, detaY);
60004
+ updateRowHeight(this, row, detaY, skipTableHeightMap);
59967
60005
  this.updateContainerHeight(row, detaY);
59968
60006
  }
59969
60007
  updateContainerWidth(col, detaX) {
@@ -64016,7 +64054,7 @@
64016
64054
  if (f != null) {
64017
64055
  retIcon[k] = f;
64018
64056
  }
64019
- else if (!this._table._hasField(iconOpt[k], col, row)) {
64057
+ else if (!this._table._hasField?.(iconOpt[k], col, row)) {
64020
64058
  retIcon[k] = iconOpt[k];
64021
64059
  }
64022
64060
  }
@@ -66581,7 +66619,7 @@
66581
66619
  return TABLE_EVENT_TYPE;
66582
66620
  }
66583
66621
  options;
66584
- version = "0.17.3-alpha.0";
66622
+ version = "0.17.3-alpha.1";
66585
66623
  pagination;
66586
66624
  id = `VTable${Date.now()}`;
66587
66625
  headerStyleCache;
@@ -68205,7 +68243,7 @@
68205
68243
  return false;
68206
68244
  }
68207
68245
  const index = table.getRecordShowIndexByCell(col, row);
68208
- return table.internalProps.dataSource.hasField(index, field);
68246
+ return table.internalProps.dataSource?.hasField(index, field);
68209
68247
  }
68210
68248
  _getCellStyle(col, row) {
68211
68249
  const { layoutMap } = this.internalProps;
@@ -75432,6 +75470,43 @@
75432
75470
  const { layoutMap } = this.internalProps;
75433
75471
  return layoutMap.getBodyIndexByCol(col);
75434
75472
  }
75473
+ getFieldData(field, col, row) {
75474
+ const table = this;
75475
+ if (table.internalProps.layoutMap.isHeader(col, row)) {
75476
+ return undefined;
75477
+ }
75478
+ if (this.dataset) {
75479
+ const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row);
75480
+ if (cellDimensionPath) {
75481
+ const colKeys = cellDimensionPath.colHeaderPaths.map((colPath) => {
75482
+ return colPath.indicatorKey ?? colPath.value;
75483
+ });
75484
+ const rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath) => {
75485
+ return rowPath.indicatorKey ?? rowPath.value;
75486
+ });
75487
+ const aggregator = this.dataset.getAggregator(!this.internalProps.layoutMap.indicatorsAsCol ? rowKeys.slice(0, -1) : rowKeys, this.internalProps.layoutMap.indicatorsAsCol ? colKeys.slice(0, -1) : colKeys, this.internalProps.layoutMap.getIndicatorKey(col, row));
75488
+ if (aggregator.records && aggregator.records.length >= 1) {
75489
+ return aggregator.records[0][field];
75490
+ }
75491
+ }
75492
+ }
75493
+ else if (this.flatDataToObjects) {
75494
+ const cellDimensionPath = this.internalProps.layoutMap.getCellHeaderPaths(col, row);
75495
+ const colKeys = cellDimensionPath.colHeaderPaths.map((colPath) => {
75496
+ return colPath.indicatorKey ?? colPath.value;
75497
+ });
75498
+ const rowKeys = cellDimensionPath.rowHeaderPaths.map((rowPath) => {
75499
+ return rowPath.indicatorKey ?? rowPath.value;
75500
+ });
75501
+ const treeNode = this.flatDataToObjects.getTreeNode(rowKeys, colKeys, this.internalProps.layoutMap.getBody(col, row).indicatorKey, false);
75502
+ if (treeNode?.record) {
75503
+ return treeNode?.record[field];
75504
+ }
75505
+ }
75506
+ const rowIndex = this.getBodyIndexByRow(row);
75507
+ const colIndex = this.getBodyIndexByCol(col);
75508
+ return this.records[rowIndex]?.[colIndex];
75509
+ }
75435
75510
  getCellValue(col, row) {
75436
75511
  const customMergeText = this.getCustomMergeValue(col, row);
75437
75512
  if (customMergeText) {
@@ -77208,7 +77283,7 @@
77208
77283
  return new Tag$1(params ? params.attribute : {});
77209
77284
  }
77210
77285
 
77211
- const version = "0.17.3-alpha.0";
77286
+ const version = "0.17.3-alpha.1";
77212
77287
  function getIcons() {
77213
77288
  return get$2();
77214
77289
  }