Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/data-process' into optimize-scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
lijinke666 committed Jul 29, 2021
2 parents c30d5d7 + b0a1377 commit 37e67f8
Show file tree
Hide file tree
Showing 28 changed files with 1,033 additions and 1,086 deletions.
325 changes: 279 additions & 46 deletions packages/s2-core/package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions packages/s2-core/package.json
Expand Up @@ -59,6 +59,7 @@
"classnames": "^2.2.5",
"d3-ease": "^1.0.5",
"lodash": "^4.17.11",
"rollup-plugin-typescript2": "^0.30.0",
"tslib": "^2.2.0"
},
"devDependencies": {
Expand Down
3 changes: 2 additions & 1 deletion packages/s2-core/rollup.config.js
@@ -1,4 +1,4 @@
import typescript from '@rollup/plugin-typescript';
import typescript from 'rollup-plugin-typescript2';
import less from 'rollup-plugin-less';
import resolve from '@rollup/plugin-node-resolve';
import { terser } from 'rollup-plugin-terser';
Expand Down Expand Up @@ -28,6 +28,7 @@ const plugins = [
resolve(),
typescript({
outDir: outDir,
abortOnError: true,
}),
less({
output: outDir + '/index.css',
Expand Down
16 changes: 8 additions & 8 deletions packages/s2-core/src/cell/detail-col-cell.ts
@@ -1,7 +1,7 @@
import { getEllipsisText } from '../utils/text';
import { renderRect } from '../utils/g-renders';
import { DEFAULT_PADDING, EXTRA_FIELD, ICON_RADIUS } from '../common/constant';
// import { addDetailTypeSortIcon } from '../facet/layout/util/add-detail-type-sort-icon';
import { addDetailTypeSortIcon } from '../facet/layout/util/add-detail-type-sort-icon';
import { DefaultTheme } from '../theme';
import { ColCell } from '@/cell/col-cell';
export class DetailColCell extends ColCell {
Expand Down Expand Up @@ -36,13 +36,13 @@ export class DetailColCell extends ColCell {
},
});

// addDetailTypeSortIcon(
// this,
// spreadsheet,
// textX + DEFAULT_PADDING,
// textY,
// key,
// );
addDetailTypeSortIcon(
this,
spreadsheet,
textX + DEFAULT_PADDING,
textY,
key,
);
}

protected drawRectBackground() {
Expand Down
1 change: 1 addition & 0 deletions packages/s2-core/src/common/constant/index.ts
Expand Up @@ -6,6 +6,7 @@ export * from './scroll';
export const VALUE_FIELD = '$$value$$';
export const EXTRA_FIELD = '$$extra$$';
export const TOTAL_VALUE = '$$total$$';
export const SERIES_NUMBER_FIELD = '$$number$$';
// export const COLUMN_FIELD_KEY = '$$column_key$$';
// icon radius
export const ICON_RADIUS = 6;
Expand Down
70 changes: 0 additions & 70 deletions packages/s2-core/src/data-set/detail-data-set.ts

This file was deleted.

3 changes: 2 additions & 1 deletion packages/s2-core/src/data-set/index.ts
Expand Up @@ -4,5 +4,6 @@
*/
import { BaseDataSet } from './base-data-set';
import { PivotDataSet } from './pivot-data-set';
import { TableDataSet } from './table-data-set';

export { BaseDataSet, PivotDataSet };
export { BaseDataSet, PivotDataSet, TableDataSet };
22 changes: 22 additions & 0 deletions packages/s2-core/src/data-set/table-data-set.ts
@@ -0,0 +1,22 @@
import { S2DataConfig } from '@/common/interface';
import { BaseDataSet } from 'src/data-set';
import { DataType, CellDataParams } from './interface';

export class TableDataSet extends BaseDataSet {
public processDataCfg(dataCfg: S2DataConfig): S2DataConfig {
return dataCfg;
}

public getDimensionValues(field: string, query?: DataType): string[] {
return [];
}

public getCellData(params: CellDataParams): DataType {
const { query } = params;
return this.originData[query.rowIndex][query.col];
}

public getMultiData(query: DataType, isTotals?: boolean): DataType[] {
return this.originData;
}
}
35 changes: 19 additions & 16 deletions packages/s2-core/src/facet/base-facet.ts
Expand Up @@ -29,6 +29,7 @@ import {
MIN_SCROLL_BAR_HEIGHT,
} from 'src/common/constant';
import { Node } from 'src/facet/layout/node';
import { ViewCellHeights } from 'src/facet/layout/interface';
import { Hierarchy } from 'src/facet/layout/hierarchy';
import { Wheel } from '@antv/g-gesture';
import * as d3Timer from 'd3-timer';
Expand Down Expand Up @@ -88,7 +89,7 @@ export abstract class BaseFacet {

public viewCellWidths: number[];

public viewCellHeights: number[];
public viewCellHeights: ViewCellHeights;

public cornerWidth: number;

Expand Down Expand Up @@ -246,7 +247,7 @@ export abstract class BaseFacet {
const { current, pageSize } = pagination;
const heights = this.viewCellHeights;
const offset = Math.max((current - 1) * pageSize, 0);
return heights[offset];
return heights.getCellHeight(offset);
}
return 0;
}
Expand Down Expand Up @@ -318,7 +319,7 @@ export abstract class BaseFacet {
};

calculateCellWidthHeight = () => {
const { colLeafNodes, rowLeafNodes } = this.layoutResult;
const { colLeafNodes } = this.layoutResult;
const widths = reduce(
colLeafNodes,
(result: number[], node: Node) => {
Expand All @@ -328,16 +329,8 @@ export abstract class BaseFacet {
[0],
);

const heights = reduce(
rowLeafNodes,
(result: number[], node: Node) => {
result.push(last(result) + node.height);
return result;
},
[0],
);
this.viewCellWidths = widths;
this.viewCellHeights = heights;
this.viewCellHeights = this.getViewCellHeights(this.layoutResult);
};

/**
Expand Down Expand Up @@ -375,6 +368,10 @@ export abstract class BaseFacet {
if (!this.cfg.spreadsheet.isScrollContainsRowHeader()) {
renderWidth = this.getCornerWidth(leftWidth, colsHierarchy);
}
if (!this.cfg.spreadsheet.isPivotMode()) {
renderWidth = 0;
}

this.cornerBBox = {
x: 0,
y: 0,
Expand Down Expand Up @@ -451,16 +448,17 @@ export abstract class BaseFacet {

getRealHeight = (): number => {
const { pagination } = this.cfg;
const heights = this.viewCellHeights;

if (pagination) {
const { current, pageSize } = pagination;
const heights = this.viewCellHeights;

const start = Math.max((current - 1) * pageSize, 0);
const end = Math.min(current * pageSize, heights.length - 1);
const end = Math.min(current * pageSize, heights.getTotalLength() - 1);

return heights[end] - heights[start];
return heights.getCellHeight(end) - heights.getCellHeight(start);
}
return last(this.viewCellHeights);
return heights.getTotalHeight();
};

clearAllGroup = () => {
Expand Down Expand Up @@ -859,6 +857,7 @@ export abstract class BaseFacet {
// indexes,
// );
const { add, remove } = diffIndexes(this.preCellIndexes, indexes);

DebuggerUtil.getInstance().debugCallback(DEBUG_VIEW_RENDER, () => {
// add new cell in panelCell
each(add, ([i, j]) => {
Expand Down Expand Up @@ -1081,4 +1080,8 @@ export abstract class BaseFacet {
}

protected abstract doLayout(): LayoutResult;

protected abstract getViewCellHeights(
layoutResult: LayoutResult,
): ViewCellHeights;
}
91 changes: 0 additions & 91 deletions packages/s2-core/src/facet/detail/index.ts

This file was deleted.

13 changes: 7 additions & 6 deletions packages/s2-core/src/facet/layout/build-header-hierarchy.ts
Expand Up @@ -6,6 +6,7 @@ import { Hierarchy } from 'src/facet/layout/hierarchy';
import { Node } from 'src/facet/layout/node';
import { buildRowTreeHierarchy } from 'src/facet/layout/build-row-tree-hierarchy';
import { buildGridHierarchy } from 'src/facet/layout/build-gird-hierarchy';
import { buildTableHierarchy } from 'src/facet/layout/build-table-hierarchy';
import { PivotDataSet } from '@/data-set';
import { buildRowCustomTreeHierarchy } from '@/facet/layout/build-row-custom-tree-hierarchy';
import { SpreadSheet } from '@/sheet-type';
Expand Down Expand Up @@ -85,19 +86,19 @@ const handleRowHeaderHierarchy = (params: HeaderParams) => {
} else {
handleGridRowColHierarchy(params);
}
} else {
// TODO 光生哥看下是否需要更改
throw new Error('There are not header hierarchy in table mode');
}
};

const handleColHeaderHierarchy = (params: HeaderParams) => {
const { isPivotMode } = params;
const { isPivotMode, hierarchy, rootNode, facetCfg } = params;
if (isPivotMode) {
handleGridRowColHierarchy(params);
} else {
// TODO 光生哥看下是否需要更改
throw new Error('There are not header hierarchy in table mode');
buildTableHierarchy({
parentNode: rootNode,
hierarchy,
facetCfg,
});
}
};

Expand Down

0 comments on commit 37e67f8

Please sign in to comment.