@visactor/vtable 0.9.2-alpha.3 → 0.9.3-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/PivotChart.d.ts +1 -0
- package/cjs/PivotChart.js +8 -0
- package/cjs/PivotChart.js.map +1 -1
- package/cjs/chartModule.js +14 -0
- package/cjs/chartModule.js.map +1 -0
- package/cjs/core/BaseTable.js +26 -9
- package/cjs/core/BaseTable.js.map +1 -1
- package/cjs/core/TABLE_EVENT_TYPE.d.ts +2 -0
- package/cjs/core/TABLE_EVENT_TYPE.js +3 -1
- package/cjs/core/TABLE_EVENT_TYPE.js.map +1 -1
- package/cjs/dataset/dataset-pivot-table.d.ts +60 -0
- package/cjs/dataset/dataset-pivot-table.js +387 -0
- package/cjs/dataset/dataset-pivot-table.js.map +1 -0
- package/cjs/dataset/dataset.d.ts +2 -0
- package/cjs/dataset/dataset.js +32 -21
- package/cjs/dataset/dataset.js.map +1 -1
- package/cjs/event/event.js +2 -2
- package/cjs/event/event.js.map +1 -1
- package/cjs/event/pivot-chart/axis-hover.d.ts +2 -0
- package/cjs/event/pivot-chart/axis-hover.js +41 -0
- package/cjs/event/pivot-chart/axis-hover.js.map +1 -0
- package/cjs/event/scroll.js +4 -3
- package/cjs/event/scroll.js.map +1 -1
- package/cjs/event/sparkline-event.js +1 -2
- package/cjs/event/util.js +1 -0
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/layout/{pivot-chart → chart-helper}/get-axis-config.js +4 -4
- package/cjs/layout/chart-helper/get-axis-config.js.map +1 -0
- package/cjs/layout/chart-helper/get-chart-spec.d.ts +7 -0
- package/cjs/layout/{pivot-chart → chart-helper}/get-chart-spec.js +23 -6
- package/cjs/layout/chart-helper/get-chart-spec.js.map +1 -0
- package/cjs/layout/pivot-header-layout.d.ts +2 -0
- package/cjs/layout/pivot-header-layout.js +8 -2
- package/cjs/layout/pivot-header-layout.js.map +1 -1
- package/cjs/layout/pivot-layout.d.ts +1 -0
- package/cjs/layout/pivot-layout.js +12 -8
- package/cjs/layout/pivot-layout.js.map +1 -1
- package/cjs/layout/simple-header-layout.d.ts +2 -0
- package/cjs/layout/simple-header-layout.js +9 -2
- package/cjs/layout/simple-header-layout.js.map +1 -1
- package/cjs/plugins/{chartTypes.js → chartModules.js} +1 -1
- package/cjs/plugins/chartModules.js.map +1 -0
- package/cjs/register.d.ts +1 -1
- package/cjs/register.js +6 -6
- package/cjs/register.js.map +1 -1
- package/cjs/render/layout/text.d.ts +33 -4
- package/cjs/render/layout/text.js +9 -3
- package/cjs/render/layout/text.js.map +1 -1
- package/cjs/scenegraph/component/custom.js +17 -16
- package/cjs/scenegraph/component/custom.js.map +1 -1
- package/cjs/scenegraph/component/menu.d.ts +41 -0
- package/cjs/scenegraph/graphic/chart.d.ts +1 -1
- package/cjs/scenegraph/graphic/chart.js +9 -12
- package/cjs/scenegraph/graphic/chart.js.map +1 -1
- package/cjs/scenegraph/graphic/contributions/chart-render.js +10 -3
- package/cjs/scenegraph/graphic/contributions/chart-render.js.map +1 -1
- package/cjs/scenegraph/graphic/contributions/group-contribution-render.d.ts +9 -9
- package/cjs/scenegraph/graphic/contributions/group-contribution-render.js +48 -29
- package/cjs/scenegraph/graphic/contributions/group-contribution-render.js.map +1 -1
- package/cjs/scenegraph/graphic/contributions/image-contribution-render.d.ts +3 -3
- package/cjs/scenegraph/graphic/contributions/image-contribution-render.js +2 -2
- package/cjs/scenegraph/graphic/contributions/image-contribution-render.js.map +1 -1
- package/cjs/scenegraph/graphic/contributions/rect-contribution-render.d.ts +3 -3
- package/cjs/scenegraph/graphic/contributions/rect-contribution-render.js +2 -2
- package/cjs/scenegraph/graphic/contributions/rect-contribution-render.js.map +1 -1
- package/cjs/scenegraph/graphic/text.d.ts +15 -0
- package/cjs/scenegraph/group-creater/cell-helper.js +2 -1
- package/cjs/scenegraph/group-creater/cell-helper.js.map +1 -1
- package/cjs/scenegraph/group-creater/cell-type/chart-cell.d.ts +1 -1
- package/cjs/scenegraph/group-creater/cell-type/chart-cell.js +4 -4
- package/cjs/scenegraph/group-creater/cell-type/chart-cell.js.map +1 -1
- package/cjs/scenegraph/layout/update-width.js +32 -2
- package/cjs/scenegraph/layout/update-width.js.map +1 -1
- package/cjs/scenegraph/refresh-node/update-chart.js +31 -5
- package/cjs/scenegraph/refresh-node/update-chart.js.map +1 -1
- package/cjs/scenegraph/scenegraph.d.ts +1 -2
- package/cjs/scenegraph/scenegraph.js +11 -41
- package/cjs/scenegraph/scenegraph.js.map +1 -1
- package/cjs/scenegraph/stick-text/index.js +4 -4
- package/cjs/scenegraph/stick-text/index.js.map +1 -1
- package/cjs/scenegraph/style/corner-cell.d.ts +3 -0
- package/cjs/scenegraph/style/corner-cell.js +29 -0
- package/cjs/scenegraph/style/corner-cell.js.map +1 -0
- package/cjs/scenegraph/style/frame-border.d.ts +1 -0
- package/cjs/scenegraph/style/frame-border.js +2 -2
- package/cjs/scenegraph/style/frame-border.js.map +1 -1
- package/cjs/scenegraph/utils/get-cell-merge.js +2 -1
- package/cjs/scenegraph/utils/get-cell-merge.js.map +1 -1
- package/cjs/themes/DARK.js +1 -2
- package/cjs/themes/DEFAULT.js +2 -1
- package/cjs/themes/theme.d.ts +10 -0
- package/cjs/themes/theme.js +50 -4
- package/cjs/themes/theme.js.map +1 -1
- package/cjs/tools/debounce.js +1 -1
- package/cjs/ts-types/customElement.d.ts +2 -0
- package/cjs/ts-types/customElement.js.map +1 -1
- package/cjs/ts-types/events.d.ts +8 -0
- package/cjs/ts-types/events.js.map +1 -1
- package/cjs/ts-types/list-table/define/basic-define.js.map +1 -1
- package/cjs/ts-types/list-table/define/chart-define.d.ts +1 -1
- package/cjs/ts-types/list-table/define/chart-define.js.map +1 -1
- package/cjs/ts-types/list-table/layout-map/api.d.ts +2 -2
- package/cjs/ts-types/list-table/layout-map/api.js.map +1 -1
- package/cjs/ts-types/new-data-set.d.ts +1 -0
- package/cjs/ts-types/new-data-set.js.map +1 -1
- package/cjs/ts-types/pivot-table/indicator/basic-indicator.js.map +1 -1
- package/cjs/ts-types/pivot-table/indicator/chart-indicator.d.ts +1 -1
- package/cjs/ts-types/pivot-table/indicator/chart-indicator.js.map +1 -1
- package/cjs/ts-types/theme.d.ts +5 -0
- package/cjs/ts-types/theme.js.map +1 -1
- package/dist/vtable.js +35578 -33046
- package/dist/vtable.min.js +4 -4
- package/es/PivotChart.d.ts +1 -0
- package/es/PivotChart.js +8 -0
- package/es/PivotChart.js.map +1 -1
- package/es/{chartType.js → chartModule.js} +2 -2
- package/es/chartModule.js.map +1 -0
- package/es/core/BaseTable.js +26 -9
- package/es/core/BaseTable.js.map +1 -1
- package/es/core/TABLE_EVENT_TYPE.d.ts +2 -0
- package/es/core/TABLE_EVENT_TYPE.js +3 -1
- package/es/core/TABLE_EVENT_TYPE.js.map +1 -1
- package/es/dataset/dataset-pivot-table.d.ts +60 -0
- package/es/dataset/dataset-pivot-table.js +378 -0
- package/es/dataset/dataset-pivot-table.js.map +1 -0
- package/es/dataset/dataset.d.ts +2 -0
- package/es/dataset/dataset.js +29 -18
- package/es/dataset/dataset.js.map +1 -1
- package/es/event/event.js +3 -1
- package/es/event/event.js.map +1 -1
- package/es/event/pivot-chart/axis-hover.d.ts +2 -0
- package/es/event/pivot-chart/axis-hover.js +33 -0
- package/es/event/pivot-chart/axis-hover.js.map +1 -0
- package/es/event/scroll.js +4 -3
- package/es/event/scroll.js.map +1 -1
- package/es/event/sparkline-event.js +1 -2
- package/es/event/util.js +2 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/layout/{pivot-chart → chart-helper}/get-axis-config.js +4 -4
- package/es/layout/chart-helper/get-axis-config.js.map +1 -0
- package/es/layout/chart-helper/get-chart-spec.d.ts +7 -0
- package/es/layout/{pivot-chart → chart-helper}/get-chart-spec.js +21 -4
- package/es/layout/chart-helper/get-chart-spec.js.map +1 -0
- package/es/layout/pivot-header-layout.d.ts +2 -0
- package/es/layout/pivot-header-layout.js +9 -1
- package/es/layout/pivot-header-layout.js.map +1 -1
- package/es/layout/pivot-layout.d.ts +1 -0
- package/es/layout/pivot-layout.js +13 -9
- package/es/layout/pivot-layout.js.map +1 -1
- package/es/layout/simple-header-layout.d.ts +2 -0
- package/es/layout/simple-header-layout.js +10 -1
- package/es/layout/simple-header-layout.js.map +1 -1
- package/es/plugins/chartModules.js +2 -0
- package/es/plugins/chartModules.js.map +1 -0
- package/es/register.d.ts +1 -1
- package/es/register.js +3 -3
- package/es/register.js.map +1 -1
- package/es/render/layout/text.d.ts +33 -4
- package/es/render/layout/text.js +9 -3
- package/es/render/layout/text.js.map +1 -1
- package/es/scenegraph/component/custom.js +17 -16
- package/es/scenegraph/component/custom.js.map +1 -1
- package/es/scenegraph/component/menu.d.ts +41 -0
- package/es/scenegraph/graphic/chart.d.ts +1 -1
- package/es/scenegraph/graphic/chart.js +8 -11
- package/es/scenegraph/graphic/chart.js.map +1 -1
- package/es/scenegraph/graphic/contributions/chart-render.js +10 -3
- package/es/scenegraph/graphic/contributions/chart-render.js.map +1 -1
- package/es/scenegraph/graphic/contributions/group-contribution-render.d.ts +9 -9
- package/es/scenegraph/graphic/contributions/group-contribution-render.js +48 -29
- package/es/scenegraph/graphic/contributions/group-contribution-render.js.map +1 -1
- package/es/scenegraph/graphic/contributions/image-contribution-render.d.ts +3 -3
- package/es/scenegraph/graphic/contributions/image-contribution-render.js +2 -2
- package/es/scenegraph/graphic/contributions/image-contribution-render.js.map +1 -1
- package/es/scenegraph/graphic/contributions/rect-contribution-render.d.ts +3 -3
- package/es/scenegraph/graphic/contributions/rect-contribution-render.js +2 -2
- package/es/scenegraph/graphic/contributions/rect-contribution-render.js.map +1 -1
- package/es/scenegraph/graphic/text.d.ts +15 -0
- package/es/scenegraph/group-creater/cell-helper.js +2 -1
- package/es/scenegraph/group-creater/cell-helper.js.map +1 -1
- package/es/scenegraph/group-creater/cell-type/chart-cell.d.ts +1 -1
- package/es/scenegraph/group-creater/cell-type/chart-cell.js +4 -4
- package/es/scenegraph/group-creater/cell-type/chart-cell.js.map +1 -1
- package/es/scenegraph/layout/update-width.js +33 -1
- package/es/scenegraph/layout/update-width.js.map +1 -1
- package/es/scenegraph/refresh-node/update-chart.js +27 -2
- package/es/scenegraph/refresh-node/update-chart.js.map +1 -1
- package/es/scenegraph/scenegraph.d.ts +1 -2
- package/es/scenegraph/scenegraph.js +11 -40
- package/es/scenegraph/scenegraph.js.map +1 -1
- package/es/scenegraph/stick-text/index.js +4 -4
- package/es/scenegraph/stick-text/index.js.map +1 -1
- package/es/scenegraph/style/corner-cell.d.ts +3 -0
- package/es/scenegraph/style/corner-cell.js +25 -0
- package/es/scenegraph/style/corner-cell.js.map +1 -0
- package/es/scenegraph/style/frame-border.d.ts +1 -0
- package/es/scenegraph/style/frame-border.js +1 -1
- package/es/scenegraph/style/frame-border.js.map +1 -1
- package/es/scenegraph/utils/get-cell-merge.js +2 -1
- package/es/scenegraph/utils/get-cell-merge.js.map +1 -1
- package/es/themes/DARK.js +1 -2
- package/es/themes/DEFAULT.js +2 -1
- package/es/themes/theme.d.ts +10 -0
- package/es/themes/theme.js +50 -4
- package/es/themes/theme.js.map +1 -1
- package/es/tools/debounce.js +1 -1
- package/es/ts-types/customElement.d.ts +2 -0
- package/es/ts-types/customElement.js.map +1 -1
- package/es/ts-types/events.d.ts +8 -0
- package/es/ts-types/events.js.map +1 -1
- package/es/ts-types/list-table/define/basic-define.js.map +1 -1
- package/es/ts-types/list-table/define/chart-define.d.ts +1 -1
- package/es/ts-types/list-table/define/chart-define.js.map +1 -1
- package/es/ts-types/list-table/layout-map/api.d.ts +2 -2
- package/es/ts-types/list-table/layout-map/api.js.map +1 -1
- package/es/ts-types/new-data-set.d.ts +1 -0
- package/es/ts-types/new-data-set.js.map +1 -1
- package/es/ts-types/pivot-table/indicator/basic-indicator.js.map +1 -1
- package/es/ts-types/pivot-table/indicator/chart-indicator.d.ts +1 -1
- package/es/ts-types/pivot-table/indicator/chart-indicator.js.map +1 -1
- package/es/ts-types/theme.d.ts +5 -0
- package/es/ts-types/theme.js.map +1 -1
- package/package.json +9 -9
- package/cjs/chartType.js +0 -14
- package/cjs/chartType.js.map +0 -1
- package/cjs/layout/pivot-chart/get-axis-config.js.map +0 -1
- package/cjs/layout/pivot-chart/get-chart-spec.d.ts +0 -4
- package/cjs/layout/pivot-chart/get-chart-spec.js.map +0 -1
- package/cjs/plugins/chartTypes.js.map +0 -1
- package/es/chartType.js.map +0 -1
- package/es/layout/pivot-chart/get-axis-config.js.map +0 -1
- package/es/layout/pivot-chart/get-chart-spec.d.ts +0 -4
- package/es/layout/pivot-chart/get-chart-spec.js.map +0 -1
- package/es/plugins/chartTypes.js +0 -2
- package/es/plugins/chartTypes.js.map +0 -1
- /package/cjs/{chartType.d.ts → chartModule.d.ts} +0 -0
- /package/cjs/layout/{pivot-chart → chart-helper}/get-axis-config.d.ts +0 -0
- /package/cjs/plugins/{chartTypes.d.ts → chartModules.d.ts} +0 -0
- /package/es/{chartType.d.ts → chartModule.d.ts} +0 -0
- /package/es/layout/{pivot-chart → chart-helper}/get-axis-config.d.ts +0 -0
- /package/es/plugins/{chartTypes.d.ts → chartModules.d.ts} +0 -0
|
@@ -29,5 +29,7 @@ export interface TableEvents {
|
|
|
29
29
|
LEGEND_ITEM_CLICK: 'legend_item_click';
|
|
30
30
|
LEGEND_ITEM_HOVER: 'legend_item_hover';
|
|
31
31
|
LEGEND_ITEM_UNHOVER: 'legend_item_unHover';
|
|
32
|
+
MOUSEENTER_AXIS: 'mouseenter_axis';
|
|
33
|
+
MOUSELEAVE_AXIS: 'mouseleave_axis';
|
|
32
34
|
}
|
|
33
35
|
export declare const TABLE_EVENT_TYPE: TableEvents;
|
|
@@ -32,6 +32,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
32
32
|
ICON_CLICK: "icon_click",
|
|
33
33
|
LEGEND_ITEM_CLICK: "legend_item_click",
|
|
34
34
|
LEGEND_ITEM_HOVER: "legend_item_hover",
|
|
35
|
-
LEGEND_ITEM_UNHOVER: "legend_item_unHover"
|
|
35
|
+
LEGEND_ITEM_UNHOVER: "legend_item_unHover",
|
|
36
|
+
MOUSEENTER_AXIS: "mouseenter_axis",
|
|
37
|
+
MOUSELEAVE_AXIS: "mouseleave_axis"
|
|
36
38
|
};
|
|
37
39
|
//# sourceMappingURL=TABLE_EVENT_TYPE.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["core/TABLE_EVENT_TYPE.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"sources":["core/TABLE_EVENT_TYPE.ts"],"names":[],"mappings":";;;AAyHa,QAAA,gBAAgB,GAAgB;IAC3C,UAAU,EAAE,YAAY;IACxB,aAAa,EAAE,eAAe;IAC9B,cAAc,EAAE,gBAAgB;IAChC,YAAY,EAAE,cAAc;IAC5B,aAAa,EAAE,eAAe;IAC9B,OAAO,EAAE,SAAS;IAClB,gBAAgB,EAAE,kBAAkB;IACpC,gBAAgB,EAAE,kBAAkB;IACpC,cAAc,EAAE,gBAAgB;IAChC,eAAe,EAAE,iBAAiB;IAClC,eAAe,EAAE,iBAAiB;IAClC,gBAAgB,EAAE,kBAAkB;IACpC,aAAa,EAAE,eAAe;IAC9B,iBAAiB,EAAE,mBAAmB;IACtC,sBAAsB,EAAE,wBAAwB;IAChD,UAAU,EAAE,YAAY;IACxB,YAAY,EAAE,cAAc;IAC5B,MAAM,EAAE,QAAQ;IAChB,kBAAkB,EAAE,oBAAoB;IACxC,sBAAsB,EAAE,wBAAwB;IAChD,eAAe,EAAE,iBAAiB;IAElC,mBAAmB,EAAE,qBAAqB;IAC1C,mBAAmB,EAAE,qBAAqB;IAE1C,2BAA2B,EAAE,6BAA6B;IAE1D,SAAS,EAAE,WAAW;IACtB,SAAS,EAAE,WAAW;IAEtB,UAAU,EAAE,YAAY;IAExB,iBAAiB,EAAE,mBAAmB;IACtC,iBAAiB,EAAE,mBAAmB;IACtC,mBAAmB,EAAE,qBAAqB;IAE1C,eAAe,EAAE,iBAAiB;IAClC,eAAe,EAAE,iBAAiB;CACpB,CAAC","file":"TABLE_EVENT_TYPE.js","sourcesContent":["export interface TableEvents {\n /**\n * 鼠标点击单元格事件\n */\n CLICK_CELL: 'click_cell';\n /**\n * 鼠标双击单元格事件\n */\n DBLCLICK_CELL: 'dblclick_cell';\n /**\n * 单元格上鼠标按下事件\n */\n MOUSEDOWN_CELL: 'mousedown_cell';\n /**\n * 单元格鼠标松开事件\n */\n MOUSEUP_CELL: 'mouseup_cell';\n\n /**\n * 单元格选中状态改变事件\n */\n SELECTED_CELL: 'selected_cell';\n /**\n * 键盘按下事件\n */\n KEYDOWN: 'keydown';\n /**\n * 鼠标进入表格事件\n */\n MOUSEENTER_TABLE: 'mouseenter_table';\n /**\n * 鼠标离开表格事件\n */\n MOUSELEAVE_TABLE: 'mouseleave_table';\n /**\n * 鼠标在某个单元格上移动事件\n */\n MOUSEMOVE_CELL: 'mousemove_cell';\n /**\n * 鼠标进入单元格事件\n */\n MOUSEENTER_CELL: 'mouseenter_cell';\n /**\n * 鼠标离开单元格事件\n */\n MOUSELEAVE_CELL: 'mouseleave_cell';\n /**\n * 单元格右键事件\n */\n CONTEXTMENU_CELL: 'contextmenu_cell';\n /**\n * 列宽调整事件\n */\n RESIZE_COLUMN: 'resize_column';\n /**\n * 列宽调整结束事件\n */\n RESIZE_COLUMN_END: 'resize_column_end';\n /**\n * 拖拽表头移动位置的事件\n */\n CHANGE_HEADER_POSITION: 'change_header_position';\n /**\n * 点击排序图标事件\n */\n SORT_CLICK: 'sort_click';\n /**\n * 点击固定列图标 冻结或者解冻事件\n */\n FREEZE_CLICK: 'freeze_click';\n /**\n * 滚动表格事件\n */\n SCROLL: 'scroll';\n\n /**\n * 点击下拉菜单图标事件\n */\n DROPDOWNMENU_CLICK: 'dropdownmenu_click';\n /**\n * 鼠标经过迷你图标记事件\n */\n MOUSEOVER_CHART_SYMBOL: 'mouseover_chart_symbol';\n\n /**\n * 拖拽框选单元格鼠标松开事件\n */\n DRAG_SELECT_END: 'drag_select_end';\n\n /**\n * 点击下拉菜单按钮\n */\n DROPDOWN_ICON_CLICK: 'dropdown_icon_click';\n /**\n * 清空下拉菜单事件(菜单显示时点击其他区域)\n */\n DROPDOWN_MENU_CLEAR: 'dropdown_menu_clear';\n\n /**\n * 树形结构展开收起的点击事件\n */\n TREE_HIERARCHY_STATE_CHANGE: 'tree_hierarchy_state_change';\n\n SHOW_MENU: 'show_menu';\n HIDE_MENU: 'hide_menu';\n /**\n * icon图标点击事件\n */\n ICON_CLICK: 'icon_click';\n\n // legend component\n LEGEND_ITEM_CLICK: 'legend_item_click';\n LEGEND_ITEM_HOVER: 'legend_item_hover';\n LEGEND_ITEM_UNHOVER: 'legend_item_unHover';\n\n MOUSEENTER_AXIS: 'mouseenter_axis';\n MOUSELEAVE_AXIS: 'mouseleave_axis';\n}\n/**\n * Table event types\n */\nexport const TABLE_EVENT_TYPE: TableEvents = {\n CLICK_CELL: 'click_cell',\n DBLCLICK_CELL: 'dblclick_cell',\n MOUSEDOWN_CELL: 'mousedown_cell',\n MOUSEUP_CELL: 'mouseup_cell',\n SELECTED_CELL: 'selected_cell',\n KEYDOWN: 'keydown',\n MOUSEENTER_TABLE: 'mouseenter_table',\n MOUSELEAVE_TABLE: 'mouseleave_table',\n MOUSEMOVE_CELL: 'mousemove_cell',\n MOUSEENTER_CELL: 'mouseenter_cell',\n MOUSELEAVE_CELL: 'mouseleave_cell',\n CONTEXTMENU_CELL: 'contextmenu_cell',\n RESIZE_COLUMN: 'resize_column',\n RESIZE_COLUMN_END: 'resize_column_end',\n CHANGE_HEADER_POSITION: 'change_header_position',\n SORT_CLICK: 'sort_click',\n FREEZE_CLICK: 'freeze_click',\n SCROLL: 'scroll',\n DROPDOWNMENU_CLICK: 'dropdownmenu_click',\n MOUSEOVER_CHART_SYMBOL: 'mouseover_chart_symbol',\n DRAG_SELECT_END: 'drag_select_end',\n\n DROPDOWN_ICON_CLICK: 'dropdown_icon_click', // 点击下拉菜单按钮\n DROPDOWN_MENU_CLEAR: 'dropdown_menu_clear', // 清空下拉菜单事件(菜单显示时点击其他区域)\n\n TREE_HIERARCHY_STATE_CHANGE: 'tree_hierarchy_state_change', //树形结构展开收起的点击事件\n\n SHOW_MENU: 'show_menu',\n HIDE_MENU: 'hide_menu',\n\n ICON_CLICK: 'icon_click',\n\n LEGEND_ITEM_CLICK: 'legend_item_click',\n LEGEND_ITEM_HOVER: 'legend_item_hover',\n LEGEND_ITEM_UNHOVER: 'legend_item_unHover',\n\n MOUSEENTER_AXIS: 'mouseenter_axis',\n MOUSELEAVE_AXIS: 'mouseleave_axis'\n} as TableEvents;\n"]}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { FilterRules, IDataConfig, SortRule, AggregationRules, SortRules, DerivedFieldRules, Totals, MappingRules, IHeaderTreeDefine } from '../ts-types';
|
|
2
|
+
import type { Aggregator } from './statistics-helper';
|
|
3
|
+
import { typeSort } from './statistics-helper';
|
|
4
|
+
export declare class DatasetForPivotTable {
|
|
5
|
+
dataConfig: IDataConfig;
|
|
6
|
+
records: any[];
|
|
7
|
+
tree: Record<string, Record<string, Aggregator[]>>;
|
|
8
|
+
private colFlatKeys;
|
|
9
|
+
private rowFlatKeys;
|
|
10
|
+
colKeys: string[][];
|
|
11
|
+
rowKeys: string[][];
|
|
12
|
+
rowKeysPath: string[][];
|
|
13
|
+
colKeysPath: string[][];
|
|
14
|
+
rowOrder: string;
|
|
15
|
+
colOrder: string;
|
|
16
|
+
sorted: boolean;
|
|
17
|
+
sortRules: SortRules;
|
|
18
|
+
filterRules: FilterRules;
|
|
19
|
+
aggregationRules: AggregationRules;
|
|
20
|
+
derivedFieldRules: DerivedFieldRules;
|
|
21
|
+
mappingRules: MappingRules;
|
|
22
|
+
totals: Totals;
|
|
23
|
+
indicatorStatistics: {
|
|
24
|
+
max: Aggregator;
|
|
25
|
+
min: Aggregator;
|
|
26
|
+
total: Aggregator;
|
|
27
|
+
}[];
|
|
28
|
+
aggregators: {
|
|
29
|
+
[key: string]: {
|
|
30
|
+
new (dimension: string | string[], formatFun?: any, isRecord?: boolean): Aggregator;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
stringJoinChar: string;
|
|
34
|
+
private rowsIsTotal;
|
|
35
|
+
private colsIsTotal;
|
|
36
|
+
private colGrandTotalLabel;
|
|
37
|
+
private colSubTotalLabel;
|
|
38
|
+
private rowGrandTotalLabel;
|
|
39
|
+
private rowSubTotalLabel;
|
|
40
|
+
rows: string[];
|
|
41
|
+
columns: string[];
|
|
42
|
+
indicatorKeys: string[];
|
|
43
|
+
constructor(dataConfig: IDataConfig, rows: string[], columns: string[], indicators: string[], records: any[], customColTree?: IHeaderTreeDefine[], customRowTree?: IHeaderTreeDefine[]);
|
|
44
|
+
registerAggregator(type: string, aggregator: any): void;
|
|
45
|
+
registerAggregators(): void;
|
|
46
|
+
setRecords(records: any[]): void;
|
|
47
|
+
processRecords(): void;
|
|
48
|
+
filterRecord(record: any): boolean;
|
|
49
|
+
processRecord(record: any): void;
|
|
50
|
+
updateSortRules(sortRules: SortRules): void;
|
|
51
|
+
private getAggregatorRule;
|
|
52
|
+
getAggregator(rowKey: string[] | string, colKey: string[] | string, indicator: string): Aggregator;
|
|
53
|
+
sortKeys(): void;
|
|
54
|
+
arrSort(fieldArr: string[], isRow: boolean): (a: string[], b: string[]) => number;
|
|
55
|
+
getSort(sortRule: SortRule, isSortRow: boolean): typeof typeSort;
|
|
56
|
+
totalStatistics(): void;
|
|
57
|
+
private ArrToTree;
|
|
58
|
+
private TreeToArr;
|
|
59
|
+
private TreeToArr2;
|
|
60
|
+
}
|
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: !0
|
|
5
|
+
}), exports.DatasetForPivotTable = void 0;
|
|
6
|
+
|
|
7
|
+
const ts_types_1 = require("../ts-types"), statistics_helper_1 = require("./statistics-helper");
|
|
8
|
+
|
|
9
|
+
class DatasetForPivotTable {
|
|
10
|
+
constructor(dataConfig, rows, columns, indicators, records, customColTree, customRowTree) {
|
|
11
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2;
|
|
12
|
+
this.tree = {}, this.colFlatKeys = {}, this.rowFlatKeys = {}, this.colKeys = [],
|
|
13
|
+
this.rowKeys = [], this.rowOrder = "key_a_to_z", this.colOrder = "key_a_to_z", this.sorted = !1,
|
|
14
|
+
this.indicatorStatistics = [], this.aggregators = {}, this.stringJoinChar = String.fromCharCode(0),
|
|
15
|
+
this.rowsIsTotal = [], this.colsIsTotal = [], this.registerAggregators(), this.dataConfig = dataConfig,
|
|
16
|
+
this.sortRules = null === (_a = this.dataConfig) || void 0 === _a ? void 0 : _a.sortRules,
|
|
17
|
+
this.aggregationRules = null === (_b = this.dataConfig) || void 0 === _b ? void 0 : _b.aggregationRules,
|
|
18
|
+
this.derivedFieldRules = null === (_c = this.dataConfig) || void 0 === _c ? void 0 : _c.derivedFieldRules,
|
|
19
|
+
this.mappingRules = null === (_d = this.dataConfig) || void 0 === _d ? void 0 : _d.mappingRules,
|
|
20
|
+
this.totals = null === (_e = this.dataConfig) || void 0 === _e ? void 0 : _e.totals,
|
|
21
|
+
this.rows = rows, this.columns = columns, this.indicatorKeys = indicators, this.colGrandTotalLabel = null !== (_h = null === (_g = null === (_f = this.totals) || void 0 === _f ? void 0 : _f.column) || void 0 === _g ? void 0 : _g.grandTotalLabel) && void 0 !== _h ? _h : "总计",
|
|
22
|
+
this.colSubTotalLabel = null !== (_l = null === (_k = null === (_j = this.totals) || void 0 === _j ? void 0 : _j.column) || void 0 === _k ? void 0 : _k.subTotalLabel) && void 0 !== _l ? _l : "小计",
|
|
23
|
+
this.rowGrandTotalLabel = null !== (_p = null === (_o = null === (_m = this.totals) || void 0 === _m ? void 0 : _m.row) || void 0 === _o ? void 0 : _o.grandTotalLabel) && void 0 !== _p ? _p : "总计",
|
|
24
|
+
this.rowSubTotalLabel = null !== (_s = null === (_r = null === (_q = this.totals) || void 0 === _q ? void 0 : _q.row) || void 0 === _r ? void 0 : _r.subTotalLabel) && void 0 !== _s ? _s : "小计",
|
|
25
|
+
this.rowsIsTotal = new Array(this.rows.length).fill(!1), this.colsIsTotal = new Array(this.columns.length).fill(!1);
|
|
26
|
+
for (let i = 0, len = null === (_v = null === (_u = null === (_t = this.totals) || void 0 === _t ? void 0 : _t.row) || void 0 === _u ? void 0 : _u.subTotalsDimensions) || void 0 === _v ? void 0 : _v.length; i < len; i++) {
|
|
27
|
+
const dimension = this.totals.row.subTotalsDimensions[i], dimensionIndex = this.rows.indexOf(dimension);
|
|
28
|
+
this.rowsIsTotal[dimensionIndex] = !0;
|
|
29
|
+
}
|
|
30
|
+
for (let i = 0, len = null === (_y = null === (_x = null === (_w = this.totals) || void 0 === _w ? void 0 : _w.column) || void 0 === _x ? void 0 : _x.subTotalsDimensions) || void 0 === _y ? void 0 : _y.length; i < len; i++) {
|
|
31
|
+
const dimension = this.totals.column.subTotalsDimensions[i], dimensionIndex = this.columns.indexOf(dimension);
|
|
32
|
+
this.colsIsTotal[dimensionIndex] = !0;
|
|
33
|
+
}
|
|
34
|
+
if (records) {
|
|
35
|
+
this.records = records;
|
|
36
|
+
const t0 = "undefined" != typeof window ? window.performance.now() : 0;
|
|
37
|
+
this.setRecords(records);
|
|
38
|
+
const t1 = "undefined" != typeof window ? window.performance.now() : 0;
|
|
39
|
+
console.log("processRecords:", t1 - t0);
|
|
40
|
+
const t4 = "undefined" != typeof window ? window.performance.now() : 0;
|
|
41
|
+
this.totalStatistics();
|
|
42
|
+
const t5 = "undefined" != typeof window ? window.performance.now() : 0;
|
|
43
|
+
console.log("totalStatistics:", t5 - t4);
|
|
44
|
+
const t2 = "undefined" != typeof window ? window.performance.now() : 0;
|
|
45
|
+
this.sortKeys();
|
|
46
|
+
const t3 = "undefined" != typeof window ? window.performance.now() : 0;
|
|
47
|
+
console.log("sortKeys:", t3 - t2);
|
|
48
|
+
const t7 = "undefined" != typeof window ? window.performance.now() : 0;
|
|
49
|
+
this.rowKeysPath = customRowTree ? this.TreeToArr2(customRowTree) : this.TreeToArr(this.ArrToTree(this.rowKeys, this.rowsIsTotal, (null === (_0 = null === (_z = null == this ? void 0 : this.totals) || void 0 === _z ? void 0 : _z.row) || void 0 === _0 ? void 0 : _0.showGrandTotals) || 0 === this.columns.length, this.rowGrandTotalLabel, this.rowSubTotalLabel)),
|
|
50
|
+
this.colKeysPath = customColTree ? this.TreeToArr2(customColTree) : this.TreeToArr(this.ArrToTree(this.colKeys, this.colsIsTotal, (null === (_2 = null === (_1 = this.totals) || void 0 === _1 ? void 0 : _1.column) || void 0 === _2 ? void 0 : _2.showGrandTotals) || 0 === this.rows.length, this.colGrandTotalLabel, this.colSubTotalLabel));
|
|
51
|
+
const t8 = "undefined" != typeof window ? window.performance.now() : 0;
|
|
52
|
+
console.log("TreeToArr:", t8 - t7);
|
|
53
|
+
}
|
|
54
|
+
delete this.rowFlatKeys, delete this.colFlatKeys;
|
|
55
|
+
}
|
|
56
|
+
registerAggregator(type, aggregator) {
|
|
57
|
+
this.aggregators[type] = aggregator;
|
|
58
|
+
}
|
|
59
|
+
registerAggregators() {
|
|
60
|
+
this.registerAggregator(ts_types_1.AggregationType.SUM, statistics_helper_1.SumAggregator),
|
|
61
|
+
this.registerAggregator(ts_types_1.AggregationType.COUNT, statistics_helper_1.CountAggregator),
|
|
62
|
+
this.registerAggregator(ts_types_1.AggregationType.MAX, statistics_helper_1.MaxAggregator),
|
|
63
|
+
this.registerAggregator(ts_types_1.AggregationType.MIN, statistics_helper_1.MinAggregator),
|
|
64
|
+
this.registerAggregator(ts_types_1.AggregationType.AVG, statistics_helper_1.AvgAggregator);
|
|
65
|
+
}
|
|
66
|
+
setRecords(records) {
|
|
67
|
+
this.processRecords();
|
|
68
|
+
}
|
|
69
|
+
processRecords() {
|
|
70
|
+
for (let i = 0, len = this.records.length; i < len; i++) {
|
|
71
|
+
const record = this.records[i];
|
|
72
|
+
this.filterRecord(record) && this.processRecord(record);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
filterRecord(record) {
|
|
76
|
+
var _a, _b, _c, _d;
|
|
77
|
+
let isReserved = !0;
|
|
78
|
+
for (let i = 0; i < (null === (_b = null === (_a = this.dataConfig) || void 0 === _a ? void 0 : _a.filterRules) || void 0 === _b ? void 0 : _b.length); i++) {
|
|
79
|
+
const filterRule = null === (_c = this.dataConfig) || void 0 === _c ? void 0 : _c.filterRules[i];
|
|
80
|
+
if (!(null === (_d = filterRule.filterFunc) || void 0 === _d ? void 0 : _d.call(filterRule, record))) {
|
|
81
|
+
isReserved = !1;
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return isReserved;
|
|
86
|
+
}
|
|
87
|
+
processRecord(record) {
|
|
88
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
89
|
+
null === (_a = this.derivedFieldRules) || void 0 === _a || _a.forEach(((derivedFieldRule, i) => {
|
|
90
|
+
record[derivedFieldRule.fieldName] = derivedFieldRule.derivedFunc(record);
|
|
91
|
+
}));
|
|
92
|
+
const colKey = [], rowKey = [];
|
|
93
|
+
for (let l = 0, len1 = this.rows.length; l < len1; l++) {
|
|
94
|
+
const rowAttr = this.rows[l];
|
|
95
|
+
rowKey.push(record[rowAttr]);
|
|
96
|
+
}
|
|
97
|
+
for (let n = 0, len2 = this.columns.length; n < len2; n++) {
|
|
98
|
+
const colAttr = this.columns[n];
|
|
99
|
+
colKey.push(record[colAttr]);
|
|
100
|
+
}
|
|
101
|
+
const flatRowKey = rowKey.join(this.stringJoinChar), flatColKey = colKey.join(this.stringJoinChar);
|
|
102
|
+
if (0 !== rowKey.length && (this.rowFlatKeys[flatRowKey] || (this.rowKeys.push(rowKey),
|
|
103
|
+
this.rowFlatKeys[flatRowKey] = 1)), 0 !== colKey.length && (this.colFlatKeys[flatColKey] || (this.colKeys.push(colKey),
|
|
104
|
+
this.colFlatKeys[flatColKey] = 1)), 0 !== colKey.length || 0 !== rowKey.length) {
|
|
105
|
+
this.tree[flatRowKey] || (this.tree[flatRowKey] = {}), (null === (_b = this.tree[flatRowKey]) || void 0 === _b ? void 0 : _b[flatColKey]) || (this.tree[flatRowKey][flatColKey] = []);
|
|
106
|
+
for (let i = 0; i < this.indicatorKeys.length; i++) {
|
|
107
|
+
if (!(null === (_d = null === (_c = this.tree[flatRowKey]) || void 0 === _c ? void 0 : _c[flatColKey]) || void 0 === _d ? void 0 : _d[i])) {
|
|
108
|
+
const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
|
|
109
|
+
this.tree[flatRowKey][flatColKey][i] = new this.aggregators[null !== (_e = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _e ? _e : ts_types_1.AggregationType.SUM](null !== (_f = null == aggRule ? void 0 : aggRule.field) && void 0 !== _f ? _f : this.indicatorKeys[i], null == aggRule ? void 0 : aggRule.formatFun);
|
|
110
|
+
}
|
|
111
|
+
null === (_h = null === (_g = this.tree[flatRowKey]) || void 0 === _g ? void 0 : _g[flatColKey]) || void 0 === _h || _h[i].push(record);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (this.mappingRules) for (let i = 0; i < this.indicatorKeys.length; i++) {
|
|
115
|
+
if (!this.indicatorStatistics[i]) {
|
|
116
|
+
const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
|
|
117
|
+
this.indicatorStatistics[i] = {
|
|
118
|
+
max: new this.aggregators[ts_types_1.AggregationType.MAX](this.indicatorKeys[i]),
|
|
119
|
+
min: new this.aggregators[ts_types_1.AggregationType.MIN](this.indicatorKeys[i]),
|
|
120
|
+
total: new this.aggregators[null !== (_j = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _j ? _j : ts_types_1.AggregationType.SUM](null !== (_k = null == aggRule ? void 0 : aggRule.field) && void 0 !== _k ? _k : this.indicatorKeys[i], null == aggRule ? void 0 : aggRule.formatFun)
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
this.indicatorStatistics[i].max.push(null === (_m = null === (_l = this.tree[flatRowKey]) || void 0 === _l ? void 0 : _l[flatColKey]) || void 0 === _m ? void 0 : _m[i].value()),
|
|
124
|
+
this.indicatorStatistics[i].min.push(null === (_p = null === (_o = this.tree[flatRowKey]) || void 0 === _o ? void 0 : _o[flatColKey]) || void 0 === _p ? void 0 : _p[i].value()),
|
|
125
|
+
this.indicatorStatistics[i].total.push(record);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
updateSortRules(sortRules) {
|
|
129
|
+
var _a, _b, _c, _d;
|
|
130
|
+
this.sorted = !1, this.sortRules = sortRules, this.sortKeys(), this.rowKeysPath = this.TreeToArr(this.ArrToTree(this.rowKeys, this.rowsIsTotal, (null === (_b = null === (_a = null == this ? void 0 : this.totals) || void 0 === _a ? void 0 : _a.row) || void 0 === _b ? void 0 : _b.showGrandTotals) || 0 === this.columns.length, this.rowGrandTotalLabel, this.rowSubTotalLabel)),
|
|
131
|
+
this.colKeysPath = this.TreeToArr(this.ArrToTree(this.colKeys, this.colsIsTotal, (null === (_d = null === (_c = this.totals) || void 0 === _c ? void 0 : _c.column) || void 0 === _d ? void 0 : _d.showGrandTotals) || 0 === this.rows.length, this.colGrandTotalLabel, this.colSubTotalLabel));
|
|
132
|
+
}
|
|
133
|
+
getAggregatorRule(indicatorKey) {
|
|
134
|
+
var _a;
|
|
135
|
+
return null === (_a = this.aggregationRules) || void 0 === _a ? void 0 : _a.find(((value, index) => indicatorKey === value.indicatorKey));
|
|
136
|
+
}
|
|
137
|
+
getAggregator(rowKey = [], colKey = [], indicator) {
|
|
138
|
+
var _a, _b;
|
|
139
|
+
const indicatorIndex = this.indicatorKeys.indexOf(indicator);
|
|
140
|
+
let agg, flatRowKey, flatColKey;
|
|
141
|
+
return flatRowKey = "string" == typeof rowKey ? rowKey : rowKey.join(this.stringJoinChar),
|
|
142
|
+
flatColKey = "string" == typeof colKey ? colKey : colKey.join(this.stringJoinChar),
|
|
143
|
+
0 === rowKey.length && 0 === colKey.length || (agg = null === (_b = null === (_a = this.tree[flatRowKey]) || void 0 === _a ? void 0 : _a[flatColKey]) || void 0 === _b ? void 0 : _b[indicatorIndex]),
|
|
144
|
+
agg || {
|
|
145
|
+
className: "",
|
|
146
|
+
push() {},
|
|
147
|
+
value: () => null,
|
|
148
|
+
formatValue: () => "",
|
|
149
|
+
reset() {}
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
sortKeys() {
|
|
153
|
+
const that = this;
|
|
154
|
+
if (!this.sorted) {
|
|
155
|
+
this.sorted = !0;
|
|
156
|
+
const getValue = function(rowKey, colKey) {
|
|
157
|
+
return that.getAggregator(rowKey, colKey, "").value();
|
|
158
|
+
};
|
|
159
|
+
switch (this.rowOrder) {
|
|
160
|
+
case "value_a_to_z":
|
|
161
|
+
this.rowKeys.sort((function(a, b) {
|
|
162
|
+
return (0, statistics_helper_1.naturalSort)(getValue(a, []), getValue(b, []));
|
|
163
|
+
}));
|
|
164
|
+
break;
|
|
165
|
+
|
|
166
|
+
case "value_z_to_a":
|
|
167
|
+
this.rowKeys.sort((function(a, b) {
|
|
168
|
+
return -(0, statistics_helper_1.naturalSort)(getValue(a, []), getValue(b, []));
|
|
169
|
+
}));
|
|
170
|
+
break;
|
|
171
|
+
|
|
172
|
+
default:
|
|
173
|
+
this.rowKeys.sort(this.arrSort(this.rows, !0));
|
|
174
|
+
}
|
|
175
|
+
switch (this.colOrder) {
|
|
176
|
+
case "value_a_to_z":
|
|
177
|
+
this.colKeys.sort((function(a, b) {
|
|
178
|
+
return (0, statistics_helper_1.naturalSort)(getValue([], a), getValue([], b));
|
|
179
|
+
}));
|
|
180
|
+
break;
|
|
181
|
+
|
|
182
|
+
case "value_z_to_a":
|
|
183
|
+
this.colKeys.sort((function(a, b) {
|
|
184
|
+
return -(0, statistics_helper_1.naturalSort)(getValue([], a), getValue([], b));
|
|
185
|
+
}));
|
|
186
|
+
break;
|
|
187
|
+
|
|
188
|
+
default:
|
|
189
|
+
const sortfun = this.arrSort(this.columns, !1);
|
|
190
|
+
this.colKeys.sort(sortfun);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
arrSort(fieldArr, isRow) {
|
|
195
|
+
let field;
|
|
196
|
+
const that = this, sortersArr = function(_this) {
|
|
197
|
+
const results = [];
|
|
198
|
+
for (let l = 0, len1 = fieldArr.length; l < len1; l++) {
|
|
199
|
+
field = fieldArr[l];
|
|
200
|
+
let isHasSortRule = !1;
|
|
201
|
+
if (that.sortRules) for (let m = 0, len2 = that.sortRules.length; m < len2; m++) that.sortRules[m].sortField === field && (isHasSortRule = !0,
|
|
202
|
+
results.push({
|
|
203
|
+
field: field,
|
|
204
|
+
fieldIndex: l,
|
|
205
|
+
sortRule: that.sortRules[m],
|
|
206
|
+
func: that.getSort(that.sortRules[m], isRow)
|
|
207
|
+
}));
|
|
208
|
+
isHasSortRule || results.push({
|
|
209
|
+
field: field,
|
|
210
|
+
fieldIndex: l,
|
|
211
|
+
func: statistics_helper_1.naturalSort
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
return results;
|
|
215
|
+
}.call(this);
|
|
216
|
+
return function(a, b) {
|
|
217
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
218
|
+
let comparison, sorter;
|
|
219
|
+
for (let i = 0; i < sortersArr.length; i++) {
|
|
220
|
+
if (sorter = sortersArr[i], null === (_a = sorter.sortRule) || void 0 === _a ? void 0 : _a.sortByIndicator) {
|
|
221
|
+
let aChanged = a, bChanged = b;
|
|
222
|
+
sorter.fieldIndex < fieldArr.length - 1 && (aChanged = a.slice(0, sorter.fieldIndex + 1),
|
|
223
|
+
aChanged.push(isRow ? null === (_c = null === (_b = that.totals) || void 0 === _b ? void 0 : _b.row) || void 0 === _c ? void 0 : _c.subTotalLabel : null === (_e = null === (_d = that.totals) || void 0 === _d ? void 0 : _d.column) || void 0 === _e ? void 0 : _e.subTotalLabel),
|
|
224
|
+
bChanged = b.slice(0, sorter.fieldIndex + 1), bChanged.push(isRow ? null === (_g = null === (_f = that.totals) || void 0 === _f ? void 0 : _f.row) || void 0 === _g ? void 0 : _g.subTotalLabel : null === (_j = null === (_h = that.totals) || void 0 === _h ? void 0 : _h.column) || void 0 === _j ? void 0 : _j.subTotalLabel)),
|
|
225
|
+
comparison = sorter.func(aChanged, bChanged);
|
|
226
|
+
} else comparison = sorter.func(a[sorter.fieldIndex], b[sorter.fieldIndex]);
|
|
227
|
+
if (0 !== comparison) return comparison * ((null === (_k = sorter.sortRule) || void 0 === _k ? void 0 : _k.sortType) === ts_types_1.SortType.DESC ? -1 : 1);
|
|
228
|
+
}
|
|
229
|
+
return 0;
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
getSort(sortRule, isSortRow) {
|
|
233
|
+
const that = this;
|
|
234
|
+
return sortRule.sortByIndicator ? (a, b) => {
|
|
235
|
+
const getValue = function(rowKey, colKey) {
|
|
236
|
+
return rowKey.length < that.rows.length && rowKey[rowKey.length - 1] !== that.rowSubTotalLabel && rowKey[rowKey.length - 1] !== that.rowGrandTotalLabel && rowKey.push(that.rowSubTotalLabel),
|
|
237
|
+
colKey.length < that.columns.length && colKey[colKey.length - 1] !== that.colSubTotalLabel && colKey[colKey.length - 1] !== that.colGrandTotalLabel && colKey.push(that.colSubTotalLabel),
|
|
238
|
+
that.getAggregator(rowKey, colKey, sortRule.sortByIndicator).value();
|
|
239
|
+
};
|
|
240
|
+
return isSortRow ? (0, statistics_helper_1.naturalSort)(getValue(a, sortRule.query), getValue(b, sortRule.query)) : (0,
|
|
241
|
+
statistics_helper_1.naturalSort)(getValue(sortRule.query, a), getValue(sortRule.query, b));
|
|
242
|
+
} : sortRule.sortBy ? (0, statistics_helper_1.sortBy)(sortRule.sortBy) : sortRule.sortType ? statistics_helper_1.typeSort : sortRule.sortFunc ? sortRule.sortFunc : statistics_helper_1.naturalSort;
|
|
243
|
+
}
|
|
244
|
+
totalStatistics() {
|
|
245
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
246
|
+
const that = this;
|
|
247
|
+
if ((null === (_b = null === (_a = null == that ? void 0 : that.totals) || void 0 === _a ? void 0 : _a.column) || void 0 === _b ? void 0 : _b.showSubTotals) && (null === (_e = null === (_d = null === (_c = null == that ? void 0 : that.totals) || void 0 === _c ? void 0 : _c.column) || void 0 === _d ? void 0 : _d.subTotalsDimensions) || void 0 === _e ? void 0 : _e.length) >= 1 || (null === (_g = null === (_f = null == that ? void 0 : that.totals) || void 0 === _f ? void 0 : _f.row) || void 0 === _g ? void 0 : _g.showSubTotals) && (null === (_k = null === (_j = null === (_h = null == that ? void 0 : that.totals) || void 0 === _h ? void 0 : _h.row) || void 0 === _j ? void 0 : _j.subTotalsDimensions) || void 0 === _k ? void 0 : _k.length) >= 1 || (null === (_m = null === (_l = null == that ? void 0 : that.totals) || void 0 === _l ? void 0 : _l.column) || void 0 === _m ? void 0 : _m.showGrandTotals) || (null === (_p = null === (_o = null == that ? void 0 : that.totals) || void 0 === _o ? void 0 : _o.row) || void 0 === _p ? void 0 : _p.showGrandTotals) || 0 === that.rows.length || 0 === that.columns.length) {
|
|
248
|
+
const rowTotalKeys = [], colCompute = (flatRowKey, flatColKey) => {
|
|
249
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
250
|
+
const colKey = flatColKey.split(this.stringJoinChar);
|
|
251
|
+
for (let i = 0, len = null === (_c = null === (_b = null === (_a = that.totals) || void 0 === _a ? void 0 : _a.column) || void 0 === _b ? void 0 : _b.subTotalsDimensions) || void 0 === _c ? void 0 : _c.length; i < len; i++) {
|
|
252
|
+
const dimension = that.totals.column.subTotalsDimensions[i], dimensionIndex = that.columns.indexOf(dimension);
|
|
253
|
+
if (dimensionIndex >= 0) {
|
|
254
|
+
const colTotalKey = colKey.slice(0, dimensionIndex + 1);
|
|
255
|
+
colTotalKey.push(null !== (_f = null === (_e = null === (_d = that.totals) || void 0 === _d ? void 0 : _d.column) || void 0 === _e ? void 0 : _e.subTotalLabel) && void 0 !== _f ? _f : "小计");
|
|
256
|
+
const flatColTotalKey = colTotalKey.join(this.stringJoinChar);
|
|
257
|
+
this.tree[flatRowKey][flatColTotalKey] || (this.tree[flatRowKey][flatColTotalKey] = []);
|
|
258
|
+
for (let i = 0; i < this.indicatorKeys.length; i++) {
|
|
259
|
+
if (!this.tree[flatRowKey][flatColTotalKey][i]) {
|
|
260
|
+
const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
|
|
261
|
+
this.tree[flatRowKey][flatColTotalKey][i] = new this.aggregators[null !== (_g = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _g ? _g : ts_types_1.AggregationType.SUM](null !== (_h = null == aggRule ? void 0 : aggRule.field) && void 0 !== _h ? _h : this.indicatorKeys[i], null == aggRule ? void 0 : aggRule.formatFun);
|
|
262
|
+
}
|
|
263
|
+
this.tree[flatRowKey][flatColTotalKey][i].push(null === (_k = null === (_j = that.tree[flatRowKey]) || void 0 === _j ? void 0 : _j[flatColKey]) || void 0 === _k ? void 0 : _k[i]);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
if ((null === (_m = null === (_l = that.totals) || void 0 === _l ? void 0 : _l.column) || void 0 === _m ? void 0 : _m.showGrandTotals) || 0 === this.rows.length) {
|
|
268
|
+
const flatColTotalKey = that.colGrandTotalLabel;
|
|
269
|
+
this.tree[flatRowKey][flatColTotalKey] || (this.tree[flatRowKey][flatColTotalKey] = []);
|
|
270
|
+
for (let i = 0; i < this.indicatorKeys.length; i++) {
|
|
271
|
+
if (!this.tree[flatRowKey][flatColTotalKey][i]) {
|
|
272
|
+
const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
|
|
273
|
+
this.tree[flatRowKey][flatColTotalKey][i] = new this.aggregators[null !== (_o = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _o ? _o : ts_types_1.AggregationType.SUM](null !== (_p = null == aggRule ? void 0 : aggRule.field) && void 0 !== _p ? _p : this.indicatorKeys[i], null == aggRule ? void 0 : aggRule.formatFun);
|
|
274
|
+
}
|
|
275
|
+
this.tree[flatRowKey][flatColTotalKey][i].push(null === (_r = null === (_q = that.tree[flatRowKey]) || void 0 === _q ? void 0 : _q[flatColKey]) || void 0 === _r ? void 0 : _r[i]);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
Object.keys(that.tree).forEach((flatRowKey => {
|
|
280
|
+
const rowKey = flatRowKey.split(this.stringJoinChar);
|
|
281
|
+
Object.keys(that.tree[flatRowKey]).forEach((flatColKey => {
|
|
282
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
283
|
+
for (let i = 0, len = null === (_c = null === (_b = null === (_a = that.totals) || void 0 === _a ? void 0 : _a.row) || void 0 === _b ? void 0 : _b.subTotalsDimensions) || void 0 === _c ? void 0 : _c.length; i < len; i++) {
|
|
284
|
+
const dimension = that.totals.row.subTotalsDimensions[i], dimensionIndex = that.rows.indexOf(dimension);
|
|
285
|
+
if (dimensionIndex >= 0) {
|
|
286
|
+
const rowTotalKey = rowKey.slice(0, dimensionIndex + 1);
|
|
287
|
+
rowTotalKey.push(null !== (_f = null === (_e = null === (_d = that.totals) || void 0 === _d ? void 0 : _d.row) || void 0 === _e ? void 0 : _e.subTotalLabel) && void 0 !== _f ? _f : "小计");
|
|
288
|
+
const flatRowTotalKey = rowTotalKey.join(this.stringJoinChar);
|
|
289
|
+
if (this.tree[flatRowTotalKey] || (this.tree[flatRowTotalKey] = {}, rowTotalKeys.push(flatRowTotalKey)),
|
|
290
|
+
!this.tree[flatRowTotalKey][flatColKey]) {
|
|
291
|
+
this.tree[flatRowTotalKey][flatColKey] = [];
|
|
292
|
+
for (let i = 0; i < this.indicatorKeys.length; i++) {
|
|
293
|
+
if (!this.tree[flatRowTotalKey][flatColKey][i]) {
|
|
294
|
+
const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
|
|
295
|
+
this.tree[flatRowTotalKey][flatColKey][i] = new this.aggregators[null !== (_g = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _g ? _g : ts_types_1.AggregationType.SUM](null !== (_h = null == aggRule ? void 0 : aggRule.field) && void 0 !== _h ? _h : this.indicatorKeys[i], null == aggRule ? void 0 : aggRule.formatFun);
|
|
296
|
+
}
|
|
297
|
+
this.tree[flatRowTotalKey][flatColKey][i].push(null === (_k = null === (_j = that.tree[flatRowKey]) || void 0 === _j ? void 0 : _j[flatColKey]) || void 0 === _k ? void 0 : _k[i]);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
if ((null === (_m = null === (_l = that.totals) || void 0 === _l ? void 0 : _l.row) || void 0 === _m ? void 0 : _m.showGrandTotals) || 0 === this.columns.length) {
|
|
302
|
+
const flatRowTotalKey = that.rowGrandTotalLabel;
|
|
303
|
+
this.tree[flatRowTotalKey] || (this.tree[flatRowTotalKey] = {}, rowTotalKeys.push(flatRowTotalKey)),
|
|
304
|
+
this.tree[flatRowTotalKey][flatColKey] || (this.tree[flatRowTotalKey][flatColKey] = []);
|
|
305
|
+
for (let i = 0; i < this.indicatorKeys.length; i++) {
|
|
306
|
+
if (!this.tree[flatRowTotalKey][flatColKey][i]) {
|
|
307
|
+
const aggRule = this.getAggregatorRule(this.indicatorKeys[i]);
|
|
308
|
+
this.tree[flatRowTotalKey][flatColKey][i] = new this.aggregators[null !== (_o = null == aggRule ? void 0 : aggRule.aggregationType) && void 0 !== _o ? _o : ts_types_1.AggregationType.SUM](null !== (_p = null == aggRule ? void 0 : aggRule.field) && void 0 !== _p ? _p : this.indicatorKeys[i], null == aggRule ? void 0 : aggRule.formatFun);
|
|
309
|
+
}
|
|
310
|
+
this.tree[flatRowTotalKey][flatColKey][i].push(null === (_r = null === (_q = that.tree[flatRowKey]) || void 0 === _q ? void 0 : _q[flatColKey]) || void 0 === _r ? void 0 : _r[i]);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
colCompute(flatRowKey, flatColKey);
|
|
314
|
+
}
|
|
315
|
+
}));
|
|
316
|
+
})), rowTotalKeys.forEach((flatRowKey => {
|
|
317
|
+
Object.keys(that.tree[flatRowKey]).forEach((flatColKey => {
|
|
318
|
+
colCompute(flatRowKey, flatColKey);
|
|
319
|
+
}));
|
|
320
|
+
}));
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
ArrToTree(arr, subTotalFlags, isGrandTotal, grandTotalLabel, subTotalLabel) {
|
|
324
|
+
const result = [], concatStr = this.stringJoinChar, map = new Map;
|
|
325
|
+
if (arr.forEach((item => function(list) {
|
|
326
|
+
const path = [];
|
|
327
|
+
let node;
|
|
328
|
+
list.forEach(((value, index) => {
|
|
329
|
+
path.push(value);
|
|
330
|
+
const flatKey = path.join(concatStr);
|
|
331
|
+
let item = map.get(flatKey);
|
|
332
|
+
if (!item) {
|
|
333
|
+
if (item = {
|
|
334
|
+
id: flatKey,
|
|
335
|
+
children: []
|
|
336
|
+
}, subTotalFlags[index]) {
|
|
337
|
+
let curChild = item.children;
|
|
338
|
+
for (let i = index; i < list.length - 1; i++) {
|
|
339
|
+
const totalChild = {
|
|
340
|
+
id: `${flatKey}${concatStr}${subTotalLabel}`,
|
|
341
|
+
children: []
|
|
342
|
+
};
|
|
343
|
+
curChild.push(totalChild), curChild = totalChild.children;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
map.set(flatKey, item), node ? subTotalFlags[index - 1] ? node.children.splice(node.children.length - 1, 0, item) : node.children.push(item) : result.push(item);
|
|
347
|
+
}
|
|
348
|
+
node = item;
|
|
349
|
+
}));
|
|
350
|
+
}(item))), isGrandTotal) {
|
|
351
|
+
const node = {
|
|
352
|
+
id: grandTotalLabel,
|
|
353
|
+
children: []
|
|
354
|
+
};
|
|
355
|
+
let curChild = node.children;
|
|
356
|
+
for (let i = 1; i < subTotalFlags.length; i++) {
|
|
357
|
+
const totalChild = {
|
|
358
|
+
id: grandTotalLabel,
|
|
359
|
+
children: []
|
|
360
|
+
};
|
|
361
|
+
curChild.push(totalChild), curChild = totalChild.children;
|
|
362
|
+
}
|
|
363
|
+
result.push(node);
|
|
364
|
+
}
|
|
365
|
+
return result;
|
|
366
|
+
}
|
|
367
|
+
TreeToArr(tree) {
|
|
368
|
+
const result = [];
|
|
369
|
+
function getPath(node, arr) {
|
|
370
|
+
var _a;
|
|
371
|
+
arr.push(node.id), node.children.length > 0 ? null === (_a = node.children) || void 0 === _a || _a.forEach((childItem => getPath(childItem, [ ...arr ]))) : result.push(arr);
|
|
372
|
+
}
|
|
373
|
+
return tree.forEach((treeNode => getPath(treeNode, []))), result;
|
|
374
|
+
}
|
|
375
|
+
TreeToArr2(tree) {
|
|
376
|
+
const result = [];
|
|
377
|
+
function getPath(node, arr) {
|
|
378
|
+
var _a, _b;
|
|
379
|
+
arr.push(arr.length > 0 ? [ arr[arr.length - 1], node.value ].join(String.fromCharCode(0)) : node.value),
|
|
380
|
+
(null === (_a = node.children) || void 0 === _a ? void 0 : _a.length) > 0 ? null === (_b = node.children) || void 0 === _b || _b.forEach((childItem => getPath(childItem, [ ...arr ]))) : result.push(arr);
|
|
381
|
+
}
|
|
382
|
+
return tree.forEach((treeNode => getPath(treeNode, []))), result;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
exports.DatasetForPivotTable = DatasetForPivotTable;
|
|
387
|
+
//# sourceMappingURL=dataset-pivot-table.js.map
|