@visactor/vtable 0.10.1-alpha.1 → 0.10.1-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/README.md +1 -2
  2. package/cjs/components/axis/axis.js +3 -3
  3. package/cjs/components/axis/axis.js.map +1 -1
  4. package/cjs/components/axis/get-axis-attributes.d.ts +0 -2
  5. package/cjs/components/axis/get-axis-attributes.js +1 -3
  6. package/cjs/components/axis/get-axis-attributes.js.map +1 -1
  7. package/cjs/components/axis/get-axis-component-size.js +33 -65
  8. package/cjs/components/axis/get-axis-component-size.js.map +1 -1
  9. package/cjs/core/BaseTable.d.ts +1 -1
  10. package/cjs/core/BaseTable.js +3 -3
  11. package/cjs/core/BaseTable.js.map +1 -1
  12. package/cjs/dataset/dataset.js +9 -11
  13. package/cjs/dataset/dataset.js.map +1 -1
  14. package/cjs/index.d.ts +1 -1
  15. package/cjs/index.js +1 -1
  16. package/cjs/index.js.map +1 -1
  17. package/cjs/layout/pivot-layout.js +4 -4
  18. package/cjs/layout/pivot-layout.js.map +1 -1
  19. package/cjs/scenegraph/group-creater/cell-helper.d.ts +1 -1
  20. package/cjs/scenegraph/group-creater/cell-helper.js +10 -8
  21. package/cjs/scenegraph/group-creater/cell-helper.js.map +1 -1
  22. package/cjs/scenegraph/group-creater/column-helper.js +3 -8
  23. package/cjs/scenegraph/group-creater/column-helper.js.map +1 -1
  24. package/cjs/ts-types/base-table.d.ts +1 -1
  25. package/cjs/ts-types/base-table.js.map +1 -1
  26. package/cjs/ts-types/new-data-set.d.ts +1 -0
  27. package/cjs/ts-types/new-data-set.js.map +1 -1
  28. package/dist/vtable.js +560 -1617
  29. package/dist/vtable.min.js +3 -3
  30. package/es/components/axis/axis.js +2 -2
  31. package/es/components/axis/axis.js.map +1 -1
  32. package/es/components/axis/get-axis-attributes.d.ts +0 -2
  33. package/es/components/axis/get-axis-attributes.js +1 -3
  34. package/es/components/axis/get-axis-attributes.js.map +1 -1
  35. package/es/components/axis/get-axis-component-size.js +33 -65
  36. package/es/components/axis/get-axis-component-size.js.map +1 -1
  37. package/es/core/BaseTable.d.ts +1 -1
  38. package/es/core/BaseTable.js +3 -3
  39. package/es/core/BaseTable.js.map +1 -1
  40. package/es/dataset/dataset.js +9 -11
  41. package/es/dataset/dataset.js.map +1 -1
  42. package/es/index.d.ts +1 -1
  43. package/es/index.js +1 -1
  44. package/es/index.js.map +1 -1
  45. package/es/layout/pivot-layout.js +4 -4
  46. package/es/layout/pivot-layout.js.map +1 -1
  47. package/es/scenegraph/group-creater/cell-helper.d.ts +1 -1
  48. package/es/scenegraph/group-creater/cell-helper.js +10 -8
  49. package/es/scenegraph/group-creater/cell-helper.js.map +1 -1
  50. package/es/scenegraph/group-creater/column-helper.js +3 -8
  51. package/es/scenegraph/group-creater/column-helper.js.map +1 -1
  52. package/es/ts-types/base-table.d.ts +1 -1
  53. package/es/ts-types/base-table.js.map +1 -1
  54. package/es/ts-types/new-data-set.d.ts +1 -0
  55. package/es/ts-types/new-data-set.js.map +1 -1
  56. package/package.json +7 -7
package/README.md CHANGED
@@ -97,7 +97,6 @@ const columns =[
97
97
  ];
98
98
 
