@visactor/vtable 0.12.1-alpha.1 → 0.12.2

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.
Files changed (79) hide show
  1. package/cjs/ListTable.js +2 -0
  2. package/cjs/ListTable.js.map +1 -1
  3. package/cjs/PivotTable.js +2 -2
  4. package/cjs/PivotTable.js.map +1 -1
  5. package/cjs/components/tooltip/TooltipHandler.js +17 -8
  6. package/cjs/components/tooltip/TooltipHandler.js.map +1 -1
  7. package/cjs/core/BaseTable.js +1 -1
  8. package/cjs/core/BaseTable.js.map +1 -1
  9. package/cjs/dataset/dataset.d.ts +1 -0
  10. package/cjs/dataset/dataset.js +89 -58
  11. package/cjs/dataset/dataset.js.map +1 -1
  12. package/cjs/event/event.js +2 -3
  13. package/cjs/event/event.js.map +1 -1
  14. package/cjs/index.d.ts +1 -1
  15. package/cjs/index.js +1 -1
  16. package/cjs/index.js.map +1 -1
  17. package/cjs/layout/chart-helper/get-axis-config.d.ts +11 -0
  18. package/cjs/layout/chart-helper/get-axis-config.js +65 -62
  19. package/cjs/layout/chart-helper/get-axis-config.js.map +1 -1
  20. package/cjs/layout/chart-helper/get-chart-spec.js +9 -24
  21. package/cjs/layout/chart-helper/get-chart-spec.js.map +1 -1
  22. package/cjs/layout/pivot-header-layout.js +2 -2
  23. package/cjs/layout/pivot-header-layout.js.map +1 -1
  24. package/cjs/scenegraph/group-creater/progress/update-position/dynamic-set-x.js +3 -3
  25. package/cjs/scenegraph/group-creater/progress/update-position/dynamic-set-x.js.map +1 -1
  26. package/cjs/scenegraph/group-creater/progress/update-position/util.d.ts +1 -1
  27. package/cjs/scenegraph/group-creater/progress/update-position/util.js +10 -5
  28. package/cjs/scenegraph/group-creater/progress/update-position/util.js.map +1 -1
  29. package/cjs/scenegraph/stick-text/index.js +20 -18
  30. package/cjs/scenegraph/stick-text/index.js.map +1 -1
  31. package/cjs/themes/DARK.js +1 -1
  32. package/cjs/themes/DARK.js.map +1 -1
  33. package/cjs/themes/SIMPLIFY.js +1 -1
  34. package/cjs/themes/SIMPLIFY.js.map +1 -1
  35. package/cjs/ts-types/base-table.js.map +1 -1
  36. package/cjs/ts-types/new-data-set.js.map +1 -1
  37. package/cjs/ts-types/table-engine.js.map +1 -1
  38. package/dist/vtable.js +238 -199
  39. package/dist/vtable.min.js +2 -2
  40. package/es/ListTable.js +2 -0
  41. package/es/ListTable.js.map +1 -1
  42. package/es/PivotTable.js +2 -2
  43. package/es/PivotTable.js.map +1 -1
  44. package/es/components/tooltip/TooltipHandler.js +17 -8
  45. package/es/components/tooltip/TooltipHandler.js.map +1 -1
  46. package/es/core/BaseTable.js +1 -1
  47. package/es/core/BaseTable.js.map +1 -1
  48. package/es/dataset/dataset.d.ts +1 -0
  49. package/es/dataset/dataset.js +89 -58
  50. package/es/dataset/dataset.js.map +1 -1
  51. package/es/event/event.js +2 -3
  52. package/es/event/event.js.map +1 -1
  53. package/es/index.d.ts +1 -1
  54. package/es/index.js +1 -1
  55. package/es/index.js.map +1 -1
  56. package/es/layout/chart-helper/get-axis-config.d.ts +11 -0
  57. package/es/layout/chart-helper/get-axis-config.js +61 -57
  58. package/es/layout/chart-helper/get-axis-config.js.map +1 -1
  59. package/es/layout/chart-helper/get-chart-spec.js +6 -21
  60. package/es/layout/chart-helper/get-chart-spec.js.map +1 -1
  61. package/es/layout/pivot-header-layout.js +2 -2
  62. package/es/layout/pivot-header-layout.js.map +1 -1
  63. package/es/scenegraph/group-creater/progress/update-position/dynamic-set-x.js +3 -3
  64. package/es/scenegraph/group-creater/progress/update-position/dynamic-set-x.js.map +1 -1
  65. package/es/scenegraph/group-creater/progress/update-position/util.d.ts +1 -1
  66. package/es/scenegraph/group-creater/progress/update-position/util.js +10 -5
  67. package/es/scenegraph/group-creater/progress/update-position/util.js.map +1 -1
  68. package/es/scenegraph/stick-text/index.js +20 -18
  69. package/es/scenegraph/stick-text/index.js.map +1 -1
  70. package/es/themes/DARK.js +1 -1
  71. package/es/themes/DARK.js.map +1 -1
  72. package/es/themes/SIMPLIFY.js +1 -1
  73. package/es/themes/SIMPLIFY.js.map +1 -1
  74. package/es/ts-types/base-table.js.map +1 -1
  75. package/es/ts-types/new-data-set.js.map +1 -1
  76. package/es/ts-types/table-engine.js.map +1 -1
  77. package/package.json +2 -2
  78. package/cjs/components/axis/get-axis-attributes.d.ts +0 -151
  79. package/es/components/axis/get-axis-attributes.d.ts +0 -151
package/es/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":[],"mappings":"AACA,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,CAAC;AACnC,OAAO,KAAK,cAAc,MAAM,0BAA0B,CAAC;AAmB3D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,KAAK,YAAY,MAAM,iBAAiB,CAAC;AAKhD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,cAAc,cAAc,CAAC;AAE7B,MAAM,CAAC,MAAM,OAAO,GAAG,gBAAgB,CAAC;AAIxC,OAAO,EAKL,KAAK,EACL,IAAI,EACJ,SAAS,EAET,UAAU,EAGV,UAAU,EAcV,MAAM,EACN,IAAI,EAEJ,QAAQ,EACR,WAAW,EAEX,QAAQ,EAIR,cAAc,EACd,YAAY,EACb,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","file":"index.js","sourcesContent":["/* eslint-disable sort-imports */\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 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 TextAlignType,\n TextBaselineType\n} from './ts-types';\nimport { ListTable } from './ListTable';\nimport { PivotTable } from './PivotTable';\nimport { PivotChart } from './PivotChart';\nimport type { MousePointerCellEvent } from './ts-types/events';\nimport * as CustomLayout from './render/layout';\n\n// import { container, loadCanvasPicker } from '@visactor/vrender';\n// loadCanvasPicker(container);\n\nexport { getDataCellPath } from './tools/get-data-path';\nexport * from './render/jsx';\n\nexport const version = \"0.12.1-alpha.1\";\n/**\n * @namespace VTable\n */\nexport {\n /**\n * Types\n * @namespace VTable.TYPES\n */\n TYPES,\n core,\n ListTable,\n ListTableConstructorOptions,\n PivotTable,\n PivotTableConstructorOptions,\n PivotChartConstructorOptions,\n PivotChart,\n IHeaderTreeDefine,\n IDimension,\n ColumnsDefine,\n ColumnDefine,\n LinkColumnDefine,\n ChartColumnDefine,\n ImageColumnDefine,\n SparklineColumnDefine,\n ProgressbarColumnDefine,\n TextColumnDefine,\n GroupColumnDefine,\n TextAlignType,\n TextBaselineType,\n themes,\n data,\n MousePointerCellEvent,\n getIcons,\n clearGlobal,\n //plugin registers\n register,\n /**\n * 暂不推荐使用\n */\n DataStatistics,\n CustomLayout\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"]}
1
+ {"version":3,"sources":["index.ts"],"names":[],"mappings":"AACA,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,CAAC;AACnC,OAAO,KAAK,cAAc,MAAM,0BAA0B,CAAC;AAmB3D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,KAAK,YAAY,MAAM,iBAAiB,CAAC;AAKhD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,cAAc,cAAc,CAAC;AAE7B,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC;AAIhC,OAAO,EAKL,KAAK,EACL,IAAI,EACJ,SAAS,EAET,UAAU,EAGV,UAAU,EAcV,MAAM,EACN,IAAI,EAEJ,QAAQ,EACR,WAAW,EAEX,QAAQ,EAIR,cAAc,EACd,YAAY,EACb,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","file":"index.js","sourcesContent":["/* eslint-disable sort-imports */\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 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 TextAlignType,\n TextBaselineType\n} from './ts-types';\nimport { ListTable } from './ListTable';\nimport { PivotTable } from './PivotTable';\nimport { PivotChart } from './PivotChart';\nimport type { MousePointerCellEvent } from './ts-types/events';\nimport * as CustomLayout from './render/layout';\n\n// import { container, loadCanvasPicker } from '@visactor/vrender';\n// loadCanvasPicker(container);\n\nexport { getDataCellPath } from './tools/get-data-path';\nexport * from './render/jsx';\n\nexport const version = \"0.12.2\";\n/**\n * @namespace VTable\n */\nexport {\n /**\n * Types\n * @namespace VTable.TYPES\n */\n TYPES,\n core,\n ListTable,\n ListTableConstructorOptions,\n PivotTable,\n PivotTableConstructorOptions,\n PivotChartConstructorOptions,\n PivotChart,\n IHeaderTreeDefine,\n IDimension,\n ColumnsDefine,\n ColumnDefine,\n LinkColumnDefine,\n ChartColumnDefine,\n ImageColumnDefine,\n SparklineColumnDefine,\n ProgressbarColumnDefine,\n TextColumnDefine,\n GroupColumnDefine,\n TextAlignType,\n TextBaselineType,\n themes,\n data,\n MousePointerCellEvent,\n getIcons,\n clearGlobal,\n //plugin registers\n register,\n /**\n * 暂不推荐使用\n */\n DataStatistics,\n CustomLayout\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"]}
@@ -1,8 +1,19 @@
1
1
  import type { PivotHeaderLayoutMap } from '../pivot-header-layout';
2
+ import type { CollectedValue } from '../../ts-types';
2
3
  export declare function getAxisConfigInPivotChart(col: number, row: number, layout: PivotHeaderLayoutMap): any;
3
4
  export declare function getAxisOption(col: number, row: number, orient: string, layout: PivotHeaderLayoutMap): {
4
5
  axisOption: any;
5
6
  isPercent: any;
6
7
  isZeroAlign: boolean;
8
+ seriesIndice: any;
9
+ } | {
10
+ axisOption: import("@visactor/vchart").ICartesianAxisSpec;
11
+ isPercent: boolean;
12
+ isZeroAlign: boolean;
13
+ seriesIndice?: undefined;
7
14
  };
8
15
  export declare function checkZeroAlign(spec: any, orient: string, layout: PivotHeaderLayoutMap): boolean;
16
+ export declare function getAxisRange(collectedValues: Record<string, Record<string, CollectedValue>>, indicatorKeys: string[], isZeroAlign: boolean, colPath: string, seriesId: number | number[]): {
17
+ max: number;
18
+ min: number;
19
+ } | null;
@@ -1,21 +1,15 @@
1
- import { isArray, isNumber, merge } from "@visactor/vutils";
1
+ import { isArray, isNumber, isValid, merge } from "@visactor/vutils";
2
2
 
3
3
  import { getAxisDomainRangeAndLabels } from "./get-axis-domain";
4
4
 
