@visactor/vtable 0.10.1-alpha.3 → 0.10.1-alpha.4

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 (69) hide show
  1. package/cjs/components/axis/axis.js +7 -5
  2. package/cjs/components/axis/axis.js.map +1 -1
  3. package/cjs/components/axis/get-axis-attributes.d.ts +2 -0
  4. package/cjs/components/axis/get-axis-attributes.js +3 -1
  5. package/cjs/components/axis/get-axis-attributes.js.map +1 -1
  6. package/cjs/components/axis/get-axis-component-size.js +66 -34
  7. package/cjs/components/axis/get-axis-component-size.js.map +1 -1
  8. package/cjs/core/BaseTable.js +3 -2
  9. package/cjs/core/BaseTable.js.map +1 -1
  10. package/cjs/index.d.ts +1 -1
  11. package/cjs/index.js +1 -1
  12. package/cjs/index.js.map +1 -1
  13. package/cjs/layout/chart-helper/get-axis-config.js +12 -4
  14. package/cjs/layout/chart-helper/get-axis-config.js.map +1 -1
  15. package/cjs/layout/chart-helper/get-chart-spec.js +7 -1
  16. package/cjs/layout/chart-helper/get-chart-spec.js.map +1 -1
  17. package/cjs/scenegraph/component/menu.d.ts +41 -0
  18. package/cjs/scenegraph/group-creater/progress/proxy.d.ts +2 -1
  19. package/cjs/scenegraph/group-creater/progress/proxy.js +8 -21
  20. package/cjs/scenegraph/group-creater/progress/proxy.js.map +1 -1
  21. package/cjs/scenegraph/group-creater/progress/update-position/sort-horizontal.d.ts +2 -0
  22. package/cjs/scenegraph/group-creater/progress/update-position/sort-horizontal.js +52 -0
  23. package/cjs/scenegraph/group-creater/progress/update-position/sort-horizontal.js.map +1 -0
  24. package/cjs/scenegraph/group-creater/progress/update-position/sort-vertical.d.ts +2 -0
  25. package/cjs/scenegraph/group-creater/progress/update-position/sort-vertical.js +52 -0
  26. package/cjs/scenegraph/group-creater/progress/update-position/sort-vertical.js.map +1 -0
  27. package/cjs/scenegraph/layout/compute-row-height.d.ts +1 -1
  28. package/cjs/scenegraph/layout/compute-row-height.js +13 -6
  29. package/cjs/scenegraph/layout/compute-row-height.js.map +1 -1
  30. package/cjs/scenegraph/layout/update-width.js +1 -1
  31. package/cjs/scenegraph/layout/update-width.js.map +1 -1
  32. package/cjs/scenegraph/scenegraph.js +5 -8
  33. package/cjs/scenegraph/scenegraph.js.map +1 -1
  34. package/dist/vtable.js +1643 -1921
  35. package/dist/vtable.min.js +3 -3
  36. package/es/components/axis/axis.js +7 -6
  37. package/es/components/axis/axis.js.map +1 -1
  38. package/es/components/axis/get-axis-attributes.d.ts +2 -0
  39. package/es/components/axis/get-axis-attributes.js +3 -1
  40. package/es/components/axis/get-axis-attributes.js.map +1 -1
  41. package/es/components/axis/get-axis-component-size.js +66 -34
  42. package/es/components/axis/get-axis-component-size.js.map +1 -1
  43. package/es/core/BaseTable.js +3 -2
  44. package/es/core/BaseTable.js.map +1 -1
  45. package/es/index.d.ts +1 -1
  46. package/es/index.js +1 -1
  47. package/es/index.js.map +1 -1
  48. package/es/layout/chart-helper/get-axis-config.js +13 -5
  49. package/es/layout/chart-helper/get-axis-config.js.map +1 -1
  50. package/es/layout/chart-helper/get-chart-spec.js +7 -1
  51. package/es/layout/chart-helper/get-chart-spec.js.map +1 -1
  52. package/es/scenegraph/component/menu.d.ts +41 -0
  53. package/es/scenegraph/group-creater/progress/proxy.d.ts +2 -1
  54. package/es/scenegraph/group-creater/progress/proxy.js +11 -20
  55. package/es/scenegraph/group-creater/progress/proxy.js.map +1 -1
  56. package/es/scenegraph/group-creater/progress/update-position/sort-horizontal.d.ts +2 -0
  57. package/es/scenegraph/group-creater/progress/update-position/sort-horizontal.js +45 -0
  58. package/es/scenegraph/group-creater/progress/update-position/sort-horizontal.js.map +1 -0
  59. package/es/scenegraph/group-creater/progress/update-position/sort-vertical.d.ts +2 -0
  60. package/es/scenegraph/group-creater/progress/update-position/sort-vertical.js +47 -0
  61. package/es/scenegraph/group-creater/progress/update-position/sort-vertical.js.map +1 -0
  62. package/es/scenegraph/layout/compute-row-height.d.ts +1 -1
  63. package/es/scenegraph/layout/compute-row-height.js +13 -6
  64. package/es/scenegraph/layout/compute-row-height.js.map +1 -1
  65. package/es/scenegraph/layout/update-width.js +1 -1
  66. package/es/scenegraph/layout/update-width.js.map +1 -1
  67. package/es/scenegraph/scenegraph.js +5 -7
  68. package/es/scenegraph/scenegraph.js.map +1 -1
  69. package/package.json +9 -9
