@visactor/vtable 0.10.0 → 0.10.1-alpha.1
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/ListTable.d.ts +1 -2
- package/cjs/ListTable.js +2 -5
- package/cjs/ListTable.js.map +1 -1
- package/cjs/PivotChart.js +10 -8
- package/cjs/PivotChart.js.map +1 -1
- package/cjs/PivotTable.js +8 -5
- package/cjs/PivotTable.js.map +1 -1
- package/cjs/components/axis/get-axis-attributes.d.ts +2 -0
- package/cjs/components/axis/get-axis-attributes.js +3 -1
- package/cjs/components/axis/get-axis-attributes.js.map +1 -1
- package/cjs/components/axis/get-axis-component-size.js +65 -33
- package/cjs/components/axis/get-axis-component-size.js.map +1 -1
- package/cjs/components/tooltip/TooltipHandler.js +2 -0
- package/cjs/components/tooltip/TooltipHandler.js.map +1 -1
- package/cjs/core/BaseTable.d.ts +4 -2
- package/cjs/core/BaseTable.js +29 -30
- package/cjs/core/BaseTable.js.map +1 -1
- package/cjs/event/drill.js +2 -0
- package/cjs/event/drill.js.map +1 -1
- package/cjs/event/event.js +1 -1
- package/cjs/event/event.js.map +1 -1
- package/cjs/event/listener/table-group.js +19 -9
- package/cjs/event/listener/table-group.js.map +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/layout/pivot-header-layout.d.ts +1 -0
- package/cjs/layout/pivot-header-layout.js +28 -4
- package/cjs/layout/pivot-header-layout.js.map +1 -1
- package/cjs/layout/simple-header-layout.js +22 -10
- package/cjs/layout/simple-header-layout.js.map +1 -1
- package/cjs/scenegraph/component/table-component.d.ts +3 -3
- package/cjs/scenegraph/component/table-component.js +6 -6
- package/cjs/scenegraph/component/table-component.js.map +1 -1
- package/cjs/scenegraph/component/util.d.ts +1 -1
- package/cjs/scenegraph/component/util.js +2 -1
- package/cjs/scenegraph/component/util.js.map +1 -1
- package/cjs/scenegraph/group-creater/progress/create-group-for-first-screen.js +1 -3
- package/cjs/scenegraph/group-creater/progress/create-group-for-first-screen.js.map +1 -1
- package/cjs/scenegraph/layout/compute-col-width.js +7 -21
- package/cjs/scenegraph/layout/compute-col-width.js.map +1 -1
- package/cjs/scenegraph/layout/update-width.js +9 -4
- package/cjs/scenegraph/layout/update-width.js.map +1 -1
- package/cjs/scenegraph/scenegraph.d.ts +1 -0
- package/cjs/scenegraph/scenegraph.js +20 -21
- package/cjs/scenegraph/scenegraph.js.map +1 -1
- package/cjs/scenegraph/utils/update-container.d.ts +2 -0
- package/cjs/scenegraph/utils/update-container.js +13 -0
- package/cjs/scenegraph/utils/update-container.js.map +1 -0
- package/cjs/state/resize/update-resize-column.d.ts +2 -0
- package/cjs/state/resize/update-resize-column.js +74 -0
- package/cjs/state/resize/update-resize-column.js.map +1 -0
- package/cjs/state/sort/index.js +4 -2
- package/cjs/state/sort/index.js.map +1 -1
- package/cjs/state/state.d.ts +2 -1
- package/cjs/state/state.js +5 -24
- package/cjs/state/state.js.map +1 -1
- package/cjs/ts-types/base-table.d.ts +3 -1
- package/cjs/ts-types/base-table.js.map +1 -1
- package/cjs/ts-types/events.d.ts +1 -1
- package/cjs/ts-types/events.js.map +1 -1
- package/dist/vtable.js +1936 -726
- package/dist/vtable.min.js +3 -3
- package/es/ListTable.d.ts +1 -2
- package/es/ListTable.js +2 -5
- package/es/ListTable.js.map +1 -1
- package/es/PivotChart.js +10 -8
- package/es/PivotChart.js.map +1 -1
- package/es/PivotTable.js +8 -5
- package/es/PivotTable.js.map +1 -1
- package/es/components/axis/get-axis-attributes.d.ts +2 -0
- package/es/components/axis/get-axis-attributes.js +3 -1
- package/es/components/axis/get-axis-attributes.js.map +1 -1
- package/es/components/axis/get-axis-component-size.js +65 -33
- package/es/components/axis/get-axis-component-size.js.map +1 -1
- package/es/components/tooltip/TooltipHandler.js +2 -0
- package/es/components/tooltip/TooltipHandler.js.map +1 -1
- package/es/core/BaseTable.d.ts +4 -2
- package/es/core/BaseTable.js +28 -28
- package/es/core/BaseTable.js.map +1 -1
- package/es/event/drill.js +2 -0
- package/es/event/drill.js.map +1 -1
- package/es/event/event.js +1 -1
- package/es/event/event.js.map +1 -1
- package/es/event/listener/table-group.js +19 -9
- package/es/event/listener/table-group.js.map +1 -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-header-layout.d.ts +1 -0
- package/es/layout/pivot-header-layout.js +26 -4
- package/es/layout/pivot-header-layout.js.map +1 -1
- package/es/layout/simple-header-layout.js +22 -10
- package/es/layout/simple-header-layout.js.map +1 -1
- package/es/scenegraph/component/table-component.d.ts +3 -3
- package/es/scenegraph/component/table-component.js +6 -6
- package/es/scenegraph/component/table-component.js.map +1 -1
- package/es/scenegraph/component/util.d.ts +1 -1
- package/es/scenegraph/component/util.js +2 -1
- package/es/scenegraph/component/util.js.map +1 -1
- package/es/scenegraph/group-creater/progress/create-group-for-first-screen.js +1 -3
- package/es/scenegraph/group-creater/progress/create-group-for-first-screen.js.map +1 -1
- package/es/scenegraph/layout/compute-col-width.js +7 -21
- package/es/scenegraph/layout/compute-col-width.js.map +1 -1
- package/es/scenegraph/layout/update-width.js +9 -4
- package/es/scenegraph/layout/update-width.js.map +1 -1
- package/es/scenegraph/scenegraph.d.ts +1 -0
- package/es/scenegraph/scenegraph.js +18 -20
- package/es/scenegraph/scenegraph.js.map +1 -1
- package/es/scenegraph/utils/update-container.d.ts +2 -0
- package/es/scenegraph/utils/update-container.js +7 -0
- package/es/scenegraph/utils/update-container.js.map +1 -0
- package/es/state/resize/update-resize-column.d.ts +2 -0
- package/es/state/resize/update-resize-column.js +68 -0
- package/es/state/resize/update-resize-column.js.map +1 -0
- package/es/state/sort/index.js +4 -2
- package/es/state/sort/index.js.map +1 -1
- package/es/state/state.d.ts +2 -1
- package/es/state/state.js +6 -23
- package/es/state/state.js.map +1 -1
- package/es/ts-types/base-table.d.ts +3 -1
- package/es/ts-types/base-table.js.map +1 -1
- package/es/ts-types/events.d.ts +1 -1
- package/es/ts-types/events.js.map +1 -1
- package/package.json +7 -7
|
@@ -65,6 +65,7 @@ export declare const commonAxis: {
|
|
|
65
65
|
};
|
|
66
66
|
};
|
|
67
67
|
export declare function getAxisAttributes(option: ICellAxisOption): {
|
|
68
|
+
orient: import("@visactor/vchart/esm/typings").IOrientType;
|
|
68
69
|
select: boolean;
|
|
69
70
|
hover: boolean;
|
|
70
71
|
line: any;
|
|
@@ -75,6 +76,7 @@ export declare function getAxisAttributes(option: ICellAxisOption): {
|
|
|
75
76
|
style: any;
|
|
76
77
|
formatMethod: (value: any, datum: any, index: number) => string | string[];
|
|
77
78
|
state: any;
|
|
79
|
+
containerAlign: "left" | "top" | "right" | "center" | "middle" | "bottom";
|
|
78
80
|
};
|
|
79
81
|
tick: {
|
|
80
82
|
visible: boolean;
|
|
@@ -30,6 +30,7 @@ function getAxisAttributes(option) {
|
|
|
30
30
|
return "left" !== spec.orient && "right" !== spec.orient || (null === (_c = spec.title) || void 0 === _c ? void 0 : _c.autoRotate) && (0,
|
|
31
31
|
vutils_1.isNil)(spec.title.angle) && (titleAngle = "left" === spec.orient ? -90 : 90,
|
|
32
32
|
titleTextStyle = DEFAULT_TITLE_STYLE[spec.orient]), {
|
|
33
|
+
orient: spec.orient,
|
|
33
34
|
select: spec.select,
|
|
34
35
|
hover: spec.hover,
|
|
35
36
|
line: (0, transform_1.transformAxisLineStyle)(spec.domainLine),
|
|
@@ -39,7 +40,8 @@ function getAxisAttributes(option) {
|
|
|
39
40
|
inside: spec.label.inside,
|
|
40
41
|
style: (0, transform_1.transformToGraphic)(spec.label.style),
|
|
41
42
|
formatMethod: spec.label.formatMethod ? (value, datum, index) => spec.label.formatMethod(datum.rawValue, datum) : null,
|
|
42
|
-
state: (0, transform_1.transformStateStyle)(spec.label.state)
|
|
43
|
+
state: (0, transform_1.transformStateStyle)(spec.label.state),
|
|
44
|
+
containerAlign: spec.label.containerAlign
|
|
43
45
|
},
|
|
44
46
|
tick: {
|
|
45
47
|
visible: spec.tick.visible,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["components/axis/get-axis-attributes.ts"],"names":[],"mappings":";;;AAAA,6CAAgE;AAChE,iDAAoG;AAGpG,MAAM,mBAAmB,GAAG;IAC1B,IAAI,EAAE;QACJ,SAAS,EAAE,QAAQ;QACnB,YAAY,EAAE,QAAQ;KACvB;IACD,KAAK,EAAE;QACL,SAAS,EAAE,QAAQ;QACnB,YAAY,EAAE,QAAQ;KACvB;IACD,MAAM,EAAE,EAAE;IACV,KAAK,EAAE,EAAE;CACV,CAAC;AAEF,MAAM,wBAAwB,GAE5B,kJAAkJ,CAAC;AAErJ,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAElC,MAAM,eAAe,GAAG;IACtB,WAAW,EAAE,wBAAwB;IACrC,eAAe,EAAE,sBAAsB;IACvC,mBAAmB,EAAE,EAAE;IACvB,eAAe,EAAE,EAAE;IACnB,cAAc,EAAE,CAAC;CAClB,CAAC;AAEW,QAAA,UAAU,GAAG;IACxB,UAAU,EAAE;QACV,OAAO,EAAE,IAAI;QACb,KAAK,EAAE;YACL,SAAS,EAAE,CAAC;YACZ,MAAM,EAAE,SAAS;YACjB,aAAa,EAAE,CAAC;SACjB;KACF;IACD,IAAI,EAAE;QACJ,OAAO,EAAE,IAAI;QACb,KAAK,EAAE;YACL,SAAS,EAAE,CAAC;YACZ,MAAM,EAAE,SAAS;YACjB,aAAa,EAAE,CAAC;YAChB,QAAQ,EAAE,EAAW;SACtB;KACF;IACD,OAAO,EAAE;QACP,OAAO,EAAE,KAAK;QACd,KAAK,EAAE;YACL,SAAS,EAAE,CAAC;YACZ,MAAM,EAAE,SAAS;YACjB,aAAa,EAAE,CAAC;YAChB,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;SACjB;KACF;IACD,IAAI,EAAE;QACJ,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,eAAe,CAAC,cAAc;QACxC,KAAK,EA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K,0CAAE,OAAO;gBAClC,KAAK,EAAE,MAAA,IAAI,CAAC,KAAK,CAAC,KAAK,0CAAE,KAAK;gBAC9B,KAAK,EAAE,IAAA,8BAAkB,EAAC,MAAA,IAAI,CAAC,KAAK,CAAC,KAAK,0CAAE,KAAK,CAAC;aACnD;YACD,UAAU,EAAE;gBACV,OAAO,EAAE,MAAA,IAAI,CAAC,KAAK,CAAC,UAAU,0CAAE,OAAO;gBACvC,KAAK,EAAE,IAAA,8BAAkB,EAAC,MAAA,IAAI,CAAC,KAAK,CAAC,UAAU,0CAAE,KAAK,CAAC;aACxD;YACD,KAAK,EAAE;gBACL,IAAI,EAAE,IAAA,+BAAmB,EAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;gBAC3C,KAAK,EAAE,IAAA,+BAAmB,EAAC,MAAA,IAAI,CAAC,KAAK,CAAC,KAAK,0CAAE,KAAK,CAAC;gBACnD,UAAU,EAAE,IAAA,+BAAmB,EAAC,MAAA,IAAI,CAAC,KAAK,CAAC,UAAU,0CAAE,KAAK,CAAC;aAC9D;SACF;QACD,KAAK,EAAE;YACL,OAAO,EAAE,MAAA,IAAI,CAAC,UAAU,0CAAE,OAAO;YACjC,KAAK,EAAE,IAAA,8BAAkB,EAAC,MAAA,IAAI,CAAC,UAAU,0CAAE,KAAK,CAAC;YACjD,KAAK,EAAE,IAAA,+BAAmB,EAAC,MAAA,IAAI,CAAC,UAAU,0CAAE,KAAK,CAAC;SACnD;KACF,CAAC;AACJ,CAAC;AA/GD,8CA+GC","file":"get-axis-attributes.js","sourcesContent":["import { degreeToRadian, isNil, merge } from '@visactor/vutils';\nimport { transformAxisLineStyle, transformStateStyle, transformToGraphic } from '../util/transform';\nimport type { ICellAxisOption } from '../../ts-types/component/axis';\n\nconst DEFAULT_TITLE_STYLE = {\n left: {\n textAlign: 'center',\n textBaseline: 'bottom'\n },\n right: {\n textAlign: 'center',\n textBaseline: 'bottom'\n },\n radius: {},\n angle: {}\n};\n\nconst DEFAULT_TEXT_FONT_FAMILY =\n // eslint-disable-next-line max-len\n 'PingFang SC,Microsoft Yahei,system-ui,-apple-system,segoe ui,Roboto,Helvetica,Arial,sans-serif, apple color emoji,segoe ui emoji,segoe ui symbol';\n\nconst DEFAULT_TEXT_FONT_SIZE = 14;\n\nconst THEME_CONSTANTS = {\n FONT_FAMILY: DEFAULT_TEXT_FONT_FAMILY,\n LABEL_FONT_SIZE: DEFAULT_TEXT_FONT_SIZE,\n MAP_LABEL_FONT_SIZE: 10,\n TITLE_FONT_SIZE: 18,\n AXIS_TICK_SIZE: 4\n};\n\nexport const commonAxis = {\n domainLine: {\n visible: true,\n style: {\n lineWidth: 1,\n stroke: '#D9DDE4',\n strokeOpacity: 1\n }\n },\n grid: {\n visible: true,\n style: {\n lineWidth: 1,\n stroke: '#EBEDF2',\n strokeOpacity: 1,\n lineDash: [] as any[]\n }\n },\n subGrid: {\n visible: false,\n style: {\n lineWidth: 1,\n stroke: '#EBEDF2',\n strokeOpacity: 1,\n lineDash: [4, 4]\n }\n },\n tick: {\n visible: true,\n tickSize: THEME_CONSTANTS.AXIS_TICK_SIZE,\n style: {\n lineWidth: 1,\n stroke: '#D9DDE4',\n strokeOpacity: 1\n }\n },\n subTick: {\n visible: false,\n tickSize: THEME_CONSTANTS.AXIS_TICK_SIZE / 2,\n style: {\n lineWidth: 1,\n stroke: '#D9DDE4',\n strokeOpacity: 1\n }\n },\n label: {\n visible: true,\n space: 1, // hack: VChart中为0,为了方便fs调试暂时改为1\n style: {\n fontSize: THEME_CONSTANTS.LABEL_FONT_SIZE,\n fill: '#89909D',\n fontWeight: 'normal',\n fillOpacity: 1\n }\n },\n title: {\n space: 10,\n style: {\n fontSize: THEME_CONSTANTS.LABEL_FONT_SIZE,\n fill: '#333333',\n fontWeight: 'normal',\n fillOpacity: 1\n }\n }\n};\n\nexport function getAxisAttributes(option: ICellAxisOption) {\n // const spec = merge({}, option, commonAxis);\n const spec = option;\n let titleAngle = spec.title?.angle ?? 0;\n let titleTextStyle;\n if (spec.orient === 'left' || spec.orient === 'right') {\n // 处理纵轴的标题样式\n if (spec.title?.autoRotate && isNil(spec.title.angle)) {\n titleAngle = spec.orient === 'left' ? -90 : 90;\n titleTextStyle = DEFAULT_TITLE_STYLE[spec.orient];\n }\n }\n\n return {\n select: spec.select,\n hover: spec.hover,\n line: transformAxisLineStyle(spec.domainLine),\n label: {\n visible: spec.label.visible,\n space: spec.label.space,\n inside: spec.label.inside,\n style:\n // isFunction(spec.label.style)\n // ? (datum: Datum, index: number) => {\n // const style = this._preprocessSpec(spec.label.style(datum.rawValue, index, datum));\n\n // return transformToGraphic(this._preprocessSpec(merge({}, this._theme.label?.style, style)));\n // }\n // :\n transformToGraphic(spec.label.style),\n formatMethod: spec.label.formatMethod\n ? (value: any, datum: any, index: number) => {\n return spec.label.formatMethod(datum.rawValue, datum);\n }\n : null,\n state: transformStateStyle(spec.label.state)\n },\n tick: {\n visible: spec.tick.visible,\n length: spec.tick.tickSize,\n inside: spec.tick.inside,\n alignWithLabel: spec.tick.alignWithLabel,\n style:\n // isFunction(spec.tick.style)\n // ? (datum: Datum, index: number) => {\n // const style = this._preprocessSpec(spec.tick.style(datum.rawValue, index, datum));\n\n // return transformToGraphic(this._preprocessSpec(merge({}, this._theme.tick?.style, style)));\n // }\n // :\n transformToGraphic(spec.tick.style),\n state: transformStateStyle(spec.tick.state)\n },\n subTick: {\n visible: spec.subTick.visible,\n length: spec.subTick.tickSize,\n inside: spec.subTick.inside,\n count: spec.subTick.tickCount,\n style: transformToGraphic(spec.subTick.style),\n state: transformStateStyle(spec.subTick.state)\n },\n grid: {\n type: 'line',\n visible: spec.grid.visible,\n alternateColor: spec.grid.alternateColor,\n alignWithLabel: spec.grid.alignWithLabel,\n style:\n // isFunction(spec.grid.style)\n // ? (datum: Datum, index: number) => {\n // const style = spec.grid.style(datum.datum?.rawValue, index, datum.datum);\n\n // return transformToGraphic(this._preprocessSpec(merge({}, this._theme.grid?.style, style)));\n // }\n // :\n transformToGraphic(spec.grid.style)\n },\n subGrid: {\n type: 'line',\n visible: spec.subGrid.visible,\n alternateColor: spec.subGrid.alternateColor,\n style: transformToGraphic(spec.subGrid.style)\n },\n title: {\n visible: spec.title.visible,\n position: spec.title.position,\n space: spec.title.space,\n autoRotate: false, // 默认不对外提供该配置\n angle: titleAngle ? degreeToRadian(titleAngle) : null,\n textStyle: merge({}, titleTextStyle, transformToGraphic(spec.title.style)),\n padding: spec.title.padding,\n shape: {\n visible: spec.title.shape?.visible,\n space: spec.title.shape?.space,\n style: transformToGraphic(spec.title.shape?.style)\n },\n background: {\n visible: spec.title.background?.visible,\n style: transformToGraphic(spec.title.background?.style)\n },\n state: {\n text: transformStateStyle(spec.title.state),\n shape: transformStateStyle(spec.title.shape?.state),\n background: transformStateStyle(spec.title.background?.state)\n }\n },\n panel: {\n visible: spec.background?.visible,\n style: transformToGraphic(spec.background?.style),\n state: transformStateStyle(spec.background?.state)\n }\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["components/axis/get-axis-attributes.ts"],"names":[],"mappings":";;;AAAA,6CAAgE;AAChE,iDAAoG;AAGpG,MAAM,mBAAmB,GAAG;IAC1B,IAAI,EAAE;QACJ,SAAS,EAAE,QAAQ;QACnB,YAAY,EAAE,QAAQ;KACvB;IACD,KAAK,EAAE;QACL,SAAS,EAAE,QAAQ;QACnB,YAAY,EAAE,QAAQ;KACvB;IACD,MAAM,EAAE,EAAE;IACV,KAAK,EAAE,EAAE;CACV,CAAC;AAEF,MAAM,wBAAwB,GAE5B,kJAAkJ,CAAC;AAErJ,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAElC,MAAM,eAAe,GAAG;IACtB,WAAW,EAAE,wBAAwB;IACrC,eAAe,EAAE,sBAAsB;IACvC,mBAAmB,EAAE,EAAE;IACvB,eAAe,EAAE,EAAE;IACnB,cAAc,EAAE,CAAC;CAClB,CAAC;AAEW,QAAA,UAAU,GAAG;IACxB,UAAU,EAAE;QACV,OAAO,EAAE,IAAI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A,IAAI,CAAC,KAAK,CAAC,UAAU,0CAAE,KAAK,CAAC;aAC9D;SACF;QACD,KAAK,EAAE;YACL,OAAO,EAAE,MAAA,IAAI,CAAC,UAAU,0CAAE,OAAO;YACjC,KAAK,EAAE,IAAA,8BAAkB,EAAC,MAAA,IAAI,CAAC,UAAU,0CAAE,KAAK,CAAC;YACjD,KAAK,EAAE,IAAA,+BAAmB,EAAC,MAAA,IAAI,CAAC,UAAU,0CAAE,KAAK,CAAC;SACnD;KACF,CAAC;AACJ,CAAC;AAjHD,8CAiHC","file":"get-axis-attributes.js","sourcesContent":["import { degreeToRadian, isNil, merge } from '@visactor/vutils';\nimport { transformAxisLineStyle, transformStateStyle, transformToGraphic } from '../util/transform';\nimport type { ICellAxisOption } from '../../ts-types/component/axis';\n\nconst DEFAULT_TITLE_STYLE = {\n left: {\n textAlign: 'center',\n textBaseline: 'bottom'\n },\n right: {\n textAlign: 'center',\n textBaseline: 'bottom'\n },\n radius: {},\n angle: {}\n};\n\nconst DEFAULT_TEXT_FONT_FAMILY =\n // eslint-disable-next-line max-len\n 'PingFang SC,Microsoft Yahei,system-ui,-apple-system,segoe ui,Roboto,Helvetica,Arial,sans-serif, apple color emoji,segoe ui emoji,segoe ui symbol';\n\nconst DEFAULT_TEXT_FONT_SIZE = 14;\n\nconst THEME_CONSTANTS = {\n FONT_FAMILY: DEFAULT_TEXT_FONT_FAMILY,\n LABEL_FONT_SIZE: DEFAULT_TEXT_FONT_SIZE,\n MAP_LABEL_FONT_SIZE: 10,\n TITLE_FONT_SIZE: 18,\n AXIS_TICK_SIZE: 4\n};\n\nexport const commonAxis = {\n domainLine: {\n visible: true,\n style: {\n lineWidth: 1,\n stroke: '#D9DDE4',\n strokeOpacity: 1\n }\n },\n grid: {\n visible: true,\n style: {\n lineWidth: 1,\n stroke: '#EBEDF2',\n strokeOpacity: 1,\n lineDash: [] as any[]\n }\n },\n subGrid: {\n visible: false,\n style: {\n lineWidth: 1,\n stroke: '#EBEDF2',\n strokeOpacity: 1,\n lineDash: [4, 4]\n }\n },\n tick: {\n visible: true,\n tickSize: THEME_CONSTANTS.AXIS_TICK_SIZE,\n style: {\n lineWidth: 1,\n stroke: '#D9DDE4',\n strokeOpacity: 1\n }\n },\n subTick: {\n visible: false,\n tickSize: THEME_CONSTANTS.AXIS_TICK_SIZE / 2,\n style: {\n lineWidth: 1,\n stroke: '#D9DDE4',\n strokeOpacity: 1\n }\n },\n label: {\n visible: true,\n space: 1, // hack: VChart中为0,为了方便fs调试暂时改为1\n style: {\n fontSize: THEME_CONSTANTS.LABEL_FONT_SIZE,\n fill: '#89909D',\n fontWeight: 'normal',\n fillOpacity: 1\n }\n },\n title: {\n space: 10,\n style: {\n fontSize: THEME_CONSTANTS.LABEL_FONT_SIZE,\n fill: '#333333',\n fontWeight: 'normal',\n fillOpacity: 1\n }\n }\n};\n\nexport function getAxisAttributes(option: ICellAxisOption) {\n // const spec = merge({}, option, commonAxis);\n const spec = option;\n let titleAngle = spec.title?.angle ?? 0;\n let titleTextStyle;\n if (spec.orient === 'left' || spec.orient === 'right') {\n // 处理纵轴的标题样式\n if (spec.title?.autoRotate && isNil(spec.title.angle)) {\n titleAngle = spec.orient === 'left' ? -90 : 90;\n titleTextStyle = DEFAULT_TITLE_STYLE[spec.orient];\n }\n }\n\n return {\n orient: spec.orient,\n select: spec.select,\n hover: spec.hover,\n line: transformAxisLineStyle(spec.domainLine),\n label: {\n visible: spec.label.visible,\n space: spec.label.space,\n inside: spec.label.inside,\n style:\n // isFunction(spec.label.style)\n // ? (datum: Datum, index: number) => {\n // const style = this._preprocessSpec(spec.label.style(datum.rawValue, index, datum));\n\n // return transformToGraphic(this._preprocessSpec(merge({}, this._theme.label?.style, style)));\n // }\n // :\n transformToGraphic(spec.label.style),\n formatMethod: spec.label.formatMethod\n ? (value: any, datum: any, index: number) => {\n return spec.label.formatMethod(datum.rawValue, datum);\n }\n : null,\n state: transformStateStyle(spec.label.state),\n containerAlign: spec.label.containerAlign\n },\n tick: {\n visible: spec.tick.visible,\n length: spec.tick.tickSize,\n inside: spec.tick.inside,\n alignWithLabel: spec.tick.alignWithLabel,\n style:\n // isFunction(spec.tick.style)\n // ? (datum: Datum, index: number) => {\n // const style = this._preprocessSpec(spec.tick.style(datum.rawValue, index, datum));\n\n // return transformToGraphic(this._preprocessSpec(merge({}, this._theme.tick?.style, style)));\n // }\n // :\n transformToGraphic(spec.tick.style),\n state: transformStateStyle(spec.tick.state)\n },\n subTick: {\n visible: spec.subTick.visible,\n length: spec.subTick.tickSize,\n inside: spec.subTick.inside,\n count: spec.subTick.tickCount,\n style: transformToGraphic(spec.subTick.style),\n state: transformStateStyle(spec.subTick.state)\n },\n grid: {\n type: 'line',\n visible: spec.grid.visible,\n alternateColor: spec.grid.alternateColor,\n alignWithLabel: spec.grid.alignWithLabel,\n style:\n // isFunction(spec.grid.style)\n // ? (datum: Datum, index: number) => {\n // const style = spec.grid.style(datum.datum?.rawValue, index, datum.datum);\n\n // return transformToGraphic(this._preprocessSpec(merge({}, this._theme.grid?.style, style)));\n // }\n // :\n transformToGraphic(spec.grid.style)\n },\n subGrid: {\n type: 'line',\n visible: spec.subGrid.visible,\n alternateColor: spec.subGrid.alternateColor,\n style: transformToGraphic(spec.subGrid.style)\n },\n title: {\n visible: spec.title.visible,\n position: spec.title.position,\n space: spec.title.space,\n autoRotate: false, // 默认不对外提供该配置\n angle: titleAngle ? degreeToRadian(titleAngle) : null,\n textStyle: merge({}, titleTextStyle, transformToGraphic(spec.title.style)),\n padding: spec.title.padding,\n shape: {\n visible: spec.title.shape?.visible,\n space: spec.title.shape?.space,\n style: transformToGraphic(spec.title.shape?.style)\n },\n background: {\n visible: spec.title.background?.visible,\n style: transformToGraphic(spec.title.background?.style)\n },\n state: {\n text: transformStateStyle(spec.title.state),\n shape: transformStateStyle(spec.title.shape?.state),\n background: transformStateStyle(spec.title.background?.state)\n }\n },\n panel: {\n visible: spec.background?.visible,\n style: transformToGraphic(spec.background?.style),\n state: transformStateStyle(spec.background?.state)\n }\n };\n}\n"]}
|
|
@@ -7,43 +7,47 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
const vutils_1 = require("@visactor/vutils"), get_axis_attributes_1 = require("./get-axis-attributes");
|
|
8
8
|
|
|
9
9
|
function computeAxisComponentWidth(config, table) {
|
|
10
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l
|
|
10
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
11
11
|
const attribute = (0, vutils_1.merge)({}, get_axis_attributes_1.commonAxis, config), tickWidth = null !== (_a = attribute.tick.width) && void 0 !== _a ? _a : 4;
|
|
12
12
|
let labelWidth = 0;
|
|
13
13
|
if (attribute.label.visible) {
|
|
14
14
|
if ("band" === attribute.type) {
|
|
15
15
|
attribute.domain.forEach((text => {
|
|
16
|
-
var _a, _b, _c, _d, _e, _f;
|
|
17
|
-
attribute.label.formatMethod && (text = attribute.label.formatMethod(text))
|
|
16
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
17
|
+
attribute.label.formatMethod && (text = attribute.label.formatMethod(text));
|
|
18
|
+
const {width: width, height: height} = table.measureText(text, {
|
|
18
19
|
fontSize: null === (_b = null === (_a = attribute.label) || void 0 === _a ? void 0 : _a.style) || void 0 === _b ? void 0 : _b.fontSize,
|
|
19
20
|
fontWeight: null === (_d = null === (_c = attribute.label) || void 0 === _c ? void 0 : _c.style) || void 0 === _d ? void 0 : _d.fontWeight,
|
|
20
21
|
fontFamily: null === (_f = null === (_e = attribute.label) || void 0 === _e ? void 0 : _e.style) || void 0 === _f ? void 0 : _f.fontFamily
|
|
21
|
-
})
|
|
22
|
+
});
|
|
23
|
+
labelWidth = Math.max(labelWidth, getSizeAfterResize(width, height, null === (_h = null === (_g = attribute.label) || void 0 === _g ? void 0 : _g.style) || void 0 === _h ? void 0 : _h.angle).width);
|
|
22
24
|
}));
|
|
23
25
|
} else {
|
|
24
26
|
const range = attribute.range, minNumber = Math.abs(range.min) > 1 ? Math.round(range.min) : range.min, maxNumber = Math.abs(range.max) > 1 ? Math.round(range.max) : range.max;
|
|
25
27
|
[ formatDecimal(minNumber), formatDecimal(maxNumber) ].forEach((text => {
|
|
26
|
-
var _a, _b, _c, _d, _e, _f;
|
|
27
|
-
attribute.label.formatMethod && (text = attribute.label.formatMethod(text))
|
|
28
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
29
|
+
attribute.label.formatMethod && (text = attribute.label.formatMethod(text));
|
|
30
|
+
const {width: width, height: height} = table.measureText(text, {
|
|
28
31
|
fontSize: null === (_b = null === (_a = attribute.label) || void 0 === _a ? void 0 : _a.style) || void 0 === _b ? void 0 : _b.fontSize,
|
|
29
32
|
fontWeight: null === (_d = null === (_c = attribute.label) || void 0 === _c ? void 0 : _c.style) || void 0 === _d ? void 0 : _d.fontWeight,
|
|
30
33
|
fontFamily: null === (_f = null === (_e = attribute.label) || void 0 === _e ? void 0 : _e.style) || void 0 === _f ? void 0 : _f.fontFamily
|
|
31
|
-
})
|
|
34
|
+
});
|
|
35
|
+
labelWidth = Math.max(labelWidth, getSizeAfterResize(width, height, null === (_h = null === (_g = attribute.label) || void 0 === _g ? void 0 : _g.style) || void 0 === _h ? void 0 : _h.angle).width + 2);
|
|
32
36
|
}));
|
|
33
37
|
}
|
|
34
38
|
labelWidth += null !== (_b = attribute.label.space) && void 0 !== _b ? _b : 4;
|
|
35
39
|
}
|
|
36
40
|
let titleWidth = 0;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
tickWidth + labelWidth + titleWidth;
|
|
41
|
+
if (attribute.title.visible && attribute.title.text) {
|
|
42
|
+
const {width: width, height: height} = table.measureText(attribute.title.text, {
|
|
43
|
+
fontSize: null === (_d = null === (_c = attribute.label) || void 0 === _c ? void 0 : _c.style) || void 0 === _d ? void 0 : _d.fontSize,
|
|
44
|
+
fontWeight: null === (_f = null === (_e = attribute.label) || void 0 === _e ? void 0 : _e.style) || void 0 === _f ? void 0 : _f.fontWeight,
|
|
45
|
+
fontFamily: null === (_h = null === (_g = attribute.label) || void 0 === _g ? void 0 : _g.style) || void 0 === _h ? void 0 : _h.fontFamily
|
|
46
|
+
}), size = getSizeAfterResize(width, height, null === (_k = null === (_j = attribute.label) || void 0 === _j ? void 0 : _j.style) || void 0 === _k ? void 0 : _k.angle);
|
|
47
|
+
titleWidth = "left" !== config.orient && "right" !== config.orient || !attribute.title.autoRotate ? size.width + 2 : size.height + 2,
|
|
48
|
+
titleWidth += null !== (_l = attribute.title.space) && void 0 !== _l ? _l : 4;
|
|
49
|
+
}
|
|
50
|
+
return tickWidth + labelWidth + titleWidth;
|
|
47
51
|
}
|
|
48
52
|
|
|
49
53
|
function computeAxisComponentHeight(config, table) {
|
|
@@ -53,38 +57,66 @@ function computeAxisComponentHeight(config, table) {
|
|
|
53
57
|
if (attribute.label.visible) {
|
|
54
58
|
if ("band" === attribute.type) {
|
|
55
59
|
attribute.domain.forEach((text => {
|
|
56
|
-
var _a, _b, _c, _d;
|
|
57
|
-
attribute.label.formatMethod && (text = attribute.label.formatMethod(text))
|
|
60
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
61
|
+
attribute.label.formatMethod && (text = attribute.label.formatMethod(text));
|
|
62
|
+
const {width: width, height: height} = table.measureText(text, {
|
|
58
63
|
fontSize: null === (_b = null === (_a = attribute.label) || void 0 === _a ? void 0 : _a.style) || void 0 === _b ? void 0 : _b.fontSize,
|
|
59
|
-
|
|
60
|
-
|
|
64
|
+
fontWeight: null === (_d = null === (_c = attribute.label) || void 0 === _c ? void 0 : _c.style) || void 0 === _d ? void 0 : _d.fontWeight,
|
|
65
|
+
fontFamily: null === (_f = null === (_e = attribute.label) || void 0 === _e ? void 0 : _e.style) || void 0 === _f ? void 0 : _f.fontFamily
|
|
66
|
+
});
|
|
67
|
+
labelHeight = Math.max(labelHeight, getSizeAfterResize(width, height, null === (_h = null === (_g = attribute.label) || void 0 === _g ? void 0 : _g.style) || void 0 === _h ? void 0 : _h.angle).height);
|
|
61
68
|
}));
|
|
62
69
|
} else {
|
|
63
70
|
const range = attribute.range, minNumber = Math.abs(range.min) > 1 ? Math.round(range.min) : range.min, maxNumber = Math.abs(range.max) > 1 ? Math.round(range.max) : range.max;
|
|
64
71
|
[ formatDecimal(minNumber), formatDecimal(maxNumber) ].forEach((text => {
|
|
65
|
-
var _a, _b, _c, _d;
|
|
66
|
-
attribute.label.formatMethod && (text = attribute.label.formatMethod(text))
|
|
72
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
73
|
+
attribute.label.formatMethod && (text = attribute.label.formatMethod(text));
|
|
74
|
+
const {width: width, height: height} = table.measureText(text, {
|
|
67
75
|
fontSize: null === (_b = null === (_a = attribute.label) || void 0 === _a ? void 0 : _a.style) || void 0 === _b ? void 0 : _b.fontSize,
|
|
68
|
-
|
|
69
|
-
|
|
76
|
+
fontWeight: null === (_d = null === (_c = attribute.label) || void 0 === _c ? void 0 : _c.style) || void 0 === _d ? void 0 : _d.fontWeight,
|
|
77
|
+
fontFamily: null === (_f = null === (_e = attribute.label) || void 0 === _e ? void 0 : _e.style) || void 0 === _f ? void 0 : _f.fontFamily
|
|
78
|
+
});
|
|
79
|
+
labelHeight = Math.max(labelHeight, getSizeAfterResize(width, height, null === (_h = null === (_g = attribute.label) || void 0 === _g ? void 0 : _g.style) || void 0 === _h ? void 0 : _h.angle).height + 2);
|
|
70
80
|
}));
|
|
71
81
|
}
|
|
72
82
|
labelHeight += null !== (_b = attribute.label.space) && void 0 !== _b ? _b : 4;
|
|
73
83
|
}
|
|
74
84
|
let titleHeight = 0;
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
85
|
+
if (attribute.title.visible && attribute.title.text) {
|
|
86
|
+
const {width: width, height: height} = table.measureText(attribute.title.text, {
|
|
87
|
+
fontSize: null === (_d = null === (_c = attribute.label) || void 0 === _c ? void 0 : _c.style) || void 0 === _d ? void 0 : _d.fontSize,
|
|
88
|
+
fontWeight: null === (_f = null === (_e = attribute.label) || void 0 === _e ? void 0 : _e.style) || void 0 === _f ? void 0 : _f.fontWeight,
|
|
89
|
+
fontFamily: null === (_h = null === (_g = attribute.label) || void 0 === _g ? void 0 : _g.style) || void 0 === _h ? void 0 : _h.fontFamily
|
|
90
|
+
}), size = getSizeAfterResize(width, height, null === (_k = null === (_j = attribute.label) || void 0 === _j ? void 0 : _j.style) || void 0 === _k ? void 0 : _k.angle);
|
|
91
|
+
titleHeight = "bottom" !== config.orient && "top" !== config.orient || !attribute.title.autoRotate ? size.height + 2 : size.width + 2,
|
|
92
|
+
titleHeight += null !== (_l = attribute.title.space) && void 0 !== _l ? _l : 4;
|
|
93
|
+
}
|
|
94
|
+
return tickHeight + labelHeight + titleHeight;
|
|
83
95
|
}
|
|
84
96
|
|
|
85
97
|
function formatDecimal(number) {
|
|
86
98
|
return "number" != typeof number && (number = Number(number)), Number(number.toPrecision(1)).toString();
|
|
87
99
|
}
|
|
88
100
|
|
|
101
|
+
function getSizeAfterResize(width, height, angle = 0) {
|
|
102
|
+
const theta = angle * Math.PI / 180, p1_x = -width / 2, p1_y = -height / 2, p2_x = width / 2, p2_y = -height / 2, p3_x = width / 2, p3_y = height / 2, p4_x = -width / 2, p4_y = height / 2, p1Rotated = {
|
|
103
|
+
x: p1_x * Math.cos(theta) - p1_y * Math.sin(theta),
|
|
104
|
+
y: p1_x * Math.sin(theta) + p1_y * Math.cos(theta)
|
|
105
|
+
}, p2Rotated = {
|
|
106
|
+
x: p2_x * Math.cos(theta) - p2_y * Math.sin(theta),
|
|
107
|
+
y: p2_x * Math.sin(theta) + p2_y * Math.cos(theta)
|
|
108
|
+
}, p3Rotated = {
|
|
109
|
+
x: p3_x * Math.cos(theta) - p3_y * Math.sin(theta),
|
|
110
|
+
y: p3_x * Math.sin(theta) + p3_y * Math.cos(theta)
|
|
111
|
+
}, p4Rotated = {
|
|
112
|
+
x: p4_x * Math.cos(theta) - p4_y * Math.sin(theta),
|
|
113
|
+
y: p4_x * Math.sin(theta) + p4_y * Math.cos(theta)
|
|
114
|
+
}, bounds_minX = Math.min(p1Rotated.x, p2Rotated.x, p3Rotated.x, p4Rotated.x), bounds_maxX = Math.max(p1Rotated.x, p2Rotated.x, p3Rotated.x, p4Rotated.x), bounds_minY = Math.min(p1Rotated.y, p2Rotated.y, p3Rotated.y, p4Rotated.y);
|
|
115
|
+
return {
|
|
116
|
+
width: bounds_maxX - bounds_minX,
|
|
117
|
+
height: Math.max(p1Rotated.y, p2Rotated.y, p3Rotated.y, p4Rotated.y) - bounds_minY
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
|
|
89
121
|
exports.computeAxisComponentWidth = computeAxisComponentWidth, exports.computeAxisComponentHeight = computeAxisComponentHeight;
|
|
90
122
|
//# sourceMappingURL=get-axis-component-size.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["components/axis/get-axis-component-size.ts"],"names":[],"mappings":";;;AAAA,6CAAyC;AAGzC,+DAAmD;AAOnD,SAAgB,yBAAyB,CAAC,MAAuB,EAAE,KAAmB;;IACpF,MAAM,SAAS,GAAG,IAAA,cAAK,EAAC,EAAE,EAAE,gCAAU,EAAE,MAAM,CAAC,CAAC;IAEhD,MAAM,SAAS,GAAG,MAAA,SAAS,CAAC,IAAI,CAAC,KAAK,mCAAI,CAAC,CAAC;IAG5C,IAAI,UAAU,GAAG,CAAC,CAAC;IACnB,IAAI,SAAS,CAAC,KAAK,CAAC,OAAO,EAAE;QAC3B,IAAI,SAAS,CAAC,IAAI,KAAK,MAAM,EAAE;YAC7B,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC;YAChC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAY,EAAE,EAAE;;gBAC9B,IAAI,SA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sourcesContent":["import { merge } from '@visactor/vutils';\nimport type { BaseTableAPI } from '../../ts-types/base-table';\nimport type { ICellAxisOption } from '../../ts-types/component/axis';\nimport { commonAxis } from './get-axis-attributes';\n\n/**\n * @description: compuational vertical axis width\n * @param {ICellAxisOption} config\n * @return {*}\n */\nexport function computeAxisComponentWidth(config: ICellAxisOption, table: BaseTableAPI) {\n const attribute = merge({}, commonAxis, config);\n // tick\n const tickWidth = attribute.tick.width ?? 4;\n\n // text\n let labelWidth = 0;\n if (attribute.label.visible) {\n if (attribute.type === 'band') {\n const domain = attribute.domain;\n domain.forEach((text: string) => {\n if (attribute.label.formatMethod) {\n text = attribute.label.formatMethod(text);\n }\n labelWidth = Math.max(\n labelWidth,\n table.measureText(text, {\n fontSize: attribute.label?.style?.fontSize,\n fontWeight: attribute.label?.style?.fontWeight,\n fontFamily: attribute.label?.style?.fontFamily\n }).width\n );\n });\n } else {\n const range = attribute.range;\n const minNumber = Math.abs(range.min) > 1 ? Math.round(range.min) : range.min;\n const maxNumber = Math.abs(range.max) > 1 ? Math.round(range.max) : range.max;\n // abs>1取整保留两位有效数字,abs<1保留一位有效数字\n const minString = formatDecimal(minNumber);\n const maxString = formatDecimal(maxNumber);\n // 这里测量的是预估的最大最小range,与实际现实的label可能不同\n [minString, maxString].forEach(text => {\n if (attribute.label.formatMethod) {\n text = attribute.label.formatMethod(text);\n }\n labelWidth = Math.max(\n labelWidth,\n table.measureText(text, {\n fontSize: attribute.label?.style?.fontSize,\n fontWeight: attribute.label?.style?.fontWeight,\n fontFamily: attribute.label?.style?.fontFamily\n }).width + 2\n );\n });\n }\n labelWidth += attribute.label.space ?? 4;\n }\n\n // title\n let titleWidth = 0;\n if (attribute.title.visible && attribute.title.text) {\n if ((config.orient === 'left' || config.orient === 'right') && attribute.title.autoRotate) {\n titleWidth =\n table.measureText(attribute.title.text as string, {\n fontSize: attribute.title?.style?.fontSize,\n fontWeight: attribute.title?.style?.fontWeight,\n fontFamily: attribute.title?.style?.fontFamily\n }).height + 2;\n } else {\n titleWidth =\n table.measureText(attribute.title.text as string, {\n fontSize: attribute.title?.style?.fontSize,\n fontWeight: attribute.title?.style?.fontWeight,\n fontFamily: attribute.title?.style?.fontFamily\n }).width + 2;\n }\n titleWidth += attribute.title.space ?? 4;\n }\n\n return tickWidth + labelWidth + titleWidth;\n}\n\n/**\n * @description: compuational horizontal axis height\n * @param {ICellAxisOption} config\n * @return {*}\n */\nexport function computeAxisComponentHeight(config: ICellAxisOption, table: BaseTableAPI) {\n const attribute = merge({}, commonAxis, config);\n // tick\n const tickHeight = attribute.tick.width ?? 4;\n\n // text\n let labelHeight = 0;\n if (attribute.label.visible) {\n if (attribute.type === 'band') {\n const domain = attribute.domain;\n domain.forEach((text: string) => {\n if (attribute.label.formatMethod) {\n text = attribute.label.formatMethod(text);\n }\n labelHeight = Math.max(\n labelHeight,\n table.measureText(text, {\n fontSize: attribute.label?.style?.fontSize,\n fontFamily: attribute.label?.style?.fontFamily\n }).height\n );\n });\n } else {\n const range = attribute.range;\n const minNumber = Math.abs(range.min) > 1 ? Math.round(range.min) : range.min;\n const maxNumber = Math.abs(range.max) > 1 ? Math.round(range.max) : range.max;\n // abs>1取整保留两位有效数字,abs<1保留一位有效数字\n const minString = formatDecimal(minNumber);\n const maxString = formatDecimal(maxNumber);\n // 这里测量的是预估的最大最小range,与实际现实的label可能不同\n [minString, maxString].forEach(text => {\n if (attribute.label.formatMethod) {\n text = attribute.label.formatMethod(text);\n }\n labelHeight = Math.max(\n labelHeight,\n table.measureText(text, {\n fontSize: attribute.label?.style?.fontSize,\n fontFamily: attribute.label?.style?.fontFamily\n }).height + 2\n );\n });\n }\n labelHeight += attribute.label.space ?? 4;\n }\n\n // title\n let titleHeight = 0;\n if (attribute.title.visible && attribute.title.text) {\n if ((config.orient === 'bottom' || config.orient === 'top') && attribute.title.autoRotate) {\n titleHeight =\n table.measureText(attribute.title.text as string, {\n fontSize: attribute.title?.style?.fontSize,\n fontFamily: attribute.title?.style?.fontFamily\n }).width + 2;\n } else {\n titleHeight =\n table.measureText(attribute.title.text as string, {\n fontSize: attribute.title?.style?.fontSize,\n fontFamily: attribute.title?.style?.fontFamily\n }).height + 2;\n }\n titleHeight += attribute.title.space ?? 4;\n }\n\n return tickHeight + labelHeight + titleHeight;\n}\n\n// 保留一位有效数字\nfunction formatDecimal(number: number) {\n if (typeof number !== 'number') {\n number = Number(number);\n }\n\n return Number(number.toPrecision(1)).toString(); // 避免科学计数法\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["components/axis/get-axis-component-size.ts"],"names":[],"mappings":";;;AAAA,6CAAyC;AAGzC,+DAAmD;AAOnD,SAAgB,yBAAyB,CAAC,MAAuB,EAAE,KAAmB;;IACpF,MAAM,SAAS,GAAG,IAAA,cAAK,EAAC,EAAE,EAAE,gCAAU,EAAE,MAAM,CAAC,CAAC;IAEhD,MAAM,SAAS,GAAG,MAAA,SAAS,CAAC,IAAI,CAAC,KAAK,mCAAI,CAAC,CAAC;IAG5C,IAAI,UAAU,GAAG,CAAC,CAAC;IACnB,IAAI,SAAS,CAAC,KAAK,CAAC,OAAO,EAAE;QAC3B,IAAI,SAAS,CAAC,IAAI,KAAK,MAAM,EAAE;YAC7B,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC;YAChC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAY,EAAE,EAAE;;gBAC9B,IAAI,SAAS,CAAC,KAAK,CAAC,YAAY,EAAE;oBAChC,IAAI,GAAG,SAAS,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;iBAC3C;gBACD,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE;oBAChD,QAAQ,EAAE,MAAA,MAAA,SAAS,CAAC,KAAK,0CAAE,KAAK,0CAAE,QAAQ;oBAC1C,UAAU,EAAE,MAAA,MAAA,SAAS,CAAC,KAAK,0CAAE,KAAK,0CAAE,UAAU;oBAC9C,U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AAC,EAAE,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC;QAClE,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC;QAClE,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC;KACnE,CAAC;IAEF,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI;QAChC,MAAM,EAAE,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI;KAClC,CAAC;AACJ,CAAC","file":"get-axis-component-size.js","sourcesContent":["import { merge } from '@visactor/vutils';\nimport type { BaseTableAPI } from '../../ts-types/base-table';\nimport type { ICellAxisOption } from '../../ts-types/component/axis';\nimport { commonAxis } from './get-axis-attributes';\n\n/**\n * @description: compuational vertical axis width\n * @param {ICellAxisOption} config\n * @return {*}\n */\nexport function computeAxisComponentWidth(config: ICellAxisOption, table: BaseTableAPI) {\n const attribute = merge({}, commonAxis, config);\n // tick\n const tickWidth = attribute.tick.width ?? 4;\n\n // text\n let labelWidth = 0;\n if (attribute.label.visible) {\n if (attribute.type === 'band') {\n const domain = attribute.domain;\n domain.forEach((text: string) => {\n if (attribute.label.formatMethod) {\n text = attribute.label.formatMethod(text);\n }\n const { width, height } = table.measureText(text, {\n fontSize: attribute.label?.style?.fontSize,\n fontWeight: attribute.label?.style?.fontWeight,\n fontFamily: attribute.label?.style?.fontFamily\n });\n labelWidth = Math.max(labelWidth, getSizeAfterResize(width, height, attribute.label?.style?.angle).width);\n });\n } else {\n const range = attribute.range;\n const minNumber = Math.abs(range.min) > 1 ? Math.round(range.min) : range.min;\n const maxNumber = Math.abs(range.max) > 1 ? Math.round(range.max) : range.max;\n // abs>1取整保留两位有效数字,abs<1保留一位有效数字\n const minString = formatDecimal(minNumber);\n const maxString = formatDecimal(maxNumber);\n // 这里测量的是预估的最大最小range,与实际现实的label可能不同\n [minString, maxString].forEach(text => {\n if (attribute.label.formatMethod) {\n text = attribute.label.formatMethod(text);\n }\n const { width, height } = table.measureText(text, {\n fontSize: attribute.label?.style?.fontSize,\n fontWeight: attribute.label?.style?.fontWeight,\n fontFamily: attribute.label?.style?.fontFamily\n });\n labelWidth = Math.max(labelWidth, getSizeAfterResize(width, height, attribute.label?.style?.angle).width + 2);\n });\n }\n labelWidth += attribute.label.space ?? 4;\n }\n\n // title\n let titleWidth = 0;\n if (attribute.title.visible && attribute.title.text) {\n const { width, height } = table.measureText(attribute.title.text, {\n fontSize: attribute.label?.style?.fontSize,\n fontWeight: attribute.label?.style?.fontWeight,\n fontFamily: attribute.label?.style?.fontFamily\n });\n const size = getSizeAfterResize(width, height, attribute.label?.style?.angle);\n if ((config.orient === 'left' || config.orient === 'right') && attribute.title.autoRotate) {\n titleWidth = size.height + 2;\n } else {\n titleWidth = size.width + 2;\n }\n titleWidth += attribute.title.space ?? 4;\n }\n\n return tickWidth + labelWidth + titleWidth;\n}\n\n/**\n * @description: compuational horizontal axis height\n * @param {ICellAxisOption} config\n * @return {*}\n */\nexport function computeAxisComponentHeight(config: ICellAxisOption, table: BaseTableAPI) {\n const attribute = merge({}, commonAxis, config);\n // tick\n const tickHeight = attribute.tick.width ?? 4;\n\n // text\n let labelHeight = 0;\n if (attribute.label.visible) {\n if (attribute.type === 'band') {\n const domain = attribute.domain;\n domain.forEach((text: string) => {\n if (attribute.label.formatMethod) {\n text = attribute.label.formatMethod(text);\n }\n const { width, height } = table.measureText(text, {\n fontSize: attribute.label?.style?.fontSize,\n fontWeight: attribute.label?.style?.fontWeight,\n fontFamily: attribute.label?.style?.fontFamily\n });\n labelHeight = Math.max(labelHeight, getSizeAfterResize(width, height, attribute.label?.style?.angle).height);\n });\n } else {\n const range = attribute.range;\n const minNumber = Math.abs(range.min) > 1 ? Math.round(range.min) : range.min;\n const maxNumber = Math.abs(range.max) > 1 ? Math.round(range.max) : range.max;\n // abs>1取整保留两位有效数字,abs<1保留一位有效数字\n const minString = formatDecimal(minNumber);\n const maxString = formatDecimal(maxNumber);\n // 这里测量的是预估的最大最小range,与实际现实的label可能不同\n [minString, maxString].forEach(text => {\n if (attribute.label.formatMethod) {\n text = attribute.label.formatMethod(text);\n }\n const { width, height } = table.measureText(text, {\n fontSize: attribute.label?.style?.fontSize,\n fontWeight: attribute.label?.style?.fontWeight,\n fontFamily: attribute.label?.style?.fontFamily\n });\n labelHeight = Math.max(\n labelHeight,\n getSizeAfterResize(width, height, attribute.label?.style?.angle).height + 2\n );\n });\n }\n labelHeight += attribute.label.space ?? 4;\n }\n\n // title\n let titleHeight = 0;\n if (attribute.title.visible && attribute.title.text) {\n const { width, height } = table.measureText(attribute.title.text, {\n fontSize: attribute.label?.style?.fontSize,\n fontWeight: attribute.label?.style?.fontWeight,\n fontFamily: attribute.label?.style?.fontFamily\n });\n const size = getSizeAfterResize(width, height, attribute.label?.style?.angle);\n if ((config.orient === 'bottom' || config.orient === 'top') && attribute.title.autoRotate) {\n titleHeight = size.width + 2;\n } else {\n titleHeight = size.height + 2;\n }\n titleHeight += attribute.title.space ?? 4;\n }\n\n return tickHeight + labelHeight + titleHeight;\n}\n\n// 保留一位有效数字\nfunction formatDecimal(number: number) {\n if (typeof number !== 'number') {\n number = Number(number);\n }\n\n return Number(number.toPrecision(1)).toString(); // 避免科学计数法\n}\n\n// 计算旋转后的size\nfunction getSizeAfterResize(width: number, height: number, angle = 0) {\n const theta = (angle * Math.PI) / 180; // 角度转为弧度\n const p1 = { x: -width / 2, y: -height / 2 };\n const p2 = { x: width / 2, y: -height / 2 };\n const p3 = { x: width / 2, y: height / 2 };\n const p4 = { x: -width / 2, y: height / 2 };\n\n const p1Rotated = {\n x: p1.x * Math.cos(theta) - p1.y * Math.sin(theta),\n y: p1.x * Math.sin(theta) + p1.y * Math.cos(theta)\n };\n const p2Rotated = {\n x: p2.x * Math.cos(theta) - p2.y * Math.sin(theta),\n y: p2.x * Math.sin(theta) + p2.y * Math.cos(theta)\n };\n const p3Rotated = {\n x: p3.x * Math.cos(theta) - p3.y * Math.sin(theta),\n y: p3.x * Math.sin(theta) + p3.y * Math.cos(theta)\n };\n const p4Rotated = {\n x: p4.x * Math.cos(theta) - p4.y * Math.sin(theta),\n y: p4.x * Math.sin(theta) + p4.y * Math.cos(theta)\n };\n\n const bounds = {\n minX: Math.min(p1Rotated.x, p2Rotated.x, p3Rotated.x, p4Rotated.x),\n maxX: Math.max(p1Rotated.x, p2Rotated.x, p3Rotated.x, p4Rotated.x),\n minY: Math.min(p1Rotated.y, p2Rotated.y, p3Rotated.y, p4Rotated.y),\n maxY: Math.max(p1Rotated.y, p2Rotated.y, p3Rotated.y, p4Rotated.y)\n };\n\n return {\n width: bounds.maxX - bounds.minX,\n height: bounds.maxY - bounds.minY\n };\n}\n"]}
|
|
@@ -103,6 +103,8 @@ class TooltipHandler {
|
|
|
103
103
|
e.related && this._isBindCell(e.related.col, e.related.row) || this._unbindFromCell();
|
|
104
104
|
})), table.on(TABLE_EVENT_TYPE_1.TABLE_EVENT_TYPE.SELECTED_CELL, (e => {
|
|
105
105
|
this._isBindCell(e.col, e.row) && this._unbindFromCell();
|
|
106
|
+
})), table.on(TABLE_EVENT_TYPE_1.TABLE_EVENT_TYPE.MOUSELEAVE_TABLE, (e => {
|
|
107
|
+
this._unbindFromCell();
|
|
106
108
|
})), table.on(TABLE_EVENT_TYPE_1.TABLE_EVENT_TYPE.SCROLL, (e => {
|
|
107
109
|
var _a;
|
|
108
110
|
const info = this._attachInfo;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["components/tooltip/TooltipHandler.ts"],"names":[],"mappings":";;;AACA,6CAA2C;AAE3C,uCAA0C;AAC1C,+CAAiD;AACjD,2CAA4C;AAG5C,kE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G,wBAAwB,CAAC,WAAW,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACvG,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,QAAQ,CAAC,cAA8B;;QACrC,IAAI,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,MAAA,IAAI,CAAC,WAAW,0CAAE,cAAc,CAAC,EAAE;YACvF,OAAO,IAAI,CAAC;SACb;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAhND,wCAgNC","file":"TooltipHandler.js","sourcesContent":["import type { CellRange, RectProps } from '../../ts-types';\nimport { Placement } from '../../ts-types';\nimport type { BaseTooltip } from './BaseTooltip';\nimport { BubbleTooltip } from './Tooltip';\nimport { cellInRange } from '../../tools/helper';\nimport { isMobile } from '../../tools/util';\n// import { DG_EVENT_TYPE } from '../core/DG_EVENT_TYPE';\nimport type { TooltipOptions } from '../../ts-types/tooltip';\nimport { TABLE_EVENT_TYPE } from '../../core/TABLE_EVENT_TYPE';\nimport type { BaseTableAPI } from '../../ts-types/base-table';\nconst TOOLTIP_INSTANCE_FACTORY = {\n // tooltip(table: BaseTableAPI): BaseTooltip {\n // return new Tooltip(table);\n // },\n 'bubble-tooltip': function (table: BaseTableAPI): BaseTooltip {\n return new BubbleTooltip(table);\n }\n};\ntype AttachInfo = {\n instance?: BaseTooltip;\n range: CellRange;\n tooltipOptions: TooltipOptions;\n};\n\nexport class TooltipHandler {\n private _table: BaseTableAPI;\n private _tooltipInstances?: { [type: string]: BaseTooltip };\n private _attachInfo?: AttachInfo | null;\n private confine?: boolean; //弹出框是否需要限定在canvas区域\n constructor(table: BaseTableAPI, confine: boolean) {\n this._table = table;\n this._tooltipInstances = {};\n this._bindTableEvent(table);\n this.confine = confine;\n }\n release(): void {\n const tooltipInstances = this._tooltipInstances;\n for (const k in tooltipInstances) {\n tooltipInstances[k]?.release?.();\n }\n delete this._tooltipInstances;\n this._attachInfo = null;\n }\n _bindToCell(col: number, row: number, tooltipOptions?: TooltipOptions): void {\n const info = this._attachInfo;\n const instance = this._getTooltipInstanceInfo(col, row);\n if (info && (!instance || info.instance !== instance)) {\n info.instance?.unbindTooltipElement();\n this._attachInfo = null;\n }\n if (!instance) {\n return;\n }\n // const { instance, info: tooltipInstanceInfo } = instanceInfo;\n const attach = instance && instance.bindTooltipElement(col, row, tooltipOptions, this.confine);\n if (attach) {\n const range = this._table.getCellRange(col, row);\n this._attachInfo = { range, instance, tooltipOptions };\n }\n }\n _move(col: number, row: number, tooltipOptions: TooltipOptions): void {\n const info = this._attachInfo;\n if (!info || !cellInRange(info.range, col, row)) {\n return;\n }\n const { instance } = info;\n instance?.moveTooltipElement(col, row, tooltipOptions, this.confine);\n }\n moveToPosition(\n col: number,\n row: number,\n position?: { x: number; y: number },\n referencePosition?: {\n rect: RectProps;\n placement?: Placement;\n }\n ): void {\n const info = this._attachInfo;\n if (!info || !cellInRange(info.range, col, row)) {\n return;\n }\n const { instance } = info;\n this._attachInfo.tooltipOptions.position = position;\n this._attachInfo.tooltipOptions.referencePosition = referencePosition;\n instance?.locateTooltipElement(col, row, position, referencePosition, this.confine);\n }\n _unbindFromCell(): void {\n const info = this._attachInfo;\n if (!info) {\n return;\n }\n const { instance } = info;\n instance?.unbindTooltipElement();\n this._attachInfo = null;\n }\n _isBindCell(col: number, row: number): boolean {\n const info = this._attachInfo;\n if (!info) {\n return false;\n }\n return cellInRange(info.range, col, row);\n }\n _bindTableEvent(table: BaseTableAPI): void {\n // (table.options.hover?.isShowTooltip || table.options.tooltip?.isShowOverflowTextTooltip) &&\n table.on(TABLE_EVENT_TYPE.MOUSEENTER_CELL, e => {\n //移动端不监听mousemove事件 (修改移动端tooltip时加的isMobile判断)\n if (isMobile()) {\n return;\n }\n // dropDownMenu区域不响应\n const { x1: left, x2: right, y1: top, y2: bottom } = table.stateManeger.menu.bounds;\n if (\n table.stateManeger.menu.isShow &&\n typeof e.x === 'number' &&\n typeof e.y === 'number' &&\n e.x > left &&\n e.x < right &&\n e.y > top &&\n e.y < bottom\n ) {\n return;\n }\n const { col, row } = e;\n if (e.related) {\n if (this._isBindCell(col, row)) {\n return;\n }\n }\n if (table.internalProps.tooltip?.isShowOverflowTextTooltip) {\n const overflowText = table.getCellOverflowText(col, row);\n const headerDescription = table.getHeaderDescription(col, row);\n const rect = table.getCellRangeRelativeRect({ col, row });\n let tooltipOption;\n if (overflowText) {\n tooltipOption = {\n content: headerDescription\n ? `${headerDescription}\n ${overflowText}`\n : overflowText,\n referencePosition: {\n placement: Placement.bottom,\n rect\n },\n style: { arrowMark: false }\n };\n }\n if (headerDescription) {\n tooltipOption = {\n content: headerDescription,\n referencePosition: {\n placement: Placement.bottom,\n rect\n },\n style: { arrowMark: false }\n };\n }\n if (tooltipOption) {\n this._bindToCell(e.col, e.row, tooltipOption);\n }\n }\n });\n table.on(TABLE_EVENT_TYPE.MOUSEMOVE_CELL, e => {\n //移动端不监听mousemove事件 (修改移动端tooltip时加的isMobile判断)\n if (isMobile()) {\n return;\n }\n if (this._attachInfo?.tooltipOptions?.referencePosition) {\n const position = this._attachInfo.tooltipOptions.referencePosition;\n const { event } = e;\n const { left, right, top, bottom } = position.rect;\n const abstractPos = table._getMouseAbstractPoint(event, false);\n if (\n !(\n abstractPos.inTable &&\n abstractPos.x >= left - 5 &&\n abstractPos.x <= right + 5 &&\n abstractPos.y >= top - 5 &&\n abstractPos.y <= bottom + 5\n )\n ) {\n // 这里加5px的判断buffer\n this._unbindFromCell();\n }\n }\n // dropDownMenu区域不响应\n if (this._attachInfo && table.stateManeger.menu.isShow) {\n this._bindToCell(e.col, e.row);\n }\n });\n table.on(TABLE_EVENT_TYPE.MOUSELEAVE_CELL, e => {\n if (e.related) {\n if (this._isBindCell(e.related.col, e.related.row)) {\n return;\n }\n }\n this._unbindFromCell();\n });\n table.on(TABLE_EVENT_TYPE.SELECTED_CELL, e => {\n if (this._isBindCell(e.col, e.row)) {\n this._unbindFromCell();\n }\n });\n table.on(TABLE_EVENT_TYPE.SCROLL, e => {\n const info = this._attachInfo;\n if (info?.tooltipOptions && info?.range?.start) {\n const { col, row } = info.range.start;\n const rect = table.getCellRangeRelativeRect({ col, row });\n info.tooltipOptions.referencePosition.rect = rect;\n this._move(info.range.start.col, info.range.start.row, info.tooltipOptions);\n }\n });\n }\n _getTooltipInstanceInfo(col: number, row: number): BaseTooltip | null {\n const table = this._table;\n const tooltipInstances = this._tooltipInstances;\n // const info = getTooltipInstanceInfo(table, col, row, tooltipOptions);\n // if (!info) {\n // return null;\n // }\n const tooltipType = 'bubble-tooltip';\n // const { tooltipType } = info;\n const instance =\n (tooltipInstances && tooltipInstances[tooltipType]) ||\n (tooltipInstances && (tooltipInstances[tooltipType] = TOOLTIP_INSTANCE_FACTORY[tooltipType](table)));\n return instance;\n }\n isBinded(tooltipOptions: TooltipOptions) {\n if (JSON.stringify(tooltipOptions) === JSON.stringify(this._attachInfo?.tooltipOptions)) {\n return true;\n }\n return false;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["components/tooltip/TooltipHandler.ts"],"names":[],"mappings":";;;AACA,6CAA2C;AAE3C,uCAA0C;AAC1C,+CAAiD;AACjD,2CAA4C;AAG5C,kEAA+D;AAE/D,MAAM,wBAAwB,GAAG;IAI/B,gBAAgB,EAAE,UAAU,KAAmB;QAC7C,OAAO,IAAI,uBAAa,CAAC,KAAK,CAAC,CAAC;IAClC,CAAC;CACF,CAAC;AAOF,MAAa,cAAc;IAKzB,YAAY,KAAmB,EAAE,OAAgB;QAC/C,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,iBAAiB,GAAG,EAAE,CAAC;QAC5B,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;QAC5B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IACD,OAAO;;QACL,MAAM,gBAAgB,GAAG,IAAI,CAAC,iBAAiB,CAAC;QAChD,KAAK,MAAM,CAAC,IAAI,gBAA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andler.js","sourcesContent":["import type { CellRange, RectProps } from '../../ts-types';\nimport { Placement } from '../../ts-types';\nimport type { BaseTooltip } from './BaseTooltip';\nimport { BubbleTooltip } from './Tooltip';\nimport { cellInRange } from '../../tools/helper';\nimport { isMobile } from '../../tools/util';\n// import { DG_EVENT_TYPE } from '../core/DG_EVENT_TYPE';\nimport type { TooltipOptions } from '../../ts-types/tooltip';\nimport { TABLE_EVENT_TYPE } from '../../core/TABLE_EVENT_TYPE';\nimport type { BaseTableAPI } from '../../ts-types/base-table';\nconst TOOLTIP_INSTANCE_FACTORY = {\n // tooltip(table: BaseTableAPI): BaseTooltip {\n // return new Tooltip(table);\n // },\n 'bubble-tooltip': function (table: BaseTableAPI): BaseTooltip {\n return new BubbleTooltip(table);\n }\n};\ntype AttachInfo = {\n instance?: BaseTooltip;\n range: CellRange;\n tooltipOptions: TooltipOptions;\n};\n\nexport class TooltipHandler {\n private _table: BaseTableAPI;\n private _tooltipInstances?: { [type: string]: BaseTooltip };\n private _attachInfo?: AttachInfo | null;\n private confine?: boolean; //弹出框是否需要限定在canvas区域\n constructor(table: BaseTableAPI, confine: boolean) {\n this._table = table;\n this._tooltipInstances = {};\n this._bindTableEvent(table);\n this.confine = confine;\n }\n release(): void {\n const tooltipInstances = this._tooltipInstances;\n for (const k in tooltipInstances) {\n tooltipInstances[k]?.release?.();\n }\n delete this._tooltipInstances;\n this._attachInfo = null;\n }\n _bindToCell(col: number, row: number, tooltipOptions?: TooltipOptions): void {\n const info = this._attachInfo;\n const instance = this._getTooltipInstanceInfo(col, row);\n if (info && (!instance || info.instance !== instance)) {\n info.instance?.unbindTooltipElement();\n this._attachInfo = null;\n }\n if (!instance) {\n return;\n }\n // const { instance, info: tooltipInstanceInfo } = instanceInfo;\n const attach = instance && instance.bindTooltipElement(col, row, tooltipOptions, this.confine);\n if (attach) {\n const range = this._table.getCellRange(col, row);\n this._attachInfo = { range, instance, tooltipOptions };\n }\n }\n _move(col: number, row: number, tooltipOptions: TooltipOptions): void {\n const info = this._attachInfo;\n if (!info || !cellInRange(info.range, col, row)) {\n return;\n }\n const { instance } = info;\n instance?.moveTooltipElement(col, row, tooltipOptions, this.confine);\n }\n moveToPosition(\n col: number,\n row: number,\n position?: { x: number; y: number },\n referencePosition?: {\n rect: RectProps;\n placement?: Placement;\n }\n ): void {\n const info = this._attachInfo;\n if (!info || !cellInRange(info.range, col, row)) {\n return;\n }\n const { instance } = info;\n this._attachInfo.tooltipOptions.position = position;\n this._attachInfo.tooltipOptions.referencePosition = referencePosition;\n instance?.locateTooltipElement(col, row, position, referencePosition, this.confine);\n }\n _unbindFromCell(): void {\n const info = this._attachInfo;\n if (!info) {\n return;\n }\n const { instance } = info;\n instance?.unbindTooltipElement();\n this._attachInfo = null;\n }\n _isBindCell(col: number, row: number): boolean {\n const info = this._attachInfo;\n if (!info) {\n return false;\n }\n return cellInRange(info.range, col, row);\n }\n _bindTableEvent(table: BaseTableAPI): void {\n // (table.options.hover?.isShowTooltip || table.options.tooltip?.isShowOverflowTextTooltip) &&\n table.on(TABLE_EVENT_TYPE.MOUSEENTER_CELL, e => {\n //移动端不监听mousemove事件 (修改移动端tooltip时加的isMobile判断)\n if (isMobile()) {\n return;\n }\n // dropDownMenu区域不响应\n const { x1: left, x2: right, y1: top, y2: bottom } = table.stateManeger.menu.bounds;\n if (\n table.stateManeger.menu.isShow &&\n typeof e.x === 'number' &&\n typeof e.y === 'number' &&\n e.x > left &&\n e.x < right &&\n e.y > top &&\n e.y < bottom\n ) {\n return;\n }\n const { col, row } = e;\n if (e.related) {\n if (this._isBindCell(col, row)) {\n return;\n }\n }\n if (table.internalProps.tooltip?.isShowOverflowTextTooltip) {\n const overflowText = table.getCellOverflowText(col, row);\n const headerDescription = table.getHeaderDescription(col, row);\n const rect = table.getCellRangeRelativeRect({ col, row });\n let tooltipOption;\n if (overflowText) {\n tooltipOption = {\n content: headerDescription\n ? `${headerDescription}\n ${overflowText}`\n : overflowText,\n referencePosition: {\n placement: Placement.bottom,\n rect\n },\n style: { arrowMark: false }\n };\n }\n if (headerDescription) {\n tooltipOption = {\n content: headerDescription,\n referencePosition: {\n placement: Placement.bottom,\n rect\n },\n style: { arrowMark: false }\n };\n }\n if (tooltipOption) {\n this._bindToCell(e.col, e.row, tooltipOption);\n }\n }\n });\n table.on(TABLE_EVENT_TYPE.MOUSEMOVE_CELL, e => {\n //移动端不监听mousemove事件 (修改移动端tooltip时加的isMobile判断)\n if (isMobile()) {\n return;\n }\n if (this._attachInfo?.tooltipOptions?.referencePosition) {\n const position = this._attachInfo.tooltipOptions.referencePosition;\n const { event } = e;\n const { left, right, top, bottom } = position.rect;\n const abstractPos = table._getMouseAbstractPoint(event, false);\n if (\n !(\n abstractPos.inTable &&\n abstractPos.x >= left - 5 &&\n abstractPos.x <= right + 5 &&\n abstractPos.y >= top - 5 &&\n abstractPos.y <= bottom + 5\n )\n ) {\n // 这里加5px的判断buffer\n this._unbindFromCell();\n }\n }\n // dropDownMenu区域不响应\n if (this._attachInfo && table.stateManeger.menu.isShow) {\n this._bindToCell(e.col, e.row);\n }\n });\n table.on(TABLE_EVENT_TYPE.MOUSELEAVE_CELL, e => {\n if (e.related) {\n if (this._isBindCell(e.related.col, e.related.row)) {\n return;\n }\n }\n this._unbindFromCell();\n });\n table.on(TABLE_EVENT_TYPE.SELECTED_CELL, e => {\n if (this._isBindCell(e.col, e.row)) {\n this._unbindFromCell();\n }\n });\n table.on(TABLE_EVENT_TYPE.MOUSELEAVE_TABLE, e => {\n this._unbindFromCell();\n });\n table.on(TABLE_EVENT_TYPE.SCROLL, e => {\n const info = this._attachInfo;\n if (info?.tooltipOptions && info?.range?.start) {\n const { col, row } = info.range.start;\n const rect = table.getCellRangeRelativeRect({ col, row });\n info.tooltipOptions.referencePosition.rect = rect;\n this._move(info.range.start.col, info.range.start.row, info.tooltipOptions);\n }\n });\n }\n _getTooltipInstanceInfo(col: number, row: number): BaseTooltip | null {\n const table = this._table;\n const tooltipInstances = this._tooltipInstances;\n // const info = getTooltipInstanceInfo(table, col, row, tooltipOptions);\n // if (!info) {\n // return null;\n // }\n const tooltipType = 'bubble-tooltip';\n // const { tooltipType } = info;\n const instance =\n (tooltipInstances && tooltipInstances[tooltipType]) ||\n (tooltipInstances && (tooltipInstances[tooltipType] = TOOLTIP_INSTANCE_FACTORY[tooltipType](table)));\n return instance;\n }\n isBinded(tooltipOptions: TooltipOptions) {\n if (JSON.stringify(tooltipOptions) === JSON.stringify(this._attachInfo?.tooltipOptions)) {\n return true;\n }\n return false;\n }\n}\n"]}
|
package/cjs/core/BaseTable.d.ts
CHANGED
|
@@ -119,7 +119,7 @@ export declare abstract class BaseTable extends EventTarget implements BaseTable
|
|
|
119
119
|
getRowHeight(row: number): number;
|
|
120
120
|
setRowHeight(row: number, height: number, clearCache?: boolean): void;
|
|
121
121
|
getRowsHeight(startRow: number, endRow: number): number;
|
|
122
|
-
|
|
122
|
+
getColWidthDefined(col: number): string | number;
|
|
123
123
|
getColWidth(col: number): number;
|
|
124
124
|
setColWidth(col: number, width: string | number, clearCache?: boolean, skipCheckFrozen?: boolean): void;
|
|
125
125
|
_clearColRangeWidthsMap(col?: number): void;
|
|
@@ -235,7 +235,7 @@ export declare abstract class BaseTable extends EventTarget implements BaseTable
|
|
|
235
235
|
get autoWrapText(): boolean;
|
|
236
236
|
set autoWrapText(autoWrapText: boolean);
|
|
237
237
|
get theme(): TableTheme;
|
|
238
|
-
|
|
238
|
+
updateTheme(theme: TableTheme): void;
|
|
239
239
|
getBodyField(col: number, row: number): FieldDef | undefined;
|
|
240
240
|
getBodyColumnDefine(col: number, row: number): ColumnDefine;
|
|
241
241
|
getBodyColumnType(col: number, row: number): ColumnTypeOption;
|
|
@@ -269,6 +269,8 @@ export declare abstract class BaseTable extends EventTarget implements BaseTable
|
|
|
269
269
|
_hasField(field: FieldDef, col: number, row: number): boolean;
|
|
270
270
|
_getCellStyle(col: number, row: number): FullExtendStyle;
|
|
271
271
|
clearCellStyleCache(): void;
|
|
272
|
+
clearRowHeightCache(): void;
|
|
273
|
+
clearColWidthCache(): void;
|
|
272
274
|
_canResizeColumn(col: number, row: number): boolean;
|
|
273
275
|
_canDragHeaderPosition(col: number, row: number): boolean;
|
|
274
276
|
getCellIcons(col: number, row: number): ColumnIconOption[];
|
package/cjs/core/BaseTable.js
CHANGED
|
@@ -45,7 +45,7 @@ class BaseTable extends EventTarget_1.EventTarget {
|
|
|
45
45
|
}
|
|
46
46
|
constructor(container, options = {}) {
|
|
47
47
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
48
|
-
if (super(), this.showFrozenIcon = !0, this.showSort = !0, this.version = "0.10.
|
|
48
|
+
if (super(), this.showFrozenIcon = !0, this.showSort = !0, this.version = "0.10.1-alpha.1",
|
|
49
49
|
this.id = `VTable${Date.now()}`, this.throttleInvalidate = (0, util_1.throttle2)(this.render.bind(this), 200),
|
|
50
50
|
!container) throw new Error("vtable's container is undefined");
|
|
51
51
|
const {frozenColCount: frozenColCount = 0, defaultRowHeight: defaultRowHeight = 40, defaultHeaderRowHeight: defaultHeaderRowHeight, defaultColWidth: defaultColWidth = 80, defaultHeaderColWidth: defaultHeaderColWidth, widthMode: widthMode = "standard", heightMode: heightMode = "standard", autoFillWidth: autoFillWidth = !1, keyboardOptions: keyboardOptions, columnResizeMode: columnResizeMode, dragHeaderMode: dragHeaderMode, showFrozenIcon: showFrozenIcon, allowFrozenColCount: allowFrozenColCount, padding: padding, hover: hover, menu: menu, select: click, customRender: customRender, pixelRatio: pixelRatio = pixel_ratio_1.defaultPixelRatio, renderChartAsync: renderChartAsync, renderChartAsyncBatchCount: renderChartAsyncBatchCount} = options;
|
|
@@ -74,9 +74,9 @@ class BaseTable extends EventTarget_1.EventTarget {
|
|
|
74
74
|
internalProps.dragHeaderMode = dragHeaderMode, internalProps.renderChartAsync = renderChartAsync,
|
|
75
75
|
(0, chart_render_helper_1.setBatchRenderChartCount)(renderChartAsyncBatchCount),
|
|
76
76
|
internalProps._rowHeightsMap = new NumberMap_1.NumberMap, internalProps._rowRangeHeightsMap = new Map,
|
|
77
|
-
internalProps._colRangeWidthsMap = new Map,
|
|
78
|
-
this.
|
|
79
|
-
internalProps.calcWidthContext = {
|
|
77
|
+
internalProps._colRangeWidthsMap = new Map, internalProps._widthResizedColMap = new Set,
|
|
78
|
+
this.colWidthsMap = new NumberMap_1.NumberMap, this.colContentWidthsMap = new NumberMap_1.NumberMap,
|
|
79
|
+
this.colWidthsLimit = {}, internalProps.calcWidthContext = {
|
|
80
80
|
_: internalProps,
|
|
81
81
|
get full() {
|
|
82
82
|
var _a;
|
|
@@ -316,23 +316,12 @@ class BaseTable extends EventTarget_1.EventTarget {
|
|
|
316
316
|
if (null != cachedColWidth) return cachedColWidth;
|
|
317
317
|
const cachedLowerColWidth = this._colRangeWidthsMap.get(`$${startCol}$${endCol - 1}`);
|
|
318
318
|
if (null != cachedLowerColWidth) {
|
|
319
|
-
const
|
|
320
|
-
let adjustW;
|
|
321
|
-
adjustW = width ? "adaptive" === this.widthMode || this.transpose ? Number(width) : this._adjustColWidth(endCol, this._colWidthDefineToPxWidth(width)) : this.getColWidth(endCol);
|
|
322
|
-
const addWidth = cachedLowerColWidth + adjustW;
|
|
319
|
+
const addWidth = cachedLowerColWidth + this.getColWidth(endCol);
|
|
323
320
|
return startCol >= 0 && endCol >= 0 && !Number.isNaN(addWidth) && this._colRangeWidthsMap.set(`$${startCol}$${endCol}`, Math.round(addWidth)),
|
|
324
321
|
Math.round(addWidth);
|
|
325
322
|
}
|
|
326
323
|
let w = 0;
|
|
327
324
|
for (let col = startCol; col <= endCol; col++) w += this.getColWidth(col);
|
|
328
|
-
this.colWidthsMap.each(startCol, endCol, ((width, col) => {
|
|
329
|
-
w += ("adaptive" === this.widthMode || this.transpose ? Number(width) : this._adjustColWidth(col, this._colWidthDefineToPxWidth(width))) - this.getColWidth(col);
|
|
330
|
-
}));
|
|
331
|
-
for (let col = startCol; col <= endCol; col++) {
|
|
332
|
-
if (this.colWidthsMap.has(col)) continue;
|
|
333
|
-
const adj = this._adjustColWidth(col, this.internalProps.defaultColWidth);
|
|
334
|
-
adj !== this.internalProps.defaultColWidth && (w += adj - this.internalProps.defaultColWidth);
|
|
335
|
-
}
|
|
336
325
|
return startCol >= 0 && endCol >= 0 && this._colRangeWidthsMap.set(`$${startCol}$${endCol}`, Math.round(w)),
|
|
337
326
|
Math.round(w);
|
|
338
327
|
}
|
|
@@ -361,13 +350,15 @@ class BaseTable extends EventTarget_1.EventTarget {
|
|
|
361
350
|
return startRow >= 0 && endRow >= 0 && h > 0 && this._rowRangeHeightsMap.set(`$${startRow}$${endRow}`, Math.round(h)),
|
|
362
351
|
Math.round(h);
|
|
363
352
|
}
|
|
364
|
-
|
|
365
|
-
var _a, _b;
|
|
366
|
-
const
|
|
367
|
-
|
|
353
|
+
getColWidthDefined(col) {
|
|
354
|
+
var _a, _b, _c;
|
|
355
|
+
const {layoutMap: layoutMap} = this.internalProps;
|
|
356
|
+
if ("autoWidth" === this.widthMode) return "auto";
|
|
357
|
+
const {width: width} = null !== (_a = null == layoutMap ? void 0 : layoutMap.getColumnWidthDefined(col)) && void 0 !== _a ? _a : {};
|
|
358
|
+
return "number" == typeof width && width <= 0 ? 0 : width || (this.isRowHeader(col, 0) || this.isCornerHeader(col, 0) ? Array.isArray(this.defaultHeaderColWidth) ? null !== (_b = this.defaultHeaderColWidth[col]) && void 0 !== _b ? _b : this.defaultColWidth : this.defaultHeaderColWidth : this.isRightFrozenColumn(col, this.columnHeaderLevelCount) && this.isPivotTable() ? Array.isArray(this.defaultHeaderColWidth) ? null !== (_c = this.defaultHeaderColWidth[this.rowHeaderLevelCount - this.rightFrozenColCount]) && void 0 !== _c ? _c : this.defaultColWidth : this.defaultHeaderColWidth : this.defaultColWidth);
|
|
368
359
|
}
|
|
369
360
|
getColWidth(col) {
|
|
370
|
-
const width = this.
|
|
361
|
+
const width = this.colWidthsMap.get(col);
|
|
371
362
|
return "adaptive" === this.widthMode && "number" == typeof width || this.transpose && "number" == typeof width ? this._colWidthDefineToPxWidth(width) : this._adjustColWidth(col, this._colWidthDefineToPxWidth(width));
|
|
372
363
|
}
|
|
373
364
|
setColWidth(col, width, clearCache, skipCheckFrozen) {
|
|
@@ -667,8 +658,9 @@ class BaseTable extends EventTarget_1.EventTarget {
|
|
|
667
658
|
(0, chart_render_helper_1.setBatchRenderChartCount)(renderChartAsyncBatchCount),
|
|
668
659
|
internalProps.cellTextOverflows = {}, internalProps._rowHeightsMap = new NumberMap_1.NumberMap,
|
|
669
660
|
internalProps._rowRangeHeightsMap = new Map, internalProps._colRangeWidthsMap = new Map,
|
|
670
|
-
|
|
671
|
-
this.
|
|
661
|
+
internalProps._widthResizedColMap = new Set, this.colWidthsMap = new NumberMap_1.NumberMap,
|
|
662
|
+
this.colContentWidthsMap = new NumberMap_1.NumberMap, this.colWidthsLimit = {},
|
|
663
|
+
internalProps.theme = themes_1.default.of(null !== (_a = options.theme) && void 0 !== _a ? _a : themes_1.default.DEFAULT),
|
|
672
664
|
internalProps.autoWrapText = options.autoWrapText, internalProps.allowFrozenColCount = null !== (_b = options.allowFrozenColCount) && void 0 !== _b ? _b : internalProps.colCount,
|
|
673
665
|
internalProps.limitMaxAutoWidth = null !== (_c = options.limitMaxAutoWidth) && void 0 !== _c ? _c : 450,
|
|
674
666
|
this.dataSet = new vdataset_1.DataSet, null === (_d = internalProps.legends) || void 0 === _d || _d.release(),
|
|
@@ -690,7 +682,8 @@ class BaseTable extends EventTarget_1.EventTarget {
|
|
|
690
682
|
internalProps.menu = Object.assign({
|
|
691
683
|
renderMode: "html"
|
|
692
684
|
}, options.menu), "html" !== internalProps.menu.renderMode || internalProps.menuHandler || (internalProps.menuHandler = new MenuHandler_1.MenuHandler(this)),
|
|
693
|
-
this.headerStyleCache = new Map, this.bodyStyleCache = new Map
|
|
685
|
+
this.headerStyleCache = new Map, this.bodyStyleCache = new Map, this.clearColWidthCache(),
|
|
686
|
+
this.clearRowHeightCache();
|
|
694
687
|
}
|
|
695
688
|
getFrozenRowsHeight() {
|
|
696
689
|
return this.getRowsHeight(0, this.frozenRowCount - 1);
|
|
@@ -879,10 +872,10 @@ class BaseTable extends EventTarget_1.EventTarget {
|
|
|
879
872
|
get theme() {
|
|
880
873
|
return this.internalProps.theme;
|
|
881
874
|
}
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
this.
|
|
885
|
-
this.
|
|
875
|
+
updateTheme(theme) {
|
|
876
|
+
this.internalProps.theme = themes_1.default.of(null != theme ? theme : themes_1.default.DEFAULT),
|
|
877
|
+
this.options.theme = theme, this.scenegraph.clearCells(), this.headerStyleCache = new Map,
|
|
878
|
+
this.bodyStyleCache = new Map, this.scenegraph.createSceneGraph(), this.render();
|
|
886
879
|
}
|
|
887
880
|
getBodyField(col, row) {
|
|
888
881
|
return this.internalProps.layoutMap.getBody(col, row).field;
|
|
@@ -968,8 +961,8 @@ class BaseTable extends EventTarget_1.EventTarget {
|
|
|
968
961
|
setRecords(records, sort) {
|
|
969
962
|
var _a, _b;
|
|
970
963
|
const time = "undefined" != typeof window ? window.performance.now() : 0;
|
|
971
|
-
if (this.scenegraph.clearCells(), void 0 !== sort && (this.sortState = sort,
|
|
972
|
-
records) {
|
|
964
|
+
if (this.scenegraph.clearCells(), void 0 !== sort && (this.internalProps.sortState = sort,
|
|
965
|
+
this.stateManeger.setSortState(this.sortState)), records) {
|
|
973
966
|
if ((0, tableHelper_1._setRecords)(this, records), this.sortState) {
|
|
974
967
|
let order, field, fieldKey;
|
|
975
968
|
if (Array.isArray(this.sortState) ? 0 !== this.sortState.length && ({order: order, field: field, fieldKey: fieldKey} = null === (_a = this.sortState) || void 0 === _a ? void 0 : _a[0]) : ({order: order, field: field, fieldKey: fieldKey} = this.sortState),
|
|
@@ -1096,6 +1089,12 @@ class BaseTable extends EventTarget_1.EventTarget {
|
|
|
1096
1089
|
clearCellStyleCache() {
|
|
1097
1090
|
this.headerStyleCache.clear();
|
|
1098
1091
|
}
|
|
1092
|
+
clearRowHeightCache() {
|
|
1093
|
+
this.internalProps._rowHeightsMap.clear(), this._clearRowRangeHeightsMap();
|
|
1094
|
+
}
|
|
1095
|
+
clearColWidthCache() {
|
|
1096
|
+
this.internalProps._colWidthsMap.clear(), this._clearColRangeWidthsMap();
|
|
1097
|
+
}
|
|
1099
1098
|
_canResizeColumn(col, row) {
|
|
1100
1099
|
if (!(col >= 0 && row >= 0)) return !1;
|
|
1101
1100
|
if (this.isCellRangeEqual(col, row, col + 1, row)) return !1;
|