Skip to content

Commit

Permalink
Merge pull request #325 from VisActor/feat/pivot-chart
Browse files Browse the repository at this point in the history
Feat/pivot chart
  • Loading branch information
Rui-Sun authored Sep 14, 2023
2 parents 9c60f27 + 2604429 commit eb54b18
Show file tree
Hide file tree
Showing 14 changed files with 49 additions and 22 deletions.
18 changes: 9 additions & 9 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/vtable/examples/pivot/pivot-size-legend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,5 +314,6 @@ export function createTable() {
})
);
});
bindDebugTool(instance.scenegraph.stage, {});
});
}
4 changes: 2 additions & 2 deletions packages/vtable/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
"build:es": "bundle --clean -f es --ignorePostTasks"
},
"dependencies": {
"@visactor/vrender": "0.15.0-alpha.13",
"@visactor/vrender-components": "0.15.0-alpha.13",
"@visactor/vrender": "0.15.1",
"@visactor/vrender-components": "0.15.1",
"@visactor/vutils": "~0.15.7",
"@visactor/vscale": "~0.15.7",
"@visactor/vdataset": "~0.15.7",
Expand Down
3 changes: 3 additions & 0 deletions packages/vtable/src/ListTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,9 @@ export class ListTable extends BaseTable implements ListTableAPI {
}
if (hd?.define?.sort) {
this.dataSource.sort(hd.field, order, sortFunc);

// clear cell range cache
this.internalProps.layoutMap.clearCellRangeMap();
this.scenegraph.sortCell();
}
}
Expand Down
9 changes: 6 additions & 3 deletions packages/vtable/src/core/BaseTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ export abstract class BaseTable extends EventTarget implements BaseTableAPI {
headerStyleCache: any;
bodyStyleCache: any;
container: HTMLElement;
isReleased: boolean = false;

constructor(container: HTMLElement, options: BaseTableConstructorOptions = {}) {
super();
if (!container) {
Expand Down Expand Up @@ -677,9 +679,8 @@ export abstract class BaseTable extends EventTarget implements BaseTableAPI {
* 根据设置的列宽配置 计算列宽值
* @param {string|number} width width definition
* @returns {number} the pixels of width
* @private
*/
private _colWidthDefineToPxWidth(width: string | number): number {
_colWidthDefineToPxWidth(width: string | number): number {
if (width === 'auto') {
// hack for defaultWidht support 'auto'
return 0;
Expand Down Expand Up @@ -722,7 +723,7 @@ export abstract class BaseTable extends EventTarget implements BaseTableAPI {
return result as never;
}

private _adjustColWidth(col: number, orgWidth: number): number {
_adjustColWidth(col: number, orgWidth: number): number {
const limits = this._getColWidthLimits(col);
return Math.max(_applyColWidthLimits(limits, orgWidth), 0);
}
Expand Down Expand Up @@ -1686,6 +1687,8 @@ export abstract class BaseTable extends EventTarget implements BaseTableAPI {
if (parentElement) {
parentElement.removeChild(internalProps.element);
}

this.isReleased = true;
}

fireListeners<TYPE extends keyof TableEventHandlersEventArgumentMap>(
Expand Down
4 changes: 4 additions & 0 deletions packages/vtable/src/event/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ export class EventManeger {
}

bindSelfEvent() {
if (this.table.isReleased) {
return;
}

const stateManeger: StateManeger = this.table.stateManeger;

// 图标点击
Expand Down
4 changes: 4 additions & 0 deletions packages/vtable/src/layout/pivot-header-layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2035,4 +2035,8 @@ export class PivotHeaderLayoutMap implements LayoutMapAPI {
}
return undefined;
}

clearCellRangeMap() {
this._cellRangeMap.clear();
}
}
4 changes: 4 additions & 0 deletions packages/vtable/src/layout/pivot-layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1602,4 +1602,8 @@ export class PivotLayoutMap implements LayoutMapAPI {
indicatorObject.chartInstance?.release();
});
}

clearCellRangeMap() {
// do nothing
}
}
4 changes: 4 additions & 0 deletions packages/vtable/src/layout/simple-header-layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -774,4 +774,8 @@ export class SimpleHeaderLayoutMap implements LayoutMapAPI {
indicatorObject.chartInstance?.release();
});
}

clearCellRangeMap() {
this._cellRangeMap.clear();
}
}
8 changes: 4 additions & 4 deletions packages/vtable/src/scenegraph/stick-text/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function handleTextStick(table: BaseTableAPI) {
adjustCellContentHorizontalLayout(
cellGroup,
frozenColsWidth + table.tableX,
table.tableNoFrameWidth - table.getRightFrozenColsWidth()
table.tableNoFrameWidth - table.getRightFrozenColsWidth() + table.tableX
);
changedCells.push({ col, row });
}
Expand All @@ -62,7 +62,7 @@ export function handleTextStick(table: BaseTableAPI) {
adjustCellContentVerticalLayout(
cellGroup,
frozenRowsHeight + table.tableY,
table.tableNoFrameHeight - table.getBottomFrozenRowsHeight()
table.tableNoFrameHeight - table.getBottomFrozenRowsHeight() + table.tableY
);
changedCells.push({ col, row });
}
Expand All @@ -77,13 +77,13 @@ export function handleTextStick(table: BaseTableAPI) {
adjustCellContentVerticalLayout(
cellGroup,
frozenRowsHeight + table.tableY,
table.tableNoFrameHeight - table.getBottomFrozenRowsHeight()
table.tableNoFrameHeight - table.getBottomFrozenRowsHeight() + table.tableY
);
// adjust cell Horizontal
adjustCellContentHorizontalLayout(
cellGroup,
frozenColsWidth + table.tableX,
table.tableNoFrameWidth - table.getRightFrozenColsWidth()
table.tableNoFrameWidth - table.getRightFrozenColsWidth() + table.tableX
);
changedCells.push({ col, row });
}
Expand Down
4 changes: 2 additions & 2 deletions packages/vtable/src/scenegraph/utils/text-icon-layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type { Scenegraph } from '../scenegraph';
import { getCellMergeInfo } from './get-cell-merge';
import { getHierarchyOffset } from './get-hierarchy-offset';
import type { BaseTableAPI } from '../../ts-types/base-table';
import { isNumber } from '@visactor/vutils';
import { isNil, isNumber, isValid } from '@visactor/vutils';

/**
* @description: 创建单元格内容
Expand Down Expand Up @@ -71,7 +71,7 @@ export function createCellContent(
let absoluteRightIconWidth = 0;

if (!Array.isArray(icons) || icons.length === 0) {
if (textStr) {
if (isValid(textStr)) {
// 没有icon,cellGroup只添加WrapText
const text = convertInternal(textStr).replace(/\r?\n/g, '\n').replace(/\r/g, '\n').split('\n');

Expand Down
4 changes: 4 additions & 0 deletions packages/vtable/src/state/sort/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ export function dealSort(col: number, row: number, table: ListTableAPI) {
if (headerC?.sort) {
executeSort(tableState, table, headerC);
}

// clear cell range cache
table.internalProps.layoutMap.clearCellRangeMap();

table.scenegraph.sortCell();
// 排序后,清除选中效果
table.stateManeger.updateSelectPos(-1, -1);
Expand Down
2 changes: 0 additions & 2 deletions packages/vtable/src/state/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -838,8 +838,6 @@ export class StateManeger {
const cellGroup = this.table.scenegraph.getCell(this.sort.col, this.sort.row);
const iconMark = cellGroup.getChildByName(name, true);

// 更新cell
this.table.scenegraph.sortCell();
// 更新icon
this.table.scenegraph.updateSortIcon(
this.sort.col,
Expand Down
2 changes: 2 additions & 0 deletions packages/vtable/src/ts-types/base-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,8 @@ export interface BaseTableAPI {
/** 当行高度不能占满容器时,是否需要自动拉高来填充容器的高度。默认false */
autoFillHeight?: boolean;

isReleased: boolean;

on: <TYPE extends keyof TableEventHandlersEventArgumentMap>(
type: TYPE,
listener: TableEventListener<TYPE> //(event: TableEventHandlersEventArgumentMap[TYPE]) => TableEventHandlersReturnMap[TYPE]
Expand Down

0 comments on commit eb54b18

Please sign in to comment.