@visactor/vtable 1.26.0 → 1.26.1-alpha.0
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.
- package/cjs/PivotTable.js +84 -12
- package/cjs/PivotTable.js.map +1 -1
- package/cjs/body-helper/style.js +2 -1
- package/cjs/core/BaseTable.js +2 -3
- package/cjs/core/BaseTable.js.map +1 -1
- package/cjs/dataset/DataStatistics.js +2 -1
- package/cjs/edit/edit-manager.js +0 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/layout/index.js +1 -1
- package/cjs/layout/layout-helper.js +1 -1
- package/cjs/layout/pivot-header-layout.js +1 -1
- package/cjs/layout/row-height-map.js +1 -1
- package/cjs/layout/simple-header-layout.js +1 -1
- package/cjs/layout/tree-helper.js +1 -1
- package/cjs/plugins/index.js +1 -1
- package/cjs/plugins/interface.js +1 -1
- package/cjs/plugins/invert-highlight.js +1 -1
- package/cjs/plugins/list-tree-stick-cell.js +1 -1
- package/cjs/plugins/plugin-manager.js +1 -1
- package/cjs/scenegraph/scenegraph.js +1 -1
- package/cjs/ts-types/dataset/aggregation.js +94 -39
- package/cjs/ts-types/dataset/aggregation.js.map +1 -1
- package/cjs/ts-types/icon.d.ts +2 -2
- package/cjs/ts-types/icon.js.map +1 -1
- package/cjs/vrender.js.map +1 -1
- package/dist/vtable.js +203 -78
- package/dist/vtable.min.js +1 -1
- package/es/PivotTable.js +84 -12
- package/es/PivotTable.js.map +1 -1
- package/es/body-helper/style.js +2 -1
- package/es/core/BaseTable.js +2 -3
- package/es/core/BaseTable.js.map +1 -1
- package/es/dataset/DataStatistics.js +2 -1
- package/es/edit/edit-manager.js +1 -2
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/layout/index.js +1 -1
- package/es/layout/layout-helper.js +1 -1
- package/es/layout/pivot-header-layout.js +1 -1
- package/es/layout/row-height-map.js +1 -1
- package/es/layout/simple-header-layout.js +1 -1
- package/es/layout/tree-helper.js +1 -1
- package/es/plugins/index.js +1 -1
- package/es/plugins/interface.js +1 -1
- package/es/plugins/invert-highlight.js +1 -1
- package/es/plugins/list-tree-stick-cell.js +1 -1
- package/es/plugins/plugin-manager.js +1 -1
- package/es/scenegraph/scenegraph.js +1 -1
- package/es/ts-types/dataset/aggregation.js +68 -38
- package/es/ts-types/dataset/aggregation.js.map +1 -1
- package/es/ts-types/icon.d.ts +2 -2
- package/es/ts-types/icon.js.map +1 -1
- package/es/vrender.js.map +1 -1
- package/package.json +7 -6
package/es/edit/edit-manager.js
CHANGED
|
@@ -163,5 +163,4 @@ function dealWithValidateValue(validateValue, editManager, oldValue, resolve) {
|
|
|
163
163
|
editManager.doExit(), null == resolve || resolve(!0), !0) : "validate-not-exit" === validateValue || "invalidate-not-exit" === validateValue ? (null == resolve || resolve(!1),
|
|
164
164
|
!1) : !0 === validateValue ? (editManager.doExit(), null == resolve || resolve(!0),
|
|
165
165
|
!0) : (null == resolve || resolve(!1), !1);
|
|
166
|
-
}
|
|
167
|
-
//# sourceMappingURL=edit-manager.js.map
|
|
166
|
+
}
|
package/es/index.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export { toBoxArray } from './tools/helper';
|
|
|
24
24
|
export { Icon } from './scenegraph/graphic/icon';
|
|
25
25
|
export { CUSTOM_MERGE_PRE_NAME, CUSTOM_CONTAINER_NAME } from './scenegraph/component/custom';
|
|
26
26
|
export { matrixAllocate, transformPointForCanvas, mapToCanvasPointForCanvas, registerGlobalEventTransformer, registerWindowEventTransformer, vglobal, Group, graphicUtil } from './vrender';
|
|
27
|
-
export declare const version = "1.26.0";
|
|
27
|
+
export declare const version = "1.26.1-alpha.0";
|
|
28
28
|
export { TYPES, core, ListTable, ListTableSimple, BaseTableAPI, ListTableConstructorOptions, PivotTable, PivotTableSimple, PivotTableConstructorOptions, PivotChartConstructorOptions, PivotChart, IHeaderTreeDefine, IDimension, IIndicator, ITitleDefine, ICornerDefine, ColumnsDefine, ColumnDefine, LinkColumnDefine, ChartColumnDefine, ImageColumnDefine, SparklineColumnDefine, ProgressbarColumnDefine, TextColumnDefine, GroupColumnDefine, TextAlignType, TextBaselineType, textMeasure, themes, data, MousePointerCellEvent, getIcons, clearGlobal, register, DataStatistics, CustomLayout, updateCell, renderChart, setCustomAlphabetCharSet, restoreMeasureText, pluginsDefinition };
|
|
29
29
|
declare function getIcons(): {
|
|
30
30
|
[key: string]: TYPES.ColumnIconOption;
|
package/es/index.js
CHANGED
|
@@ -50,7 +50,7 @@ export { CUSTOM_MERGE_PRE_NAME, CUSTOM_CONTAINER_NAME } from "./scenegraph/compo
|
|
|
50
50
|
|
|
51
51
|
export { matrixAllocate, transformPointForCanvas, mapToCanvasPointForCanvas, registerGlobalEventTransformer, registerWindowEventTransformer, vglobal, Group, graphicUtil } from "./vrender";
|
|
52
52
|
|
|
53
|
-
export const version = "1.26.0";
|
|
53
|
+
export const version = "1.26.1-alpha.0";
|
|
54
54
|
|
|
55
55
|
export { TYPES, core, ListTable, ListTableSimple, PivotTable, PivotTableSimple, PivotChart, textMeasure, themes, data, getIcons, clearGlobal, register, DataStatistics, CustomLayout, updateCell, renderChart, setCustomAlphabetCharSet, restoreMeasureText, pluginsDefinition };
|
|
56
56
|
|
package/es/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/C,kBAAkB,EAAE,CAAC;AAErB,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,MAAM,MAAM,UAAU,CA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EACL,WAAW,EACZ,MAAM,WAAW,CAAC;AAKnB,MAAM,CAAC,MAAM,OAAO,GAAG,gBAAgB,CAAC;AAIxC,OAAO,EAKL,KAAK,EACL,IAAI,EACJ,SAAS,EACT,eAAe,EAGf,UAAU,EACV,gBAAgB,EAGhB,UAAU,EAiBV,WAAW,EACX,MAAM,EACN,IAAI,EAEJ,QAAQ,EACR,WAAW,EAEX,QAAQ,EAIR,cAAc,EACd,YAAY,EACZ,UAAU,EACV,WAAW,EACX,wBAAwB,EACxB,kBAAkB,EAClB,iBAAiB,EAClB,CAAC;AAGF,SAAS,QAAQ;IAGf,OAAO,KAAK,CAAC,GAAG,EAAE,CAAC;AACrB,CAAC;AAED,SAAS,WAAW;IAClB,QAAQ,CAAC,QAAQ,EAAE,CAAC;AAGtB,CAAC;AACD,KAAK,CAAC,eAAe,CAAC;AAEtB,cAAc,cAAc,CAAC;AAC7B,cAAc,sCAAsC,CAAC;AAErD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,+CAA+C,CAAC;AAE/G,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC","file":"index.js","sourcesContent":["/* eslint-disable sort-imports */\nimport { registerForVrender } from './vrender';\nregisterForVrender();\n\nimport * as TYPES from './ts-types';\nimport * as core from './core';\nimport * as data from './data';\nimport * as icons from './icons';\nimport * as register from './register';\nimport * as themes from './themes';\nimport * as DataStatistics from './dataset/DataStatistics';\nimport * as pluginsDefinition from './plugins';\nimport type {\n ColumnDefine,\n ColumnsDefine,\n LinkColumnDefine,\n ChartColumnDefine,\n ImageColumnDefine,\n SparklineColumnDefine,\n ProgressbarColumnDefine,\n TextColumnDefine,\n GroupColumnDefine,\n ListTableConstructorOptions,\n PivotTableConstructorOptions,\n PivotChartConstructorOptions,\n IHeaderTreeDefine,\n IDimension,\n IIndicator,\n ITitleDefine,\n ICornerDefine,\n TextAlignType,\n TextBaselineType\n} from './ts-types';\nimport { ListTableAll as ListTable } from './ListTable-all';\nimport { ListTableSimple } from './ListTable-simple';\n// import { PivotTable } from './PivotTable';\nimport { PivotTableAll as PivotTable } from './PivotTable-all';\nimport { PivotTableSimple } from './PivotTable-simple';\nimport { PivotChart } from './PivotChart';\nimport type { MousePointerCellEvent } from './ts-types/events';\nimport * as CustomLayout from './render/layout';\n\nimport { updateCell } from './scenegraph/group-creater/cell-helper';\nimport { renderChart } from './scenegraph/graphic/contributions/chart-render-helper';\nimport { restoreMeasureText, setCustomAlphabetCharSet, textMeasure } from './scenegraph/utils/text-measure';\nimport type { BaseTableAPI } from './ts-types/base-table';\n\n// import { container, loadCanvasPicker } from '@src/vrender';\n// loadCanvasPicker(container);\n\nexport { getDataCellPath } from './tools/get-data-path';\nexport * from './render/jsx';\nexport { getTargetCell } from './event/util';\nexport { toBoxArray } from './tools/helper';\nexport { Icon } from './scenegraph/graphic/icon';\nexport { CUSTOM_MERGE_PRE_NAME, CUSTOM_CONTAINER_NAME } from './scenegraph/component/custom';\n// 为插件等场景提供必要的 vrender 能力:只导出用到的符号,避免与 render/jsx 的导出成员发生命名冲突。\nexport {\n matrixAllocate,\n transformPointForCanvas,\n mapToCanvasPointForCanvas,\n registerGlobalEventTransformer,\n registerWindowEventTransformer,\n vglobal,\n Group,\n graphicUtil\n} from './vrender';\n\n// export * as VRender from './vrender';\n// import * as VRender from './vrender';\n\nexport const version = \"1.26.1-alpha.0\";\n/**\n * @namespace VTable\n */\nexport {\n /**\n * Types\n * @namespace VTable.TYPES\n */\n TYPES,\n core,\n ListTable,\n ListTableSimple,\n BaseTableAPI,\n ListTableConstructorOptions,\n PivotTable,\n PivotTableSimple,\n PivotTableConstructorOptions,\n PivotChartConstructorOptions,\n PivotChart,\n IHeaderTreeDefine,\n IDimension,\n IIndicator,\n ITitleDefine,\n ICornerDefine,\n ColumnsDefine,\n ColumnDefine,\n LinkColumnDefine,\n ChartColumnDefine,\n ImageColumnDefine,\n SparklineColumnDefine,\n ProgressbarColumnDefine,\n TextColumnDefine,\n GroupColumnDefine,\n TextAlignType,\n TextBaselineType,\n textMeasure,\n themes,\n data,\n MousePointerCellEvent,\n getIcons,\n clearGlobal,\n //plugin registers\n register,\n /**\n * 暂不推荐使用\n */\n DataStatistics,\n CustomLayout,\n updateCell,\n renderChart,\n setCustomAlphabetCharSet,\n restoreMeasureText,\n pluginsDefinition\n};\n\n/** @private */\nfunction getIcons(): {\n [key: string]: TYPES.ColumnIconOption;\n} {\n return icons.get();\n}\n/** 清理内部的全局变量 如注册的icon theme等 以及共享的header column类实例 */\nfunction clearGlobal() {\n register.clearAll();\n // headers.type.clearGlobal();\n // columns.type.clearGlobal();\n}\nTYPES.AggregationType;\n\nexport * from './components';\nexport * from './scenegraph/group-creater/cell-type';\n\nexport { TABLE_EVENT_TYPE } from './core/TABLE_EVENT_TYPE';\nexport { PIVOT_CHART_EVENT_TYPE, PIVOT_TABLE_EVENT_TYPE } from './ts-types/pivot-table/PIVOT_TABLE_EVENT_TYPE';\n\nexport { EventTarget } from './event/EventTarget';\n"]}
|
package/es/layout/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { SimpleHeaderLayoutMap } from "./simple-header-layout";
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -143,4 +143,4 @@ export function deleteHideIndicatorNode(treeNodeChildren, indicators, hasHideNod
|
|
|
143
143
|
}
|
|
144
144
|
(hasHideSettingIndicators.length || hasHideNode) && deleteTreeHideNode(treeNodeChildren, [], hasHideSettingIndicators, hasHideNode, table);
|
|
145
145
|
}
|
|
146
|
-
//# sourceMappingURL=layout-helper.js.map
|
|
146
|
+
//# sourceMappingURL=layout-helper.js.map
|
|
@@ -2026,4 +2026,4 @@ function bandSpace(count, paddingInner, paddingOuter) {
|
|
|
2026
2026
|
return space = 1 === count ? count + 2 * paddingOuter : count - paddingInner + 2 * paddingOuter,
|
|
2027
2027
|
count ? space > 0 ? space : 1 : 0;
|
|
2028
2028
|
}
|
|
2029
|
-
//# sourceMappingURL=pivot-header-layout.js.map
|
|
2029
|
+
//# sourceMappingURL=pivot-header-layout.js.map
|
|
@@ -812,4 +812,4 @@ export class SimpleHeaderLayoutMap {
|
|
|
812
812
|
if (col >= 0) return col < this.leftRowSeriesNumberColumnCount ? this.leftRowSeriesNumberColumn[col].define : this.transpose ? this._columns[row].define : this._columns[col - this.leftRowSeriesNumberColumnCount].define;
|
|
813
813
|
}
|
|
814
814
|
}
|
|
815
|
-
//# sourceMappingURL=simple-header-layout.js.map
|
|
815
|
+
//# sourceMappingURL=simple-header-layout.js.map
|
package/es/layout/tree-helper.js
CHANGED
package/es/plugins/index.js
CHANGED
package/es/plugins/interface.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { };
|
|
2
|
-
//# sourceMappingURL=interface.js.map
|
|
2
|
+
//# sourceMappingURL=interface.js.map
|
|
@@ -175,4 +175,4 @@ function scrollToRow(row, table) {
|
|
|
175
175
|
export const registerListTreeStickCellPlugin = () => {
|
|
176
176
|
Factory.registerComponent("listTreeStickCellPlugin", ListTreeStickCellPlugin);
|
|
177
177
|
};
|
|
178
|
-
//# sourceMappingURL=list-tree-stick-cell.js.map
|
|
178
|
+
//# sourceMappingURL=list-tree-stick-cell.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isValid } from "@visactor/vutils";
|
|
1
|
+
import { isValid, precisionAdd, precisionSub } from "@visactor/vutils";
|
|
2
2
|
|
|
3
3
|
import { AggregationType, SortType } from "..";
|
|
4
4
|
|
|
@@ -160,45 +160,54 @@ export class SumAggregator extends Aggregator {
|
|
|
160
160
|
record.isAggregator && this.children) {
|
|
161
161
|
this.children.push(record);
|
|
162
162
|
const value = record.value();
|
|
163
|
-
this.sum
|
|
163
|
+
this.sum = precisionAdd(this.sum, null != value ? value : 0), this.needSplitPositiveAndNegativeForSum && (value > 0 ? this.positiveSum = precisionAdd(this.positiveSum, value) : value < 0 && (this.nagetiveSum = precisionAdd(this.nagetiveSum, value)));
|
|
164
164
|
} else if (this.field && !isNaN(parseFloat(record[this.field]))) {
|
|
165
165
|
const value = parseFloat(record[this.field]);
|
|
166
|
-
this.sum
|
|
166
|
+
this.sum = precisionAdd(this.sum, value), this.needSplitPositiveAndNegativeForSum && (value > 0 ? this.positiveSum = precisionAdd(this.positiveSum, value) : value < 0 && (this.nagetiveSum = precisionAdd(this.nagetiveSum, value)));
|
|
167
167
|
}
|
|
168
168
|
this.clearCacheValue();
|
|
169
169
|
}
|
|
170
170
|
deleteRecord(record) {
|
|
171
|
-
if (record)
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
171
|
+
if (record) {
|
|
172
|
+
if (this.isRecord && this.records) {
|
|
173
|
+
const index = this.records.indexOf(record);
|
|
174
|
+
-1 !== index && this.records.splice(index, 1);
|
|
175
|
+
}
|
|
176
|
+
if (record.isAggregator && this.children) {
|
|
177
|
+
const index = this.children.indexOf(record);
|
|
178
|
+
-1 !== index && this.children.splice(index, 1);
|
|
179
|
+
const value = record.value();
|
|
180
|
+
this.sum = precisionSub(this.sum, null != value ? value : 0), this.needSplitPositiveAndNegativeForSum && (value > 0 ? this.positiveSum = precisionSub(this.positiveSum, value) : value < 0 && (this.nagetiveSum = precisionSub(this.nagetiveSum, value)));
|
|
181
|
+
} else if (this.field && !isNaN(parseFloat(record[this.field]))) {
|
|
182
|
+
const value = parseFloat(record[this.field]);
|
|
183
|
+
this.sum = precisionSub(this.sum, value), this.needSplitPositiveAndNegativeForSum && (value > 0 ? this.positiveSum = precisionSub(this.positiveSum, value) : value < 0 && (this.nagetiveSum = precisionSub(this.nagetiveSum, value)));
|
|
184
|
+
}
|
|
179
185
|
}
|
|
180
186
|
this.clearCacheValue();
|
|
181
187
|
}
|
|
182
188
|
updateRecord(oldRecord, newRecord) {
|
|
183
189
|
if (oldRecord && newRecord) {
|
|
184
|
-
if (this.isRecord && this.records
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
190
|
+
if (this.isRecord && this.records) {
|
|
191
|
+
const index = this.records.indexOf(oldRecord);
|
|
192
|
+
-1 !== index && (this.records[index] = newRecord);
|
|
193
|
+
}
|
|
194
|
+
if (oldRecord.isAggregator && this.children) {
|
|
195
|
+
const oldValue = oldRecord.value(), index = this.children.indexOf(oldRecord);
|
|
196
|
+
-1 !== index && (this.children[index] = newRecord);
|
|
188
197
|
const newValue = newRecord.value();
|
|
189
|
-
this.
|
|
190
|
-
newValue > 0 ? this.positiveSum
|
|
198
|
+
this.sum = precisionAdd(this.sum, precisionSub(newValue, oldValue)), this.needSplitPositiveAndNegativeForSum && (oldValue > 0 ? this.positiveSum = precisionSub(this.positiveSum, oldValue) : oldValue < 0 && (this.nagetiveSum = precisionSub(this.nagetiveSum, oldValue)),
|
|
199
|
+
newValue > 0 ? this.positiveSum = precisionAdd(this.positiveSum, newValue) : newValue < 0 && (this.nagetiveSum = precisionAdd(this.nagetiveSum, newValue)));
|
|
191
200
|
} else if (this.field && !isNaN(parseFloat(oldRecord[this.field]))) {
|
|
192
201
|
const oldValue = parseFloat(oldRecord[this.field]), newValue = parseFloat(newRecord[this.field]);
|
|
193
|
-
this.sum
|
|
194
|
-
newValue > 0 ? this.positiveSum
|
|
202
|
+
this.sum = precisionAdd(this.sum, precisionSub(newValue, oldValue)), this.needSplitPositiveAndNegativeForSum && (oldValue > 0 ? this.positiveSum = precisionSub(this.positiveSum, oldValue) : oldValue < 0 && (this.nagetiveSum = precisionSub(this.nagetiveSum, oldValue)),
|
|
203
|
+
newValue > 0 ? this.positiveSum = precisionAdd(this.positiveSum, newValue) : newValue < 0 && (this.nagetiveSum = precisionAdd(this.nagetiveSum, newValue)));
|
|
195
204
|
}
|
|
196
205
|
this.clearCacheValue();
|
|
197
206
|
}
|
|
198
207
|
}
|
|
199
208
|
value() {
|
|
200
|
-
var _a
|
|
201
|
-
return null !== (_a = this.changedValue) && void 0 !== _a ? _a :
|
|
209
|
+
var _a;
|
|
210
|
+
return null !== (_a = this.changedValue) && void 0 !== _a ? _a : this.records && this.records.length >= 1 || !1 === this.isRecord ? this.sum : void 0;
|
|
202
211
|
}
|
|
203
212
|
positiveValue() {
|
|
204
213
|
return this.positiveSum;
|
|
@@ -214,16 +223,16 @@ export class SumAggregator extends Aggregator {
|
|
|
214
223
|
const child = this.children[i];
|
|
215
224
|
if (child.isAggregator) {
|
|
216
225
|
const value = child.value();
|
|
217
|
-
this.sum
|
|
226
|
+
this.sum = precisionAdd(this.sum, null != value ? value : 0), this.needSplitPositiveAndNegativeForSum && (value > 0 ? this.positiveSum = precisionAdd(this.positiveSum, value) : value < 0 && (this.nagetiveSum = precisionAdd(this.nagetiveSum, value)));
|
|
218
227
|
}
|
|
219
228
|
} else if (this.records) for (let i = 0; i < this.records.length; i++) {
|
|
220
229
|
const record = this.records[i];
|
|
221
230
|
if (record.isAggregator) {
|
|
222
231
|
const value = record.value();
|
|
223
|
-
this.sum
|
|
232
|
+
this.sum = precisionAdd(this.sum, null != value ? value : 0), this.needSplitPositiveAndNegativeForSum && (value > 0 ? this.positiveSum = precisionAdd(this.positiveSum, value) : value < 0 && (this.nagetiveSum = precisionAdd(this.nagetiveSum, value)));
|
|
224
233
|
} else if (this.field && !isNaN(parseFloat(record[this.field]))) {
|
|
225
234
|
const value = parseFloat(record[this.field]);
|
|
226
|
-
this.sum
|
|
235
|
+
this.sum = precisionAdd(this.sum, value), this.needSplitPositiveAndNegativeForSum && (value > 0 ? this.positiveSum = precisionAdd(this.positiveSum, value) : value < 0 && (this.nagetiveSum = precisionAdd(this.nagetiveSum, value)));
|
|
227
236
|
}
|
|
228
237
|
}
|
|
229
238
|
}
|
|
@@ -276,24 +285,45 @@ export class AvgAggregator extends Aggregator {
|
|
|
276
285
|
push(record) {
|
|
277
286
|
record && (this.isRecord && this.records && (record.isAggregator ? this.records.push(...record.records) : this.records.push(record)),
|
|
278
287
|
record.isAggregator && record.type === AggregationType.AVG ? (this.children && this.children.push(record),
|
|
279
|
-
this.sum
|
|
288
|
+
this.sum = precisionAdd(this.sum, record.sum), this.count += record.count) : this.field && !isNaN(parseFloat(record[this.field])) && (this.sum = precisionAdd(this.sum, parseFloat(record[this.field])),
|
|
280
289
|
this.count++)), this.clearCacheValue();
|
|
281
290
|
}
|
|
282
291
|
deleteRecord(record) {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
292
|
+
if (record) {
|
|
293
|
+
if (this.isRecord && this.records) {
|
|
294
|
+
const index = this.records.indexOf(record);
|
|
295
|
+
-1 !== index && this.records.splice(index, 1);
|
|
296
|
+
}
|
|
297
|
+
if (record.isAggregator && record.type === AggregationType.AVG) {
|
|
298
|
+
if (this.children) {
|
|
299
|
+
const index = this.children.indexOf(record);
|
|
300
|
+
-1 !== index && this.children.splice(index, 1);
|
|
301
|
+
}
|
|
302
|
+
this.sum = precisionSub(this.sum, record.sum), this.count -= record.count;
|
|
303
|
+
} else this.field && !isNaN(parseFloat(record[this.field])) && (this.sum = precisionSub(this.sum, parseFloat(record[this.field])),
|
|
304
|
+
this.count--);
|
|
305
|
+
}
|
|
306
|
+
this.clearCacheValue();
|
|
287
307
|
}
|
|
288
308
|
updateRecord(oldRecord, newRecord) {
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
309
|
+
if (oldRecord && newRecord) {
|
|
310
|
+
if (this.isRecord && this.records) {
|
|
311
|
+
const index = this.records.indexOf(oldRecord);
|
|
312
|
+
-1 !== index && (this.records[index] = newRecord);
|
|
313
|
+
}
|
|
314
|
+
if (oldRecord.isAggregator && oldRecord.type === AggregationType.AVG) {
|
|
315
|
+
if (this.children && newRecord.isAggregator) {
|
|
316
|
+
const index = this.children.indexOf(oldRecord);
|
|
317
|
+
-1 !== index && (this.children[index] = newRecord);
|
|
318
|
+
}
|
|
319
|
+
this.sum = precisionAdd(this.sum, precisionSub(newRecord.sum, oldRecord.sum)), this.count += newRecord.count - oldRecord.count;
|
|
320
|
+
} else this.field && !isNaN(parseFloat(oldRecord[this.field])) && (this.sum = precisionAdd(this.sum, precisionSub(parseFloat(newRecord[this.field]), parseFloat(oldRecord[this.field]))));
|
|
321
|
+
this.clearCacheValue();
|
|
322
|
+
}
|
|
293
323
|
}
|
|
294
324
|
value() {
|
|
295
|
-
var _a
|
|
296
|
-
return null !== (_a = this.changedValue) && void 0 !== _a ? _a :
|
|
325
|
+
var _a;
|
|
326
|
+
return null !== (_a = this.changedValue) && void 0 !== _a ? _a : this.records && this.records.length >= 1 || !1 === this.isRecord && this.count > 0 ? this.sum / this.count : void 0;
|
|
297
327
|
}
|
|
298
328
|
reset() {
|
|
299
329
|
this.changedValue = void 0, this.children = [], this.records = [], this.sum = 0,
|
|
@@ -304,12 +334,12 @@ export class AvgAggregator extends Aggregator {
|
|
|
304
334
|
const child = this.children[i];
|
|
305
335
|
if (child.isAggregator && child.type === AggregationType.AVG) {
|
|
306
336
|
const childValue = child.value();
|
|
307
|
-
this.sum
|
|
337
|
+
this.sum = precisionAdd(this.sum, childValue * child.count), this.count += child.count;
|
|
308
338
|
}
|
|
309
339
|
} else if (this.records) for (let i = 0; i < this.records.length; i++) {
|
|
310
340
|
const record = this.records[i];
|
|
311
|
-
record.isAggregator && record.type === AggregationType.AVG ? (this.sum
|
|
312
|
-
this.count += record.count) : this.field && !isNaN(parseFloat(record[this.field])) && (this.sum
|
|
341
|
+
record.isAggregator && record.type === AggregationType.AVG ? (this.sum = precisionAdd(this.sum, record.sum),
|
|
342
|
+
this.count += record.count) : this.field && !isNaN(parseFloat(record[this.field])) && (this.sum = precisionAdd(this.sum, parseFloat(record[this.field])),
|
|
313
343
|
this.count++);
|
|
314
344
|
}
|
|
315
345
|
}
|