@visactor/vtable 0.10.1-alpha.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.
Files changed (53) hide show
  1. package/cjs/components/axis/get-axis-attributes.d.ts +2 -0
  2. package/cjs/components/axis/get-axis-attributes.js +3 -1
  3. package/cjs/components/axis/get-axis-attributes.js.map +1 -1
  4. package/cjs/components/axis/get-axis-component-size.js +65 -33
  5. package/cjs/components/axis/get-axis-component-size.js.map +1 -1
  6. package/cjs/core/BaseTable.d.ts +4 -2
  7. package/cjs/core/BaseTable.js +27 -28
  8. package/cjs/core/BaseTable.js.map +1 -1
  9. package/cjs/index.d.ts +1 -1
  10. package/cjs/index.js +1 -1
  11. package/cjs/index.js.map +1 -1
  12. package/cjs/layout/simple-header-layout.js +22 -10
  13. package/cjs/layout/simple-header-layout.js.map +1 -1
  14. package/cjs/scenegraph/component/menu.d.ts +41 -0
  15. package/cjs/scenegraph/graphic/text.d.ts +15 -0
  16. package/cjs/scenegraph/group-creater/progress/create-group-for-first-screen.js +1 -3
  17. package/cjs/scenegraph/group-creater/progress/create-group-for-first-screen.js.map +1 -1
  18. package/cjs/scenegraph/layout/compute-col-width.js +7 -21
  19. package/cjs/scenegraph/layout/compute-col-width.js.map +1 -1
  20. package/cjs/scenegraph/scenegraph.js +1 -0
  21. package/cjs/scenegraph/scenegraph.js.map +1 -1
  22. package/cjs/state/resize/update-resize-column.js +10 -8
  23. package/cjs/state/resize/update-resize-column.js.map +1 -1
  24. package/cjs/ts-types/base-table.d.ts +2 -1
  25. package/cjs/ts-types/base-table.js.map +1 -1
  26. package/dist/vtable.js +2740 -2410
  27. package/dist/vtable.min.js +3 -3
  28. package/es/components/axis/get-axis-attributes.d.ts +2 -0
  29. package/es/components/axis/get-axis-attributes.js +3 -1
  30. package/es/components/axis/get-axis-attributes.js.map +1 -1
  31. package/es/components/axis/get-axis-component-size.js +65 -33
  32. package/es/components/axis/get-axis-component-size.js.map +1 -1
  33. package/es/core/BaseTable.d.ts +4 -2
  34. package/es/core/BaseTable.js +26 -26
  35. package/es/core/BaseTable.js.map +1 -1
  36. package/es/index.d.ts +1 -1
  37. package/es/index.js +1 -1
  38. package/es/index.js.map +1 -1
  39. package/es/layout/simple-header-layout.js +22 -10
  40. package/es/layout/simple-header-layout.js.map +1 -1
  41. package/es/scenegraph/component/menu.d.ts +41 -0
  42. package/es/scenegraph/graphic/text.d.ts +15 -0
  43. package/es/scenegraph/group-creater/progress/create-group-for-first-screen.js +1 -3
  44. package/es/scenegraph/group-creater/progress/create-group-for-first-screen.js.map +1 -1
  45. package/es/scenegraph/layout/compute-col-width.js +7 -21
  46. package/es/scenegraph/layout/compute-col-width.js.map +1 -1
  47. package/es/scenegraph/scenegraph.js +1 -0
  48. package/es/scenegraph/scenegraph.js.map +1 -1
  49. package/es/state/resize/update-resize-column.js +10 -8
  50. package/es/state/resize/update-resize-column.js.map +1 -1
  51. package/es/ts-types/base-table.d.ts +2 -1
  52. package/es/ts-types/base-table.js.map +1 -1
  53. package/package.json +4 -4
