Skip to content

Commit

Permalink
fix: cr problems
Browse files Browse the repository at this point in the history
  • Loading branch information
brucetoo committed Jun 17, 2021
1 parent 0502009 commit 0ca30ef
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
7 changes: 3 additions & 4 deletions packages/s2-core/src/data-set/base-data-set.ts
Expand Up @@ -96,11 +96,10 @@ export abstract class BaseDataSet {
public abstract getDimensionValues(field: string, query?: DataType): string[];

/**
* In most case, this function to get the specific
* cross data cell data. And we need mark total if
* the pending cell is totals cell
* In most cases, this function to get the specific
* cross data cell data
* @param query
* @param rowNode some times, we need rowNode to locate data
* @param rowNode
*/
public abstract getCellData(query: DataType, rowNode?: Node): DataType;

Expand Down
6 changes: 3 additions & 3 deletions packages/s2-core/src/data-set/interface.ts
Expand Up @@ -15,9 +15,9 @@ export type DataPathParams = {
rowDimensionValues: string[];
colDimensionValues: string[];
// first create data path
firstCreate?: boolean;
// use in multi query data
isFirstCreate?: boolean;
// use for multiple data queries
careUndefined?: boolean;
// use in row tree mode to append extra info
// use in row tree mode to append fields information
rowFields?: string[];
};
16 changes: 8 additions & 8 deletions packages/s2-core/src/data-set/pivot-data-set.ts
Expand Up @@ -3,7 +3,7 @@ import { DataPathParams, DataType, PivotMeta } from 'src/data-set/interface';
import { DerivedValue, Meta, S2DataConfig } from 'src/common/interface';
import { i18n } from 'src/common/i18n';
import { EXTRA_FIELD, VALUE_FIELD } from 'src/common/constant';
import * as _ from 'lodash';
import _ from 'lodash';
import { DEBUG_TRANSFORM_DATA, DebuggerUtil } from 'src/common/debug';
import { Node } from '@/facet/layout/node';

Expand Down Expand Up @@ -59,7 +59,7 @@ export class PivotDataSet extends BaseDataSet {
const { columns } = this.fields;
const rows = Node.getFieldPath(rowNode);
const store = this.spreadsheet.store;
// 1、add extra fields info in data by values
// 1、通过values在data中注入额外的维度信息
const values = this.fields.values;
for (const drillDownDatum of drillDownData) {
for (const value of values) {
Expand All @@ -69,7 +69,7 @@ export class PivotDataSet extends BaseDataSet {
});
}
}
// 2、transform data
// 2、转换数据
const drillDownDataPaths = this.transformIndexesData(
[...rows, extraRowField],
columns,
Expand All @@ -79,7 +79,7 @@ export class PivotDataSet extends BaseDataSet {
const rowNodeId = rowNode.id;
const idPathMap = store.get('drillDownIdPathMap') ?? new Map();
if (idPathMap.has(rowNodeId)) {
// current node has one drill-down field, clean it, add new one
// the current node has a drill-down field, clean it and add new one
idPathMap
.get(rowNodeId)
.map((path) => _.set(this.indexesData, path, undefined));
Expand Down Expand Up @@ -127,7 +127,7 @@ export class PivotDataSet extends BaseDataSet {
const path = this.getDataPath({
rowDimensionValues,
colDimensionValues,
firstCreate: true,
isFirstCreate: true,
rowFields: rows,
});
paths.push(path);
Expand Down Expand Up @@ -247,7 +247,7 @@ export class PivotDataSet extends BaseDataSet {
rowDimensionValues,
colDimensionValues,
careUndefined,
firstCreate,
isFirstCreate,
rowFields,
} = params;
const getPath = (dimensionValues: string[], isRow = true): number[] => {
Expand All @@ -257,7 +257,7 @@ export class PivotDataSet extends BaseDataSet {
for (let i = 0; i < dimensionValues.length; i++) {
const value = dimensionValues[i];
if (!currentMeta.has(value)) {
if (firstCreate) {
if (isFirstCreate) {
currentMeta.set(value, {
level: currentMeta.size,
children: new Map(),
Expand All @@ -272,7 +272,7 @@ export class PivotDataSet extends BaseDataSet {
}
}
const meta = currentMeta.get(value);
if (firstCreate) {
if (isFirstCreate) {
// mark the child field
meta.childField = fields?.[i + 1];
}
Expand Down

0 comments on commit 0ca30ef

Please sign in to comment.