@@ -132,14 +132,16 @@ class CartesianAxis {
132
132
  };
133
133
  }
134
134
  _getTitleLimit(isX) {
135
- var _a, _b;
135
+ var _a, _b, _c;
136
136
  if (this.option.title.visible && (0, vutils_1.isNil)(null === (_a = this.option.title.style) || void 0 === _a ? void 0 : _a.maxLineWidth)) {
137
- const angle = (null === (_b = this.option.title.style) || void 0 === _b ? void 0 : _b.angle) || 0;
138
- if (isX) {
139
- const width = this.getLayoutRect().width, cosValue = Math.abs(Math.cos(angle));
137
+ let angle = (null === (_b = this.option.title.style) || void 0 === _b ? void 0 : _b.angle) || 0;
138
+ if ((null === (_c = this.option.title) || void 0 === _c ? void 0 : _c.autoRotate) && (0,
139
+ vutils_1.isNil)(this.option.title.angle) && (angle = "left" === this.option.orient ? -90 : 90),
140
+ isX) {
141
+ const width = this.getLayoutRect().width, cosValue = Math.abs(Math.cos((0, vutils_1.degreeToRadian)(angle)));
140
142
  return cosValue < 1e-6 ? 1 / 0 : width / cosValue;
141
143
  }
142
- const height = this.getLayoutRect().height, sinValue = Math.abs(Math.sin(angle));
144
+ const height = this.getLayoutRect().height, sinValue = Math.abs(Math.sin((0, vutils_1.degreeToRadian)(angle)));
143
145
  return sinValue < 1e-6 ? 1 / 0 : height / sinValue;
144
146
  }
145
147
  return null;
@@ -1 +1 @@
1
- {"version":3,"sources":["components/axis/axis.ts"],"names":[],"mappings":";;;AAAA,6CAA+D;AAG/D,qEAAiF;AACjF,+DAAsE;AACtE,2CAAkD;AAElD,6CAA6C;AAC7C,+CAAmG;AAEnG,iDAA8C;AAE9C,iDAA0C;AAC1C,iDAAiD;AACjD,mDAA4C;AAE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MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;YAG3C,OAAO,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,GAAG,QAAQ,CAAC;SACvD;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;IAC3B,CAAC;IAED,aAAa;QACX,OAAQ,IAAI,CAAC,KAAyB,CAAC,MAAM,CAAC;IAChD,CAAC;CACF;AAjPD,sCAiPC","file":"axis.js","sourcesContent":["import { isNil, isValidNumber, merge } from '@visactor/vutils';\nimport type { BaseTableAPI } from '../../ts-types/base-table';\nimport type { ICellAxisOption } from '../../ts-types/component/axis';\nimport { LineAxis, type LineAxisAttributes } from '@visactor/vrender-components';\nimport { commonAxis, getAxisAttributes } from './get-axis-attributes';\nimport { isXAxis, isYAxis } from '../util/orient';\nimport type { IOrientType } from '../../ts-types/component/util';\nimport { BandAxisScale } from './band-scale';\nimport { registerDataSetInstanceParser, registerDataSetInstanceTransform } from '../util/register';\nimport type { Parser } from '@visactor/vdataset';\nimport { DataView } from '@visactor/vdataset';\nimport type { IBaseScale } from '@visactor/vscale';\nimport { ticks } from '../util/tick-data';\nimport { LinearAxisScale } from './linear-scale';\nimport { doOverlap } from './label-overlap';\n\nconst DEFAULT_BAND_INNER_PADDING = 0.1;\nconst DEFAULT_BAND_OUTER_PADDING = 0.3;\nconst scaleParser: Parser = (scale: IBaseScale) => {\n return scale;\n};\n\nexport class CartesianAxis {\n width: number;\n height: number;\n table: BaseTableAPI;\n option: ICellAxisOption;\n orient: IOrientType;\n visible: boolean;\n type: 'linear' | 'band' | 'time';\n inverse: boolean;\n data?: any[];\n tickData: DataView;\n scale: BandAxisScale | LinearAxisScale;\n component: LineAxis;\n\n constructor(option: ICellAxisOption, width: number, height: number, table: BaseTableAPI) {\n this.table = table;\n this.width = width;\n this.height = height;\n // this.option = cloneDeep(option);\n this.option = merge({}, commonAxis, option);\n\n this.orient = option.orient ?? 'left';\n this.visible = option.visible ?? true;\n this.type = option.type ?? 'band';\n this.inverse = 'inverse' in option ? !!option.inverse : false;\n if (option.type === 'band') {\n this.data = option.domain;\n }\n\n this.initScale();\n this.initData();\n this.createComponent();\n this.initEvent();\n }\n\n initScale() {\n const option = this.option as any;\n if (this.type === 'band') {\n this.scale = new BandAxisScale();\n this.scale.bandPadding = option.bandPadding;\n this.scale.paddingInner = option.paddingInner;\n this.scale.paddingOuter = option.paddingOuter;\n this.scale.calcScales(DEFAULT_BAND_INNER_PADDING, DEFAULT_BAND_OUTER_PADDING); // 0.1 0.3\n this.scale.updateScaleDomain(this.data);\n this.updateScaleRange();\n } else if (this.type === 'linear' || this.type === 'time') {\n this.scale = new LinearAxisScale();\n this.scale.setExtraAttrFromSpec(option.nice, option.zero, option.range, option.expand);\n this.scale.transformScaleDomain();\n this.scale.updateScaleDomain();\n this.updateScaleRange();\n }\n }\n\n initData() {\n registerDataSetInstanceParser(this.table._vDataSet, 'scale', scaleParser);\n registerDataSetInstanceTransform(this.table._vDataSet, 'ticks', ticks);\n\n const label = this.option.label || {};\n const tick = this.option.tick || {};\n const tickData = new DataView(this.table._vDataSet)\n .parse(this.scale._scale, {\n type: 'scale'\n })\n .transform(\n {\n type: 'ticks',\n options: {\n tickCount: tick.tickCount,\n forceTickCount: tick.forceTickCount,\n tickStep: tick.tickStep,\n\n axisOrientType: this.orient,\n coordinateType: 'cartesian',\n\n labelStyle: label.style,\n labelFormatter: label.formatMethod,\n // labelGap: label.minGap,\n\n labelLastVisible: label.lastVisible,\n labelFlush: label.flush\n }\n },\n false\n );\n this.tickData = tickData;\n\n this.computeData();\n }\n\n computeData(): void {\n this.tickData.reRunAllTransform();\n }\n\n initEvent() {\n // to be added\n }\n\n createComponent() {\n const axisStylrAttrs = getAxisAttributes(this.option);\n const attrs = this.getUpdateAttribute();\n attrs.verticalFactor = this.orient === 'top' || this.orient === 'right' ? -1 : 1;\n this.component = new LineAxis(merge({}, axisStylrAttrs, attrs));\n this.component.setAttributes(this.setLayoutStartPosition({ x: 0, y: 0 }));\n (this.component as any).originAxis = this;\n }\n\n resize(width: number, height: number) {\n this.width = width;\n this.height = height;\n this.updateScaleRange();\n this.computeData();\n const axisStylrAttrs = getAxisAttributes(this.option);\n const attrs = this.getUpdateAttribute();\n attrs.verticalFactor = this.orient === 'top' || this.orient === 'right' ? -1 : 1;\n this.component.setAttributes(merge({}, axisStylrAttrs, attrs));\n this.component.setAttributes(this.setLayoutStartPosition({ x: 0, y: 0 }));\n this.overlap();\n }\n\n overlap() {\n doOverlap(this.component, this);\n }\n\n getLayoutRect() {\n return {\n width: this.width,\n height: this.height\n };\n }\n\n getUpdateAttribute() {\n // 获取更新的坐标轴属性\n const regionHeight = this.table.tableNoFrameHeight;\n const regionWidth = this.table.tableNoFrameWidth;\n\n const { width, height } = this.getLayoutRect();\n const isX = isXAxis(this.orient);\n const isY = isYAxis(this.orient);\n let end = { x: 0, y: 0 };\n let gridLength = 0;\n let axisLength = 0;\n if (isX) {\n end = { x: width, y: 0 };\n gridLength = regionHeight;\n axisLength = width;\n } else if (isY) {\n end = { x: 0, y: height };\n gridLength = regionWidth;\n axisLength = height;\n }\n const attrs: LineAxisAttributes = {\n start: { x: 0, y: 0 },\n end,\n grid: {\n type: 'line',\n length: gridLength,\n visible: this.option.grid.visible\n },\n title: {\n text: this.option.title.text,\n maxWidth: this._getTitleLimit(isX)\n },\n items: this.getLabelItems(axisLength)\n };\n return attrs;\n }\n\n getLabelItems(length: number) {\n return [\n this.tickData.latestData\n .map((obj: any) => {\n return {\n id: obj.value,\n label: obj.value,\n value: length === 0 ? 0 : this.scale.dataToPosition([obj.value]) / length,\n rawValue: obj.value\n };\n })\n .filter((entry: any) => entry.value >= 0 && entry.value <= 1)\n ];\n }\n\n updateScaleRange() {\n const { width, height } = this.getLayoutRect();\n const inverse = (this.option as any).inverse || false;\n let newRange: [number, number] = [0, 0];\n if (isXAxis(this.orient)) {\n if (isValidNumber(width)) {\n newRange = inverse ? [width, 0] : [0, width];\n }\n } else {\n if (isValidNumber(height)) {\n newRange = inverse ? [0, height] : [height, 0];\n }\n }\n\n this.scale.updateRange(newRange);\n }\n\n setLayoutStartPosition(pos: any) {\n let { x, y } = pos;\n\n if (isValidNumber(x)) {\n x += Number(this.orient === 'left') * this.getLayoutRect().width;\n }\n if (isValidNumber(y)) {\n y += Number(this.orient === 'top') * this.getLayoutRect().height;\n }\n\n return { x, y };\n // super.setLayoutStartPosition({ x, y });\n }\n\n private _getTitleLimit(isX: boolean) {\n if (this.option.title.visible && isNil(this.option.title.style?.maxLineWidth)) {\n const angle = this.option.title.style?.angle || 0;\n if (isX) {\n const width = this.getLayoutRect().width;\n const cosValue = Math.abs(Math.cos(angle));\n // VRender 接收到的limit是考虑角度计算后的宽度\n // TODO:还需要考虑angle后,高度是否太高,综合计算一个limit,比如高度不能超过图表整体高度的1/4\n return cosValue < 1e-6 ? Infinity : width / cosValue;\n }\n const height = this.getLayoutRect().height;\n const sinValue = Math.abs(Math.sin(angle));\n\n // TODO:还需要考虑angle后,宽度是否太宽,综合计算一个limit,比如宽度度不能超过图表整体宽度的1/4\n return sinValue < 1e-6 ? Infinity : height / sinValue;\n }\n\n return null;\n }\n\n getScale() {\n return this.scale._scale;\n }\n\n getDomainSpec() {\n return (this.scale as LinearAxisScale).domain;\n }\n}\n"]}
1
+ {"version":3,"sources":["components/axis/axis.ts"],"names":[],"mappings":";;;AAAA,6CAA+E;AAG/E,qEAAiF;AACjF,+DAAsE;AACtE,2CAAkD;AAElD,6CAA6C;AAC7C,+CAAmG;AAEnG,iDAA8C;AAE9C,iDAA0C;AAC1C,iDAAiD;AACjD,mDAA4C;AAE5C,MAAM,0BAA0B,GAAG,GAAG,CAAC;AACvC,MAAM,0BAA0B,GAAG,GAAG,CAAC;AACvC,MAAM,WAAW,GAAW,CAAC,KAAiB,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AAC;gBAG3D,OAAO,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,GAAG,QAAQ,CAAC;aACtD;YACD,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC,MAAM,CAAC;YAC3C,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAA,uBAAc,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAG3D,OAAO,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,GAAG,QAAQ,CAAC;SACvD;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;IAC3B,CAAC;IAED,aAAa;QACX,OAAQ,IAAI,CAAC,KAAyB,CAAC,MAAM,CAAC;IAChD,CAAC;CACF;AApPD,sCAoPC","file":"axis.js","sourcesContent":["import { degreeToRadian, isNil, isValidNumber, merge } from '@visactor/vutils';\nimport type { BaseTableAPI } from '../../ts-types/base-table';\nimport type { ICellAxisOption } from '../../ts-types/component/axis';\nimport { LineAxis, type LineAxisAttributes } from '@visactor/vrender-components';\nimport { commonAxis, getAxisAttributes } from './get-axis-attributes';\nimport { isXAxis, isYAxis } from '../util/orient';\nimport type { IOrientType } from '../../ts-types/component/util';\nimport { BandAxisScale } from './band-scale';\nimport { registerDataSetInstanceParser, registerDataSetInstanceTransform } from '../util/register';\nimport type { Parser } from '@visactor/vdataset';\nimport { DataView } from '@visactor/vdataset';\nimport type { IBaseScale } from '@visactor/vscale';\nimport { ticks } from '../util/tick-data';\nimport { LinearAxisScale } from './linear-scale';\nimport { doOverlap } from './label-overlap';\n\nconst DEFAULT_BAND_INNER_PADDING = 0.1;\nconst DEFAULT_BAND_OUTER_PADDING = 0.3;\nconst scaleParser: Parser = (scale: IBaseScale) => {\n return scale;\n};\n\nexport class CartesianAxis {\n width: number;\n height: number;\n table: BaseTableAPI;\n option: ICellAxisOption;\n orient: IOrientType;\n visible: boolean;\n type: 'linear' | 'band' | 'time';\n inverse: boolean;\n data?: any[];\n tickData: DataView;\n scale: BandAxisScale | LinearAxisScale;\n component: LineAxis;\n\n constructor(option: ICellAxisOption, width: number, height: number, table: BaseTableAPI) {\n this.table = table;\n this.width = width;\n this.height = height;\n // this.option = cloneDeep(option);\n this.option = merge({}, commonAxis, option);\n\n this.orient = option.orient ?? 'left';\n this.visible = option.visible ?? true;\n this.type = option.type ?? 'band';\n this.inverse = 'inverse' in option ? !!option.inverse : false;\n if (option.type === 'band') {\n this.data = option.domain;\n }\n\n this.initScale();\n this.initData();\n this.createComponent();\n this.initEvent();\n }\n\n initScale() {\n const option = this.option as any;\n if (this.type === 'band') {\n this.scale = new BandAxisScale();\n this.scale.bandPadding = option.bandPadding;\n this.scale.paddingInner = option.paddingInner;\n this.scale.paddingOuter = option.paddingOuter;\n this.scale.calcScales(DEFAULT_BAND_INNER_PADDING, DEFAULT_BAND_OUTER_PADDING); // 0.1 0.3\n this.scale.updateScaleDomain(this.data);\n this.updateScaleRange();\n } else if (this.type === 'linear' || this.type === 'time') {\n this.scale = new LinearAxisScale();\n this.scale.setExtraAttrFromSpec(option.nice, option.zero, option.range, option.expand);\n this.scale.transformScaleDomain();\n this.scale.updateScaleDomain();\n this.updateScaleRange();\n }\n }\n\n initData() {\n registerDataSetInstanceParser(this.table._vDataSet, 'scale', scaleParser);\n registerDataSetInstanceTransform(this.table._vDataSet, 'ticks', ticks);\n\n const label = this.option.label || {};\n const tick = this.option.tick || {};\n const tickData = new DataView(this.table._vDataSet)\n .parse(this.scale._scale, {\n type: 'scale'\n })\n .transform(\n {\n type: 'ticks',\n options: {\n tickCount: tick.tickCount,\n forceTickCount: tick.forceTickCount,\n tickStep: tick.tickStep,\n\n axisOrientType: this.orient,\n coordinateType: 'cartesian',\n\n labelStyle: label.style,\n labelFormatter: label.formatMethod,\n // labelGap: label.minGap,\n\n labelLastVisible: label.lastVisible,\n labelFlush: label.flush\n }\n },\n false\n );\n this.tickData = tickData;\n\n this.computeData();\n }\n\n computeData(): void {\n this.tickData.reRunAllTransform();\n }\n\n initEvent() {\n // to be added\n }\n\n createComponent() {\n const axisStylrAttrs = getAxisAttributes(this.option);\n const attrs = this.getUpdateAttribute();\n attrs.verticalFactor = this.orient === 'top' || this.orient === 'right' ? -1 : 1;\n this.component = new LineAxis(merge({}, axisStylrAttrs, attrs));\n this.component.setAttributes(this.setLayoutStartPosition({ x: 0, y: 0 }));\n (this.component as any).originAxis = this;\n }\n\n resize(width: number, height: number) {\n this.width = width;\n this.height = height;\n this.updateScaleRange();\n this.computeData();\n const axisStylrAttrs = getAxisAttributes(this.option);\n const attrs = this.getUpdateAttribute();\n attrs.verticalFactor = this.orient === 'top' || this.orient === 'right' ? -1 : 1;\n this.component.setAttributes(merge({}, axisStylrAttrs, attrs));\n this.component.setAttributes(this.setLayoutStartPosition({ x: 0, y: 0 }));\n this.overlap();\n }\n\n overlap() {\n doOverlap(this.component, this);\n }\n\n getLayoutRect() {\n return {\n width: this.width,\n height: this.height\n };\n }\n\n getUpdateAttribute() {\n // 获取更新的坐标轴属性\n const regionHeight = this.table.tableNoFrameHeight;\n const regionWidth = this.table.tableNoFrameWidth;\n\n const { width, height } = this.getLayoutRect();\n const isX = isXAxis(this.orient);\n const isY = isYAxis(this.orient);\n let end = { x: 0, y: 0 };\n let gridLength = 0;\n let axisLength = 0;\n if (isX) {\n end = { x: width, y: 0 };\n gridLength = regionHeight;\n axisLength = width;\n } else if (isY) {\n end = { x: 0, y: height };\n gridLength = regionWidth;\n axisLength = height;\n }\n const attrs: LineAxisAttributes = {\n start: { x: 0, y: 0 },\n end,\n grid: {\n type: 'line',\n length: gridLength,\n visible: this.option.grid.visible\n },\n title: {\n text: this.option.title.text,\n maxWidth: this._getTitleLimit(isX)\n },\n items: this.getLabelItems(axisLength)\n };\n return attrs;\n }\n\n getLabelItems(length: number) {\n return [\n this.tickData.latestData\n .map((obj: any) => {\n return {\n id: obj.value,\n label: obj.value,\n value: length === 0 ? 0 : this.scale.dataToPosition([obj.value]) / length,\n rawValue: obj.value\n };\n })\n .filter((entry: any) => entry.value >= 0 && entry.value <= 1)\n ];\n }\n\n updateScaleRange() {\n const { width, height } = this.getLayoutRect();\n const inverse = (this.option as any).inverse || false;\n let newRange: [number, number] = [0, 0];\n if (isXAxis(this.orient)) {\n if (isValidNumber(width)) {\n newRange = inverse ? [width, 0] : [0, width];\n }\n } else {\n if (isValidNumber(height)) {\n newRange = inverse ? [0, height] : [height, 0];\n }\n }\n\n this.scale.updateRange(newRange);\n }\n\n setLayoutStartPosition(pos: any) {\n let { x, y } = pos;\n\n if (isValidNumber(x)) {\n x += Number(this.orient === 'left') * this.getLayoutRect().width;\n }\n if (isValidNumber(y)) {\n y += Number(this.orient === 'top') * this.getLayoutRect().height;\n }\n\n return { x, y };\n // super.setLayoutStartPosition({ x, y });\n }\n\n private _getTitleLimit(isX: boolean) {\n if (this.option.title.visible && isNil(this.option.title.style?.maxLineWidth)) {\n let angle = this.option.title.style?.angle || 0;\n if (this.option.title?.autoRotate && isNil(this.option.title.angle)) {\n angle = this.option.orient === 'left' ? -90 : 90;\n }\n if (isX) {\n const width = this.getLayoutRect().width;\n const cosValue = Math.abs(Math.cos(degreeToRadian(angle)));\n // VRender 接收到的limit是考虑角度计算后的宽度\n // TODO:还需要考虑angle后,高度是否太高,综合计算一个limit,比如高度不能超过图表整体高度的1/4\n return cosValue < 1e-6 ? Infinity : width / cosValue;\n }\n const height = this.getLayoutRect().height;\n const sinValue = Math.abs(Math.sin(degreeToRadian(angle)));\n\n // TODO:还需要考虑angle后,宽度是否太宽,综合计算一个limit,比如宽度度不能超过图表整体宽度的1/4\n return sinValue < 1e-6 ? Infinity : height / sinValue;\n }\n\n return null;\n }\n\n getScale() {\n return this.scale._scale;\n }\n\n getDomainSpec() {\n return (this.scale as LinearAxisScale).domain;\n }\n}\n"]}
@@ -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;QACn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A,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;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,KA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nD;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,84 +7,116 @@ 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, _m, _o;
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, _j, _k;
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
+ }), widthLimit = (null === (_h = null === (_g = attribute.label) || void 0 === _g ? void 0 : _g.style) || void 0 === _h ? void 0 : _h.maxLineWidth) || 1 / 0;
23
+ labelWidth = Math.max(labelWidth, getSizeAfterResize(Math.min(width, widthLimit), height, null === (_k = null === (_j = attribute.label) || void 0 === _j ? void 0 : _j.style) || void 0 === _k ? void 0 : _k.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, _j, _k;
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
+ }), widthLimit = (null === (_h = null === (_g = attribute.label) || void 0 === _g ? void 0 : _g.style) || void 0 === _h ? void 0 : _h.maxLineWidth) || 1 / 0;
35
+ labelWidth = Math.max(labelWidth, getSizeAfterResize(Math.min(width, widthLimit), height, null === (_k = null === (_j = attribute.label) || void 0 === _j ? void 0 : _j.style) || void 0 === _k ? void 0 : _k.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.title) || void 0 === _c ? void 0 : _c.style) || void 0 === _d ? void 0 : _d.fontSize,
44
+ fontWeight: null === (_f = null === (_e = attribute.title) || void 0 === _e ? void 0 : _e.style) || void 0 === _f ? void 0 : _f.fontWeight,
45
+ fontFamily: null === (_h = null === (_g = attribute.title) || void 0 === _g ? void 0 : _g.style) || void 0 === _h ? void 0 : _h.fontFamily
46
+ }), widthLimit = (null === (_k = null === (_j = attribute.label) || void 0 === _j ? void 0 : _j.style) || void 0 === _k ? void 0 : _k.maxLineWidth) || 1 / 0, size = getSizeAfterResize(Math.min(width, widthLimit), height, null === (_m = null === (_l = attribute.title) || void 0 === _l ? void 0 : _l.style) || void 0 === _m ? void 0 : _m.angle);
47
+ titleWidth = "left" !== config.orient && "right" !== config.orient || !attribute.title.autoRotate ? size.width + 2 : size.height + 2,
48
+ titleWidth += null !== (_o = attribute.title.space) && void 0 !== _o ? _o : 4;
49
+ }
50
+ return tickWidth + labelWidth + titleWidth;
47
51
  }