5
5
  export function getAxisConfigInPivotChart(col, row, layout) {
6
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
6
+ var _a, _b, _c, _d, _e, _f;
7
7
  if (layout._table.isPivotChart()) if (layout.indicatorsAsCol) {
8
8
  if (layout.hasTwoIndicatorAxes && row === layout.columnHeaderLevelCount - 1 && col >= layout.rowHeaderLevelCount && col < layout.colCount - layout.rightFrozenColCount) {
9
- const indicatorKeys = layout.getIndicatorKeyInChartSpec(col, layout.columnHeaderLevelCount - 1);
10
- let defaultKey = null == indicatorKeys ? void 0 : indicatorKeys[1];
11
- if (isArray(defaultKey) && (defaultKey = defaultKey[0]), !defaultKey) return;
12
- const {axisOption: axisOption, isPercent: isPercent, isZeroAlign: isZeroAlign} = getAxisOption(col, row + 1, "top", layout), data = layout.dataset.collectedValues[defaultKey + (isZeroAlign ? "_align" : "")] ? layout.dataset.collectedValues[defaultKey + (isZeroAlign ? "_align" : "")] : layout.dataset.collectedValues[defaultKey], colPath = layout.getColKeysPath(col, row), range = merge({}, null !== (_a = null == data ? void 0 : data[null != colPath ? colPath : ""]) && void 0 !== _a ? _a : {
13
- min: 0,
14
- max: 1
15
- });
16
- if (range.positiveMax && range.positiveMax > range.max && (range.max = range.positiveMax),
17
- range.negativeMin && range.negativeMin < range.min && (range.min = range.negativeMin),
18
- range.min === range.max && (range.min > 0 ? range.min = 0 : range.max = 0), !1 === (null == axisOption ? void 0 : axisOption.visible)) return;
9
+ const {axisOption: axisOption, isPercent: isPercent, isZeroAlign: isZeroAlign, seriesIndice: seriesIndice} = getAxisOption(col, row + 1, "top", layout);
10
+ if (!1 === (null == axisOption ? void 0 : axisOption.visible)) return;
11
+ const indicatorKeys = layout.getIndicatorKeyInChartSpec(col, layout.columnHeaderLevelCount - 1), colPath = layout.getColKeysPath(col, row), range = getAxisRange(layout.dataset.collectedValues, indicatorKeys, isZeroAlign, colPath, null != seriesIndice ? seriesIndice : 1);
12
+ if (!range) return;
19
13
  isPercent && (range.min = range.min < 0 ? -1 : 0, range.max = range.max > 0 ? 1 : 0);
20
14
  const {range: niceRange, ticks: ticks} = getAxisDomainRangeAndLabels(range.min, range.max, axisOption, isZeroAlign);
21
15
  return range.min = isNaN(niceRange[0]) ? 0 : niceRange[0], range.max = isNaN(niceRange[1]) ? 1 : niceRange[1],
@@ -33,22 +27,15 @@ export function getAxisConfigInPivotChart(col, row, layout) {
33
27
  });
34
28
  }
35
29
  if (row === layout.rowCount - layout.bottomFrozenRowCount && col >= layout.rowHeaderLevelCount && col < layout.colCount - layout.rightFrozenColCount) {
36
- const indicatorKeys = layout.getIndicatorKeyInChartSpec(col, row);
37
- let defaultKey = null == indicatorKeys ? void 0 : indicatorKeys[0];
38
- isArray(defaultKey) && (defaultKey = defaultKey[0]);
39
- const {axisOption: axisOption, isPercent: isPercent, isZeroAlign: isZeroAlign} = getAxisOption(col, row - 1, "bottom", layout), data = layout.dataset.collectedValues[defaultKey + (isZeroAlign ? "_align" : "")] ? layout.dataset.collectedValues[defaultKey + (isZeroAlign ? "_align" : "")] : layout.dataset.collectedValues[defaultKey], colPath = layout.getColKeysPath(col, row), range = merge({}, null !== (_b = null == data ? void 0 : data[null != colPath ? colPath : ""]) && void 0 !== _b ? _b : {
40
- min: 0,
41
- max: 1
42
- });
43
- range.positiveMax && range.positiveMax > range.max && (range.max = range.positiveMax),
44
- range.negativeMin && range.negativeMin < range.min && (range.min = range.negativeMin),
45
- range.min === range.max && (range.min > 0 ? range.min = 0 : range.max = 0);
30
+ const {axisOption: axisOption, isPercent: isPercent, isZeroAlign: isZeroAlign, seriesIndice: seriesIndice} = getAxisOption(col, row - 1, "bottom", layout);
31
+ if (!1 === (null == axisOption ? void 0 : axisOption.visible)) return;
32
+ const indicatorKeys = layout.getIndicatorKeyInChartSpec(col, row), colPath = layout.getColKeysPath(col, row), range = getAxisRange(layout.dataset.collectedValues, indicatorKeys, isZeroAlign, colPath, null != seriesIndice ? seriesIndice : 0);
33
+ if (!range) return;
46
34
  let indicatorInfo = null;
47
- if (null == indicatorKeys || indicatorKeys.forEach((key => {
35
+ null == indicatorKeys || indicatorKeys.forEach((key => {
48
36
  const info = layout.getIndicatorInfo(key);
49
37
  info && (indicatorInfo = info);
50
- })), !1 === (null == axisOption ? void 0 : axisOption.visible)) return;
51
- isPercent && (range.min = range.min < 0 ? -1 : 0, range.max = range.max > 0 ? 1 : 0);
38
+ })), isPercent && (range.min = range.min < 0 ? -1 : 0, range.max = range.max > 0 ? 1 : 0);
52
39
  const {range: niceRange, ticks: ticks} = getAxisDomainRangeAndLabels(range.min, range.max, axisOption, isZeroAlign);
53
40
  return range.min = isNaN(niceRange[0]) ? 0 : niceRange[0], range.max = isNaN(niceRange[1]) ? 1 : niceRange[1],
54
41
  isNumber(null == axisOption ? void 0 : axisOption.min) && (range.min = axisOption.min),
@@ -69,9 +56,9 @@ export function getAxisConfigInPivotChart(col, row, layout) {
69
56
  });
70
57
  }