@@ -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,S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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;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AI,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;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, _m, _o, _p, _q;
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)), labelWidth = Math.max(labelWidth, table.measureText(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
- }).width);
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)), labelWidth = Math.max(labelWidth, table.measureText(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
- }).width + 2);
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
- return attribute.title.visible && attribute.title.text && (titleWidth = "left" !== config.orient && "right" !== config.orient || !attribute.title.autoRotate ? table.measureText(attribute.title.text, {
38
- fontSize: null === (_k = null === (_j = attribute.title) || void 0 === _j ? void 0 : _j.style) || void 0 === _k ? void 0 : _k.fontSize,
39
- fontWeight: null === (_m = null === (_l = attribute.title) || void 0 === _l ? void 0 : _l.style) || void 0 === _m ? void 0 : _m.fontWeight,
40
- fontFamily: null === (_p = null === (_o = attribute.title) || void 0 === _o ? void 0 : _o.style) || void 0 === _p ? void 0 : _p.fontFamily
41
- }).width + 2 : table.measureText(attribute.title.text, {
42
- fontSize: null === (_d = null === (_c = attribute.title) || void 0 === _c ? void 0 : _c.style) || void 0 === _d ? void 0 : _d.fontSize,
43
- fontWeight: null === (_f = null === (_e = attribute.title) || void 0 === _e ? void 0 : _e.style) || void 0 === _f ? void 0 : _f.fontWeight,
44
- fontFamily: null === (_h = null === (_g = attribute.title) || void 0 === _g ? void 0 : _g.style) || void 0 === _h ? void 0 : _h.fontFamily
45
- }).height + 2, titleWidth += null !== (_q = attribute.title.space) && void 0 !== _q ? _q : 4),
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)), labelHeight = Math.max(labelHeight, table.measureText(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
- fontFamily: null === (_d = null === (_c = attribute.label) || void 0 === _c ? void 0 : _c.style) || void 0 === _d ? void 0 : _d.fontFamily
60
- }).height);
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)), labelHeight = Math.max(labelHeight, table.measureText(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
- fontFamily: null === (_d = null === (_c = attribute.label) || void 0 === _c ? void 0 : _c.style) || void 0 === _d ? void 0 : _d.fontFamily
69
- }).height + 2);
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
- return attribute.title.visible && attribute.title.text && (titleHeight = "bottom" !== config.orient && "top" !== config.orient || !attribute.title.autoRotate ? table.measureText(attribute.title.text, {
76
- fontSize: null === (_h = null === (_g = attribute.title) || void 0 === _g ? void 0 : _g.style) || void 0 === _h ? void 0 : _h.fontSize,
77
- fontFamily: null === (_k = null === (_j = attribute.title) || void 0 === _j ? void 0 : _j.style) || void 0 === _k ? void 0 : _k.fontFamily
78
- }).height + 2 : table.measureText(attribute.title.text, {
79
- fontSize: null === (_d = null === (_c = attribute.title) || void 0 === _c ? void 0 : _c.style) || void 0 === _d ? void 0 : _d.fontSize,
80
- fontFamily: null === (_f = null === (_e = attribute.title) || void 0 === _e ? void 0 : _e.style) || void 0 === _f ? void 0 : _f.fontFamily
81
- }).width + 2, titleHeight += null !== (_l = attribute.title.space) && void 0 !== _l ? _l : 4),
82
- tickHeight + labelHeight + titleHeight;
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,SAAS,CAAC,KAAK,CAAC,YAAY,EAAE;oBAChC,IAAI,GAAG,SAAS,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;iBAC3C;gBACD,UAAU,GAAG,IAAI,CAAC,GAAG,CACnB,UAAU,EACV,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE;oBACtB,QAAQ,EAAE,MAAA,MAAA,SAAS,CAAC,KAAK,0CAAE,KAAK,0CAAE,QAAQ;oBAC1C,UAAU,EAAE,MAAA,MAAA,SAAS,CAAC,KAAK,0CAAE,KAAK,0CAAE,UAAU;oBAC9C,UAAU,EAAE,MAAA,MAAA,SAAS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AK,0CAAE,QAAQ;oBAC1C,UAAU,EAAE,MAAA,MAAA,SAAS,CAAC,KAAK,0CAAE,KAAK,0CAAE,UAAU;iBAC/C,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC;SAChB;aAAM;YACL,WAAW;gBACT,KAAK,CAAC,WAAW,CAAC,SAAS,CAAC,KAAK,CAAC,IAAc,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;iBAC/C,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;SACjB;QACD,WAAW,IAAI,MAAA,SAAS,CAAC,KAAK,CAAC,KAAK,mCAAI,CAAC,CAAC;KAC3C;IAED,OAAO,UAAU,GAAG,WAAW,GAAG,WAAW,CAAC;AAChD,CAAC;AAlED,gEAkEC;AAGD,SAAS,aAAa,CAAC,MAAc;IACnC,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;QAC9B,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;KACzB;IAED,OAAO,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;AAClD,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 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,SA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M,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"]}
@@ -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
- getColWidthDefine(col: number): string | number;
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
- set theme(theme: TableTheme);
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[];
@@ -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.1-alpha.0",
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, this.colWidthsMap = new NumberMap_1.NumberMap,
78
- this.colContentWidthsMap = new NumberMap_1.NumberMap, this.colWidthsLimit = {},
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 width = this.colWidthsMap.get(endCol);
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
- getColWidthDefine(col) {
365
- var _a, _b;
366
- const width = this.colWidthsMap.get(col);
367
- return "number" == typeof width && width <= 0 ? 0 : width || (this.isRowHeader(col, 0) || this.isCornerHeader(col, 0) ? Array.isArray(this.defaultHeaderColWidth) ? null !== (_a = this.defaultHeaderColWidth[col]) && void 0 !== _a ? _a : this.defaultColWidth : this.defaultHeaderColWidth : this.isRightFrozenColumn(col, this.columnHeaderLevelCount) ? Array.isArray(this.defaultHeaderColWidth) ? null !== (_b = this.defaultHeaderColWidth[this.rowHeaderLevelCount - this.rightFrozenColCount]) && void 0 !== _b ? _b : this.defaultColWidth : this.defaultHeaderColWidth : this.defaultColWidth);
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.getColWidthDefine(col);
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
- this.colWidthsMap = new NumberMap_1.NumberMap, this.colContentWidthsMap = new NumberMap_1.NumberMap,
671
- this.colWidthsLimit = {}, internalProps.theme = themes_1.default.of(null !== (_a = options.theme) && void 0 !== _a ? _a : themes_1.default.DEFAULT),
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
- set theme(theme) {
883
- const t = themes_1.default.of(theme);
884
- this.internalProps.theme = t || themes_1.default.DEFAULT, this.options.theme = theme,
885
- this.resize();
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;
@@ -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;