48
52
 
49
53
  function computeAxisComponentHeight(config, table) {
50
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
54
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
51
55
  const attribute = (0, vutils_1.merge)({}, get_axis_attributes_1.commonAxis, config), tickHeight = null !== (_a = attribute.tick.width) && void 0 !== _a ? _a : 4;
52
56
  let labelHeight = 0;
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, _j, _k;
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
+ }), widthLimit = (null === (_h = null === (_g = attribute.label) || void 0 === _g ? void 0 : _g.style) || void 0 === _h ? void 0 : _h.maxLineWidth) || 1 / 0;
67
+ labelHeight = Math.max(labelHeight, getSizeAfterResize(Math.min(width, widthLimit), height, null === (_k = null === (_j = attribute.label) || void 0 === _j ? void 0 : _j.style) || void 0 === _k ? void 0 : _k.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, _j, _k;
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
+ }), widthLimit = (null === (_h = null === (_g = attribute.label) || void 0 === _g ? void 0 : _g.style) || void 0 === _h ? void 0 : _h.maxLineWidth) || 1 / 0;
79
+ labelHeight = Math.max(labelHeight, getSizeAfterResize(Math.min(width, widthLimit), height, null === (_k = null === (_j = attribute.label) || void 0 === _j ? void 0 : _j.style) || void 0 === _k ? void 0 : _k.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.title) || void 0 === _c ? void 0 : _c.style) || void 0 === _d ? void 0 : _d.fontSize,
88
+ fontWeight: null === (_f = null === (_e = attribute.title) || void 0 === _e ? void 0 : _e.style) || void 0 === _f ? void 0 : _f.fontWeight,
89
+ fontFamily: null === (_h = null === (_g = attribute.title) || void 0 === _g ? void 0 : _g.style) || void 0 === _h ? void 0 : _h.fontFamily
90
+ }), widthLimit = (null === (_k = null === (_j = attribute.label) || void 0 === _j ? void 0 : _j.style) || void 0 === _k ? void 0 : _k.maxLineWidth) || 1 / 0, size = getSizeAfterResize(Math.min(width, widthLimit), height, null === (_m = null === (_l = attribute.title) || void 0 === _l ? void 0 : _l.style) || void 0 === _m ? void 0 : _m.angle);
91
+ titleHeight = "bottom" !== config.orient && "top" !== config.orient || !attribute.title.autoRotate ? size.height + 2 : size.width + 2,
92
+ titleHeight += null !== (_o = attribute.title.space) && void 0 !== _o ? _o : 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,EAA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K,KAAK,CAAC,IAAI,SAAS,CAAC,KAAK,CAAC,UAAU,EAAE;YACzF,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,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,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,UAAU,EAAE,MAAA,MAAA,SAAS,CAAC,KAAK,0CAAE,KAAK,0CAAE,UAAU;iBAC/C,CAAC,CAAC;gBACH,MAAM,UAAU,GAAG,CAAA,MAAA,MAAA,SAAS,CAAC,KAAK,0CAAE,KAAK,0CAAE,YAAY,KAAI,QAAQ,CAAC;gBACpE,UAAU,GA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ge } 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 const widthLimit = attribute.label?.style?.maxLineWidth || Infinity;\n labelWidth = Math.max(\n labelWidth,\n getSizeAfterResize(Math.min(width, widthLimit), height, attribute.label?.style?.angle).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 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 const widthLimit = attribute.label?.style?.maxLineWidth || Infinity;\n labelWidth = Math.max(\n labelWidth,\n getSizeAfterResize(Math.min(width, widthLimit), height, attribute.label?.style?.angle).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 const { width, height } = table.measureText(attribute.title.text, {\n fontSize: attribute.title?.style?.fontSize,\n fontWeight: attribute.title?.style?.fontWeight,\n fontFamily: attribute.title?.style?.fontFamily\n });\n const widthLimit = attribute.label?.style?.maxLineWidth || Infinity;\n const size = getSizeAfterResize(Math.min(width, widthLimit), height, attribute.title?.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 const widthLimit = attribute.label?.style?.maxLineWidth || Infinity;\n labelHeight = Math.max(\n labelHeight,\n getSizeAfterResize(Math.min(width, widthLimit), height, attribute.label?.style?.angle).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 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 const widthLimit = attribute.label?.style?.maxLineWidth || Infinity;\n labelHeight = Math.max(\n labelHeight,\n getSizeAfterResize(Math.min(width, widthLimit), 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.title?.style?.fontSize,\n fontWeight: attribute.title?.style?.fontWeight,\n fontFamily: attribute.title?.style?.fontFamily\n });\n const widthLimit = attribute.label?.style?.maxLineWidth || Infinity;\n const size = getSizeAfterResize(Math.min(width, widthLimit), height, attribute.title?.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"]}
@@ -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.3",
48
+ if (super(), this.showFrozenIcon = !0, this.showSort = !0, this.version = "0.10.1-alpha.4",
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;
@@ -358,7 +358,8 @@ class BaseTable extends EventTarget_1.EventTarget {
358
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);
359
359
  }
360
360
  getColWidth(col) {
361
- const width = this.colWidthsMap.get(col);
361
+ var _a;
362
+ const width = null !== (_a = this.colWidthsMap.get(col)) && void 0 !== _a ? _a : 0;
362
363
  return "adaptive" === this.widthMode && "number" == typeof width || this.transpose && "number" == typeof width ? this._colWidthDefineToPxWidth(width) : this._adjustColWidth(col, this._colWidthDefineToPxWidth(width));
363
364
  }
364
365
  setColWidth(col, width, clearCache, skipCheckFrozen) {