71
58
  if (col === layout.rowHeaderLevelCount - 1 && row >= layout.columnHeaderLevelCount && row < layout.rowCount - layout.bottomFrozenRowCount) {
72
- let rowDimensionKey = null === (_c = layout.getDimensionKeyInChartSpec(layout.rowHeaderLevelCount, row)) || void 0 === _c ? void 0 : _c[0];
59
+ let rowDimensionKey = null === (_a = layout.getDimensionKeyInChartSpec(layout.rowHeaderLevelCount, row)) || void 0 === _a ? void 0 : _a[0];
73
60
  isArray(rowDimensionKey) && (rowDimensionKey = rowDimensionKey[0]);
74
- const data = null !== (_d = layout.dataset.collectedValues[rowDimensionKey]) && void 0 !== _d ? _d : [], rowPath = layout.getRowKeysPath(col, row), domain = null !== (_e = data[null != rowPath ? rowPath : ""]) && void 0 !== _e ? _e : [], {axisOption: axisOption, isPercent: isPercent} = getAxisOption(col + 1, row, "left", layout);
61
+ const data = null !== (_b = layout.dataset.collectedValues[rowDimensionKey]) && void 0 !== _b ? _b : [], rowPath = layout.getRowKeysPath(col, row), domain = null !== (_c = data[null != rowPath ? rowPath : ""]) && void 0 !== _c ? _c : [], {axisOption: axisOption, isPercent: isPercent} = getAxisOption(col + 1, row, "left", layout);
75
62
  if (!1 === (null == axisOption ? void 0 : axisOption.visible)) return;
76
63
  return merge({
77
64
  domain: Array.from(domain).reverse(),
@@ -85,22 +72,15 @@ export function getAxisConfigInPivotChart(col, row, layout) {
85
72
  }
86
73
  } else {
87
74
  if (col === layout.rowHeaderLevelCount - 1 && row >= layout.columnHeaderLevelCount && row < layout.rowCount - layout.bottomFrozenRowCount) {
88
- const indicatorKeys = layout.getIndicatorKeyInChartSpec(col, row);
89
- let defaultKey = null == indicatorKeys ? void 0 : indicatorKeys[0];
90
- isArray(defaultKey) && (defaultKey = defaultKey[0]);
91
- const {axisOption: axisOption, isPercent: isPercent, isZeroAlign: isZeroAlign} = getAxisOption(col + 1, row, "left", layout), data = layout.dataset.collectedValues[defaultKey + (isZeroAlign ? "_align" : "")] ? layout.dataset.collectedValues[defaultKey + (isZeroAlign ? "_align" : "")] : layout.dataset.collectedValues[defaultKey], rowPath = layout.getRowKeysPath(col, row), range = merge({}, null !== (_f = null == data ? void 0 : data[null != rowPath ? rowPath : ""]) && void 0 !== _f ? _f : {
92
- min: 0,
93
- max: 1
94
- });
95
- range.positiveMax && range.positiveMax > range.max && (range.max = range.positiveMax),
96
- range.negativeMin && range.negativeMin < range.min && (range.min = range.negativeMin),
97
- range.min === range.max && (range.min > 0 ? range.min = 0 : range.max = 0);
75
+ const {axisOption: axisOption, isPercent: isPercent, isZeroAlign: isZeroAlign, seriesIndice: seriesIndice} = getAxisOption(col + 1, row, "left", layout);
76
+ if (!1 === (null == axisOption ? void 0 : axisOption.visible)) return;
77
+ const indicatorKeys = layout.getIndicatorKeyInChartSpec(col, row), rowPath = layout.getRowKeysPath(col, row), range = getAxisRange(layout.dataset.collectedValues, indicatorKeys, isZeroAlign, rowPath, null != seriesIndice ? seriesIndice : 0);
78
+ if (!range) return;
98
79
  let indicatorInfo = null;
99
- if (null == indicatorKeys || indicatorKeys.forEach((key => {
80
+ null == indicatorKeys || indicatorKeys.forEach((key => {
100
81
  const info = layout.getIndicatorInfo(key);
101
82
  info && (indicatorInfo = info);
102
- })), !1 === (null == axisOption ? void 0 : axisOption.visible)) return;
103
- isPercent && (range.min = range.min < 0 ? -1 : 0, range.max = range.max > 0 ? 1 : 0);
83
+ })), isPercent && (range.min = range.min < 0 ? -1 : 0, range.max = range.max > 0 ? 1 : 0);
104
84
  const {range: niceRange, ticks: ticks} = getAxisDomainRangeAndLabels(range.min, range.max, axisOption, isZeroAlign);
105
85
  return range.min = isNaN(niceRange[0]) ? 0 : niceRange[0], range.max = isNaN(niceRange[1]) ? 1 : niceRange[1],
106
86
  isNumber(null == axisOption ? void 0 : axisOption.min) && (range.min = axisOption.min),
@@ -122,16 +102,10 @@ export function getAxisConfigInPivotChart(col, row, layout) {
122
102
  });
123
103
  }
124
104
  if (col === layout.colCount - layout.rightFrozenColCount && row >= layout.columnHeaderLevelCount && row < layout.rowCount - layout.bottomFrozenRowCount) {
125
- const indicatorKeys = layout.getIndicatorKeyInChartSpec(layout.rowHeaderLevelCount - 1, row);
126
- let defaultKey = null == indicatorKeys ? void 0 : indicatorKeys[1];
127
- if (isArray(defaultKey) && (defaultKey = defaultKey[0]), !defaultKey) return;
128
- const {axisOption: axisOption, isPercent: isPercent, isZeroAlign: isZeroAlign} = getAxisOption(col - 1, row, "right", layout), data = layout.dataset.collectedValues[defaultKey + (isZeroAlign ? "_align" : "")] ? layout.dataset.collectedValues[defaultKey + (isZeroAlign ? "_align" : "")] : layout.dataset.collectedValues[defaultKey], rowPath = layout.getRowKeysPath(col, row), range = merge({}, null !== (_g = null == data ? void 0 : data[null != rowPath ? rowPath : ""]) && void 0 !== _g ? _g : {
129
- min: 0,
130
- max: 1
131
- });
132
- if (range.positiveMax && range.positiveMax > range.max && (range.max = range.positiveMax),
133
- range.negativeMin && range.negativeMin < range.min && (range.min = range.negativeMin),
134
- range.min === range.max && (range.min > 0 ? range.min = 0 : range.max = 0), !1 === (null == axisOption ? void 0 : axisOption.visible)) return;
105
+ const {axisOption: axisOption, isPercent: isPercent, isZeroAlign: isZeroAlign, seriesIndice: seriesIndice} = getAxisOption(col - 1, row, "right", layout);
106
+ if (!1 === (null == axisOption ? void 0 : axisOption.visible)) return;
107
+ const indicatorKeys = layout.getIndicatorKeyInChartSpec(layout.rowHeaderLevelCount - 1, row), rowPath = layout.getRowKeysPath(col, row), range = getAxisRange(layout.dataset.collectedValues, indicatorKeys, isZeroAlign, rowPath, null != seriesIndice ? seriesIndice : 1);
108
+ if (!range) return;
135
109
  isPercent && (range.min = range.min < 0 ? -1 : 0, range.max = range.max > 0 ? 1 : 0);
136
110
  const {range: niceRange, ticks: ticks} = getAxisDomainRangeAndLabels(range.min, range.max, axisOption, isZeroAlign);
137
111
  return range.min = isNaN(niceRange[0]) ? 0 : niceRange[0], range.max = isNaN(niceRange[1]) ? 1 : niceRange[1],
@@ -152,9 +126,9 @@ export function getAxisConfigInPivotChart(col, row, layout) {
152
126
  });
153
127
  }
154
128
  if (row === layout.rowCount - layout.bottomFrozenRowCount && col >= layout.rowHeaderLevelCount && col < layout.colCount - layout.rightFrozenColCount) {
155
- let columnDimensionKey = null === (_h = layout.getDimensionKeyInChartSpec(col, layout.columnHeaderLevelCount)) || void 0 === _h ? void 0 : _h[0];
129
+ let columnDimensionKey = null === (_d = layout.getDimensionKeyInChartSpec(col, layout.columnHeaderLevelCount)) || void 0 === _d ? void 0 : _d[0];
156
130
  isArray(columnDimensionKey) && (columnDimensionKey = columnDimensionKey[0]);
157
- const data = null !== (_j = layout.dataset.collectedValues[columnDimensionKey]) && void 0 !== _j ? _j : [], colPath = layout.getColKeysPath(col, row), domain = null !== (_k = null == data ? void 0 : data[null != colPath ? colPath : ""]) && void 0 !== _k ? _k : [], {axisOption: axisOption, isPercent: isPercent} = getAxisOption(col, row - 1, "bottom", layout);
131
+ const data = null !== (_e = layout.dataset.collectedValues[columnDimensionKey]) && void 0 !== _e ? _e : [], colPath = layout.getColKeysPath(col, row), domain = null !== (_f = null == data ? void 0 : data[null != colPath ? colPath : ""]) && void 0 !== _f ? _f : [], {axisOption: axisOption, isPercent: isPercent} = getAxisOption(col, row - 1, "bottom", layout);
158
132
  if (!1 === (null == axisOption ? void 0 : axisOption.visible)) return;
159
133
  return merge({
160
134
  domain: Array.from(domain)
@@ -170,11 +144,17 @@ export function getAxisOption(col, row, orient, layout) {
170
144
  const spec = layout.getRawChartSpec(col, row);
171
145
  if (spec && isArray(spec.axes)) {
172
146
  const axisOption = spec.axes.find((axis => axis.orient === orient));
173
- if (axisOption) return {
174
- axisOption: axisOption,
175
- isPercent: spec.percent,
176
- isZeroAlign: checkZeroAlign(spec, orient, layout)
177
- };
147
+ if (axisOption) {
148
+ const {seriesIndex: seriesIndex, seriesId: seriesId} = axisOption;
149
+ let seriesIndice;
150
+ return isValid(seriesId) && isArray(spec.series) ? seriesIndice = (isArray(seriesId) ? seriesId : [ seriesId ]).map((id => spec.series.findIndex((s => s.id === id)))) : isValid(seriesIndex) && isArray(spec.series) && (seriesIndice = seriesIndex),
151
+ {
152
+ axisOption: axisOption,
153
+ isPercent: spec.percent,
154
+ isZeroAlign: checkZeroAlign(spec, orient, layout),
155
+ seriesIndice: seriesIndice
156
+ };
157
+ }
178
158
  }
179
159
  return {
180
160
  axisOption: layout._table.pivotChartAxes.find((axisOption => axisOption.orient === orient)),
@@ -200,4 +180,28 @@ export function checkZeroAlign(spec, orient, layout) {
200
180
  }
201
181
  return !1;
202
182
  }
183
+
184
+ export function getAxisRange(collectedValues, indicatorKeys, isZeroAlign, colPath, seriesId) {
185
+ var _a;
186
+ if (isArray(seriesId)) {
187
+ const range = {
188
+ min: 1 / 0,
189
+ max: -1 / 0
190
+ };
191
+ for (let i = 0; i < seriesId.length; i++) {
192
+ const singleRange = getAxisRange(collectedValues, indicatorKeys, isZeroAlign, colPath, seriesId[i]);
193
+ singleRange && (range.min = Math.min(range.min, singleRange.min), range.max = Math.max(range.max, singleRange.max));
194
+ }
195
+ return isFinite(range.min) && isFinite(range.max) ? range : null;
196
+ }
197
+ let defaultKey = null == indicatorKeys ? void 0 : indicatorKeys[seriesId];
198
+ if (isArray(defaultKey) && (defaultKey = defaultKey[0]), !defaultKey) return null;
199
+ const data = collectedValues[defaultKey + (isZeroAlign ? "_align" : "")] ? collectedValues[defaultKey + (isZeroAlign ? "_align" : "")] : collectedValues[defaultKey], range = merge({}, null !== (_a = null == data ? void 0 : data[null != colPath ? colPath : ""]) && void 0 !== _a ? _a : {
200
+ min: 0,
201
+ max: 1
202
+ });
203
+ return range.positiveMax && range.positiveMax > range.max && (range.max = range.positiveMax),
204
+ range.negativeMin && range.negativeMin < range.min && (range.min = range.negativeMin),
205
+ range.min === range.max && (range.min > 0 ? range.min = 0 : range.max = 0), range;
206
+ }
203
207
  //# sourceMappingURL=get-axis-config.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["lay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ACL,QAAQ,GAAI,MAAM,CAAC,MAAqB,CAAC,cAAoC,CAAC;KAC/E;IACD,IAAI,OAAO,CAAC,QAAQ,CAAC,EAAE;QACrB,MAAM,IAAI,GAAU,EAAE,CAAC;QACvB,QAAQ,CAAC,OAAO,CAAC,CAAC,IAAS,EAAE,EAAE;YAC7B,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;gBACjC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aACjB;QACH,CAAC,CAAC,CAAC;QACH,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACpC,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;YACrB,IACE,IAAI,CAAC,IAAI;gBACT,IAAI,CAAC,IAAI,CAAC,SAAS;gBACnB,IAAI,CAAC,IAAI,CAAC,MAAM;gBAChB,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;oBACnB,OAAO,QAAQ,CAAC,EAAE,KAAK,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;gBAC1C,CAAC,CAAC,EACF;gBACA,OAAO,IAAI,CAAC;aACb;SACF;KACF;IAED,OAAO,KAAK,CAAC;AACf,CAAC","file":"get-axis-config.js","sourcesContent":["import { isArray, isNumber, merge } from '@visactor/vutils';\nimport type { PivotHeaderLayoutMap } from '../pivot-header-layout';\nimport type { ITableAxisOption } from '../../ts-types/component/axis';\nimport type { PivotChart } from '../../PivotChart';\nimport { getAxisDomainRangeAndLabels } from './get-axis-domain';\n\nexport function getAxisConfigInPivotChart(col: number, row: number, layout: PivotHeaderLayoutMap): any {\n if (!layout._table.isPivotChart()) {\n return undefined;\n }\n\n // 是否是指标\n if (layout.indicatorsAsCol) {\n if (\n layout.hasTwoIndicatorAxes &&\n row === layout.columnHeaderLevelCount - 1 &&\n col >= layout.rowHeaderLevelCount &&\n col < layout.colCount - layout.rightFrozenColCount\n ) {\n const indicatorKeys = layout.getIndicatorKeyInChartSpec(col, layout.columnHeaderLevelCount - 1);\n let defaultKey = indicatorKeys?.[1];\n if (isArray(defaultKey)) {\n defaultKey = defaultKey[0];\n }\n if (!defaultKey) {\n return undefined;\n }\n\n const { axisOption, isPercent, isZeroAlign } = getAxisOption(col, row + 1, 'top', layout);\n // const isZeroAlign = checkZeroAlign(col, row, 'top', layout);\n // const data = layout.dataset.collectedValues[defaultKey];\n const data = layout.dataset.collectedValues[defaultKey + (isZeroAlign ? '_align' : '')]\n ? layout.dataset.collectedValues[defaultKey + (isZeroAlign ? '_align' : '')]\n : layout.dataset.collectedValues[defaultKey];\n const colPath = layout.getColKeysPath(col, row);\n\n const range = merge({}, (data?.[colPath ?? ''] as { min: number; max: number }) ?? { min: 0, max: 1 });\n if (range.positiveMax && range.positiveMax > range.max) {\n range.max = range.positiveMax;\n }\n if (range.negativeMin && range.negativeMin < range.min) {\n range.min = range.negativeMin;\n }\n // const { axisOption, isPercent } = getAxisOption(col, row + 1, 'top', layout);\n if (range.min === range.max) {\n if (range.min > 0) {\n range.min = 0;\n } else {\n range.max = 0;\n }\n }\n if (axisOption?.visible === false) {\n return;\n }\n if (isPercent) {\n (range as any).min = (range as any).min < 0 ? -1 : 0;\n (range as any).max = (range as any).max > 0 ? 1 : 0;\n }\n const { range: niceRange, ticks } = getAxisDomainRangeAndLabels(range.min, range.max, axisOption, isZeroAlign);\n range.min = !isNaN(niceRange[0]) ? niceRange[0] : 0;\n range.max = !isNaN(niceRange[1]) ? niceRange[1] : 1;\n\n if (isNumber(axisOption?.min)) {\n (range as any).min = axisOption.min;\n }\n if (isNumber(axisOption?.max)) {\n (range as any).max = axisOption.max;\n }\n // 顶部副指标轴\n return merge(\n {\n range: range\n },\n axisOption,\n {\n orient: 'top',\n type: 'linear',\n label: {\n flush: true\n },\n __ticksForVTable: ticks\n }\n );\n } else if (\n row === layout.rowCount - layout.bottomFrozenRowCount &&\n col >= layout.rowHeaderLevelCount &&\n col < layout.colCount - layout.rightFrozenColCount\n ) {\n const indicatorKeys = layout.getIndicatorKeyInChartSpec(col, row);\n let defaultKey = indicatorKeys?.[0];\n if (isArray(defaultKey)) {\n defaultKey = defaultKey[0];\n }\n\n // const isZeroAlign = checkZeroAlign(col, row, 'bottom', layout);\n const { axisOption, isPercent, isZeroAlign } = getAxisOption(col, row - 1, 'bottom', layout);\n\n const data = layout.dataset.collectedValues[defaultKey + (isZeroAlign ? '_align' : '')]\n ? layout.dataset.collectedValues[defaultKey + (isZeroAlign ? '_align' : '')]\n : layout.dataset.collectedValues[defaultKey];\n const colPath = layout.getColKeysPath(col, row);\n const range = merge({}, (data?.[colPath ?? ''] as { min: number; max: number }) ?? { min: 0, max: 1 });\n if (range.positiveMax && range.positiveMax > range.max) {\n range.max = range.positiveMax;\n }\n if (range.negativeMin && range.negativeMin < range.min) {\n range.min = range.negativeMin;\n }\n if (range.min === range.max) {\n if (range.min > 0) {\n range.min = 0;\n } else {\n range.max = 0;\n }\n }\n let indicatorInfo = null;\n indicatorKeys?.forEach(key => {\n const info = layout.getIndicatorInfo(key);\n if (info) {\n indicatorInfo = info;\n }\n });\n\n // const { axisOption, isPercent } = getAxisOption(col, row - 1, 'bottom', layout);\n if (axisOption?.visible === false) {\n return;\n }\n if (isPercent) {\n (range as any).min = (range as any).min < 0 ? -1 : 0;\n (range as any).max = (range as any).max > 0 ? 1 : 0;\n }\n const { range: niceRange, ticks } = getAxisDomainRangeAndLabels(range.min, range.max, axisOption, isZeroAlign);\n range.min = !isNaN(niceRange[0]) ? niceRange[0] : 0;\n range.max = !isNaN(niceRange[1]) ? niceRange[1] : 1;\n\n if (isNumber(axisOption?.min)) {\n (range as any).min = axisOption.min;\n }\n if (isNumber(axisOption?.max)) {\n (range as any).max = axisOption.max;\n }\n // 底侧指标轴\n return merge(\n {\n title: {\n visible: true,\n text: (indicatorInfo as any)?.title\n // autoRotate: true\n },\n range: range\n },\n axisOption,\n {\n orient: 'bottom',\n type: 'linear',\n label: {\n flush: true\n },\n __ticksForVTable: ticks\n }\n );\n } else if (\n col === layout.rowHeaderLevelCount - 1 &&\n row >= layout.columnHeaderLevelCount &&\n row < layout.rowCount - layout.bottomFrozenRowCount\n ) {\n let rowDimensionKey = layout.getDimensionKeyInChartSpec(layout.rowHeaderLevelCount, row)?.[0];\n if (isArray(rowDimensionKey)) {\n rowDimensionKey = rowDimensionKey[0];\n }\n const data = layout.dataset.collectedValues[rowDimensionKey] ?? ([] as string[]);\n\n const rowPath = layout.getRowKeysPath(col, row);\n const domain = (data[rowPath ?? ''] as Array<string>) ?? [];\n\n const { axisOption, isPercent } = getAxisOption(col + 1, row, 'left', layout);\n if (axisOption?.visible === false) {\n return;\n }\n // 左侧维度轴\n return merge(\n {\n domain: Array.from(domain).reverse(),\n title: {\n autoRotate: true\n }\n },\n axisOption,\n {\n orient: 'left',\n type: 'band'\n }\n );\n }\n } else {\n if (\n col === layout.rowHeaderLevelCount - 1 &&\n row >= layout.columnHeaderLevelCount &&\n row < layout.rowCount - layout.bottomFrozenRowCount\n ) {\n const indicatorKeys = layout.getIndicatorKeyInChartSpec(col, row);\n let defaultKey = indicatorKeys?.[0];\n if (isArray(defaultKey)) {\n defaultKey = defaultKey[0];\n }\n\n // const isZeroAlign = checkZeroAlign(col, row, 'left', layout);\n const { axisOption, isPercent, isZeroAlign } = getAxisOption(col + 1, row, 'left', layout);\n\n const data = layout.dataset.collectedValues[defaultKey + (isZeroAlign ? '_align' : '')]\n ? layout.dataset.collectedValues[defaultKey + (isZeroAlign ? '_align' : '')]\n : layout.dataset.collectedValues[defaultKey];\n const rowPath = layout.getRowKeysPath(col, row);\n const range = merge({}, (data?.[rowPath ?? ''] as { min: number; max: number }) ?? { min: 0, max: 1 });\n if (range.positiveMax && range.positiveMax > range.max) {\n range.max = range.positiveMax;\n }\n if (range.negativeMin && range.negativeMin < range.min) {\n range.min = range.negativeMin;\n }\n if (range.min === range.max) {\n if (range.min > 0) {\n range.min = 0;\n } else {\n range.max = 0;\n }\n }\n let indicatorInfo = null;\n indicatorKeys?.forEach(key => {\n const info = layout.getIndicatorInfo(key);\n if (info) {\n indicatorInfo = info;\n }\n });\n\n // const { axisOption, isPercent } = getAxisOption(col + 1, row, 'left', layout);\n if (axisOption?.visible === false) {\n return;\n }\n if (isPercent) {\n (range as any).min = (range as any).min < 0 ? -1 : 0;\n (range as any).max = (range as any).max > 0 ? 1 : 0;\n }\n const { range: niceRange, ticks } = getAxisDomainRangeAndLabels(range.min, range.max, axisOption, isZeroAlign);\n range.min = !isNaN(niceRange[0]) ? niceRange[0] : 0;\n range.max = !isNaN(niceRange[1]) ? niceRange[1] : 1;\n\n if (isNumber(axisOption?.min)) {\n (range as any).min = axisOption.min;\n }\n if (isNumber(axisOption?.max)) {\n (range as any).max = axisOption.max;\n }\n // 左侧指标轴\n return merge(\n {\n title: {\n visible: true,\n text: (indicatorInfo as any)?.title,\n autoRotate: true\n },\n range: range\n },\n axisOption,\n {\n orient: 'left',\n type: 'linear',\n label: {\n flush: true\n },\n __ticksForVTable: ticks\n }\n );\n } else if (\n col === layout.colCount - layout.rightFrozenColCount &&\n row >= layout.columnHeaderLevelCount &&\n row < layout.rowCount - layout.bottomFrozenRowCount\n ) {\n const indicatorKeys = layout.getIndicatorKeyInChartSpec(layout.rowHeaderLevelCount - 1, row);\n let defaultKey = indicatorKeys?.[1];\n if (isArray(defaultKey)) {\n defaultKey = defaultKey[0];\n }\n\n if (!defaultKey) {\n return undefined;\n }\n\n // const isZeroAlign = checkZeroAlign(col, row, 'right', layout);\n const { axisOption, isPercent, isZeroAlign } = getAxisOption(col - 1, row, 'right', layout);\n\n const data = layout.dataset.collectedValues[defaultKey + (isZeroAlign ? '_align' : '')]\n ? layout.dataset.collectedValues[defaultKey + (isZeroAlign ? '_align' : '')]\n : layout.dataset.collectedValues[defaultKey];\n const rowPath = layout.getRowKeysPath(col, row);\n const range = merge({}, (data?.[rowPath ?? ''] as { min: number; max: number }) ?? { min: 0, max: 1 });\n if (range.positiveMax && range.positiveMax > range.max) {\n range.max = range.positiveMax;\n }\n if (range.negativeMin && range.negativeMin < range.min) {\n range.min = range.negativeMin;\n }\n // const { axisOption, isPercent } = getAxisOption(col - 1, row, 'right', layout);\n if (range.min === range.max) {\n if (range.min > 0) {\n range.min = 0;\n } else {\n range.max = 0;\n }\n }\n if (axisOption?.visible === false) {\n return;\n }\n if (isPercent) {\n (range as any).min = (range as any).min < 0 ? -1 : 0;\n (range as any).max = (range as any).max > 0 ? 1 : 0;\n }\n const { range: niceRange, ticks } = getAxisDomainRangeAndLabels(range.min, range.max, axisOption, isZeroAlign);\n range.min = !isNaN(niceRange[0]) ? niceRange[0] : 0;\n range.max = !isNaN(niceRange[1]) ? niceRange[1] : 1;\n\n if (isNumber(axisOption?.min)) {\n (range as any).min = axisOption.min;\n }\n if (isNumber(axisOption?.max)) {\n (range as any).max = axisOption.max;\n }\n // 右侧副指标轴\n return merge(\n {\n range: range,\n title: {\n autoRotate: true\n }\n },\n axisOption,\n {\n orient: 'right',\n type: 'linear',\n label: {\n flush: true\n },\n __ticksForVTable: ticks\n }\n );\n } else if (\n row === layout.rowCount - layout.bottomFrozenRowCount &&\n col >= layout.rowHeaderLevelCount &&\n col < layout.colCount - layout.rightFrozenColCount\n ) {\n // const indicatorKeys = layout.getIndicatorKeyInChartSpec(col, row);\n\n let columnDimensionKey = layout.getDimensionKeyInChartSpec(col, layout.columnHeaderLevelCount)?.[0];\n if (isArray(columnDimensionKey)) {\n columnDimensionKey = columnDimensionKey[0];\n }\n const data = layout.dataset.collectedValues[columnDimensionKey] ?? ([] as string[]);\n\n const colPath = layout.getColKeysPath(col, row);\n const domain = (data?.[colPath ?? ''] as Array<string>) ?? [];\n\n const { axisOption, isPercent } = getAxisOption(col, row - 1, 'bottom', layout);\n if (axisOption?.visible === false) {\n return;\n }\n // 底部维度轴\n return merge(\n {\n domain: Array.from(domain)\n },\n axisOption,\n {\n orient: 'bottom',\n type: 'band'\n }\n );\n }\n }\n\n return undefined;\n}\n\nexport function getAxisOption(col: number, row: number, orient: string, layout: PivotHeaderLayoutMap) {\n const spec = layout.getRawChartSpec(col, row);\n if (spec && isArray(spec.axes)) {\n const axisOption = spec.axes.find((axis: any) => {\n return axis.orient === orient;\n });\n if (axisOption) {\n return {\n axisOption,\n isPercent: spec.percent,\n isZeroAlign: checkZeroAlign(spec, orient, layout)\n };\n }\n }\n const axisOption = ((layout._table as PivotChart).pivotChartAxes as ITableAxisOption[]).find(axisOption => {\n return axisOption.orient === orient;\n });\n return {\n axisOption,\n isPercent: false,\n isZeroAlign: checkZeroAlign(spec, orient, layout)\n };\n}\n\nexport function checkZeroAlign(spec: any, orient: string, layout: PivotHeaderLayoutMap) {\n // check condition:\n // 1. two axes and one set sync\n // 2. axisId in sync is another\n const orients: string[] = [];\n if (orient === 'left' || orient === 'right') {\n orients.push('left', 'right');\n } else if (orient === 'top' || orient === 'bottom') {\n orients.push('top', 'bottom');\n }\n // const spec = layout.getRawChartSpec(col, row);\n let axesSpec;\n if (spec && isArray(spec.axes)) {\n axesSpec = spec.axes;\n } else {\n axesSpec = (layout._table as PivotChart).pivotChartAxes as ITableAxisOption[];\n }\n if (isArray(axesSpec)) {\n const axes: any[] = [];\n axesSpec.forEach((axis: any) => {\n if (orients.includes(axis.orient)) {\n axes.push(axis);\n }\n });\n for (let i = 0; i < axes.length; i++) {\n const axis = axes[i];\n if (\n axis.sync &&\n axis.sync.zeroAlign &&\n axis.sync.axisId &&\n axes.find(axisSync => {\n return axisSync.id === axis.sync.axisId;\n })\n ) {\n return true;\n }\n }\n }\n\n return false;\n}\n"]}
1
+ {"version":3,"sources":["layout/chart-helper/get-axis-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAIrE,OAAO,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAC;AAGhE,MAAM,UAAU,yBAAy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KAAK,CAAC,WAAW,CAAC;KAC/B;IACD,IAAI,KAAK,CAAC,GAAG,KAAK,KAAK,CAAC,GAAG,EAAE;QAC3B,IAAI,KAAK,CAAC,GAAG,GAAG,CAAC,EAAE;YACjB,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC;SACf;aAAM;YACL,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC;SACf;KACF;IAED,OAAO,KAAK,CAAC;AACf,CAAC","file":"get-axis-config.js","sourcesContent":["import { isArray, isNumber, isValid, merge } from '@visactor/vutils';\nimport type { PivotHeaderLayoutMap } from '../pivot-header-layout';\nimport type { ITableAxisOption } from '../../ts-types/component/axis';\nimport type { PivotChart } from '../../PivotChart';\nimport { getAxisDomainRangeAndLabels } from './get-axis-domain';\nimport type { CollectedValue } from '../../ts-types';\n\nexport function getAxisConfigInPivotChart(col: number, row: number, layout: PivotHeaderLayoutMap): any {\n if (!layout._table.isPivotChart()) {\n return undefined;\n }\n\n // 是否是指标\n if (layout.indicatorsAsCol) {\n if (\n layout.hasTwoIndicatorAxes &&\n row === layout.columnHeaderLevelCount - 1 &&\n col >= layout.rowHeaderLevelCount &&\n col < layout.colCount - layout.rightFrozenColCount\n ) {\n const { axisOption, isPercent, isZeroAlign, seriesIndice } = getAxisOption(col, row + 1, 'top', layout);\n if (axisOption?.visible === false) {\n return;\n }\n const indicatorKeys = layout.getIndicatorKeyInChartSpec(col, layout.columnHeaderLevelCount - 1);\n const colPath = layout.getColKeysPath(col, row);\n\n const range = getAxisRange(\n layout.dataset.collectedValues,\n indicatorKeys,\n isZeroAlign,\n colPath,\n seriesIndice ?? 1\n );\n if (!range) {\n return;\n }\n\n // let defaultKey = indicatorKeys?.[1];\n // if (isArray(defaultKey)) {\n // defaultKey = defaultKey[0];\n // }\n // if (!defaultKey) {\n // return undefined;\n // }\n\n // // const isZeroAlign = checkZeroAlign(col, row, 'top', layout);\n // // const data = layout.dataset.collectedValues[defaultKey];\n // const data = layout.dataset.collectedValues[defaultKey + (isZeroAlign ? '_align' : '')]\n // ? layout.dataset.collectedValues[defaultKey + (isZeroAlign ? '_align' : '')]\n // : layout.dataset.collectedValues[defaultKey];\n\n // const range = merge({}, (data?.[colPath ?? ''] as { min: number; max: number }) ?? { min: 0, max: 1 });\n // if (range.positiveMax && range.positiveMax > range.max) {\n // range.max = range.positiveMax;\n // }\n // if (range.negativeMin && range.negativeMin < range.min) {\n // range.min = range.negativeMin;\n // }\n // // const { axisOption, isPercent } = getAxisOption(col, row + 1, 'top', layout);\n // if (range.min === range.max) {\n // if (range.min > 0) {\n // range.min = 0;\n // } else {\n // range.max = 0;\n // }\n // }\n if (isPercent) {\n range.min = range.min < 0 ? -1 : 0;\n range.max = range.max > 0 ? 1 : 0;\n }\n const { range: niceRange, ticks } = getAxisDomainRangeAndLabels(range.min, range.max, axisOption, isZeroAlign);\n range.min = !isNaN(niceRange[0]) ? niceRange[0] : 0;\n range.max = !isNaN(niceRange[1]) ? niceRange[1] : 1;\n\n if (isNumber(axisOption?.min)) {\n range.min = axisOption.min;\n }\n if (isNumber(axisOption?.max)) {\n range.max = axisOption.max;\n }\n // 顶部副指标轴\n return merge(\n {\n range: range\n },\n axisOption,\n {\n orient: 'top',\n type: 'linear',\n label: {\n flush: true\n },\n __ticksForVTable: ticks\n }\n );\n } else if (\n row === layout.rowCount - layout.bottomFrozenRowCount &&\n col >= layout.rowHeaderLevelCount &&\n col < layout.colCount - layout.rightFrozenColCount\n ) {\n const { axisOption, isPercent, isZeroAlign, seriesIndice } = getAxisOption(col, row - 1, 'bottom', layout);\n if (axisOption?.visible === false) {\n return;\n }\n const indicatorKeys = layout.getIndicatorKeyInChartSpec(col, row);\n const colPath = layout.getColKeysPath(col, row);\n\n const range = getAxisRange(\n layout.dataset.collectedValues,\n indicatorKeys,\n isZeroAlign,\n colPath,\n seriesIndice ?? 0\n );\n if (!range) {\n return;\n }\n\n // let defaultKey = indicatorKeys?.[0];\n // if (isArray(defaultKey)) {\n // defaultKey = defaultKey[0];\n // }\n // const data = layout.dataset.collectedValues[defaultKey + (isZeroAlign ? '_align' : '')]\n // ? layout.dataset.collectedValues[defaultKey + (isZeroAlign ? '_align' : '')]\n // : layout.dataset.collectedValues[defaultKey];\n // const range = merge({}, (data?.[colPath ?? ''] as { min: number; max: number }) ?? { min: 0, max: 1 });\n // if (range.positiveMax && range.positiveMax > range.max) {\n // range.max = range.positiveMax;\n // }\n // if (range.negativeMin && range.negativeMin < range.min) {\n // range.min = range.negativeMin;\n // }\n // if (range.min === range.max) {\n // if (range.min > 0) {\n // range.min = 0;\n // } else {\n // range.max = 0;\n // }\n // }\n\n let indicatorInfo = null;\n indicatorKeys?.forEach(key => {\n const info = layout.getIndicatorInfo(key);\n if (info) {\n indicatorInfo = info;\n }\n });\n\n // const { axisOption, isPercent } = getAxisOption(col, row - 1, 'bottom', layout);\n if (isPercent) {\n (range as any).min = (range as any).min < 0 ? -1 : 0;\n (range as any).max = (range as any).max > 0 ? 1 : 0;\n }\n const { range: niceRange, ticks } = getAxisDomainRangeAndLabels(range.min, range.max, axisOption, isZeroAlign);\n range.min = !isNaN(niceRange[0]) ? niceRange[0] : 0;\n range.max = !isNaN(niceRange[1]) ? niceRange[1] : 1;\n\n if (isNumber(axisOption?.min)) {\n (range as any).min = axisOption.min;\n }\n if (isNumber(axisOption?.max)) {\n (range as any).max = axisOption.max;\n }\n // 底侧指标轴\n return merge(\n {\n title: {\n visible: true,\n text: (indicatorInfo as any)?.title\n // autoRotate: true\n },\n range: range\n },\n axisOption,\n {\n orient: 'bottom',\n type: 'linear',\n label: {\n flush: true\n },\n __ticksForVTable: ticks\n }\n );\n } else if (\n col === layout.rowHeaderLevelCount - 1 &&\n row >= layout.columnHeaderLevelCount &&\n row < layout.rowCount - layout.bottomFrozenRowCount\n ) {\n let rowDimensionKey = layout.getDimensionKeyInChartSpec(layout.rowHeaderLevelCount, row)?.[0];\n if (isArray(rowDimensionKey)) {\n rowDimensionKey = rowDimensionKey[0];\n }\n const data = layout.dataset.collectedValues[rowDimensionKey] ?? ([] as string[]);\n\n const rowPath = layout.getRowKeysPath(col, row);\n const domain = (data[rowPath ?? ''] as Array<string>) ?? [];\n\n const { axisOption, isPercent } = getAxisOption(col + 1, row, 'left', layout);\n if (axisOption?.visible === false) {\n return;\n }\n // 左侧维度轴\n return merge(\n {\n domain: Array.from(domain).reverse(),\n title: {\n autoRotate: true\n }\n },\n axisOption,\n {\n orient: 'left',\n type: 'band'\n }\n );\n }\n } else {\n if (\n col === layout.rowHeaderLevelCount - 1 &&\n row >= layout.columnHeaderLevelCount &&\n row < layout.rowCount - layout.bottomFrozenRowCount\n ) {\n const { axisOption, isPercent, isZeroAlign, seriesIndice } = getAxisOption(col + 1, row, 'left', layout);\n if (axisOption?.visible === false) {\n return;\n }\n const indicatorKeys = layout.getIndicatorKeyInChartSpec(col, row);\n const rowPath = layout.getRowKeysPath(col, row);\n const range = getAxisRange(\n layout.dataset.collectedValues,\n indicatorKeys,\n isZeroAlign,\n rowPath,\n seriesIndice ?? 0\n );\n if (!range) {\n return;\n }\n\n // let defaultKey = indicatorKeys?.[0];\n // if (isArray(defaultKey)) {\n // defaultKey = defaultKey[0];\n // }\n // const data = layout.dataset.collectedValues[defaultKey + (isZeroAlign ? '_align' : '')]\n // ? layout.dataset.collectedValues[defaultKey + (isZeroAlign ? '_align' : '')]\n // : layout.dataset.collectedValues[defaultKey];\n // const range = merge({}, (data?.[rowPath ?? ''] as { min: number; max: number }) ?? { min: 0, max: 1 });\n // if (range.positiveMax && range.positiveMax > range.max) {\n // range.max = range.positiveMax;\n // }\n // if (range.negativeMin && range.negativeMin < range.min) {\n // range.min = range.negativeMin;\n // }\n // if (range.min === range.max) {\n // if (range.min > 0) {\n // range.min = 0;\n // } else {\n // range.max = 0;\n // }\n // }\n\n let indicatorInfo = null;\n indicatorKeys?.forEach(key => {\n const info = layout.getIndicatorInfo(key);\n if (info) {\n indicatorInfo = info;\n }\n });\n\n if (isPercent) {\n range.min = range.min < 0 ? -1 : 0;\n range.max = range.max > 0 ? 1 : 0;\n }\n const { range: niceRange, ticks } = getAxisDomainRangeAndLabels(range.min, range.max, axisOption, isZeroAlign);\n range.min = !isNaN(niceRange[0]) ? niceRange[0] : 0;\n range.max = !isNaN(niceRange[1]) ? niceRange[1] : 1;\n\n if (isNumber(axisOption?.min)) {\n range.min = axisOption.min;\n }\n if (isNumber(axisOption?.max)) {\n range.max = axisOption.max;\n }\n // 左侧指标轴\n return merge(\n {\n title: {\n visible: true,\n text: (indicatorInfo as any)?.title,\n autoRotate: true\n },\n range: range\n },\n axisOption,\n {\n orient: 'left',\n type: 'linear',\n label: {\n flush: true\n },\n __ticksForVTable: ticks\n }\n );\n } else if (\n col === layout.colCount - layout.rightFrozenColCount &&\n row >= layout.columnHeaderLevelCount &&\n row < layout.rowCount - layout.bottomFrozenRowCount\n ) {\n const { axisOption, isPercent, isZeroAlign, seriesIndice } = getAxisOption(col - 1, row, 'right', layout);\n if (axisOption?.visible === false) {\n return;\n }\n const indicatorKeys = layout.getIndicatorKeyInChartSpec(layout.rowHeaderLevelCount - 1, row);\n const rowPath = layout.getRowKeysPath(col, row);\n const range = getAxisRange(\n layout.dataset.collectedValues,\n indicatorKeys,\n isZeroAlign,\n rowPath,\n seriesIndice ?? 1\n );\n if (!range) {\n return;\n }\n\n // let defaultKey = indicatorKeys?.[1];\n // if (isArray(defaultKey)) {\n // defaultKey = defaultKey[0];\n // }\n // if (!defaultKey) {\n // return undefined;\n // }\n // const data = layout.dataset.collectedValues[defaultKey + (isZeroAlign ? '_align' : '')]\n // ? layout.dataset.collectedValues[defaultKey + (isZeroAlign ? '_align' : '')]\n // : layout.dataset.collectedValues[defaultKey];\n // const range = merge({}, (data?.[rowPath ?? ''] as { min: number; max: number }) ?? { min: 0, max: 1 });\n // if (range.positiveMax && range.positiveMax > range.max) {\n // range.max = range.positiveMax;\n // }\n // if (range.negativeMin && range.negativeMin < range.min) {\n // range.min = range.negativeMin;\n // }\n // // const { axisOption, isPercent } = getAxisOption(col - 1, row, 'right', layout);\n // if (range.min === range.max) {\n // if (range.min > 0) {\n // range.min = 0;\n // } else {\n // range.max = 0;\n // }\n // }\n\n if (isPercent) {\n (range as any).min = (range as any).min < 0 ? -1 : 0;\n (range as any).max = (range as any).max > 0 ? 1 : 0;\n }\n const { range: niceRange, ticks } = getAxisDomainRangeAndLabels(range.min, range.max, axisOption, isZeroAlign);\n range.min = !isNaN(niceRange[0]) ? niceRange[0] : 0;\n range.max = !isNaN(niceRange[1]) ? niceRange[1] : 1;\n\n if (isNumber(axisOption?.min)) {\n (range as any).min = axisOption.min;\n }\n if (isNumber(axisOption?.max)) {\n (range as any).max = axisOption.max;\n }\n // 右侧副指标轴\n return merge(\n {\n range: range,\n title: {\n autoRotate: true\n }\n },\n axisOption,\n {\n orient: 'right',\n type: 'linear',\n label: {\n flush: true\n },\n __ticksForVTable: ticks\n }\n );\n } else if (\n row === layout.rowCount - layout.bottomFrozenRowCount &&\n col >= layout.rowHeaderLevelCount &&\n col < layout.colCount - layout.rightFrozenColCount\n ) {\n // const indicatorKeys = layout.getIndicatorKeyInChartSpec(col, row);\n\n let columnDimensionKey = layout.getDimensionKeyInChartSpec(col, layout.columnHeaderLevelCount)?.[0];\n if (isArray(columnDimensionKey)) {\n columnDimensionKey = columnDimensionKey[0];\n }\n const data = layout.dataset.collectedValues[columnDimensionKey] ?? ([] as string[]);\n\n const colPath = layout.getColKeysPath(col, row);\n const domain = (data?.[colPath ?? ''] as Array<string>) ?? [];\n\n const { axisOption, isPercent } = getAxisOption(col, row - 1, 'bottom', layout);\n if (axisOption?.visible === false) {\n return;\n }\n // 底部维度轴\n return merge(\n {\n domain: Array.from(domain)\n },\n axisOption,\n {\n orient: 'bottom',\n type: 'band'\n }\n );\n }\n }\n\n return undefined;\n}\n\nexport function getAxisOption(col: number, row: number, orient: string, layout: PivotHeaderLayoutMap) {\n const spec = layout.getRawChartSpec(col, row);\n if (spec && isArray(spec.axes)) {\n const axisOption = spec.axes.find((axis: any) => {\n return axis.orient === orient;\n });\n if (axisOption) {\n const { seriesIndex, seriesId } = axisOption;\n let seriesIndice;\n if (isValid(seriesId) && isArray(spec.series)) {\n seriesIndice = (isArray(seriesId) ? seriesId : [seriesId]).map(id =>\n spec.series.findIndex((s: any) => s.id === id)\n );\n } else if (isValid(seriesIndex) && isArray(spec.series)) {\n seriesIndice = seriesIndex;\n }\n return {\n axisOption,\n isPercent: spec.percent,\n isZeroAlign: checkZeroAlign(spec, orient, layout),\n seriesIndice\n };\n }\n }\n const axisOption = ((layout._table as PivotChart).pivotChartAxes as ITableAxisOption[]).find(axisOption => {\n return axisOption.orient === orient;\n });\n return {\n axisOption,\n isPercent: false,\n isZeroAlign: checkZeroAlign(spec, orient, layout)\n };\n}\n\nexport function checkZeroAlign(spec: any, orient: string, layout: PivotHeaderLayoutMap) {\n // check condition:\n // 1. two axes and one set sync\n // 2. axisId in sync is another\n const orients: string[] = [];\n if (orient === 'left' || orient === 'right') {\n orients.push('left', 'right');\n } else if (orient === 'top' || orient === 'bottom') {\n orients.push('top', 'bottom');\n }\n // const spec = layout.getRawChartSpec(col, row);\n let axesSpec;\n if (spec && isArray(spec.axes)) {\n axesSpec = spec.axes;\n } else {\n axesSpec = (layout._table as PivotChart).pivotChartAxes as ITableAxisOption[];\n }\n if (isArray(axesSpec)) {\n const axes: any[] = [];\n axesSpec.forEach((axis: any) => {\n if (orients.includes(axis.orient)) {\n axes.push(axis);\n }\n });\n for (let i = 0; i < axes.length; i++) {\n const axis = axes[i];\n if (\n axis.sync &&\n axis.sync.zeroAlign &&\n axis.sync.axisId &&\n axes.find(axisSync => {\n return axisSync.id === axis.sync.axisId;\n })\n ) {\n return true;\n }\n }\n }\n\n return false;\n}\n\nexport function getAxisRange(\n collectedValues: Record<string, Record<string, CollectedValue>>,\n indicatorKeys: string[],\n isZeroAlign: boolean,\n colPath: string,\n seriesId: number | number[]\n): { max: number; min: number } | null {\n if (isArray(seriesId)) {\n const range = { min: Infinity, max: -Infinity };\n for (let i = 0; i < seriesId.length; i++) {\n const singleRange = getAxisRange(collectedValues, indicatorKeys, isZeroAlign, colPath, seriesId[i]);\n if (singleRange) {\n range.min = Math.min(range.min, singleRange.min);\n range.max = Math.max(range.max, singleRange.max);\n }\n }\n if (isFinite(range.min) && isFinite(range.max)) {\n return range;\n }\n return null;\n }\n let defaultKey = indicatorKeys?.[seriesId];\n if (isArray(defaultKey)) {\n defaultKey = defaultKey[0];\n }\n if (!defaultKey) {\n return null;\n }\n const data = collectedValues[defaultKey + (isZeroAlign ? '_align' : '')]\n ? collectedValues[defaultKey + (isZeroAlign ? '_align' : '')]\n : collectedValues[defaultKey];\n const range = merge({}, (data?.[colPath ?? ''] as { min: number; max: number }) ?? { min: 0, max: 1 });\n\n if (range.positiveMax && range.positiveMax > range.max) {\n range.max = range.positiveMax;\n }\n if (range.negativeMin && range.negativeMin < range.min) {\n range.min = range.negativeMin;\n }\n if (range.min === range.max) {\n if (range.min > 0) {\n range.min = 0;\n } else {\n range.max = 0;\n }\n }\n\n return range;\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import { cloneDeep, isArray, isNumber, merge } from "@visactor/vutils";
2
2
 
3
- import { getAxisOption } from "./get-axis-config";
3
+ import { getAxisOption, getAxisRange } from "./get-axis-config";
4
4
 
5
5
  import { getAxisDomainRangeAndLabels } from "./get-axis-domain";
6
6
 
@@ -33,18 +33,10 @@ export function getChartAxes(col, row, layout) {
33
33
  var _a, _b;
34
34
  const axes = [];
35
35
  if (layout.indicatorsAsCol) {
36
- const indicatorKeys = layout.getIndicatorKeyInChartSpec(col, row);
37
- layout.getRecordIndexByCol(col);
36
+ const indicatorKeys = layout.getIndicatorKeyInChartSpec(col, row), colPath = layout.getColKeysPath(col, row);
38
37
  indicatorKeys.forEach(((key, index) => {
39
- var _a;
40
- isArray(key) && (key = key[0]);
41
- const {axisOption: axisOption, isPercent: isPercent, isZeroAlign: isZeroAlign} = getAxisOption(col, row, 0 === index ? "bottom" : "top", layout), data = layout.dataset.collectedValues[key + (isZeroAlign ? "_align" : "")] ? layout.dataset.collectedValues[key + (isZeroAlign ? "_align" : "")] : layout.dataset.collectedValues[key], colPath = layout.getColKeysPath(col, row), range = merge({}, null !== (_a = null == data ? void 0 : data[null != colPath ? colPath : ""]) && void 0 !== _a ? _a : {
42
- min: 0,
43
- max: 1
44
- });
45
- if (range.positiveMax && range.positiveMax > range.max && (range.max = range.positiveMax),
46
- range.negativeMin && range.negativeMin < range.min && (range.min = range.negativeMin),
47
- isPercent && (range.min = range.min < 0 ? -1 : 0, range.max = range.max > 0 ? 1 : 0),
38
+ const {axisOption: axisOption, isPercent: isPercent, isZeroAlign: isZeroAlign, seriesIndice: seriesIndice} = getAxisOption(col, row, 0 === index ? "bottom" : "top", layout), range = getAxisRange(layout.dataset.collectedValues, indicatorKeys, isZeroAlign, colPath, null != seriesIndice ? seriesIndice : index);
39
+ if (isPercent && (range.min = range.min < 0 ? -1 : 0, range.max = range.max > 0 ? 1 : 0),
48
40
  ((null == axisOption ? void 0 : axisOption.zero) || range.min === range.max) && (range.min = Math.min(range.min, 0),
49
41
  range.max = Math.max(range.max, 0)), null == axisOption ? void 0 : axisOption.nice) {
50
42
  const {range: axisRange} = getAxisDomainRangeAndLabels(range.min, range.max, axisOption, isZeroAlign);
@@ -101,15 +93,8 @@ export function getChartAxes(col, row, layout) {
101
93
  } else {
102
94
  const indicatorKeys = layout.getIndicatorKeyInChartSpec(col, row), rowPath = layout.getRowKeysPath(col, row);
103
95
  indicatorKeys.forEach(((key, index) => {
104
- var _a;
105
- isArray(key) && (key = key[0]);
106
- const {axisOption: axisOption, isPercent: isPercent, isZeroAlign: isZeroAlign} = getAxisOption(col, row, 0 === index ? "left" : "right", layout), data = layout.dataset.collectedValues[key + (isZeroAlign ? "_align" : "")] ? layout.dataset.collectedValues[key + (isZeroAlign ? "_align" : "")] : layout.dataset.collectedValues[key], range = merge({}, null !== (_a = null == data ? void 0 : data[null != rowPath ? rowPath : ""]) && void 0 !== _a ? _a : {
107
- min: 0,
108
- max: 1
109
- });
110
- if (range.positiveMax && range.positiveMax > range.max && (range.max = range.positiveMax),
111
- range.negativeMin && range.negativeMin < range.min && (range.min = range.negativeMin),
112
- isPercent && (range.min = range.min < 0 ? -1 : 0, range.max = range.max > 0 ? 1 : 0),
96
+ const {axisOption: axisOption, isPercent: isPercent, isZeroAlign: isZeroAlign, seriesIndice: seriesIndice} = getAxisOption(col, row, 0 === index ? "left" : "right", layout), range = getAxisRange(layout.dataset.collectedValues, indicatorKeys, isZeroAlign, rowPath, null != seriesIndice ? seriesIndice : index);
97
+ if (isPercent && (range.min = range.min < 0 ? -1 : 0, range.max = range.max > 0 ? 1 : 0),
113
98
  ((null == axisOption ? void 0 : axisOption.zero) || range.min === range.max) && (range.min = Math.min(range.min, 0),
114
99
  range.max = Math.max(range.max, 0)), null == axisOption ? void 0 : axisOption.nice) {
115
100
  const {range: axisRange} = getAxisDomainRangeAndLabels(range.min, range.max, axisOption, isZeroAlign);
@@ -1 +1 @@
1
- {"version":3,"sources":["layout/chart-helper/get-chart-spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAGvE,OAAO,EAAkB,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAC;AAEhE,MAAM,oBAAoB,GAAG,sBAAsB,CAAC;AAEpD,MAAM,UAAU,eAAe,CAAC,GAAW,EAAE,GAAW,EAAE,MAA4B;;IACpF,MAAM,KAAK,GAAG,MAAM,CAAC,kBAAkB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAClD,IAAI,YAAY,CAAC;IACjB,IAAI,MAAM,CAAC,eAAe,EAAE;QAC1B,MAAM,YAAY,GAAG,MAAA,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,YAAY,CAAC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C,CAAC,CAAC;QACH,OAAO,WAAW,CAAC;KACpB;IACD,OAAO,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;AAC3B,CAAC","file":"get-chart-spec.js","sourcesContent":["import { cloneDeep, isArray, isNumber, merge } from '@visactor/vutils';\nimport type { PivotHeaderLayoutMap } from '../pivot-header-layout';\nimport type { SimpleHeaderLayoutMap } from '../simple-header-layout';\nimport { checkZeroAlign, getAxisOption } from './get-axis-config';\nimport { getAxisDomainRangeAndLabels } from './get-axis-domain';\n\nconst NO_AXISID_FRO_VTABLE = 'NO_AXISID_FRO_VTABLE';\n\nexport function getRawChartSpec(col: number, row: number, layout: PivotHeaderLayoutMap): any {\n const paths = layout.getCellHeaderPaths(col, row);\n let indicatorObj;\n if (layout.indicatorsAsCol) {\n const indicatorKey = paths.colHeaderPaths.find(colPath => colPath.indicatorKey)?.indicatorKey;\n indicatorObj = layout.columnObjects.find(indicator => indicator.indicatorKey === indicatorKey);\n } else {\n const indicatorKey = paths.rowHeaderPaths.find(rowPath => rowPath.indicatorKey)?.indicatorKey;\n indicatorObj = layout.columnObjects.find(indicator => indicator.indicatorKey === indicatorKey);\n }\n const chartSpec = indicatorObj?.chartSpec;\n\n return chartSpec;\n}\n\nexport function getChartSpec(col: number, row: number, layout: PivotHeaderLayoutMap): any {\n let chartSpec = layout.getRawChartSpec(col, row);\n if (chartSpec) {\n chartSpec = cloneDeep(chartSpec);\n chartSpec.sortDataByAxis = true;\n if (isArray(chartSpec.series)) {\n chartSpec.series.forEach((serie: any) => {\n serie.sortDataByAxis = true;\n });\n }\n chartSpec.axes = layout.getChartAxes(col, row);\n chartSpec.padding = 0;\n chartSpec.dataZoom = []; // Do not support datazoom temply\n return chartSpec;\n }\n return null;\n}\n\nexport function getChartAxes(col: number, row: number, layout: PivotHeaderLayoutMap): any {\n const axes = [];\n if (layout.indicatorsAsCol) {\n const indicatorKeys = layout.getIndicatorKeyInChartSpec(col, row);\n const colIndex = layout.getRecordIndexByCol(col);\n indicatorKeys.forEach((key, index) => {\n if (isArray(key)) {\n key = key[0];\n }\n\n const { axisOption, isPercent, isZeroAlign } = getAxisOption(col, row, index === 0 ? 'bottom' : 'top', layout);\n\n const data = layout.dataset.collectedValues[key + (isZeroAlign ? '_align' : '')]\n ? layout.dataset.collectedValues[key + (isZeroAlign ? '_align' : '')]\n : layout.dataset.collectedValues[key];\n const colPath = layout.getColKeysPath(col, row);\n const range = merge({}, (data?.[colPath ?? ''] as { max?: number; min?: number }) ?? { min: 0, max: 1 });\n if (range.positiveMax && range.positiveMax > range.max) {\n range.max = range.positiveMax;\n }\n if (range.negativeMin && range.negativeMin < range.min) {\n range.min = range.negativeMin;\n }\n if (isPercent) {\n (range as any).min = (range as any).min < 0 ? -1 : 0;\n (range as any).max = (range as any).max > 0 ? 1 : 0;\n }\n if (axisOption?.zero || range.min === range.max) {\n range.min = Math.min(range.min, 0);\n range.max = Math.max(range.max, 0);\n }\n if (axisOption?.nice) {\n const { range: axisRange } = getAxisDomainRangeAndLabels(range.min, range.max, axisOption, isZeroAlign);\n range.min = axisRange[0];\n range.max = axisRange[1];\n }\n if (isNumber(axisOption?.min)) {\n (range as any).min = axisOption.min;\n }\n if (isNumber(axisOption?.max)) {\n (range as any).max = axisOption.max;\n }\n axes.push(\n merge(\n {\n range\n },\n axisOption,\n {\n type: 'linear',\n orient: index === 0 ? 'bottom' : 'top',\n // visible: true,\n label: { visible: false },\n title: { visible: false },\n domainLine: { visible: false },\n seriesIndex: index,\n height: -1,\n\n sync: { axisId: NO_AXISID_FRO_VTABLE } // hack for fs\n }\n )\n );\n });\n\n let rowDimensionKey = layout.getDimensionKeyInChartSpec(layout.rowHeaderLevelCount, row)?.[0];\n if (isArray(rowDimensionKey)) {\n rowDimensionKey = rowDimensionKey[0];\n }\n const data =\n layout.dataset.cacheCollectedValues[rowDimensionKey] ||\n layout.dataset.collectedValues[rowDimensionKey] ||\n ([] as string[]);\n const rowPath = layout.getRowKeysPath(col, row);\n const domain = data[rowPath ?? ''] as Set<string>;\n\n const { axisOption, isPercent } = getAxisOption(col, row, 'left', layout);\n axes.push(\n merge(\n {\n domain: Array.from(domain ?? [])\n },\n axisOption,\n {\n type: 'band',\n orient: 'left',\n // visible: true,\n label: { visible: false },\n domainLine: { visible: false },\n tick: { visible: false },\n subTick: { visible: false },\n title: { visible: false },\n // height: -1,\n width: -1\n // autoIndent: false,\n }\n )\n );\n } else {\n const indicatorKeys = layout.getIndicatorKeyInChartSpec(col, row);\n const rowPath = layout.getRowKeysPath(col, row);\n indicatorKeys.forEach((key, index) => {\n if (isArray(key)) {\n key = key[0];\n }\n\n const { axisOption, isPercent, isZeroAlign } = getAxisOption(col, row, index === 0 ? 'left' : 'right', layout);\n\n const data = layout.dataset.collectedValues[key + (isZeroAlign ? '_align' : '')]\n ? layout.dataset.collectedValues[key + (isZeroAlign ? '_align' : '')]\n : layout.dataset.collectedValues[key];\n\n const range = merge({}, (data?.[rowPath ?? ''] as { max?: number; min?: number }) ?? { min: 0, max: 1 });\n if (range.positiveMax && range.positiveMax > range.max) {\n range.max = range.positiveMax;\n }\n if (range.negativeMin && range.negativeMin < range.min) {\n range.min = range.negativeMin;\n }\n if (isPercent) {\n (range as any).min = (range as any).min < 0 ? -1 : 0;\n (range as any).max = (range as any).max > 0 ? 1 : 0;\n }\n if (axisOption?.zero || range.min === range.max) {\n range.min = Math.min(range.min, 0);\n range.max = Math.max(range.max, 0);\n }\n if (axisOption?.nice) {\n const { range: axisRange } = getAxisDomainRangeAndLabels(range.min, range.max, axisOption, isZeroAlign);\n range.min = axisRange[0];\n range.max = axisRange[1];\n }\n if (isNumber(axisOption?.min)) {\n (range as any).min = axisOption.min;\n }\n if (isNumber(axisOption?.max)) {\n (range as any).max = axisOption.max;\n }\n axes.push(\n merge(\n {\n range\n },\n axisOption,\n {\n type: 'linear',\n orient: index === 0 ? 'left' : 'right',\n // visible: true,\n label: { visible: false },\n // label: { flush: true },\n title: { visible: false },\n domainLine: { visible: false },\n seriesIndex: index,\n width: -1,\n // grid: index === 0 ? undefined : { visible: false }\n\n sync: { axisId: NO_AXISID_FRO_VTABLE } // hack for fs\n }\n )\n );\n });\n\n let columnDimensionKey = layout.getDimensionKeyInChartSpec(col, layout.columnHeaderLevelCount)[0];\n if (isArray(columnDimensionKey)) {\n columnDimensionKey = columnDimensionKey[0];\n }\n const data =\n layout.dataset.cacheCollectedValues[columnDimensionKey] ||\n layout.dataset.collectedValues[columnDimensionKey] ||\n ([] as string[]);\n const colPath = layout.getColKeysPath(col, row);\n const domain: string[] | Set<string> = (data?.[colPath ?? ''] as Set<string>) ?? [];\n\n const { axisOption, isPercent } = getAxisOption(col, row, 'bottom', layout);\n axes.push(\n merge(\n {\n domain: Array.from(domain)\n },\n axisOption,\n {\n type: 'band',\n orient: 'bottom',\n visible: true,\n label: { visible: false },\n domainLine: { visible: false },\n tick: { visible: false },\n subTick: { visible: false },\n title: { visible: false },\n height: -1\n // autoIndent: false,\n }\n )\n );\n }\n return axes;\n}\n/**\n * 获取单元格对应spec的dataId。\n * 如果是spec外层的dataId,则是string,否则通过series获取到的是Record<string, string> => <dataId, series-chart的指标key用于过滤数据>\n * @param col\n * @param row\n * @param layout\n * @returns\n */\nexport function getChartDataId(\n col: number,\n row: number,\n layout: PivotHeaderLayoutMap | SimpleHeaderLayoutMap\n): string | Record<string, string> {\n const chartSpec = layout.getRawChartSpec(col, row);\n // 如果chartSpec配置了组合图 series 则需要考虑 series中存在的多个指标\n if (chartSpec?.series) {\n const dataIdfield: Record<string, string> = {};\n\n if (chartSpec.data?.id) {\n dataIdfield[chartSpec.data.id] = undefined;\n }\n chartSpec?.series.forEach((seriesSpec: any) => {\n if (!seriesSpec.data?.fromDataId) {\n if (!seriesSpec.data?.transforms) {\n const seriesField = seriesSpec.direction === 'horizontal' ? seriesSpec.xField : seriesSpec.yField;\n dataIdfield[seriesSpec.data?.id ?? chartSpec.data?.id ?? 'data'] = seriesSpec.data?.id\n ? seriesField\n : undefined;\n } else {\n dataIdfield[seriesSpec.data?.id ?? chartSpec.data?.id ?? 'data'] = undefined;\n }\n }\n });\n return dataIdfield;\n }\n return chartSpec.data.id;\n}\n"]}
1
+ {"version":3,"sources":["layout/chart-helper/get-chart-spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAGvE,OAAO,EAAkB,aAAa,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAChF,OAAO,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAC;AAEhE,MAAM,oBAAoB,GAAG,sBAAsB,CAAC;AAEpD,MAAM,UAAU,eAAe,CAAC,GAAW,EAAE,GAAW,EAAE,MAA4B;;IACpF,MAAM,KAAK,GAAG,MAAM,CAAC,kBAAkB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAClD,IAAI,YAAY,CAAC;IACjB,IAAI,MAAM,CAAC,eAAe,EAAE;QAC1B,MAAM,YAAY,GAAG,MAAA,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,YAAY,CAAC,0CAAE,YAAY,CAAC;QAC9F,YAAY,GAAG,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,YAAY,KAAK,YAAY,CAAC,CAAC;KAChG;SAAM;QACL,MAAM,YAAY,GAAG,MAAA,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,YAAY,CAAC,0CAAE,YAAY,CAAC;QAC9F,YAAY,GAAG,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,YAAY,KAAK,YAAY,CAAC,CAAC;KAChG;IACD,MAAM,SAAS,GAAG,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,SAAS,CAAC;IAE1C,OAAO,SAAS,CAAC;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AC,GAAG,CAAA,MAAA,UAAU,CAAC,IAAI,0CAAE,EAAE;wBACpF,CAAC,CAAC,WAAW;wBACb,CAAC,CAAC,SAAS,CAAC;iBACf;qBAAM;oBACL,WAAW,CAAC,MAAA,MAAA,MAAA,UAAU,CAAC,IAAI,0CAAE,EAAE,mCAAI,MAAA,SAAS,CAAC,IAAI,0CAAE,EAAE,mCAAI,MAAM,CAAC,GAAG,SAAS,CAAC;iBAC9E;aACF;QACH,CAAC,CAAC,CAAC;QACH,OAAO,WAAW,CAAC;KACpB;IACD,OAAO,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;AAC3B,CAAC","file":"get-chart-spec.js","sourcesContent":["import { cloneDeep, isArray, isNumber, merge } from '@visactor/vutils';\nimport type { PivotHeaderLayoutMap } from '../pivot-header-layout';\nimport type { SimpleHeaderLayoutMap } from '../simple-header-layout';\nimport { checkZeroAlign, getAxisOption, getAxisRange } from './get-axis-config';\nimport { getAxisDomainRangeAndLabels } from './get-axis-domain';\n\nconst NO_AXISID_FRO_VTABLE = 'NO_AXISID_FRO_VTABLE';\n\nexport function getRawChartSpec(col: number, row: number, layout: PivotHeaderLayoutMap): any {\n const paths = layout.getCellHeaderPaths(col, row);\n let indicatorObj;\n if (layout.indicatorsAsCol) {\n const indicatorKey = paths.colHeaderPaths.find(colPath => colPath.indicatorKey)?.indicatorKey;\n indicatorObj = layout.columnObjects.find(indicator => indicator.indicatorKey === indicatorKey);\n } else {\n const indicatorKey = paths.rowHeaderPaths.find(rowPath => rowPath.indicatorKey)?.indicatorKey;\n indicatorObj = layout.columnObjects.find(indicator => indicator.indicatorKey === indicatorKey);\n }\n const chartSpec = indicatorObj?.chartSpec;\n\n return chartSpec;\n}\n\nexport function getChartSpec(col: number, row: number, layout: PivotHeaderLayoutMap): any {\n let chartSpec = layout.getRawChartSpec(col, row);\n if (chartSpec) {\n chartSpec = cloneDeep(chartSpec);\n chartSpec.sortDataByAxis = true;\n if (isArray(chartSpec.series)) {\n chartSpec.series.forEach((serie: any) => {\n serie.sortDataByAxis = true;\n });\n }\n chartSpec.axes = layout.getChartAxes(col, row);\n chartSpec.padding = 0;\n chartSpec.dataZoom = []; // Do not support datazoom temply\n return chartSpec;\n }\n return null;\n}\n\nexport function getChartAxes(col: number, row: number, layout: PivotHeaderLayoutMap): any {\n const axes = [];\n if (layout.indicatorsAsCol) {\n const indicatorKeys = layout.getIndicatorKeyInChartSpec(col, row);\n // const colIndex = layout.getRecordIndexByCol(col);\n const colPath = layout.getColKeysPath(col, row);\n indicatorKeys.forEach((key, index) => {\n // if (isArray(key)) {\n // key = key[0];\n // }\n\n const { axisOption, isPercent, isZeroAlign, seriesIndice } = getAxisOption(\n col,\n row,\n index === 0 ? 'bottom' : 'top',\n layout\n );\n const range = getAxisRange(\n layout.dataset.collectedValues,\n indicatorKeys,\n isZeroAlign,\n colPath,\n seriesIndice ?? index\n );\n // const data = layout.dataset.collectedValues[key + (isZeroAlign ? '_align' : '')]\n // ? layout.dataset.collectedValues[key + (isZeroAlign ? '_align' : '')]\n // : layout.dataset.collectedValues[key];\n // const range = merge({}, (data?.[colPath ?? ''] as { max?: number; min?: number }) ?? { min: 0, max: 1 });\n // if (range.positiveMax && range.positiveMax > range.max) {\n // range.max = range.positiveMax;\n // }\n // if (range.negativeMin && range.negativeMin < range.min) {\n // range.min = range.negativeMin;\n // }\n if (isPercent) {\n (range as any).min = (range as any).min < 0 ? -1 : 0;\n (range as any).max = (range as any).max > 0 ? 1 : 0;\n }\n if (axisOption?.zero || range.min === range.max) {\n range.min = Math.min(range.min, 0);\n range.max = Math.max(range.max, 0);\n }\n if (axisOption?.nice) {\n const { range: axisRange } = getAxisDomainRangeAndLabels(range.min, range.max, axisOption, isZeroAlign);\n range.min = axisRange[0];\n range.max = axisRange[1];\n }\n if (isNumber(axisOption?.min)) {\n (range as any).min = axisOption.min;\n }\n if (isNumber(axisOption?.max)) {\n (range as any).max = axisOption.max;\n }\n axes.push(\n merge(\n {\n range\n },\n axisOption,\n {\n type: 'linear',\n orient: index === 0 ? 'bottom' : 'top',\n // visible: true,\n label: { visible: false },\n title: { visible: false },\n domainLine: { visible: false },\n seriesIndex: index,\n height: -1,\n\n sync: { axisId: NO_AXISID_FRO_VTABLE } // hack for fs\n }\n )\n );\n });\n\n let rowDimensionKey = layout.getDimensionKeyInChartSpec(layout.rowHeaderLevelCount, row)?.[0];\n if (isArray(rowDimensionKey)) {\n rowDimensionKey = rowDimensionKey[0];\n }\n const data =\n layout.dataset.cacheCollectedValues[rowDimensionKey] ||\n layout.dataset.collectedValues[rowDimensionKey] ||\n ([] as string[]);\n const rowPath = layout.getRowKeysPath(col, row);\n const domain = data[rowPath ?? ''] as Set<string>;\n\n const { axisOption, isPercent } = getAxisOption(col, row, 'left', layout);\n axes.push(\n merge(\n {\n domain: Array.from(domain ?? [])\n },\n axisOption,\n {\n type: 'band',\n orient: 'left',\n // visible: true,\n label: { visible: false },\n domainLine: { visible: false },\n tick: { visible: false },\n subTick: { visible: false },\n title: { visible: false },\n // height: -1,\n width: -1\n // autoIndent: false,\n }\n )\n );\n } else {\n const indicatorKeys = layout.getIndicatorKeyInChartSpec(col, row);\n const rowPath = layout.getRowKeysPath(col, row);\n indicatorKeys.forEach((key, index) => {\n // if (isArray(key)) {\n // key = key[0];\n // }\n\n const { axisOption, isPercent, isZeroAlign, seriesIndice } = getAxisOption(\n col,\n row,\n index === 0 ? 'left' : 'right',\n layout\n );\n const range = getAxisRange(\n layout.dataset.collectedValues,\n indicatorKeys,\n isZeroAlign,\n rowPath,\n seriesIndice ?? index\n );\n\n // const data = layout.dataset.collectedValues[key + (isZeroAlign ? '_align' : '')]\n // ? layout.dataset.collectedValues[key + (isZeroAlign ? '_align' : '')]\n // : layout.dataset.collectedValues[key];\n\n // const range = merge({}, (data?.[rowPath ?? ''] as { max?: number; min?: number }) ?? { min: 0, max: 1 });\n // if (range.positiveMax && range.positiveMax > range.max) {\n // range.max = range.positiveMax;\n // }\n // if (range.negativeMin && range.negativeMin < range.min) {\n // range.min = range.negativeMin;\n // }\n if (isPercent) {\n (range as any).min = (range as any).min < 0 ? -1 : 0;\n (range as any).max = (range as any).max > 0 ? 1 : 0;\n }\n if (axisOption?.zero || range.min === range.max) {\n range.min = Math.min(range.min, 0);\n range.max = Math.max(range.max, 0);\n }\n if (axisOption?.nice) {\n const { range: axisRange } = getAxisDomainRangeAndLabels(range.min, range.max, axisOption, isZeroAlign);\n range.min = axisRange[0];\n range.max = axisRange[1];\n }\n if (isNumber(axisOption?.min)) {\n (range as any).min = axisOption.min;\n }\n if (isNumber(axisOption?.max)) {\n (range as any).max = axisOption.max;\n }\n axes.push(\n merge(\n {\n range\n },\n axisOption,\n {\n type: 'linear',\n orient: index === 0 ? 'left' : 'right',\n // visible: true,\n label: { visible: false },\n // label: { flush: true },\n title: { visible: false },\n domainLine: { visible: false },\n seriesIndex: index,\n width: -1,\n // grid: index === 0 ? undefined : { visible: false }\n\n sync: { axisId: NO_AXISID_FRO_VTABLE } // hack for fs\n }\n )\n );\n });\n\n let columnDimensionKey = layout.getDimensionKeyInChartSpec(col, layout.columnHeaderLevelCount)[0];\n if (isArray(columnDimensionKey)) {\n columnDimensionKey = columnDimensionKey[0];\n }\n const data =\n layout.dataset.cacheCollectedValues[columnDimensionKey] ||\n layout.dataset.collectedValues[columnDimensionKey] ||\n ([] as string[]);\n const colPath = layout.getColKeysPath(col, row);\n const domain: string[] | Set<string> = (data?.[colPath ?? ''] as Set<string>) ?? [];\n\n const { axisOption, isPercent } = getAxisOption(col, row, 'bottom', layout);\n axes.push(\n merge(\n {\n domain: Array.from(domain)\n },\n axisOption,\n {\n type: 'band',\n orient: 'bottom',\n visible: true,\n label: { visible: false },\n domainLine: { visible: false },\n tick: { visible: false },\n subTick: { visible: false },\n title: { visible: false },\n height: -1\n // autoIndent: false,\n }\n )\n );\n }\n return axes;\n}\n/**\n * 获取单元格对应spec的dataId。\n * 如果是spec外层的dataId,则是string,否则通过series获取到的是Record<string, string> => <dataId, series-chart的指标key用于过滤数据>\n * @param col\n * @param row\n * @param layout\n * @returns\n */\nexport function getChartDataId(\n col: number,\n row: number,\n layout: PivotHeaderLayoutMap | SimpleHeaderLayoutMap\n): string | Record<string, string> {\n const chartSpec = layout.getRawChartSpec(col, row);\n // 如果chartSpec配置了组合图 series 则需要考虑 series中存在的多个指标\n if (chartSpec?.series) {\n const dataIdfield: Record<string, string> = {};\n\n if (chartSpec.data?.id) {\n dataIdfield[chartSpec.data.id] = undefined;\n }\n chartSpec?.series.forEach((seriesSpec: any) => {\n if (!seriesSpec.data?.fromDataId) {\n if (!seriesSpec.data?.transforms) {\n const seriesField = seriesSpec.direction === 'horizontal' ? seriesSpec.xField : seriesSpec.yField;\n dataIdfield[seriesSpec.data?.id ?? chartSpec.data?.id ?? 'data'] = seriesSpec.data?.id\n ? seriesField\n : undefined;\n } else {\n dataIdfield[seriesSpec.data?.id ?? chartSpec.data?.id ?? 'data'] = undefined;\n }\n }\n });\n return dataIdfield;\n }\n return chartSpec.data.id;\n}\n"]}
@@ -144,7 +144,7 @@ export class PivotHeaderLayoutMap {
144
144
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
145
145
  const id = hd.id, dimensionInfo = null !== (_b = null === (_a = this.rowsDefine) || void 0 === _a ? void 0 : _a.find((dimension => "string" != typeof dimension && dimension.dimensionKey === hd.dimensionKey))) && void 0 !== _b ? _b : null === (_c = this.columnsDefine) || void 0 === _c ? void 0 : _c.find((dimension => "string" != typeof dimension && dimension.dimensionKey === hd.dimensionKey)), indicatorInfo = null === (_d = this.indicatorsDefine) || void 0 === _d ? void 0 : _d.find((indicator => "string" != typeof indicator && (hd.indicatorKey ? indicator.indicatorKey === hd.indicatorKey : indicator.title === hd.value))), cell = {
146
146
  id: id,
147
- title: null !== (_e = hd.value) && void 0 !== _e ? _e : indicatorInfo.title,
147
+ title: null !== (_e = hd.value) && void 0 !== _e ? _e : null == indicatorInfo ? void 0 : indicatorInfo.title,
148
148
  field: hd.dimensionKey,
149
149
  style: "function" == typeof (null === (_f = null != indicatorInfo ? indicatorInfo : dimensionInfo) || void 0 === _f ? void 0 : _f.headerStyle) ? null === (_g = null != indicatorInfo ? indicatorInfo : dimensionInfo) || void 0 === _g ? void 0 : _g.headerStyle : Object.assign({}, null === (_h = null != indicatorInfo ? indicatorInfo : dimensionInfo) || void 0 === _h ? void 0 : _h.headerStyle),
150
150
  headerType: null !== (_k = null !== (_j = null == indicatorInfo ? void 0 : indicatorInfo.headerType) && void 0 !== _j ? _j : null == dimensionInfo ? void 0 : dimensionInfo.headerType) && void 0 !== _k ? _k : "text",
@@ -655,7 +655,7 @@ export class PivotHeaderLayoutMap {
655
655
  row: row
656
656
  }
657
657
  };
658
- if (!this.isHeader(col, row) || -1 === col || -1 === row || this.isIndicatorHeader(col, row)) return result;
658
+ if (!this.isHeader(col, row) || -1 === col || -1 === row) return result;
659
659
  if (this.isRightFrozenColumn(col, row) || this.isBottomFrozenRow(col, row)) return result;
660
660
  if (this._cellRangeMap.has(`${col}-${row}`)) return this._cellRangeMap.get(`${col}-${row}`);
661
661
  if (this.isHeader(col, row) && -1 !== col && -1 !== row) {