99
99
  const option = {
100
- parentElement: document.getElementById(Table_CONTAINER_DOM_ID),
101
100
  records:[
102
101
  {
103
102
  "Order ID": "CA-2018-156720",
@@ -118,7 +117,7 @@ const option = {
118
117
  columns,
119
118
  widthMode:'standard'
120
119
  };
121
- const tableInstance = new VTable.ListTable(option);
120
+ const tableInstance = new VTable.ListTable(document.getElementById(CONTAINER_ID), option);
122
121
 
123
122
 
124
123
 
@@ -24,9 +24,9 @@ class CartesianAxis {
24
24
  this.scale.transformScaleDomain(), this.scale.updateScaleDomain(), this.updateScaleRange());
25
25
  }
26
26
  initData() {
27
- (0, register_1.registerDataSetInstanceParser)(this.table.dataSet, "scale", scaleParser),
28
- (0, register_1.registerDataSetInstanceTransform)(this.table.dataSet, "ticks", tick_data_1.ticks);
29
- const label = this.option.label || {}, tick = this.option.tick || {}, tickData = new vdataset_1.DataView(this.table.dataSet).parse(this.scale._scale, {
27
+ (0, register_1.registerDataSetInstanceParser)(this.table._vDataSet, "scale", scaleParser),
28
+ (0, register_1.registerDataSetInstanceTransform)(this.table._vDataSet, "ticks", tick_data_1.ticks);
29
+ const label = this.option.label || {}, tick = this.option.tick || {}, tickData = new vdataset_1.DataView(this.table._vDataSet).parse(this.scale._scale, {
30
30
  type: "scale"
31
31
  }).transform({
32
32
  type: "ticks",
@@ -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;AAE5C,MAAM,0BAA0B,GAAG,GAAG,CAAC;AACvC,MAAM,0BAA0B,GAAG,GAAG,CAAC;AACvC,MAAM,WAAW,GAAW,CAAC,KAAiB,EAAE,EAAE;IAChD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,MAAa,aAAa;IAcxB,YAAY,MAAuB,EAAE,KAAa,EAAE,MAAc,EAAE,KAAmB;;QACrF,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,IAAI,CAAC,MAAM,GAAG,IAAA,cAAK,EAAC,EAAE,EAAE,gCAAU,EAAE,MAAM,CAAC,CAAC;QAE5C,IAAI,CAAC,MAAM,GAAG,MAAA,MAAM,CAAC,MAAM,mCAAI,MAAM,CAAC;QACtC,IAAI,CAAC,OAAO,GAAG,MAAA,MAAM,CAAC,OAAO,mCAAI,IAAI,CAAC;QACtC,IAAI,CAAC,IAAI,GAAG,MAAA,MAAM,CAAC,IAAI,mCAAI,MAAM,CAAC;QAClC,IAAI,CAAC,OAA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AAC,KAAK,CAAC,KAAK,0CAAE,YAAY,CAAC,EAAE;YAC7E,MAAM,KAAK,GAAG,CAAA,MAAA,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,0CAAE,KAAK,KAAI,CAAC,CAAC;YAClD,IAAI,GAAG,EAAE;gBACP,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC,KAAK,CAAC;gBACzC,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;gBAG3C,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,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.dataSet, 'scale', scaleParser);\n registerDataSetInstanceTransform(this.table.dataSet, 'ticks', ticks);\n\n const label = this.option.label || {};\n const tick = this.option.tick || {};\n const tickData = new DataView(this.table.dataSet)\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+D;AAG/D,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,EAAE,EAAE;IAChD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,MAAa,aAAa;IAcxB,YAAY,MAAuB,EAAE,KAAa,EAAE,MAAc,EAAE,KAAmB;;QACrF,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,IAAI,CAAC,MAAM,GAAG,IAAA,cAAK,EAAC,EAAE,EAAE,gCAAU,EAAE,MAAM,CAAC,CAAC;QAE5C,IAAI,CAAC,MAAM,GAAG,MAAA,MAAM,CAAC,MAAM,mCAAI,MAAM,CAAC;QACtC,IAAI,CAAC,OAAO,GAAG,MAAA,MAAM,CAAC,OAAO,mCAAI,IAAI,CAAC;QACtC,IAAI,CAAC,IAAI,GAAG,MAAA,MAAM,CAAC,IAAI,mCAAI,MAAM,CAAC;QAClC,IAAI,CAAC,OAAO,GAAG,SAAS,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;QAC9D,IAAI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CAAC,KAAK,0CAAE,KAAK,KAAI,CAAC,CAAC;YAClD,IAAI,GAAG,EAAE;gBACP,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC,KAAK,CAAC;gBACzC,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;gBAG3C,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,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"]}
@@ -65,7 +65,6 @@ export declare const commonAxis: {
65
65
  };
66
66
  };
67
67
  export declare function getAxisAttributes(option: ICellAxisOption): {
68
- orient: import("@visactor/vchart/esm/typings").IOrientType;
69
68
  select: boolean;
70
69
  hover: boolean;
71
70
  line: any;
@@ -76,7 +75,6 @@ export declare function getAxisAttributes(option: ICellAxisOption): {
76
75
  style: any;
77
76
  formatMethod: (value: any, datum: any, index: number) => string | string[];
78
77
  state: any;
79
- containerAlign: "left" | "top" | "right" | "center" | "middle" | "bottom";
80
78
  };
81
79
  tick: {
82
80
  visible: boolean;
@@ -30,7 +30,6 @@ 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,
34
33
  select: spec.select,
35
34
  hover: spec.hover,
36
35
  line: (0, transform_1.transformAxisLineStyle)(spec.domainLine),
@@ -40,8 +39,7 @@ function getAxisAttributes(option) {
40
39
  inside: spec.label.inside,
41
40
  style: (0, transform_1.transformToGraphic)(spec.label.style),
42
41
  formatMethod: spec.label.formatMethod ? (value, datum, index) => spec.label.formatMethod(datum.rawValue, datum) : null,
43
- state: (0, transform_1.transformStateStyle)(spec.label.state),
44
- containerAlign: spec.label.containerAlign
42
+ state: (0, transform_1.transformStateStyle)(spec.label.state)
45
43
  },
46
44
  tick: {
47
45
  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,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AAkB,EAAC,MAAA,IAAI,CAAC,KAAK,CAAC,KAAK,0CAAE,KAAK,CAAC;aACnD;YACD,UAAU,EAAE;gBACV,OAAO,EAAE,MAAA,IAAI,CAAC,KAAK,CAAC,UAAU,0CAAE,OAAO;gBACvC,KAAK,EAAE,IAAA,8BAAkB,EAAC,MAAA,IAAI,CAAC,KAAK,CAAC,UAAU,0CAAE,KAAK,CAAC;aACxD;YACD,KAAK,EAAE;gBACL,IAAI,EAAE,IAAA,+BAAmB,EAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;gBAC3C,KAAK,EAAE,IAAA,+BAAmB,EAAC,MAAA,IAAI,CAAC,KAAK,CAAC,KAAK,0CAAE,KAAK,CAAC;gBACnD,UAAU,EAAE,IAAA,+BAAmB,EAAC,MAAA,IAAI,CAAC,KAAK,CAAC,UAAU,0CAAE,KAAK,CAAC;aAC9D;SACF;QACD,KAAK,EAAE;YACL,OAAO,EAAE,MAAA,IAAI,CAAC,UAAU,0CAAE,OAAO;YACjC,KAAK,EAAE,IAAA,8BAAkB,EAAC,MAAA,IAAI,CAAC,UAAU,0CAAE,KAAK,CAAC;YACjD,KAAK,EAAE,IAAA,+BAAmB,EAAC,MAAA,IAAI,CAAC,UAAU,0CAAE,KAAK,CAAC;SACnD;KACF,CAAC;AACJ,CAAC;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"]}
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,CA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C,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"]}
@@ -7,47 +7,43 @@ Object.defineProperty(exports, "__esModule", {
7
7
  const vutils_1 = require("@visactor/vutils"), get_axis_attributes_1 = require("./get-axis-attributes");
8
8
 
9
9
  function computeAxisComponentWidth(config, table) {
10
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
10
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
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, _g, _h;
17
- attribute.label.formatMethod && (text = attribute.label.formatMethod(text));
18
- const {width: width, height: height} = table.measureText(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, {
19
18
  fontSize: null === (_b = null === (_a = attribute.label) || void 0 === _a ? void 0 : _a.style) || void 0 === _b ? void 0 : _b.fontSize,
20
19
  fontWeight: null === (_d = null === (_c = attribute.label) || void 0 === _c ? void 0 : _c.style) || void 0 === _d ? void 0 : _d.fontWeight,
21
20
  fontFamily: null === (_f = null === (_e = attribute.label) || void 0 === _e ? void 0 : _e.style) || void 0 === _f ? void 0 : _f.fontFamily
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);
21
+ }).width);
24
22
  }));
25
23
  } else {
26
24
  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;
27
25
  [ formatDecimal(minNumber), formatDecimal(maxNumber) ].forEach((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, {
26
+ var _a, _b, _c, _d, _e, _f;
27
+ attribute.label.formatMethod && (text = attribute.label.formatMethod(text)), labelWidth = Math.max(labelWidth, table.measureText(text, {
31
28
  fontSize: null === (_b = null === (_a = attribute.label) || void 0 === _a ? void 0 : _a.style) || void 0 === _b ? void 0 : _b.fontSize,
32
29
  fontWeight: null === (_d = null === (_c = attribute.label) || void 0 === _c ? void 0 : _c.style) || void 0 === _d ? void 0 : _d.fontWeight,
33
30
  fontFamily: null === (_f = null === (_e = attribute.label) || void 0 === _e ? void 0 : _e.style) || void 0 === _f ? void 0 : _f.fontFamily
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);
31
+ }).width + 2);
36
32
  }));
37
33
  }
38
34
  labelWidth += null !== (_b = attribute.label.space) && void 0 !== _b ? _b : 4;
39
35
  }
40
36
  let titleWidth = 0;
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;
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;
51
47
  }
52
48
 
53
49
  function computeAxisComponentHeight(config, table) {
@@ -57,66 +53,38 @@ function computeAxisComponentHeight(config, table) {
57
53
  if (attribute.label.visible) {
58
54
  if ("band" === attribute.type) {
59
55
  attribute.domain.forEach((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, {
56
+ var _a, _b, _c, _d;
57
+ attribute.label.formatMethod && (text = attribute.label.formatMethod(text)), labelHeight = Math.max(labelHeight, table.measureText(text, {
63
58
  fontSize: null === (_b = null === (_a = attribute.label) || void 0 === _a ? void 0 : _a.style) || void 0 === _b ? void 0 : _b.fontSize,
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);
59
+ fontFamily: null === (_d = null === (_c = attribute.label) || void 0 === _c ? void 0 : _c.style) || void 0 === _d ? void 0 : _d.fontFamily
60
+ }).height);
68
61
  }));
69
62
  } else {
70
63
  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;
71
64
  [ formatDecimal(minNumber), formatDecimal(maxNumber) ].forEach((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, {
65
+ var _a, _b, _c, _d;
66
+ attribute.label.formatMethod && (text = attribute.label.formatMethod(text)), labelHeight = Math.max(labelHeight, table.measureText(text, {
75
67
  fontSize: null === (_b = null === (_a = attribute.label) || void 0 === _a ? void 0 : _a.style) || void 0 === _b ? void 0 : _b.fontSize,
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);
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);
80
70
  }));
81
71
  }
82
72
  labelHeight += null !== (_b = attribute.label.space) && void 0 !== _b ? _b : 4;
83
73
  }
84
74
  let titleHeight = 0;
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;
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;
95
83
  }
96
84
 
97
85
  function formatDecimal(number) {
98
86
  return "number" != typeof number && (number = Number(number)), Number(number.toPrecision(1)).toString();
99
87
  }
100
88
 
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
-
121
89
  exports.computeAxisComponentWidth = computeAxisComponentWidth, exports.computeAxisComponentHeight = computeAxisComponentHeight;
122
90
  //# 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;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,CAAC,GAAG,CAAC,KAAK,CAAC;KACnD,CAAC;IACF,MAAM,SAAS,GAAG;QAChB,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC;QAClD,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC;KACnD,CAAC;IAEF,MAAM,MAAM,GAAG;QACb,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC;QAClE,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC;QAClE,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC;QAClE,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC;KACnE,CAAC;IAEF,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI;QAChC,MAAM,EAAE,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI;KAClC,CAAC;AACJ,CAAC","file":"get-axis-component-size.js","sourcesContent":["import { merge } from '@visactor/vutils';\nimport type { BaseTableAPI } from '../../ts-types/base-table';\nimport type { ICellAxisOption } from '../../ts-types/component/axis';\nimport { commonAxis } from './get-axis-attributes';\n\n/**\n * @description: compuational vertical axis width\n * @param {ICellAxisOption} config\n * @return {*}\n */\nexport function computeAxisComponentWidth(config: ICellAxisOption, table: BaseTableAPI) {\n const attribute = merge({}, commonAxis, config);\n // tick\n const tickWidth = attribute.tick.width ?? 4;\n\n // text\n let labelWidth = 0;\n if (attribute.label.visible) {\n if (attribute.type === 'band') {\n const domain = attribute.domain;\n domain.forEach((text: string) => {\n if (attribute.label.formatMethod) {\n text = attribute.label.formatMethod(text);\n }\n const { width, height } = table.measureText(text, {\n fontSize: attribute.label?.style?.fontSize,\n fontWeight: attribute.label?.style?.fontWeight,\n fontFamily: attribute.label?.style?.fontFamily\n });\n labelWidth = Math.max(labelWidth, getSizeAfterResize(width, height, attribute.label?.style?.angle).width);\n });\n } else {\n const range = attribute.range;\n const minNumber = Math.abs(range.min) > 1 ? Math.round(range.min) : range.min;\n const maxNumber = Math.abs(range.max) > 1 ? Math.round(range.max) : range.max;\n // abs>1取整保留两位有效数字,abs<1保留一位有效数字\n const minString = formatDecimal(minNumber);\n const maxString = formatDecimal(maxNumber);\n // 这里测量的是预估的最大最小range,与实际现实的label可能不同\n [minString, maxString].forEach(text => {\n if (attribute.label.formatMethod) {\n text = attribute.label.formatMethod(text);\n }\n const { width, height } = table.measureText(text, {\n fontSize: attribute.label?.style?.fontSize,\n fontWeight: attribute.label?.style?.fontWeight,\n fontFamily: attribute.label?.style?.fontFamily\n });\n labelWidth = Math.max(labelWidth, getSizeAfterResize(width, height, attribute.label?.style?.angle).width + 2);\n });\n }\n labelWidth += attribute.label.space ?? 4;\n }\n\n // title\n let titleWidth = 0;\n if (attribute.title.visible && attribute.title.text) {\n const { width, height } = table.measureText(attribute.title.text, {\n fontSize: attribute.label?.style?.fontSize,\n fontWeight: attribute.label?.style?.fontWeight,\n fontFamily: attribute.label?.style?.fontFamily\n });\n const size = getSizeAfterResize(width, height, attribute.label?.style?.angle);\n if ((config.orient === 'left' || config.orient === 'right') && attribute.title.autoRotate) {\n titleWidth = size.height + 2;\n } else {\n titleWidth = size.width + 2;\n }\n titleWidth += attribute.title.space ?? 4;\n }\n\n return tickWidth + labelWidth + titleWidth;\n}\n\n/**\n * @description: compuational horizontal axis height\n * @param {ICellAxisOption} config\n * @return {*}\n */\nexport function computeAxisComponentHeight(config: ICellAxisOption, table: BaseTableAPI) {\n const attribute = merge({}, commonAxis, config);\n // tick\n const tickHeight = attribute.tick.width ?? 4;\n\n // text\n let labelHeight = 0;\n if (attribute.label.visible) {\n if (attribute.type === 'band') {\n const domain = attribute.domain;\n domain.forEach((text: string) => {\n if (attribute.label.formatMethod) {\n text = attribute.label.formatMethod(text);\n }\n const { width, height } = table.measureText(text, {\n fontSize: attribute.label?.style?.fontSize,\n fontWeight: attribute.label?.style?.fontWeight,\n fontFamily: attribute.label?.style?.fontFamily\n });\n labelHeight = Math.max(labelHeight, getSizeAfterResize(width, height, attribute.label?.style?.angle).height);\n });\n } else {\n const range = attribute.range;\n const minNumber = Math.abs(range.min) > 1 ? Math.round(range.min) : range.min;\n const maxNumber = Math.abs(range.max) > 1 ? Math.round(range.max) : range.max;\n // abs>1取整保留两位有效数字,abs<1保留一位有效数字\n const minString = formatDecimal(minNumber);\n const maxString = formatDecimal(maxNumber);\n // 这里测量的是预估的最大最小range,与实际现实的label可能不同\n [minString, maxString].forEach(text => {\n if (attribute.label.formatMethod) {\n text = attribute.label.formatMethod(text);\n }\n const { width, height } = table.measureText(text, {\n fontSize: attribute.label?.style?.fontSize,\n fontWeight: attribute.label?.style?.fontWeight,\n fontFamily: attribute.label?.style?.fontFamily\n });\n labelHeight = Math.max(\n labelHeight,\n getSizeAfterResize(width, height, attribute.label?.style?.angle).height + 2\n );\n });\n }\n labelHeight += attribute.label.space ?? 4;\n }\n\n // title\n let titleHeight = 0;\n if (attribute.title.visible && attribute.title.text) {\n const { width, height } = table.measureText(attribute.title.text, {\n fontSize: attribute.label?.style?.fontSize,\n fontWeight: attribute.label?.style?.fontWeight,\n fontFamily: attribute.label?.style?.fontFamily\n });\n const size = getSizeAfterResize(width, height, attribute.label?.style?.angle);\n if ((config.orient === 'bottom' || config.orient === 'top') && attribute.title.autoRotate) {\n titleHeight = size.width + 2;\n } else {\n titleHeight = size.height + 2;\n }\n titleHeight += attribute.title.space ?? 4;\n }\n\n return tickHeight + labelHeight + titleHeight;\n}\n\n// 保留一位有效数字\nfunction formatDecimal(number: number) {\n if (typeof number !== 'number') {\n number = Number(number);\n }\n\n return Number(number.toPrecision(1)).toString(); // 避免科学计数法\n}\n\n// 计算旋转后的size\nfunction getSizeAfterResize(width: number, height: number, angle = 0) {\n const theta = (angle * Math.PI) / 180; // 角度转为弧度\n const p1 = { x: -width / 2, y: -height / 2 };\n const p2 = { x: width / 2, y: -height / 2 };\n const p3 = { x: width / 2, y: height / 2 };\n const p4 = { x: -width / 2, y: height / 2 };\n\n const p1Rotated = {\n x: p1.x * Math.cos(theta) - p1.y * Math.sin(theta),\n y: p1.x * Math.sin(theta) + p1.y * Math.cos(theta)\n };\n const p2Rotated = {\n x: p2.x * Math.cos(theta) - p2.y * Math.sin(theta),\n y: p2.x * Math.sin(theta) + p2.y * Math.cos(theta)\n };\n const p3Rotated = {\n x: p3.x * Math.cos(theta) - p3.y * Math.sin(theta),\n y: p3.x * Math.sin(theta) + p3.y * Math.cos(theta)\n };\n const p4Rotated = {\n x: p4.x * Math.cos(theta) - p4.y * Math.sin(theta),\n y: p4.x * Math.sin(theta) + p4.y * Math.cos(theta)\n };\n\n const bounds = {\n minX: Math.min(p1Rotated.x, p2Rotated.x, p3Rotated.x, p4Rotated.x),\n maxX: Math.max(p1Rotated.x, p2Rotated.x, p3Rotated.x, p4Rotated.x),\n minY: Math.min(p1Rotated.y, p2Rotated.y, p3Rotated.y, p4Rotated.y),\n maxY: Math.max(p1Rotated.y, p2Rotated.y, p3Rotated.y, p4Rotated.y)\n };\n\n return {\n width: bounds.maxX - bounds.minX,\n height: bounds.maxY - bounds.minY\n };\n}\n"]}
1
+ {"version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,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"]}
@@ -36,7 +36,7 @@ export declare abstract class BaseTable extends EventTarget implements BaseTable
36
36
  customRender?: ICustomRender;
37
37
  canvasWidth?: number;
38
38
  canvasHeight?: number;
39
- dataSet: DataSet;
39
+ _vDataSet: DataSet;
40
40
  scenegraph: Scenegraph;
41
41
  stateManeger?: StateManeger;
42
42
  eventManeger?: EventManeger;
@@ -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.1",
48
+ if (super(), this.showFrozenIcon = !0, this.showSort = !0, this.version = "0.10.1-alpha.2",
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;
@@ -88,7 +88,7 @@ class BaseTable extends EventTarget_1.EventTarget {
88
88
  internalProps.bodyHelper = new body_helper_1.BodyHelper(this), internalProps.headerHelper = new header_helper_1.HeaderHelper(this),
89
89
  internalProps.autoWrapText = options.autoWrapText, internalProps.allowFrozenColCount = null !== (_c = options.allowFrozenColCount) && void 0 !== _c ? _c : internalProps.colCount,
90
90
  internalProps.limitMaxAutoWidth = null !== (_d = options.limitMaxAutoWidth) && void 0 !== _d ? _d : 450,
91
- this.dataSet = new vdataset_1.DataSet, this.scenegraph = new scenegraph_1.Scenegraph(this),
91
+ this._vDataSet = new vdataset_1.DataSet, this.scenegraph = new scenegraph_1.Scenegraph(this),
92
92
  this.stateManeger = new state_1.StateManeger(this), this.eventManeger = new event_1.EventManeger(this),
93
93
  options.legends && (internalProps.legends = new legend_1.TableLegend(options.legends, this),
94
94
  this.scenegraph.tableGroup.setAttributes({
@@ -663,7 +663,7 @@ class BaseTable extends EventTarget_1.EventTarget {
663
663
  internalProps.theme = themes_1.default.of(null !== (_a = options.theme) && void 0 !== _a ? _a : themes_1.default.DEFAULT),
664
664
  internalProps.autoWrapText = options.autoWrapText, internalProps.allowFrozenColCount = null !== (_b = options.allowFrozenColCount) && void 0 !== _b ? _b : internalProps.colCount,
665
665
  internalProps.limitMaxAutoWidth = null !== (_c = options.limitMaxAutoWidth) && void 0 !== _c ? _c : 450,
666
- this.dataSet = new vdataset_1.DataSet, null === (_d = internalProps.legends) || void 0 === _d || _d.release(),
666
+ this._vDataSet = new vdataset_1.DataSet, null === (_d = internalProps.legends) || void 0 === _d || _d.release(),
667
667
  null === (_e = internalProps.title) || void 0 === _e || _e.release(), internalProps.layoutMap.release(),
668
668
  this.scenegraph.clearCells(), this.stateManeger.initState(), this._updateSize(),
669
669
  options.legends && (internalProps.legends = new legend_1.TableLegend(options.legends, this),