@visactor/vrender-components 0.21.0-alpha.2 → 0.21.0-vstory.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/cjs/axis/circle.js +3 -3
  2. package/cjs/axis/circle.js.map +1 -1
  3. package/cjs/axis/overlap/auto-limit.js +7 -9
  4. package/cjs/axis/overlap/auto-limit.js.map +1 -1
  5. package/cjs/axis/overlap/auto-wrap.js +21 -8
  6. package/cjs/axis/overlap/auto-wrap.js.map +1 -1
  7. package/cjs/axis/type.d.ts +4 -0
  8. package/cjs/axis/type.js.map +1 -1
  9. package/cjs/index.d.ts +2 -1
  10. package/cjs/index.js +2 -2
  11. package/cjs/index.js.map +1 -1
  12. package/cjs/interface.d.ts +2 -1
  13. package/cjs/interface.js.map +1 -1
  14. package/cjs/label/base.d.ts +4 -2
  15. package/cjs/label/base.js +34 -7
  16. package/cjs/label/base.js.map +1 -1
  17. package/cjs/label/overlap/place.js +3 -1
  18. package/cjs/label/overlap/place.js.map +1 -1
  19. package/cjs/label/overlap/scaler.d.ts +6 -0
  20. package/cjs/label/overlap/scaler.js +16 -14
  21. package/cjs/label/overlap/scaler.js.map +1 -1
  22. package/cjs/label/overlap/shiftY.d.ts +8 -0
  23. package/cjs/label/overlap/shiftY.js +47 -0
  24. package/cjs/label/overlap/shiftY.js.map +1 -0
  25. package/cjs/label/type.d.ts +8 -1
  26. package/cjs/label/type.js.map +1 -1
  27. package/cjs/legend/base.d.ts +1 -0
  28. package/cjs/legend/base.js +7 -6
  29. package/cjs/legend/base.js.map +1 -1
  30. package/cjs/legend/discrete/discrete.d.ts +1 -0
  31. package/cjs/legend/discrete/discrete.js +17 -10
  32. package/cjs/legend/discrete/discrete.js.map +1 -1
  33. package/cjs/weather/index.d.ts +1 -0
  34. package/cjs/weather/index.js +21 -0
  35. package/cjs/weather/index.js.map +1 -0
  36. package/cjs/weather/register.d.ts +1 -0
  37. package/cjs/weather/register.js +14 -0
  38. package/cjs/weather/register.js.map +1 -0
  39. package/cjs/weather/type.d.ts +24 -0
  40. package/cjs/weather/type.js +6 -0
  41. package/cjs/weather/type.js.map +1 -0
  42. package/cjs/weather/weather-box.d.ts +13 -0
  43. package/cjs/weather/weather-box.js +129 -0
  44. package/cjs/weather/weather-box.js.map +1 -0
  45. package/dist/index.es.js +5948 -5270
  46. package/es/axis/circle.js +3 -3
  47. package/es/axis/circle.js.map +1 -1
  48. package/es/axis/overlap/auto-limit.js +5 -8
  49. package/es/axis/overlap/auto-limit.js.map +1 -1
  50. package/es/axis/overlap/auto-wrap.js +20 -8
  51. package/es/axis/overlap/auto-wrap.js.map +1 -1
  52. package/es/axis/type.d.ts +4 -0
  53. package/es/axis/type.js.map +1 -1
  54. package/es/index.d.ts +2 -1
  55. package/es/index.js +3 -1
  56. package/es/index.js.map +1 -1
  57. package/es/interface.d.ts +2 -1
  58. package/es/interface.js.map +1 -1
  59. package/es/label/base.d.ts +4 -2
  60. package/es/label/base.js +34 -5
  61. package/es/label/base.js.map +1 -1
  62. package/es/label/overlap/place.js +4 -2
  63. package/es/label/overlap/place.js.map +1 -1
  64. package/es/label/overlap/scaler.d.ts +6 -0
  65. package/es/label/overlap/scaler.js +11 -10
  66. package/es/label/overlap/scaler.js.map +1 -1
  67. package/es/label/overlap/shiftY.d.ts +8 -0
  68. package/es/label/overlap/shiftY.js +41 -0
  69. package/es/label/overlap/shiftY.js.map +1 -0
  70. package/es/label/type.d.ts +8 -1
  71. package/es/label/type.js.map +1 -1
  72. package/es/legend/base.d.ts +1 -0
  73. package/es/legend/base.js +7 -5
  74. package/es/legend/base.js.map +1 -1
  75. package/es/legend/discrete/discrete.d.ts +1 -0
  76. package/es/legend/discrete/discrete.js +17 -10
  77. package/es/legend/discrete/discrete.js.map +1 -1
  78. package/es/weather/index.d.ts +1 -0
  79. package/es/weather/index.js +2 -0
  80. package/es/weather/index.js.map +1 -0
  81. package/es/weather/register.d.ts +1 -0
  82. package/es/weather/register.js +6 -0
  83. package/es/weather/register.js.map +1 -0
  84. package/es/weather/type.d.ts +24 -0
  85. package/es/weather/type.js +2 -0
  86. package/es/weather/type.js.map +1 -0
  87. package/es/weather/weather-box.d.ts +13 -0
  88. package/es/weather/weather-box.js +127 -0
  89. package/es/weather/weather-box.js.map +1 -0
  90. package/package.json +8 -8
@@ -102,11 +102,11 @@ class CircleAxis extends base_1.AxisBase {
102
102
  beforeLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {}
103
103
  handleLabelsOverlap(labelShapes, labelData, labelContainer, layer, layerCount) {
104
104
  if ((0, vutils_1.isEmpty)(labelShapes)) return;
105
- const {inside: inside, radius: radius, center: center, width: width, height: height, label: label, orient: orient} = this.attribute, bounds = width && height ? {
105
+ const {inside: inside, radius: radius, center: center, size: size, label: label, orient: orient} = this.attribute, bounds = size ? {
106
106
  x1: 0,
107
107
  y1: 0,
108
- x2: width,
109
- y2: height
108
+ x2: size.width,
109
+ y2: size.height
110
110
  } : {
111
111
  x1: center.x - radius,
112
112
  y1: center.y - radius,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/axis/circle.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAYA,yDAAwD;AAGxD,6CAA+G;AAC/G,0CAAiE;AAEjE,iCAAkC;AAClC,qCAA8C;AAC9C,yCAA+D;AAC/D,2CAAiD;AACjD,iCAAiF;AAEjF,yCAAqD;AACrD,mDAA+D;AAC/D,mEAA8D;AAE9D,IAAA,kCAAuB,GAAE,CAAC;AAK1B,MAAa,UAAW,SAAQ,eAA8B;IAG5D,YAAY,UAAgC,EAAE,OAA0B;QACtE,KAAK,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,EAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAA,cAAK,EAAC,EAAE,EAAE,UAAU,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;IACjG,CAAC;IAES,UAAU,CAAC,SAAiB;QACp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,CAAC,GAAG,CAAC,EAAE;YACxB,OAAO,QAAQ,CAAC;SACjB;aAAM,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE;YACxB,OAAO,KAAK,CAAC;SACd;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;IAES,aAAa,CACrB,MAAwB,EACxB,MAAgB,EAChB,KAAc;QAEd,IAAI,IAAA,sBAAa,EAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE;YAC/B,OAAO;gBACL,SAAS,EAAE,QAAQ;gBACnB,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ;aAC/C,CAAC;SACH;aAAM,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE;YACxB,OAAO;gBACL,SAAS,EAAE,OAAO;gBAClB,YAAY,EAAE,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC;aAC3C,CAAC;SACH;aAAM,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE;YACxB,OAAO;gBACL,SAAS,EAAE,MAAM;gBACjB,YAAY,EAAE,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC;aAC3C,CAAC;SACH;QAED,OAAO;YACL,SAAS,EAAE,QAAQ;YACnB,YAAY,EAAE,QAAQ;SACvB,CAAC;IACJ,CAAC;IAES,gBAAgB,CACxB,KAAY,EACZ,MAAwB,EACxB,IAAqB,EACrB,KAAqC;QAErC,OAAO,KAAK,CAAC;IACf,CAAC;;AArRH,gCAsRC;AArRQ,4BAAiB,GAAG,2BAAkB,CAAC;AAuRhD,IAAA,cAAK,EAAC,UAAU,EAAE,wBAAe,CAAC,CAAC","file":"circle.js","sourcesContent":["/**\n * @description 圆弧型坐标轴\n */\nimport type {\n IGraphic,\n IGroup,\n IText,\n ITextGraphicAttribute,\n TextAlignType,\n TextBaselineType\n} from '@visactor/vrender-core';\n// eslint-disable-next-line no-duplicate-imports\nimport { graphicCreator } from '@visactor/vrender-core';\n// eslint-disable-next-line no-duplicate-imports\nimport type { Point } from '@visactor/vutils';\nimport { isNil, get, merge, isNumberClose, isEmpty, mixin, isValidNumber, isFunction } from '@visactor/vutils';\nimport { POLAR_END_ANGLE, POLAR_START_ANGLE } from '../constant';\nimport type { CircleAxisAttributes, TitleAttributes, SubTickAttributes, TickLineItem, AxisItem } from './type';\nimport { AxisBase } from './base';\nimport { DEFAULT_AXIS_THEME } from './config';\nimport { AXIS_ELEMENT_NAME, DEFAULT_STATES } from './constant';\nimport { CircleAxisMixin } from './mixin/circle';\nimport { getCircleLabelPosition, getCirclePoints, getPolygonPath } from './util';\nimport type { ComponentOptions } from '../interface';\nimport { loadCircleAxisComponent } from './register';\nimport { autoHide as autoHideFunc } from './overlap/auto-hide';\nimport { circleAutoLimit } from './overlap/circle-auto-limit';\n\nloadCircleAxisComponent();\nexport interface CircleAxis\n extends Pick<CircleAxisMixin, 'isInValidValue' | 'getTickCoord' | 'getVerticalVector' | 'getRelativeVector'>,\n AxisBase<CircleAxisAttributes> {}\n\nexport class CircleAxis extends AxisBase<CircleAxisAttributes> {\n static defaultAttributes = DEFAULT_AXIS_THEME;\n\n constructor(attributes: CircleAxisAttributes, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, CircleAxis.defaultAttributes, attributes));\n }\n\n protected renderLine(container: IGroup): void {\n const {\n startAngle = POLAR_START_ANGLE,\n endAngle = POLAR_END_ANGLE,\n radius,\n center,\n innerRadius = 0,\n line = {},\n inside = false,\n sides\n } = this.attribute as CircleAxisAttributes;\n\n let arcRadius = radius;\n let arcInnerRadius = innerRadius;\n if (inside && innerRadius > 0) {\n arcRadius = innerRadius;\n arcInnerRadius = 0;\n }\n\n let lineGraphic: IGraphic;\n if (isValidNumber(sides) && sides >= 3) {\n const gridPoints = getCirclePoints(center as Point, sides as number, arcRadius, startAngle, endAngle);\n\n lineGraphic = graphicCreator.path({\n ...line.style,\n path: getPolygonPath(gridPoints, true)\n });\n } else {\n const arcAttrs = {\n ...center,\n startAngle,\n endAngle,\n radius: arcRadius,\n innerRadius: arcInnerRadius,\n ...line.style\n };\n lineGraphic = graphicCreator.circle(arcAttrs);\n }\n\n lineGraphic.name = AXIS_ELEMENT_NAME.line;\n lineGraphic.id = this._getNodeId('line');\n\n if (!isEmpty(line.state)) {\n lineGraphic.states = merge({}, DEFAULT_STATES, line.state);\n }\n container.add(lineGraphic);\n }\n\n protected getTitleAttribute() {\n const { center, radius, innerRadius = 0 } = this.attribute as CircleAxisAttributes;\n const {\n space = 4,\n textStyle = {},\n shape,\n background,\n state = {},\n ...restAttrs\n } = this.attribute.title as TitleAttributes;\n let titlePoint = center;\n let labelHeight = 0;\n if (this.attribute.label?.visible && this.attribute.label.inside === false) {\n // 这里取 label 的最大长度\n labelHeight = get(this.attribute.label, 'style.fontSize', 12) + get(this.attribute.label, 'space', 4);\n }\n let tickLength = 0;\n if (this.attribute.tick?.visible && this.attribute.tick.inside === false) {\n tickLength = this.attribute.tick.length || 4;\n }\n if (this.attribute.subTick?.visible && this.attribute.subTick.inside === false) {\n tickLength = Math.max(tickLength, this.attribute.subTick.length || 2);\n }\n const offset = radius + tickLength + labelHeight + space;\n let textBaseline: TextBaselineType = 'middle';\n let { position } = this.attribute.title as TitleAttributes;\n if (isNil(position)) {\n position = innerRadius === 0 ? 'end' : 'middle';\n }\n if (position === 'start') {\n textBaseline = 'bottom';\n titlePoint = {\n x: center.x,\n y: center.y - offset\n };\n } else if (position === 'end') {\n textBaseline = 'top';\n titlePoint = {\n x: center.x,\n y: center.y + offset\n };\n }\n const attrs: any = {\n ...titlePoint,\n ...restAttrs,\n textStyle: {\n textBaseline,\n textAlign: 'center',\n ...textStyle\n },\n state: {\n text: merge({}, DEFAULT_STATES, state.text),\n shape: merge({}, DEFAULT_STATES, state.shape),\n panel: merge({}, DEFAULT_STATES, state.background)\n }\n };\n\n const { angle } = restAttrs; // 用户设置的是角度\n attrs.angle = angle;\n\n if (shape && shape.visible) {\n attrs.shape = {\n visible: true,\n ...shape.style\n };\n if (shape.space) {\n attrs.space = shape.space;\n }\n }\n\n if (background && background.visible) {\n attrs.panel = {\n visible: true,\n ...background.style\n };\n }\n\n return attrs;\n }\n\n protected getSubTickLineItems() {\n const { subTick } = this.attribute as CircleAxisAttributes;\n const subTickLineItems: TickLineItem[] = [];\n const { count: subCount = 4, inside = false, length = 2 } = subTick as SubTickAttributes;\n const tickLineItems = this.tickLineItems;\n const tickLineCount = tickLineItems.length;\n // 刻度线的数量大于 2 时,才绘制子刻度\n if (tickLineCount >= 2) {\n const tickSegment = this.data[1].value - this.data[0].value;\n const isAlignWithLable = this.attribute?.tick?.alignWithLabel;\n for (let i = 0; i < tickLineCount; i++) {\n const pre = tickLineItems[i];\n const next = tickLineItems[i + 1];\n for (let j = 0; j < subCount; j++) {\n const percent = (j + 1) / (subCount + 1);\n const value =\n (1 - percent) * pre.value + percent * (next ? next.value : isAlignWithLable ? 1 : pre.value + tickSegment);\n const point = this.getTickCoord(value);\n const endPoint = this.getVerticalCoord(point, length, inside);\n subTickLineItems.push({\n start: point,\n end: endPoint,\n value\n });\n }\n }\n }\n\n return subTickLineItems;\n }\n protected beforeLabelsOverlap(\n labelShapes: IText[],\n labelData: AxisItem[],\n labelContainer: IGroup,\n layer: number,\n layerCount: number\n ): void {\n return;\n }\n protected handleLabelsOverlap(\n labelShapes: IText[],\n labelData: AxisItem[],\n labelContainer: IGroup,\n layer: number,\n layerCount: number\n ): void {\n if (isEmpty(labelShapes)) {\n return;\n }\n\n const { inside, radius, center, width, height, label, orient } = this.attribute;\n // 宽高为0的异常情况,还是以圆心进行布局\n const bounds =\n width && height\n ? {\n x1: 0,\n y1: 0,\n x2: width,\n y2: height\n }\n : {\n x1: center.x - radius,\n y1: center.y - radius,\n x2: center.x + radius,\n y2: center.y + radius\n };\n const { layoutFunc, autoLimit, limitEllipsis, autoHide, autoHideMethod, autoHideSeparation, autoWrap } = label;\n\n if (isFunction(layoutFunc)) {\n // 自定义布局\n layoutFunc(labelShapes, labelData, layer, this);\n } else {\n // autoWrap has computed width & height limit\n if (autoLimit || autoWrap) {\n circleAutoLimit(labelShapes, { inside, autoWrap, bounds, ellipsis: limitEllipsis, center });\n }\n if (autoHide) {\n autoHideFunc(labelShapes, {\n orient,\n method: autoHideMethod,\n separation: autoHideSeparation\n });\n }\n }\n }\n protected afterLabelsOverlap(\n labelShapes: IText[],\n labelData: AxisItem[],\n labelContainer: IGroup,\n layer: number,\n layerCount: number\n ): void {\n return;\n }\n\n protected getTextBaseline(vector: [number, number]) {\n if (Math.abs(vector[1] / vector[0]) < 0.3) {\n return 'middle';\n } else if (vector[1] < 0) {\n return 'bottom';\n } else if (vector[1] > 0) {\n return 'top';\n }\n\n return 'middle';\n }\n\n protected getLabelAlign(\n vector: [number, number],\n inside?: boolean,\n angle?: number\n ): { textAlign: TextAlignType; textBaseline: TextBaselineType } {\n if (isNumberClose(vector[0], 0)) {\n return {\n textAlign: 'center',\n textBaseline: vector[1] > 0 ? 'top' : 'bottom'\n };\n } else if (vector[0] < 0) {\n return {\n textAlign: 'right',\n textBaseline: this.getTextBaseline(vector)\n };\n } else if (vector[0] > 0) {\n return {\n textAlign: 'left',\n textBaseline: this.getTextBaseline(vector)\n };\n }\n\n return {\n textAlign: 'center', //'left',\n textBaseline: 'middle' //'top'\n };\n }\n\n protected getLabelPosition(\n point: Point,\n vector: [number, number],\n text: string | number,\n style: Partial<ITextGraphicAttribute>\n ) {\n return point;\n }\n}\n\nmixin(CircleAxis, CircleAxisMixin);\n"]}
1
+ {"version":3,"sources":["../src/axis/circle.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAYA,yDAAwD;AAGxD,6CAA+G;AAC/G,0CAAiE;AAEjE,iCAAkC;AAClC,qCAA8C;AAC9C,yCAA+D;AAC/D,2CAAiD;AACjD,iCAAyD;AAEzD,yCAAqD;AACrD,mDAA+D;AAC/D,mEAA8D;AAE9D,IAAA,kCAAu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ACxB,IAAqB,EACrB,KAAqC;QAErC,OAAO,KAAK,CAAC;IACf,CAAC;;AApRH,gCAqRC;AApRQ,4BAAiB,GAAG,2BAAkB,CAAC;AAsRhD,IAAA,cAAK,EAAC,UAAU,EAAE,wBAAe,CAAC,CAAC","file":"circle.js","sourcesContent":["/**\n * @description 圆弧型坐标轴\n */\nimport type {\n IGraphic,\n IGroup,\n IText,\n ITextGraphicAttribute,\n TextAlignType,\n TextBaselineType\n} from '@visactor/vrender-core';\n// eslint-disable-next-line no-duplicate-imports\nimport { graphicCreator } from '@visactor/vrender-core';\n// eslint-disable-next-line no-duplicate-imports\nimport type { Point } from '@visactor/vutils';\nimport { isNil, get, merge, isNumberClose, isEmpty, mixin, isValidNumber, isFunction } from '@visactor/vutils';\nimport { POLAR_END_ANGLE, POLAR_START_ANGLE } from '../constant';\nimport type { CircleAxisAttributes, TitleAttributes, SubTickAttributes, TickLineItem, AxisItem } from './type';\nimport { AxisBase } from './base';\nimport { DEFAULT_AXIS_THEME } from './config';\nimport { AXIS_ELEMENT_NAME, DEFAULT_STATES } from './constant';\nimport { CircleAxisMixin } from './mixin/circle';\nimport { getCirclePoints, getPolygonPath } from './util';\nimport type { ComponentOptions } from '../interface';\nimport { loadCircleAxisComponent } from './register';\nimport { autoHide as autoHideFunc } from './overlap/auto-hide';\nimport { circleAutoLimit } from './overlap/circle-auto-limit';\n\nloadCircleAxisComponent();\nexport interface CircleAxis\n extends Pick<CircleAxisMixin, 'isInValidValue' | 'getTickCoord' | 'getVerticalVector' | 'getRelativeVector'>,\n AxisBase<CircleAxisAttributes> {}\n\nexport class CircleAxis extends AxisBase<CircleAxisAttributes> {\n static defaultAttributes = DEFAULT_AXIS_THEME;\n\n constructor(attributes: CircleAxisAttributes, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, CircleAxis.defaultAttributes, attributes));\n }\n\n protected renderLine(container: IGroup): void {\n const {\n startAngle = POLAR_START_ANGLE,\n endAngle = POLAR_END_ANGLE,\n radius,\n center,\n innerRadius = 0,\n line = {},\n inside = false,\n sides\n } = this.attribute as CircleAxisAttributes;\n\n let arcRadius = radius;\n let arcInnerRadius = innerRadius;\n if (inside && innerRadius > 0) {\n arcRadius = innerRadius;\n arcInnerRadius = 0;\n }\n\n let lineGraphic: IGraphic;\n if (isValidNumber(sides) && sides >= 3) {\n const gridPoints = getCirclePoints(center as Point, sides as number, arcRadius, startAngle, endAngle);\n\n lineGraphic = graphicCreator.path({\n ...line.style,\n path: getPolygonPath(gridPoints, true)\n });\n } else {\n const arcAttrs = {\n ...center,\n startAngle,\n endAngle,\n radius: arcRadius,\n innerRadius: arcInnerRadius,\n ...line.style\n };\n lineGraphic = graphicCreator.circle(arcAttrs);\n }\n\n lineGraphic.name = AXIS_ELEMENT_NAME.line;\n lineGraphic.id = this._getNodeId('line');\n\n if (!isEmpty(line.state)) {\n lineGraphic.states = merge({}, DEFAULT_STATES, line.state);\n }\n container.add(lineGraphic);\n }\n\n protected getTitleAttribute() {\n const { center, radius, innerRadius = 0 } = this.attribute as CircleAxisAttributes;\n const {\n space = 4,\n textStyle = {},\n shape,\n background,\n state = {},\n ...restAttrs\n } = this.attribute.title as TitleAttributes;\n let titlePoint = center;\n let labelHeight = 0;\n if (this.attribute.label?.visible && this.attribute.label.inside === false) {\n // 这里取 label 的最大长度\n labelHeight = get(this.attribute.label, 'style.fontSize', 12) + get(this.attribute.label, 'space', 4);\n }\n let tickLength = 0;\n if (this.attribute.tick?.visible && this.attribute.tick.inside === false) {\n tickLength = this.attribute.tick.length || 4;\n }\n if (this.attribute.subTick?.visible && this.attribute.subTick.inside === false) {\n tickLength = Math.max(tickLength, this.attribute.subTick.length || 2);\n }\n const offset = radius + tickLength + labelHeight + space;\n let textBaseline: TextBaselineType = 'middle';\n let { position } = this.attribute.title as TitleAttributes;\n if (isNil(position)) {\n position = innerRadius === 0 ? 'end' : 'middle';\n }\n if (position === 'start') {\n textBaseline = 'bottom';\n titlePoint = {\n x: center.x,\n y: center.y - offset\n };\n } else if (position === 'end') {\n textBaseline = 'top';\n titlePoint = {\n x: center.x,\n y: center.y + offset\n };\n }\n const attrs: any = {\n ...titlePoint,\n ...restAttrs,\n textStyle: {\n textBaseline,\n textAlign: 'center',\n ...textStyle\n },\n state: {\n text: merge({}, DEFAULT_STATES, state.text),\n shape: merge({}, DEFAULT_STATES, state.shape),\n panel: merge({}, DEFAULT_STATES, state.background)\n }\n };\n\n const { angle } = restAttrs; // 用户设置的是角度\n attrs.angle = angle;\n\n if (shape && shape.visible) {\n attrs.shape = {\n visible: true,\n ...shape.style\n };\n if (shape.space) {\n attrs.space = shape.space;\n }\n }\n\n if (background && background.visible) {\n attrs.panel = {\n visible: true,\n ...background.style\n };\n }\n\n return attrs;\n }\n\n protected getSubTickLineItems() {\n const { subTick } = this.attribute as CircleAxisAttributes;\n const subTickLineItems: TickLineItem[] = [];\n const { count: subCount = 4, inside = false, length = 2 } = subTick as SubTickAttributes;\n const tickLineItems = this.tickLineItems;\n const tickLineCount = tickLineItems.length;\n // 刻度线的数量大于 2 时,才绘制子刻度\n if (tickLineCount >= 2) {\n const tickSegment = this.data[1].value - this.data[0].value;\n const isAlignWithLable = this.attribute?.tick?.alignWithLabel;\n for (let i = 0; i < tickLineCount; i++) {\n const pre = tickLineItems[i];\n const next = tickLineItems[i + 1];\n for (let j = 0; j < subCount; j++) {\n const percent = (j + 1) / (subCount + 1);\n const value =\n (1 - percent) * pre.value + percent * (next ? next.value : isAlignWithLable ? 1 : pre.value + tickSegment);\n const point = this.getTickCoord(value);\n const endPoint = this.getVerticalCoord(point, length, inside);\n subTickLineItems.push({\n start: point,\n end: endPoint,\n value\n });\n }\n }\n }\n\n return subTickLineItems;\n }\n protected beforeLabelsOverlap(\n labelShapes: IText[],\n labelData: AxisItem[],\n labelContainer: IGroup,\n layer: number,\n layerCount: number\n ): void {\n return;\n }\n protected handleLabelsOverlap(\n labelShapes: IText[],\n labelData: AxisItem[],\n labelContainer: IGroup,\n layer: number,\n layerCount: number\n ): void {\n if (isEmpty(labelShapes)) {\n return;\n }\n\n const { inside, radius, center, size, label, orient } = this.attribute;\n // 宽高为0的异常情况,还是以圆心进行布局\n const bounds = size\n ? {\n x1: 0,\n y1: 0,\n x2: size.width,\n y2: size.height\n }\n : {\n x1: center.x - radius,\n y1: center.y - radius,\n x2: center.x + radius,\n y2: center.y + radius\n };\n const { layoutFunc, autoLimit, limitEllipsis, autoHide, autoHideMethod, autoHideSeparation, autoWrap } = label;\n\n if (isFunction(layoutFunc)) {\n // 自定义布局\n layoutFunc(labelShapes, labelData, layer, this);\n } else {\n // autoWrap has computed width & height limit\n if (autoLimit || autoWrap) {\n circleAutoLimit(labelShapes, { inside, autoWrap, bounds, ellipsis: limitEllipsis, center });\n }\n if (autoHide) {\n autoHideFunc(labelShapes, {\n orient,\n method: autoHideMethod,\n separation: autoHideSeparation\n });\n }\n }\n }\n protected afterLabelsOverlap(\n labelShapes: IText[],\n labelData: AxisItem[],\n labelContainer: IGroup,\n layer: number,\n layerCount: number\n ): void {\n return;\n }\n\n protected getTextBaseline(vector: [number, number]) {\n if (Math.abs(vector[1] / vector[0]) < 0.3) {\n return 'middle';\n } else if (vector[1] < 0) {\n return 'bottom';\n } else if (vector[1] > 0) {\n return 'top';\n }\n\n return 'middle';\n }\n\n protected getLabelAlign(\n vector: [number, number],\n inside?: boolean,\n angle?: number\n ): { textAlign: TextAlignType; textBaseline: TextBaselineType } {\n if (isNumberClose(vector[0], 0)) {\n return {\n textAlign: 'center',\n textBaseline: vector[1] > 0 ? 'top' : 'bottom'\n };\n } else if (vector[0] < 0) {\n return {\n textAlign: 'right',\n textBaseline: this.getTextBaseline(vector)\n };\n } else if (vector[0] > 0) {\n return {\n textAlign: 'left',\n textBaseline: this.getTextBaseline(vector)\n };\n }\n\n return {\n textAlign: 'center', //'left',\n textBaseline: 'middle' //'top'\n };\n }\n\n protected getLabelPosition(\n point: Point,\n vector: [number, number],\n text: string | number,\n style: Partial<ITextGraphicAttribute>\n ) {\n return point;\n }\n}\n\nmixin(CircleAxis, CircleAxisMixin);\n"]}
@@ -22,17 +22,15 @@ function normalizeOverflowLimitLength(overflowLimitLength) {
22
22
  function autoLimit(labels, config) {
23
23
  const {limitLength: limitLength, verticalLimitLength: verticalLimitLength, ellipsis: ellipsis = "...", orient: orient, axisLength: axisLength} = config;
24
24
  if ((0, vutils_1.isEmpty)(labels) || !(0, vutils_1.isValidNumber)(limitLength)) return;
25
- Math.sin(Math.PI / 10);
26
- const overflowLimitLength = normalizeOverflowLimitLength(config.overflowLimitLength);
25
+ const overflowLimitLength = normalizeOverflowLimitLength(config.overflowLimitLength), firstLabel = labels[0], angle = firstLabel.attribute.angle, hasAngle = !(0,
26
+ vutils_1.isNil)(angle), cos = hasAngle ? Math.cos(angle) : 1, sin = hasAngle ? Math.sin(angle) : 0, isHorizontal = (0,
27
+ util_1.isAngleHorizontal)(angle), isVertical = (0, util_1.isAngleVertical)(angle), isX = "top" === orient || "bottom" === orient, direction = firstLabel.attribute.direction, checkBox = !isHorizontal && !isVertical && isX && (labels.length < 2 || labels.some((label => Math.abs(label.AABBBounds.width() - firstLabel.AABBBounds.width()) >= 2))) && firstLabel.AABBBounds.width() > Math.abs(limitLength / sin);
27
28
  labels.forEach((label => {
28
29
  var _a;
29
- const angle = label.attribute.angle, hasAngle = !(0, vutils_1.isNil)(angle), cos = hasAngle ? Math.cos(angle) : 1, sin = hasAngle ? Math.sin(angle) : 0, isHorizontal = (0,
30
- util_1.isAngleHorizontal)(angle), isVertical = (0, util_1.isAngleVertical)(angle), isX = "top" === orient || "bottom" === orient;
31
30
  if (isX) {
32
31
  if (isVertical && Math.floor(label.AABBBounds.height()) <= limitLength) return;
33
32
  if (isHorizontal && Math.floor(label.AABBBounds.width()) <= verticalLimitLength) return;
34
33
  }
35
- const direction = label.attribute.direction;
36
34
  if (!isX) {
37
35
  if ("vertical" === direction && Math.floor(label.AABBBounds.height()) <= verticalLimitLength) return;
38
36
  if ("vertical" !== direction) {
@@ -43,11 +41,11 @@ function autoLimit(labels, config) {
43
41
  let limitLabelLength = null;
44
42
  if (isHorizontal || isVertical) limitLabelLength = isX ? isHorizontal ? verticalLimitLength : limitLength : "vertical" === direction || isVertical ? verticalLimitLength : limitLength; else if (isX) {
45
43
  const {x1: x1, x2: x2} = label.AABBBounds, tan = sin / cos, verticalSizeLimit = Math.abs(limitLength / sin);
46
- if (tan > 0 && x1 <= axisLength && limitLength / tan + x1 > axisLength) {
47
- const lengthLimit = (axisLength - x1) / Math.abs(cos) + overflowLimitLength.right;
44
+ if (checkBox && tan > 0 && x1 <= axisLength + overflowLimitLength.right && limitLength / tan + x1 > axisLength + overflowLimitLength.right) {
45
+ const lengthLimit = (axisLength - x1 + overflowLimitLength.right) / Math.abs(cos);
48
46
  limitLabelLength = Math.min(lengthLimit, verticalSizeLimit);
49
- } else if (tan < 0 && x2 >= 0 && limitLength / tan + x2 < 0) {
50
- const lengthLimit = x2 / Math.abs(cos) + overflowLimitLength.left;
47
+ } else if (checkBox && tan < 0 && x2 >= -overflowLimitLength.left && limitLength / tan + x2 < -overflowLimitLength.left) {
48
+ const lengthLimit = (x2 + overflowLimitLength.left) / Math.abs(cos);
51
49
  limitLabelLength = Math.min(lengthLimit, verticalSizeLimit);
52
50
  } else limitLabelLength = verticalSizeLimit;
53
51
  } else limitLabelLength = Math.abs(limitLength / cos);
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/axis/overlap/auto-limit.ts"],"names":[],"mappings":";;;AAIA,iCAA4D;AAE5D,6CAA2E;AAW3E,SAAS,4BAA4B,CAAC,mBAA6D;IACjG,IAAI,IAAA,sBAAa,EAAC,mBAAmB,CAAC,EAAE;QACtC,OAAO;YACL,IAAI,EAAE,mBAAmB;YACzB,KAAK,EAAE,mBAAmB;SAG3B,CAAC;KACH;SAAM,IAAI,IAAA,iBAAQ,EAAC,mBAAmB,CAAC,EAAE;QACxC,OAAO;YACL,IAAI,EAAE,mBAAmB,CAAC,IAAI,IAAI,CAAC;YACnC,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AA,KAAK,CAAC,SAAS,CAAC,QAAQ,mCAAI,QAAQ;SAC/C,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AA5FD,8BA4FC","file":"auto-limit.js","sourcesContent":["/**\n * 自动省略\n */\nimport type { IText } from '@visactor/vrender-core';\nimport { isAngleHorizontal, isAngleVertical } from './util';\nimport type { AxisLabelOverlap } from '../type';\nimport { isEmpty, isNil, isObject, isValidNumber } from '@visactor/vutils';\n\ntype LimitConfig = {\n orient: string;\n limitLength: number;\n axisLength: number;\n verticalLimitLength?: number;\n ellipsis?: string;\n overflowLimitLength?: AxisLabelOverlap['overflowLimitLength'];\n};\n\nfunction normalizeOverflowLimitLength(overflowLimitLength?: AxisLabelOverlap['overflowLimitLength']) {\n if (isValidNumber(overflowLimitLength)) {\n return {\n left: overflowLimitLength,\n right: overflowLimitLength\n // top: overflowLimitLength,\n // bottom: overflowLimitLength\n };\n } else if (isObject(overflowLimitLength)) {\n return {\n left: overflowLimitLength.left || 0,\n right: overflowLimitLength.right || 0\n // top: overflowLimitLength.top || 0,\n // bottom: overflowLimitLength.bottom || 0\n };\n }\n return { left: 0, right: 0 };\n}\n\nexport function autoLimit(labels: IText[], config: LimitConfig) {\n const { limitLength, verticalLimitLength, ellipsis = '...', orient, axisLength } = config;\n if (isEmpty(labels) || !isValidNumber(limitLength)) {\n return;\n }\n const DELTA = Math.sin(Math.PI / 10);\n\n const overflowLimitLength = normalizeOverflowLimitLength(config.overflowLimitLength);\n\n labels.forEach(label => {\n const angle = label.attribute.angle;\n\n const hasAngle = !isNil(angle);\n const cos = hasAngle ? Math.cos(angle) : 1;\n const sin = hasAngle ? Math.sin(angle) : 0;\n const isHorizontal = isAngleHorizontal(angle);\n const isVertical = isAngleVertical(angle);\n\n const isX = orient === 'top' || orient === 'bottom';\n\n if (isX) {\n if (isVertical && Math.floor(label.AABBBounds.height()) <= limitLength) {\n return;\n }\n if (isHorizontal && Math.floor(label.AABBBounds.width()) <= verticalLimitLength) {\n return;\n }\n }\n\n const direction = label.attribute.direction;\n if (!isX) {\n if (direction === 'vertical' && Math.floor(label.AABBBounds.height()) <= verticalLimitLength) {\n return;\n }\n\n if (direction !== 'vertical') {\n if (isHorizontal && Math.floor(label.AABBBounds.width()) <= limitLength) {\n return;\n }\n if (isVertical && Math.floor(label.AABBBounds.height()) <= verticalLimitLength) {\n return;\n }\n }\n }\n\n // 如果水平并且文本未发生旋转,则不配置 maxLineWidth\n let limitLabelLength = null;\n\n if (!isHorizontal && !isVertical) {\n if (isX) {\n const { x1, x2 } = label.AABBBounds;\n const tan = sin / cos;\n const verticalSizeLimit = Math.abs(limitLength / sin);\n if (tan > 0 && x1 <= axisLength && limitLength / tan + x1 > axisLength) {\n // 以 x1 近似为锚点,文字在 x1 右侧\n const lengthLimit = (axisLength - x1) / Math.abs(cos) + overflowLimitLength.right;\n limitLabelLength = Math.min(lengthLimit, verticalSizeLimit);\n } else if (tan < 0 && x2 >= 0 && limitLength / tan + x2 < 0) {\n // 以 x2 近似为锚点,文字在 x2 左侧\n const lengthLimit = x2 / Math.abs(cos) + overflowLimitLength.left;\n limitLabelLength = Math.min(lengthLimit, verticalSizeLimit);\n } else {\n limitLabelLength = verticalSizeLimit;\n }\n } else {\n // y轴暂时不限制在平行于坐标轴的矩形内,后续可以考虑通过配置开启\n // const { y1, y2 } = label.AABBBounds;\n // const tan = sin / cos;\n // if (tan > 0 && y2 >= 0 && y2 - tan * limitLength < 0) {\n // limitLabelLength = y2 / Math.abs(sin);\n // } else if (tan < 0 && y1 <= axisLength && y1 - tan * limitLength > axisLength) {\n // limitLabelLength = (axisLength - y1) / Math.abs(sin);\n // } else {\n // }\n limitLabelLength = Math.abs(limitLength / cos);\n }\n } else if (isX) {\n limitLabelLength = isHorizontal ? verticalLimitLength : limitLength;\n } else {\n limitLabelLength = direction === 'vertical' || isVertical ? verticalLimitLength : limitLength;\n }\n\n if (isValidNumber(label.attribute.maxLineWidth)) {\n limitLabelLength = isValidNumber(limitLabelLength)\n ? Math.min(label.attribute.maxLineWidth, limitLabelLength)\n : label.attribute.maxLineWidth;\n }\n label.setAttributes({\n maxLineWidth: limitLabelLength,\n ellipsis: label.attribute.ellipsis ?? ellipsis\n });\n });\n}\n"]}
1
+ {"version":3,"sources":["../src/axis/overlap/auto-limit.ts"],"names":[],"mappings":";;;AAIA,iCAA4D;AAE5D,6CAA2E;AAW3E,SAAS,4BAA4B,CAAC,mBAA6D;IACjG,IAAI,IAAA,sBAAa,EAAC,mBAAmB,CAAC,EAAE;QACtC,OAAO;YACL,IAAI,EAAE,mBAAmB;YACzB,KAAK,EAAE,mBAAmB;SAG3B,CAAC;KACH;SAAM,IAAI,IAAA,iBAAQ,EAAC,mBAAmB,CAAC,EAAE;QACxC,OAAO;YACL,IAAI,EAAE,mBAAmB,CAAC,IAAI,IAAI,CAAC;YACnC,KAAK,EAAE,mBAAmB,CAAC,KAAK,IAAI,CAAC;SAGtC,CAAC;KACH;IACD,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;AAC/B,CAAC;AAED,SAAgB,SAAS,CAAC,MAAe,EAAE,MAAmB;IAC5D,MAAM,EAAE,WAAW,EAAE,mBAAmB,EAAE,QAAQ,GAAG,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;IAC1F,IAAI,IAAA,gBAAO,EAAC,MAAM,CAAC,IAAI,CAAC,IAAA,sBAAa,EAAC,WAAW,CAAC,EAAE;QAClD,OAAO;KACR;IACD,MAAM,mBAAmB,GAAG,4BAA4B,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;IAErF,MAAM,UAAU,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IAC7B,MAAM,KAAK,GAAG,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC;IACzC,MAAM,QAAQ,GAAG,CAAC,IAAA,cAAK,EAAC,KAAK,CAAC,CAAC;IAC/B,MAAM,GAAG,GAAG,QAAQ,CAA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vrender-core';\nimport { isAngleHorizontal, isAngleVertical } from './util';\nimport type { AxisLabelOverlap } from '../type';\nimport { isEmpty, isNil, isObject, isValidNumber } from '@visactor/vutils';\n\ntype LimitConfig = {\n orient: string;\n limitLength: number;\n axisLength: number;\n verticalLimitLength?: number;\n ellipsis?: string;\n overflowLimitLength?: AxisLabelOverlap['overflowLimitLength'];\n};\n\nfunction normalizeOverflowLimitLength(overflowLimitLength?: AxisLabelOverlap['overflowLimitLength']) {\n if (isValidNumber(overflowLimitLength)) {\n return {\n left: overflowLimitLength,\n right: overflowLimitLength\n // top: overflowLimitLength,\n // bottom: overflowLimitLength\n };\n } else if (isObject(overflowLimitLength)) {\n return {\n left: overflowLimitLength.left || 0,\n right: overflowLimitLength.right || 0\n // top: overflowLimitLength.top || 0,\n // bottom: overflowLimitLength.bottom || 0\n };\n }\n return { left: 0, right: 0 };\n}\n\nexport function autoLimit(labels: IText[], config: LimitConfig) {\n const { limitLength, verticalLimitLength, ellipsis = '...', orient, axisLength } = config;\n if (isEmpty(labels) || !isValidNumber(limitLength)) {\n return;\n }\n const overflowLimitLength = normalizeOverflowLimitLength(config.overflowLimitLength);\n // 注意:自动隐藏算法暂时只考虑所有标签角度都一致的情况\n const firstLabel = labels[0];\n const angle = firstLabel.attribute.angle;\n const hasAngle = !isNil(angle);\n const cos = hasAngle ? Math.cos(angle) : 1;\n const sin = hasAngle ? Math.sin(angle) : 0;\n const isHorizontal = isAngleHorizontal(angle);\n const isVertical = isAngleVertical(angle);\n const isX = orient === 'top' || orient === 'bottom';\n const direction = firstLabel.attribute.direction;\n // 判断有长度差异的阀值\n const THRESHOLD = 2;\n const checkBox =\n !isHorizontal &&\n !isVertical &&\n isX &&\n (labels.length < 2 ||\n labels.some(label => Math.abs(label.AABBBounds.width() - firstLabel.AABBBounds.width()) >= THRESHOLD)) &&\n firstLabel.AABBBounds.width() > Math.abs(limitLength / sin);\n\n labels.forEach(label => {\n if (isX) {\n if (isVertical && Math.floor(label.AABBBounds.height()) <= limitLength) {\n return;\n }\n if (isHorizontal && Math.floor(label.AABBBounds.width()) <= verticalLimitLength) {\n return;\n }\n }\n\n if (!isX) {\n if (direction === 'vertical' && Math.floor(label.AABBBounds.height()) <= verticalLimitLength) {\n return;\n }\n\n if (direction !== 'vertical') {\n if (isHorizontal && Math.floor(label.AABBBounds.width()) <= limitLength) {\n return;\n }\n if (isVertical && Math.floor(label.AABBBounds.height()) <= verticalLimitLength) {\n return;\n }\n }\n }\n\n // 如果水平并且文本未发生旋转,则不配置 maxLineWidth\n let limitLabelLength = null;\n\n if (!isHorizontal && !isVertical) {\n if (isX) {\n const { x1, x2 } = label.AABBBounds;\n const tan = sin / cos;\n const verticalSizeLimit = Math.abs(limitLength / sin);\n\n if (\n checkBox &&\n tan > 0 &&\n x1 <= axisLength + overflowLimitLength.right &&\n limitLength / tan + x1 > axisLength + overflowLimitLength.right\n ) {\n // 以 x1 近似为锚点,文字在 x1 右侧\n const lengthLimit = (axisLength - x1 + overflowLimitLength.right) / Math.abs(cos);\n limitLabelLength = Math.min(lengthLimit, verticalSizeLimit);\n } else if (\n checkBox &&\n tan < 0 &&\n x2 >= -overflowLimitLength.left &&\n limitLength / tan + x2 < -overflowLimitLength.left\n ) {\n // 以 x2 近似为锚点,文字在 x2 左侧\n const lengthLimit = (x2 + overflowLimitLength.left) / Math.abs(cos);\n limitLabelLength = Math.min(lengthLimit, verticalSizeLimit);\n } else {\n limitLabelLength = verticalSizeLimit;\n }\n } else {\n // y轴暂时不限制在平行于坐标轴的矩形内,后续可以考虑通过配置开启\n // const { y1, y2 } = label.AABBBounds;\n // const tan = sin / cos;\n // if (tan > 0 && y2 >= 0 && y2 - tan * limitLength < 0) {\n // limitLabelLength = y2 / Math.abs(sin);\n // } else if (tan < 0 && y1 <= axisLength && y1 - tan * limitLength > axisLength) {\n // limitLabelLength = (axisLength - y1) / Math.abs(sin);\n // } else {\n // }\n limitLabelLength = Math.abs(limitLength / cos);\n }\n } else if (isX) {\n limitLabelLength = isHorizontal ? verticalLimitLength : limitLength;\n } else {\n limitLabelLength = direction === 'vertical' || isVertical ? verticalLimitLength : limitLength;\n }\n\n if (isValidNumber(label.attribute.maxLineWidth)) {\n limitLabelLength = isValidNumber(limitLabelLength)\n ? Math.min(label.attribute.maxLineWidth, limitLabelLength)\n : label.attribute.maxLineWidth;\n }\n label.setAttributes({\n maxLineWidth: limitLabelLength,\n ellipsis: label.attribute.ellipsis ?? ellipsis\n });\n });\n}\n"]}
@@ -9,16 +9,22 @@ const vutils_1 = require("@visactor/vutils"), util_1 = require("./util");
9
9
  function autoWrap(labels, config) {
10
10
  const {limitLength: limitLength, axisLength: axisLength, ellipsis: ellipsis = "...", orient: orient} = config;
11
11
  if ((0, vutils_1.isEmpty)(labels) || !(0, vutils_1.isValidNumber)(limitLength)) return;
12
- const verticalLimitLength = axisLength / labels.length;
13
- labels.forEach((label => {
14
- var _a;
15
- const angle = label.attribute.angle, isHorizontal = (0, util_1.isAngleHorizontal)(angle), isVertical = (0,
16
- util_1.isAngleVertical)(angle), isX = "top" === orient || "bottom" === orient;
12
+ const angle = labels[0].attribute.angle, isHorizontal = (0, util_1.isAngleHorizontal)(angle), isVertical = (0,
13
+ util_1.isAngleVertical)(angle), isX = "top" === orient || "bottom" === orient;
14
+ let verticalLimitLength = axisLength / labels.length;
15
+ labels.forEach(((label, index) => {
16
+ var _a, _b, _c, _d, _e;
17
17
  if (isX) {
18
18
  if (isVertical && Math.floor(label.AABBBounds.height()) <= limitLength) return;
19
- if (isHorizontal && Math.floor(label.AABBBounds.width()) <= verticalLimitLength) return;
19
+ if (isHorizontal) {
20
+ const minGap = getLabelMinGap(label.attribute.x, null === (_a = labels[index + 1]) || void 0 === _a ? void 0 : _a.attribute.x, null === (_b = labels[index - 1]) || void 0 === _b ? void 0 : _b.attribute.x);
21
+ (0, vutils_1.isValidNumber)(minGap) && (verticalLimitLength = (0, vutils_1.min)(verticalLimitLength, minGap));
22
+ }
20
23
  } else {
21
- if (isVertical && Math.floor(label.AABBBounds.height()) <= verticalLimitLength) return;
24
+ if (isVertical) {
25
+ const minGap = getLabelMinGap(label.attribute.y, null === (_c = labels[index + 1]) || void 0 === _c ? void 0 : _c.attribute.y, null === (_d = labels[index - 1]) || void 0 === _d ? void 0 : _d.attribute.y);
26
+ (0, vutils_1.isValidNumber)(minGap) && (verticalLimitLength = (0, vutils_1.min)(verticalLimitLength, minGap));
27
+ }
22
28
  if (isHorizontal && Math.floor(label.AABBBounds.width()) <= limitLength) return;
23
29
  }
24
30
  let limitLabelLength = null, heightLimit = null;
@@ -27,12 +33,19 @@ function autoWrap(labels, config) {
27
33
  heightLimit = limitLength) : (limitLabelLength = limitLength, heightLimit = verticalLimitLength),
28
34
  label.setAttributes({
29
35
  maxLineWidth: limitLabelLength,
30
- ellipsis: null !== (_a = label.attribute.ellipsis) && void 0 !== _a ? _a : ellipsis,
36
+ ellipsis: null !== (_e = label.attribute.ellipsis) && void 0 !== _e ? _e : ellipsis,
31
37
  whiteSpace: "normal",
32
38
  heightLimit: heightLimit
33
39
  });
34
40
  }));
35
41
  }
36
42
 
43
+ function getLabelMinGap(current, next, prev) {
44
+ let minGap;
45
+ return (0, vutils_1.isValidNumber)(next) && (minGap = Math.abs(next - current)),
46
+ (0, vutils_1.isValidNumber)(prev) && (minGap = (0, vutils_1.isValidNumber)(minGap) ? Math.min(Math.abs(current - prev), minGap) : Math.abs(current - prev)),
47
+ minGap;
48
+ }
49
+
37
50
  exports.autoWrap = autoWrap;
38
51
  //# sourceMappingURL=auto-wrap.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/axis/overlap/auto-wrap.ts"],"names":[],"mappings":";;;AACA,6CAA0D;AAC1D,iCAA4D;AAS5D,SAAgB,QAAQ,CAAC,MAAe,EAAE,MAAkB;IAC1D,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IACrE,IAAI,IAAA,gBAAO,EAAC,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CAAC;gBACvC,WAAW,GAAG,WAAW,CAAC;aAC3B;SACF;aAAM;YACL,IAAI,UAAU,EAAE;gBACd,gBAAgB,GAAG,mBAAmB,CAAC;gBACvC,WAAW,GAAG,WAAW,CAAC;aAC3B;iBAAM;gBACL,gBAAgB,GAAG,WAAW,CAAC;gBAC/B,WAAW,GAAG,mBAAmB,CAAC;aACnC;SACF;QAED,KAAK,CAAC,aAAa,CAAC;YAClB,YAAY,EAAE,gBAAgB;YAC9B,QAAQ,EAAE,MAAA,KAAK,CAAC,SAAS,CAAC,QAAQ,mCAAI,QAAQ;YAC9C,UAAU,EAAE,QAAQ;YACpB,WAAW;SACZ,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AA3DD,4BA2DC","file":"auto-wrap.js","sourcesContent":["import type { IText } from '@visactor/vrender-core';\nimport { isEmpty, isValidNumber } from '@visactor/vutils';\nimport { isAngleHorizontal, isAngleVertical } from './util';\n\ntype WrapConfig = {\n orient: string;\n limitLength: number;\n axisLength: number;\n ellipsis?: string;\n};\n\nexport function autoWrap(labels: IText[], config: WrapConfig) {\n const { limitLength, axisLength, ellipsis = '...', orient } = config;\n if (isEmpty(labels) || !isValidNumber(limitLength)) {\n return;\n }\n\n const verticalLimitLength = axisLength / labels.length;\n\n labels.forEach(label => {\n const angle = label.attribute.angle;\n\n const isHorizontal = isAngleHorizontal(angle);\n const isVertical = isAngleVertical(angle);\n const isX = orient === 'top' || orient === 'bottom';\n\n if (isX) {\n if (isVertical && Math.floor(label.AABBBounds.height()) <= limitLength) {\n return;\n }\n if (isHorizontal && Math.floor(label.AABBBounds.width()) <= verticalLimitLength) {\n return;\n }\n } else {\n if (isVertical && Math.floor(label.AABBBounds.height()) <= verticalLimitLength) {\n return;\n }\n if (isHorizontal && Math.floor(label.AABBBounds.width()) <= limitLength) {\n return;\n }\n }\n\n let limitLabelLength = null;\n let heightLimit = null;\n\n if (isX) {\n if (isVertical) {\n limitLabelLength = limitLength;\n heightLimit = verticalLimitLength;\n } else {\n limitLabelLength = verticalLimitLength;\n heightLimit = limitLength;\n }\n } else {\n if (isVertical) {\n limitLabelLength = verticalLimitLength;\n heightLimit = limitLength;\n } else {\n limitLabelLength = limitLength;\n heightLimit = verticalLimitLength;\n }\n }\n\n label.setAttributes({\n maxLineWidth: limitLabelLength,\n ellipsis: label.attribute.ellipsis ?? ellipsis,\n whiteSpace: 'normal',\n heightLimit\n });\n });\n}\n"]}
1
+ {"version":3,"sources":["../src/axis/overlap/auto-wrap.ts"],"names":[],"mappings":";;;AACA,6CAA+D;AAC/D,iCAA4D;AAS5D,SAAgB,QAAQ,CAAC,MAAe,EAAE,MAAkB;IAC1D,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IACrE,IAAI,IAAA,gBAAO,EAAC,MAAM,CAAC,IAAI,CAAC,IAAA,sBAAa,EAAC,WAAW,CAAC,EAAE;QAClD,OAAO;KACR;IAGD,MAAM,UAAU,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IAC7B,MAAM,KAAK,GAAG,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC;IACzC,MAAM,YAAY,GAAG,IAAA,wBAAiB,EAAC,KAAK,CAAC,CAAC;IAC9C,MAAM,UAAU,GAAG,IAAA,sBAAe,EAAC,KAAK,CAAC,CAAC;IAC1C,MAAM,GAAG,GAAG,MAAM,KAAK,KAAK,IAAI,MAAM,KAAK,QAAQ,CAAC;IAEpD,IAAI,mBAAmB,GAAG,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC;IAErD,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;;QAC9B,IAAI,GAAG,EAAE;YACP,IAAI,UAAU,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,IAAI,WAAW,EAAE;gBACtE,OAAO;aACR;YACD,IAAI,YAAY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EAAE;gBACd,gBAAgB,GAAG,WAAW,CAAC;gBAC/B,WAAW,GAAG,mBAAmB,CAAC;aACnC;iBAAM;gBACL,gBAAgB,GAAG,mBAAmB,CAAC;gBACvC,WAAW,GAAG,WAAW,CAAC;aAC3B;SACF;aAAM;YACL,IAAI,UAAU,EAAE;gBACd,gBAAgB,GAAG,mBAAmB,CAAC;gBACvC,WAAW,GAAG,WAAW,CAAC;aAC3B;iBAAM;gBACL,gBAAgB,GAAG,WAAW,CAAC;gBAC/B,WAAW,GAAG,mBAAmB,CAAC;aACnC;SACF;QACD,KAAK,CAAC,aAAa,CAAC;YAClB,YAAY,EAAE,gBAAgB;YAC9B,QAAQ,EAAE,MAAA,KAAK,CAAC,SAAS,CAAC,QAAQ,mCAAI,QAAQ;YAC9C,UAAU,EAAE,QAAQ;YACpB,WAAW;SACZ,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAvED,4BAuEC;AAED,SAAS,cAAc,CAAC,OAAe,EAAE,IAAa,EAAE,IAAa;IACnE,IAAI,MAAM,CAAC;IACX,IAAI,IAAA,sBAAa,EAAC,IAAI,CAAC,EAAE;QACvB,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,OAAO,CAAC,CAAC;KACnC;IAED,IAAI,IAAA,sBAAa,EAAC,IAAI,CAAC,EAAE;QACvB,IAAI,IAAA,sBAAa,EAAC,MAAM,CAAC,EAAE;YACzB,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC;SACrD;aAAM;YACL,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;SACnC;KACF;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","file":"auto-wrap.js","sourcesContent":["import type { IText } from '@visactor/vrender-core';\nimport { isEmpty, isValidNumber, min } from '@visactor/vutils';\nimport { isAngleHorizontal, isAngleVertical } from './util';\n\ntype WrapConfig = {\n orient: string;\n limitLength: number;\n axisLength: number;\n ellipsis?: string;\n};\n\nexport function autoWrap(labels: IText[], config: WrapConfig) {\n const { limitLength, axisLength, ellipsis = '...', orient } = config;\n if (isEmpty(labels) || !isValidNumber(limitLength)) {\n return;\n }\n\n // 注意:自动换行算法暂时只考虑所有标签角度都一致的情况\n const firstLabel = labels[0];\n const angle = firstLabel.attribute.angle;\n const isHorizontal = isAngleHorizontal(angle);\n const isVertical = isAngleVertical(angle);\n const isX = orient === 'top' || orient === 'bottom';\n\n let verticalLimitLength = axisLength / labels.length;\n\n labels.forEach((label, index) => {\n if (isX) {\n if (isVertical && Math.floor(label.AABBBounds.height()) <= limitLength) {\n return;\n }\n if (isHorizontal) {\n const curLabelX = label.attribute.x;\n const nextLabelX = labels[index + 1]?.attribute.x;\n const lastLabelX = labels[index - 1]?.attribute.x;\n const minGap = getLabelMinGap(curLabelX, nextLabelX, lastLabelX);\n if (isValidNumber(minGap)) {\n verticalLimitLength = min(verticalLimitLength, minGap);\n }\n }\n } else {\n if (isVertical) {\n const curLabelY = label.attribute.y;\n const nextLabelY = labels[index + 1]?.attribute.y;\n const lastLabelY = labels[index - 1]?.attribute.y;\n const minGap = getLabelMinGap(curLabelY, nextLabelY, lastLabelY);\n if (isValidNumber(minGap)) {\n verticalLimitLength = min(verticalLimitLength, minGap);\n }\n }\n if (isHorizontal && Math.floor(label.AABBBounds.width()) <= limitLength) {\n return;\n }\n }\n\n let limitLabelLength = null;\n let heightLimit = null;\n\n if (isX) {\n if (isVertical) {\n limitLabelLength = limitLength;\n heightLimit = verticalLimitLength;\n } else {\n limitLabelLength = verticalLimitLength;\n heightLimit = limitLength;\n }\n } else {\n if (isVertical) {\n limitLabelLength = verticalLimitLength;\n heightLimit = limitLength;\n } else {\n limitLabelLength = limitLength;\n heightLimit = verticalLimitLength;\n }\n }\n label.setAttributes({\n maxLineWidth: limitLabelLength,\n ellipsis: label.attribute.ellipsis ?? ellipsis,\n whiteSpace: 'normal',\n heightLimit\n });\n });\n}\n\nfunction getLabelMinGap(current: number, next?: number, prev?: number) {\n let minGap;\n if (isValidNumber(next)) {\n minGap = Math.abs(next - current);\n }\n\n if (isValidNumber(prev)) {\n if (isValidNumber(minGap)) {\n minGap = Math.min(Math.abs(current - prev), minGap);\n } else {\n minGap = Math.abs(current - prev);\n }\n }\n\n return minGap;\n}\n"]}
@@ -80,6 +80,10 @@ export interface LineAxisAttributes extends Omit<AxisBaseAttributes, 'label'> {
80
80
  breaks?: AxisBreakProps[];
81
81
  }
82
82
  export interface CircleAxisAttributes extends AxisBaseAttributes {
83
+ size?: {
84
+ width: number;
85
+ height: number;
86
+ };
83
87
  inside?: boolean;
84
88
  center: Point;
85
89
  startAngle?: number;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/axis/type.ts"],"names":[],"mappings":"","file":"type.js","sourcesContent":["import type {\n ILineGraphicAttribute,\n SymbolType,\n ITextGraphicAttribute,\n ISymbolGraphicAttribute,\n IRectGraphicAttribute,\n IGroupGraphicAttribute,\n IText,\n IGroup,\n IGraphic\n} from '@visactor/vrender-core';\nimport type { Dict } from '@visactor/vutils';\nimport type { ContinuousScale, CustomTicksFunc } from '@visactor/vscale';\nimport type { Point, TextContent } from '../core/type';\nimport type { SegmentAttributes } from '../segment';\nimport type { TagAttributes } from '../tag';\n\nexport type AxisItemStateStyle<T> = {\n hover?: T;\n hover_reverse?: T;\n selected?: T;\n selected_reverse?: T;\n};\n\nexport type callbackFunc<T> = (datum: Dict<any>, index: number, data?: Dict<any>[], layer?: number) => T;\n\n// 处理过的用于绘制的 tickLine 数据\nexport type TickLineItem = {\n start: Point;\n end: Point;\n /** 归一化后的数据 */\n value: number;\n // 3d数据\n anchor?: [number, number];\n alpha?: number;\n beta?: number;\n [key: string]: any;\n};\n\n// 处理过的用于绘制的数据\nexport type TransformedAxisItem = AxisItem & {\n point: Point;\n};\n\nexport type AxisItem = {\n /** 标识符,用于动画以及图形查找 */\n id?: string | number;\n /** 显示文本 */\n label: string | number;\n /** 归一化后的数据 */\n value: number;\n /** 对应原始数据 */\n rawValue: any;\n [key: string]: any;\n};\n\nexport interface AxisBaseAttributes extends IGroupGraphicAttribute {\n /**\n * 是否开启选中交互\n * @default false\n */\n select?: boolean;\n /**\n * 是否开启 hover 交互\n * @default false\n */\n hover?: boolean;\n /**\n * 垂直于坐标轴方向的因子,默认为 1\n */\n verticalFactor?: number;\n /**\n * 坐标轴的显示位置,用于文本的防重叠处理\n */\n orient?: string;\n /** 坐标轴数据 */\n items: AxisItem[][];\n /**\n * 轴标题配置\n */\n title?: TitleAttributes;\n /**\n * 轴标签配置\n */\n label?: LabelAttributes;\n /**\n * 轴刻度线配置\n */\n tick?: TickAttributes;\n /**\n * 自刻度线配置\n */\n subTick?: SubTickAttributes;\n /**\n * 轴线配置\n */\n line?: LineAttributes;\n /**\n * 关闭交互效果\n * @default false\n */\n disableTriggerEvent?: boolean;\n}\n\nexport interface ILine3dType {\n alpha: number;\n anchor3d?: [number, number];\n}\n\nexport interface BreakSymbol {\n /**\n * 是否显示\n */\n visible?: boolean;\n /**\n * 截断图形旋转的弧度。\n */\n angle?: number;\n\n /**\n * 样式配置\n */\n style?: Partial<ISymbolGraphicAttribute>;\n}\nexport interface AxisBreakProps {\n /**\n * 轴截断的范围,值为归一化后的数据\n */\n range: [number, number];\n /**\n * 截断图形配置\n */\n breakSymbol?: BreakSymbol;\n /**\n * 轴截断原始的数据范围\n */\n rawRange?: [number, number];\n}\n\nexport interface TransformedAxisBreak extends AxisBreakProps {\n /**\n * 截断的起始点\n */\n startPoint: Point;\n /**\n * 截断的结束点\n */\n endPoint: Point;\n}\n\nexport interface LineAxisAttributes extends Omit<AxisBaseAttributes, 'label'> {\n /**\n * 起始点坐标\n */\n start: Point;\n /**\n * 结束点坐标\n */\n end: Point;\n /**\n * 坐标轴垂直方向的限制空间,该配置会影响文本的显示,\n * 即如果超出,文本则会进行自动旋转、自动隐藏等动作。\n */\n verticalLimitSize?: number;\n /**\n * 坐标轴垂直方向的最小空间,如果小于该值,则以该值占据显示空间。\n * 如果同时声明了 verticalLimitSize,请保证 verticalMinSize <= verticalLimitSize,否则会以 verticalLimitSize 为准。\n */\n verticalMinSize?: number;\n\n /**\n * 轴标签配置\n */\n label?: LabelAttributes & {\n /**\n * label 相对于容器整体的对齐方式\n * - `top`:整体向上对齐(垂直方向)\n * - `middle`:整体居中对齐(垂直方向)\n * - `bottom`:整体向下对齐(垂直方向)\n * - `left`:整体向左对齐(水平方向)\n * - `center`:整体居中对齐(水平方向)\n * - `right`:整体向右对齐(水平方向)\n */\n containerAlign?: 'left' | 'right' | 'center' | 'top' | 'bottom' | 'middle';\n /**\n * 坐标轴首尾文字向内收缩\n * @default false\n */\n flush?: boolean;\n /**\n * 保证最后的label必须展示\n * @default false\n * @since 0.17.10\n */\n lastVisible?: boolean;\n /**\n * 保证第一个的label必须展示\n * @default false\n * @since 0.20.7\n */\n firstVisible?: boolean;\n };\n /**\n * 坐标轴背景配置\n */\n panel?: {\n /**\n * 是否绘制坐标轴背景\n */\n visible?: boolean;\n /**\n * 坐标轴背景配置\n */\n style?: Partial<IRectGraphicAttribute>;\n /**\n * 坐标轴背景交互状态样式配置\n */\n state?: AxisItemStateStyle<Partial<IRectGraphicAttribute>>;\n };\n\n /**\n * 轴截断配置\n * @since 0.20.3\n */\n breaks?: AxisBreakProps[];\n}\n\nexport interface CircleAxisAttributes extends AxisBaseAttributes {\n /**\n * 当配置了 innerRadius 时,可以通过设置 inside: true,将坐标轴战士在内圆半径上。\n * @default false\n */\n inside?: boolean;\n /**\n * 圆心坐标\n */\n center: Point;\n /**\n * **弧度值**,起始弧度,默认 -0.5 * Math.PI\n *\n */\n startAngle?: number;\n /**\n * **弧度值**,结束弧度,默认 1.5 * Math.PI\n */\n endAngle?: number;\n /**\n * 半径\n */\n radius: number;\n /** 内半径 */\n innerRadius?: number;\n /**\n * 边数\n * @since 0.19.24\n */\n sides?: number;\n}\n\n// 坐标轴标题配置\nexport type TitleAttributes = Omit<TagAttributes, 'shape' | 'space' | 'panel' | 'state'> & {\n /**\n * 是否展示标题\n */\n visible?: boolean;\n /**\n * 标题的显示位置,默认 'middle'\n */\n position?: 'start' | 'middle' | 'end';\n /**\n * 标题距离坐标轴(轴线、刻度、标签共同构成的包围盒)的距离\n */\n space?: number;\n /**\n * 标题是否自动旋转以和坐标轴平行\n */\n autoRotate?: boolean;\n shape?: {\n /**\n * 是否展示 shape\n */\n visible?: boolean;\n /**\n * shape 同 文本的间距\n */\n space?: number;\n style?: Omit<Partial<ISymbolGraphicAttribute>, 'visible'>;\n };\n /**\n * 背景设置\n */\n background?: {\n /**\n * 是否绘制背景层\n */\n visible?: boolean;\n /**\n * 背景层样式\n */\n style?: Omit<Partial<IRectGraphicAttribute>, 'visible' | 'width' | 'height'>;\n };\n\n /**\n * 交互状态样式配置\n */\n state?: {\n /**\n * text 文本的状态配置\n */\n text?: AxisItemStateStyle<Partial<ITextGraphicAttribute>>;\n /**\n * shape 标记的状态配置\n */\n shape?: AxisItemStateStyle<Partial<ISymbolGraphicAttribute>>;\n /**\n * panel 背景的状态配置\n */\n background?: AxisItemStateStyle<Partial<IRectGraphicAttribute>>;\n };\n};\n// 坐标轴线配置\nexport interface LineAttributes extends Pick<SegmentAttributes, 'startSymbol' | 'endSymbol'> {\n /**\n * 是否展示轴线\n */\n visible?: boolean;\n /**\n * 线的样式配置\n */\n style?: Partial<ILineGraphicAttribute>;\n state?: AxisItemStateStyle<Partial<ILineGraphicAttribute>>;\n}\n\n// 轴刻度线配置\nexport interface TickAttributes {\n /** 是否显示轴刻度线 */\n visible: boolean;\n /**\n * 刻度线朝向,默认朝外(坐标线包围盒外部)\n * @default false\n */\n inside?: boolean;\n /**\n * tick 是否与 label 对齐\n * @default true\n */\n alignWithLabel?: boolean;\n /**\n * 刻度线的长度\n */\n length?: number;\n /**\n * 刻度线样式配置\n */\n style?: Partial<ILineGraphicAttribute> | callbackFunc<Partial<ILineGraphicAttribute> | undefined>;\n /**\n * 刻度线状态样式配置\n */\n state?: AxisItemStateStyle<Partial<ILineGraphicAttribute> | callbackFunc<Partial<ILineGraphicAttribute> | undefined>>;\n /**\n * 用于 tick 的数据过滤\n * @param data\n * @returns\n */\n dataFilter?: (data: AxisItem[]) => AxisItem[];\n}\n\n// 子轴刻度线配置\nexport interface SubTickAttributes {\n /** 是否显示子轴刻度线 */\n visible: boolean;\n /**\n * TODO: 考虑下 log 轴,自刻度线之间的间距是不均匀的问题\n * 子刻度个数\n */\n count?: number;\n /**\n * 子刻度线朝向,默认朝外(坐标线包围盒外部)\n * @default false\n */\n inside?: boolean;\n /**\n * 子刻度线的长度\n */\n length?: number;\n /**\n * 子刻度线样式配置\n */\n style?: Partial<ILineGraphicAttribute> | callbackFunc<Partial<ILineGraphicAttribute> | undefined>;\n /**\n * 子刻度线状态样式配置\n */\n state?: AxisItemStateStyle<Partial<ILineGraphicAttribute> | callbackFunc<Partial<ILineGraphicAttribute> | undefined>>;\n}\n\nexport type CustomMethod = (items: IText[], separation: number) => IText[];\n\nexport interface AxisLabelOverlap {\n /**\n * 自动旋转配置\n * @default false\n */\n autoRotate?: boolean;\n /**\n * 仅当 `autoRotate` 为 true 时生效,可选的旋转范围,默认为 [0, 45, 90]\n * @default [0, 45, 90]\n */\n autoRotateAngle?: number[];\n /**\n * 自动隐藏配置\n * @default false\n */\n autoHide?: boolean;\n /**\n * 防重叠策略,默认为 'parity'。\n * - 'parity': 奇偶校验,使用删除所有其他标签的策略(这对于标准线性轴非常有效)。\n * - 'greedy': 将执行标签的线性扫描,并删除与最后一个可见标签重叠的所有标签。\n * - 也可以传入函数用于自定义策略\n * @default 'parity'\n */\n autoHideMethod?: 'parity' | 'greedy' | CustomMethod;\n /**\n * 仅当 `autoHide` 为 true 时生效,设置文本之间的间隔距离,单位 px\n * @default 0\n */\n autoHideSeparation?: number;\n /**\n * 自动隐藏配置\n * @default false\n */\n autoLimit?: boolean;\n /**\n * 仅当 `autoLimit` 为 true 时生效,省略占位符,默认为 '...'\n * @default '...'\n */\n limitEllipsis?: string;\n /**\n * 文字超出坐标轴范围时,两侧可以提供扩充的空间大小。\n * 例如,x 轴坐标 135 度旋转时,左侧第一个标签可能超出坐标轴范围,导致文本被缩略,此时可以通过配置 `overflowLimitLength` 优化效果。\n * 仅当 `autoLimit` 为 true 时生效。\n * @default 0\n * @since 0.20.3 支持 X 轴配置生效\n */\n overflowLimitLength?:\n | number\n | {\n left?: number;\n right?: number;\n // top?: number;\n // bottom?: number;\n };\n\n /**\n * 自定义布局配置,如果声明了 `layoutFunc`,则默认提供的防重叠相关的配置(`autoHide`, `autoRotate`, `autoLimit`)均不生效\n * @param labels 标签图形元素\n * @param labelData 标签数据\n * @param layer 当前轴的层级\n * @param axis 当前轴组件实例\n * @returns void\n */\n layoutFunc?: (labels: IText[], labelData: AxisItem[], layer: number, axis: IGroup) => void;\n\n /**\n * 标签自动换行。与 `autoRotate` 不能同时生效,若开启了 `autoRotate`,则优先使用自动旋转策略。\n * @since 0.20.3\n * @default false\n */\n autoWrap?: boolean;\n}\n\nexport type LabelAttributes = Omit<AxisLabelOverlap, 'text'> &\n TextContent & {\n /** 是否展示标签 */\n visible: boolean;\n /**\n * 标签朝向,默认朝外(坐标线包围盒外部)\n * @default false\n */\n inside?: boolean;\n /** 标签同 tick 之间的间距 */\n space?: number;\n /**\n * 格式化文本回调\n * @param text 文本原始值\n * @param item 对应的图形元素\n * @param index 文本索引顺序\n * @returns 格式化文本\n */\n formatMethod?: (value: string, datum: Dict<any>, index: number, data?: Dict<any>[], layer?: number) => string;\n /**\n * 文本样式\n */\n style?: Partial<ITextGraphicAttribute> | callbackFunc<Partial<ITextGraphicAttribute> | undefined>;\n /**\n * 文本状态样式配置\n */\n state?: AxisItemStateStyle<\n Partial<ITextGraphicAttribute> | callbackFunc<Partial<ITextGraphicAttribute> | undefined>\n >;\n\n /**\n * 用于 label 的数据过滤\n * @param data\n * @param layer\n * @returns\n */\n dataFilter?: (data: AxisItem[], layer: number) => AxisItem[];\n };\n\nexport type CoordinateType = 'cartesian' | 'polar' | 'geo' | 'none';\nexport type IOrientType = 'left' | 'top' | 'right' | 'bottom' | 'z';\nexport type IPolarOrientType = 'radius' | 'angle';\n\ntype breakData = {\n /**\n * 截断后的值域范围\n */\n domain?: [number, number][];\n /**\n * 截断后的归一化范围\n */\n scope?: [number, number][];\n /**\n * 用户配置的截断范围\n */\n breakDomains: [number, number][];\n};\n\nexport interface ITickDataOpt {\n /**\n * 是否进行轴采样\n */\n sampling?: boolean;\n tickCount?: number | ((option: ITickCallbackOption) => number);\n forceTickCount?: number;\n tickStep?: number;\n tickMode?: 'average' | 'd3' | string | CustomTicksFunc<ContinuousScale>;\n noDecimals?: boolean;\n\n coordinateType: CoordinateType;\n axisOrientType: IOrientType | IPolarOrientType;\n startAngle?: number;\n\n labelFormatter?: (value: any) => string;\n labelStyle: ITextGraphicAttribute;\n labelGap?: number;\n labelFirstVisible?: boolean;\n labelLastVisible?: boolean;\n /**\n * 截断数据范围配置\n */\n breakData?: () => breakData;\n}\n\nexport interface ICartesianTickDataOpt extends ITickDataOpt {\n axisOrientType: IOrientType;\n labelFlush: boolean;\n /**\n * 截断数据范围配置\n */\n breakData?: () => breakData;\n}\n\nexport interface IPolarTickDataOpt extends ITickDataOpt {\n axisOrientType: IPolarOrientType;\n getRadius: () => number;\n labelOffset: number;\n inside: boolean;\n}\n\nexport interface ITickData {\n index: number;\n value: number | string;\n // label: string;\n}\n\nexport type ITickCallbackOption = {\n /**\n * 坐标轴占据的画布大小。\n * 直角坐标系中为轴的宽度或高度。\n * 极坐标系中半径轴的长度。\n */\n axisLength?: number;\n /**\n * 轴标签的样式\n */\n labelStyle?: ITextGraphicAttribute;\n};\n\nexport interface ILabelItem<T> extends Pick<IGraphic, 'AABBBounds'> {\n value?: T;\n}\n"]}
1
+ {"version":3,"sources":["../src/axis/type.ts"],"names":[],"mappings":"","file":"type.js","sourcesContent":["import type {\n ILineGraphicAttribute,\n SymbolType,\n ITextGraphicAttribute,\n ISymbolGraphicAttribute,\n IRectGraphicAttribute,\n IGroupGraphicAttribute,\n IText,\n IGroup,\n IGraphic\n} from '@visactor/vrender-core';\nimport type { Dict } from '@visactor/vutils';\nimport type { ContinuousScale, CustomTicksFunc } from '@visactor/vscale';\nimport type { Point, TextContent } from '../core/type';\nimport type { SegmentAttributes } from '../segment';\nimport type { TagAttributes } from '../tag';\n\nexport type AxisItemStateStyle<T> = {\n hover?: T;\n hover_reverse?: T;\n selected?: T;\n selected_reverse?: T;\n};\n\nexport type callbackFunc<T> = (datum: Dict<any>, index: number, data?: Dict<any>[], layer?: number) => T;\n\n// 处理过的用于绘制的 tickLine 数据\nexport type TickLineItem = {\n start: Point;\n end: Point;\n /** 归一化后的数据 */\n value: number;\n // 3d数据\n anchor?: [number, number];\n alpha?: number;\n beta?: number;\n [key: string]: any;\n};\n\n// 处理过的用于绘制的数据\nexport type TransformedAxisItem = AxisItem & {\n point: Point;\n};\n\nexport type AxisItem = {\n /** 标识符,用于动画以及图形查找 */\n id?: string | number;\n /** 显示文本 */\n label: string | number;\n /** 归一化后的数据 */\n value: number;\n /** 对应原始数据 */\n rawValue: any;\n [key: string]: any;\n};\n\nexport interface AxisBaseAttributes extends IGroupGraphicAttribute {\n /**\n * 是否开启选中交互\n * @default false\n */\n select?: boolean;\n /**\n * 是否开启 hover 交互\n * @default false\n */\n hover?: boolean;\n /**\n * 垂直于坐标轴方向的因子,默认为 1\n */\n verticalFactor?: number;\n /**\n * 坐标轴的显示位置,用于文本的防重叠处理\n */\n orient?: string;\n /** 坐标轴数据 */\n items: AxisItem[][];\n /**\n * 轴标题配置\n */\n title?: TitleAttributes;\n /**\n * 轴标签配置\n */\n label?: LabelAttributes;\n /**\n * 轴刻度线配置\n */\n tick?: TickAttributes;\n /**\n * 自刻度线配置\n */\n subTick?: SubTickAttributes;\n /**\n * 轴线配置\n */\n line?: LineAttributes;\n /**\n * 关闭交互效果\n * @default false\n */\n disableTriggerEvent?: boolean;\n}\n\nexport interface ILine3dType {\n alpha: number;\n anchor3d?: [number, number];\n}\n\nexport interface BreakSymbol {\n /**\n * 是否显示\n */\n visible?: boolean;\n /**\n * 截断图形旋转的弧度。\n */\n angle?: number;\n\n /**\n * 样式配置\n */\n style?: Partial<ISymbolGraphicAttribute>;\n}\nexport interface AxisBreakProps {\n /**\n * 轴截断的范围,值为归一化后的数据\n */\n range: [number, number];\n /**\n * 截断图形配置\n */\n breakSymbol?: BreakSymbol;\n /**\n * 轴截断原始的数据范围\n */\n rawRange?: [number, number];\n}\n\nexport interface TransformedAxisBreak extends AxisBreakProps {\n /**\n * 截断的起始点\n */\n startPoint: Point;\n /**\n * 截断的结束点\n */\n endPoint: Point;\n}\n\nexport interface LineAxisAttributes extends Omit<AxisBaseAttributes, 'label'> {\n /**\n * 起始点坐标\n */\n start: Point;\n /**\n * 结束点坐标\n */\n end: Point;\n /**\n * 坐标轴垂直方向的限制空间,该配置会影响文本的显示,\n * 即如果超出,文本则会进行自动旋转、自动隐藏等动作。\n */\n verticalLimitSize?: number;\n /**\n * 坐标轴垂直方向的最小空间,如果小于该值,则以该值占据显示空间。\n * 如果同时声明了 verticalLimitSize,请保证 verticalMinSize <= verticalLimitSize,否则会以 verticalLimitSize 为准。\n */\n verticalMinSize?: number;\n\n /**\n * 轴标签配置\n */\n label?: LabelAttributes & {\n /**\n * label 相对于容器整体的对齐方式\n * - `top`:整体向上对齐(垂直方向)\n * - `middle`:整体居中对齐(垂直方向)\n * - `bottom`:整体向下对齐(垂直方向)\n * - `left`:整体向左对齐(水平方向)\n * - `center`:整体居中对齐(水平方向)\n * - `right`:整体向右对齐(水平方向)\n */\n containerAlign?: 'left' | 'right' | 'center' | 'top' | 'bottom' | 'middle';\n /**\n * 坐标轴首尾文字向内收缩\n * @default false\n */\n flush?: boolean;\n /**\n * 保证最后的label必须展示\n * @default false\n * @since 0.17.10\n */\n lastVisible?: boolean;\n /**\n * 保证第一个的label必须展示\n * @default false\n * @since 0.20.7\n */\n firstVisible?: boolean;\n };\n /**\n * 坐标轴背景配置\n */\n panel?: {\n /**\n * 是否绘制坐标轴背景\n */\n visible?: boolean;\n /**\n * 坐标轴背景配置\n */\n style?: Partial<IRectGraphicAttribute>;\n /**\n * 坐标轴背景交互状态样式配置\n */\n state?: AxisItemStateStyle<Partial<IRectGraphicAttribute>>;\n };\n\n /**\n * 轴截断配置\n * @since 0.20.3\n */\n breaks?: AxisBreakProps[];\n}\n\nexport interface CircleAxisAttributes extends AxisBaseAttributes {\n /**\n * 坐标轴可用布局区域的大小,之前是通过width,height传入,会影响组件的Bounds大小,影响拾取\n * @since 0.20.11\n */\n size?: { width: number; height: number };\n /**\n * 当配置了 innerRadius 时,可以通过设置 inside: true,将坐标轴战士在内圆半径上。\n * @default false\n */\n inside?: boolean;\n /**\n * 圆心坐标\n */\n center: Point;\n /**\n * **弧度值**,起始弧度,默认 -0.5 * Math.PI\n *\n */\n startAngle?: number;\n /**\n * **弧度值**,结束弧度,默认 1.5 * Math.PI\n */\n endAngle?: number;\n /**\n * 半径\n */\n radius: number;\n /** 内半径 */\n innerRadius?: number;\n /**\n * 边数\n * @since 0.19.24\n */\n sides?: number;\n}\n\n// 坐标轴标题配置\nexport type TitleAttributes = Omit<TagAttributes, 'shape' | 'space' | 'panel' | 'state'> & {\n /**\n * 是否展示标题\n */\n visible?: boolean;\n /**\n * 标题的显示位置,默认 'middle'\n */\n position?: 'start' | 'middle' | 'end';\n /**\n * 标题距离坐标轴(轴线、刻度、标签共同构成的包围盒)的距离\n */\n space?: number;\n /**\n * 标题是否自动旋转以和坐标轴平行\n */\n autoRotate?: boolean;\n shape?: {\n /**\n * 是否展示 shape\n */\n visible?: boolean;\n /**\n * shape 同 文本的间距\n */\n space?: number;\n style?: Omit<Partial<ISymbolGraphicAttribute>, 'visible'>;\n };\n /**\n * 背景设置\n */\n background?: {\n /**\n * 是否绘制背景层\n */\n visible?: boolean;\n /**\n * 背景层样式\n */\n style?: Omit<Partial<IRectGraphicAttribute>, 'visible' | 'width' | 'height'>;\n };\n\n /**\n * 交互状态样式配置\n */\n state?: {\n /**\n * text 文本的状态配置\n */\n text?: AxisItemStateStyle<Partial<ITextGraphicAttribute>>;\n /**\n * shape 标记的状态配置\n */\n shape?: AxisItemStateStyle<Partial<ISymbolGraphicAttribute>>;\n /**\n * panel 背景的状态配置\n */\n background?: AxisItemStateStyle<Partial<IRectGraphicAttribute>>;\n };\n};\n// 坐标轴线配置\nexport interface LineAttributes extends Pick<SegmentAttributes, 'startSymbol' | 'endSymbol'> {\n /**\n * 是否展示轴线\n */\n visible?: boolean;\n /**\n * 线的样式配置\n */\n style?: Partial<ILineGraphicAttribute>;\n state?: AxisItemStateStyle<Partial<ILineGraphicAttribute>>;\n}\n\n// 轴刻度线配置\nexport interface TickAttributes {\n /** 是否显示轴刻度线 */\n visible: boolean;\n /**\n * 刻度线朝向,默认朝外(坐标线包围盒外部)\n * @default false\n */\n inside?: boolean;\n /**\n * tick 是否与 label 对齐\n * @default true\n */\n alignWithLabel?: boolean;\n /**\n * 刻度线的长度\n */\n length?: number;\n /**\n * 刻度线样式配置\n */\n style?: Partial<ILineGraphicAttribute> | callbackFunc<Partial<ILineGraphicAttribute> | undefined>;\n /**\n * 刻度线状态样式配置\n */\n state?: AxisItemStateStyle<Partial<ILineGraphicAttribute> | callbackFunc<Partial<ILineGraphicAttribute> | undefined>>;\n /**\n * 用于 tick 的数据过滤\n * @param data\n * @returns\n */\n dataFilter?: (data: AxisItem[]) => AxisItem[];\n}\n\n// 子轴刻度线配置\nexport interface SubTickAttributes {\n /** 是否显示子轴刻度线 */\n visible: boolean;\n /**\n * TODO: 考虑下 log 轴,自刻度线之间的间距是不均匀的问题\n * 子刻度个数\n */\n count?: number;\n /**\n * 子刻度线朝向,默认朝外(坐标线包围盒外部)\n * @default false\n */\n inside?: boolean;\n /**\n * 子刻度线的长度\n */\n length?: number;\n /**\n * 子刻度线样式配置\n */\n style?: Partial<ILineGraphicAttribute> | callbackFunc<Partial<ILineGraphicAttribute> | undefined>;\n /**\n * 子刻度线状态样式配置\n */\n state?: AxisItemStateStyle<Partial<ILineGraphicAttribute> | callbackFunc<Partial<ILineGraphicAttribute> | undefined>>;\n}\n\nexport type CustomMethod = (items: IText[], separation: number) => IText[];\n\nexport interface AxisLabelOverlap {\n /**\n * 自动旋转配置\n * @default false\n */\n autoRotate?: boolean;\n /**\n * 仅当 `autoRotate` 为 true 时生效,可选的旋转范围,默认为 [0, 45, 90]\n * @default [0, 45, 90]\n */\n autoRotateAngle?: number[];\n /**\n * 自动隐藏配置\n * @default false\n */\n autoHide?: boolean;\n /**\n * 防重叠策略,默认为 'parity'。\n * - 'parity': 奇偶校验,使用删除所有其他标签的策略(这对于标准线性轴非常有效)。\n * - 'greedy': 将执行标签的线性扫描,并删除与最后一个可见标签重叠的所有标签。\n * - 也可以传入函数用于自定义策略\n * @default 'parity'\n */\n autoHideMethod?: 'parity' | 'greedy' | CustomMethod;\n /**\n * 仅当 `autoHide` 为 true 时生效,设置文本之间的间隔距离,单位 px\n * @default 0\n */\n autoHideSeparation?: number;\n /**\n * 自动隐藏配置\n * @default false\n */\n autoLimit?: boolean;\n /**\n * 仅当 `autoLimit` 为 true 时生效,省略占位符,默认为 '...'\n * @default '...'\n */\n limitEllipsis?: string;\n /**\n * 文字超出坐标轴范围时,两侧可以提供扩充的空间大小。\n * 例如,x 轴坐标 135 度旋转时,左侧第一个标签可能超出坐标轴范围,导致文本被缩略,此时可以通过配置 `overflowLimitLength` 优化效果。\n * 仅当 `autoLimit` 为 true 时生效。\n * @default 0\n * @since 0.20.3 支持 X 轴配置生效\n */\n overflowLimitLength?:\n | number\n | {\n left?: number;\n right?: number;\n // top?: number;\n // bottom?: number;\n };\n\n /**\n * 自定义布局配置,如果声明了 `layoutFunc`,则默认提供的防重叠相关的配置(`autoHide`, `autoRotate`, `autoLimit`)均不生效\n * @param labels 标签图形元素\n * @param labelData 标签数据\n * @param layer 当前轴的层级\n * @param axis 当前轴组件实例\n * @returns void\n */\n layoutFunc?: (labels: IText[], labelData: AxisItem[], layer: number, axis: IGroup) => void;\n\n /**\n * 标签自动换行。与 `autoRotate` 不能同时生效,若开启了 `autoRotate`,则优先使用自动旋转策略。\n * @since 0.20.3\n * @default false\n */\n autoWrap?: boolean;\n}\n\nexport type LabelAttributes = Omit<AxisLabelOverlap, 'text'> &\n TextContent & {\n /** 是否展示标签 */\n visible: boolean;\n /**\n * 标签朝向,默认朝外(坐标线包围盒外部)\n * @default false\n */\n inside?: boolean;\n /** 标签同 tick 之间的间距 */\n space?: number;\n /**\n * 格式化文本回调\n * @param text 文本原始值\n * @param item 对应的图形元素\n * @param index 文本索引顺序\n * @returns 格式化文本\n */\n formatMethod?: (value: string, datum: Dict<any>, index: number, data?: Dict<any>[], layer?: number) => string;\n /**\n * 文本样式\n */\n style?: Partial<ITextGraphicAttribute> | callbackFunc<Partial<ITextGraphicAttribute> | undefined>;\n /**\n * 文本状态样式配置\n */\n state?: AxisItemStateStyle<\n Partial<ITextGraphicAttribute> | callbackFunc<Partial<ITextGraphicAttribute> | undefined>\n >;\n\n /**\n * 用于 label 的数据过滤\n * @param data\n * @param layer\n * @returns\n */\n dataFilter?: (data: AxisItem[], layer: number) => AxisItem[];\n };\n\nexport type CoordinateType = 'cartesian' | 'polar' | 'geo' | 'none';\nexport type IOrientType = 'left' | 'top' | 'right' | 'bottom' | 'z';\nexport type IPolarOrientType = 'radius' | 'angle';\n\ntype breakData = {\n /**\n * 截断后的值域范围\n */\n domain?: [number, number][];\n /**\n * 截断后的归一化范围\n */\n scope?: [number, number][];\n /**\n * 用户配置的截断范围\n */\n breakDomains: [number, number][];\n};\n\nexport interface ITickDataOpt {\n /**\n * 是否进行轴采样\n */\n sampling?: boolean;\n tickCount?: number | ((option: ITickCallbackOption) => number);\n forceTickCount?: number;\n tickStep?: number;\n tickMode?: 'average' | 'd3' | string | CustomTicksFunc<ContinuousScale>;\n noDecimals?: boolean;\n\n coordinateType: CoordinateType;\n axisOrientType: IOrientType | IPolarOrientType;\n startAngle?: number;\n\n labelFormatter?: (value: any) => string;\n labelStyle: ITextGraphicAttribute;\n labelGap?: number;\n labelFirstVisible?: boolean;\n labelLastVisible?: boolean;\n /**\n * 截断数据范围配置\n */\n breakData?: () => breakData;\n}\n\nexport interface ICartesianTickDataOpt extends ITickDataOpt {\n axisOrientType: IOrientType;\n labelFlush: boolean;\n /**\n * 截断数据范围配置\n */\n breakData?: () => breakData;\n}\n\nexport interface IPolarTickDataOpt extends ITickDataOpt {\n axisOrientType: IPolarOrientType;\n getRadius: () => number;\n labelOffset: number;\n inside: boolean;\n}\n\nexport interface ITickData {\n index: number;\n value: number | string;\n // label: string;\n}\n\nexport type ITickCallbackOption = {\n /**\n * 坐标轴占据的画布大小。\n * 直角坐标系中为轴的宽度或高度。\n * 极坐标系中半径轴的长度。\n */\n axisLength?: number;\n /**\n * 轴标签的样式\n */\n labelStyle?: ITextGraphicAttribute;\n};\n\nexport interface ILabelItem<T> extends Pick<IGraphic, 'AABBBounds'> {\n value?: T;\n}\n"]}
package/cjs/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const version = "0.21.0-alpha.2";
1
+ export declare const version = "0.21.0-vstory.1";
2
2
  export * from './core/base';
3
3
  export * from './core/type';
4
4
  export * from './scrollbar';
@@ -26,4 +26,5 @@ export * from './jsx';
26
26
  export * from './checkbox';
27
27
  export * from './radio';
28
28
  export * from './empty-tip';
29
+ export * from './weather';
29
30
  export * from './util';
package/cjs/index.js CHANGED
@@ -17,7 +17,7 @@ var __createBinding = this && this.__createBinding || (Object.create ? function(
17
17
 
18
18
  Object.defineProperty(exports, "__esModule", {
19
19
  value: !0
20
- }), exports.version = void 0, exports.version = "0.21.0-alpha.2", __exportStar(require("./core/base"), exports),
20
+ }), exports.version = void 0, exports.version = "0.21.0-vstory.1", __exportStar(require("./core/base"), exports),
21
21
  __exportStar(require("./core/type"), exports), __exportStar(require("./scrollbar"), exports),
22
22
  __exportStar(require("./tag"), exports), __exportStar(require("./poptip"), exports),
23
23
  __exportStar(require("./crosshair"), exports), __exportStar(require("./label"), exports),
@@ -31,5 +31,5 @@ __exportStar(require("./brush"), exports), __exportStar(require("./tooltip"), ex
31
31
  __exportStar(require("./timeline"), exports), __exportStar(require("./interface"), exports),
32
32
  __exportStar(require("./jsx"), exports), __exportStar(require("./checkbox"), exports),
33
33
  __exportStar(require("./radio"), exports), __exportStar(require("./empty-tip"), exports),
34
- __exportStar(require("./util"), exports);
34
+ __exportStar(require("./weather"), exports), __exportStar(require("./util"), exports);
35
35
  //# sourceMappingURL=index.js.map
package/cjs/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACa,QAAA,OAAO,GAAG,gBAAgB,CAAC;AAExC,8CAA4B;AAC5B,8CAA4B;AAC5B,8CAA4B;AAC5B,wCAAsB;AACtB,2CAAyB;AACzB,8CAA4B;AAC5B,0CAAwB;AACxB,yCAAuB;AACvB,8CAA4B;AAC5B,4CAA0B;AAC1B,8CAA4B;AAC5B,2CAAyB;AACzB,0CAAwB;AACxB,2CAAyB;AACzB,0CAAwB;AACxB,8CAA4B;AAC5B,2CAAyB;AACzB,8CAA4B;AAC5B,2CAAyB;AACzB,0CAAwB;AACxB,4CAA0B;AAC1B,6CAA2B;AAC3B,8CAA4B;AAC5B,wCAAsB;AACtB,6CAA2B;AAC3B,0CAAwB;AACxB,8CAA4B;AAC5B,yCAAuB","file":"index.js","sourcesContent":["// 导出版本号\nexport const version = \"0.21.0-alpha.2\";\n\nexport * from './core/base';\nexport * from './core/type';\nexport * from './scrollbar';\nexport * from './tag';\nexport * from './poptip';\nexport * from './crosshair';\nexport * from './label';\nexport * from './axis';\nexport * from './axis/grid';\nexport * from './segment';\nexport * from './data-zoom';\nexport * from './marker';\nexport * from './pager';\nexport * from './legend';\nexport * from './title';\nexport * from './indicator';\nexport * from './slider';\nexport * from './link-path';\nexport * from './player';\nexport * from './brush';\nexport * from './tooltip';\nexport * from './timeline';\nexport * from './interface';\nexport * from './jsx';\nexport * from './checkbox';\nexport * from './radio';\nexport * from './empty-tip';\nexport * from './util';\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACa,QAAA,OAAO,GAAG,iBAAiB,CAAC;AAEzC,8CAA4B;AAC5B,8CAA4B;AAC5B,8CAA4B;AAC5B,wCAAsB;AACtB,2CAAyB;AACzB,8CAA4B;AAC5B,0CAAwB;AACxB,yCAAuB;AACvB,8CAA4B;AAC5B,4CAA0B;AAC1B,8CAA4B;AAC5B,2CAAyB;AACzB,0CAAwB;AACxB,2CAAyB;AACzB,0CAAwB;AACxB,8CAA4B;AAC5B,2CAAyB;AACzB,8CAA4B;AAC5B,2CAAyB;AACzB,0CAAwB;AACxB,4CAA0B;AAC1B,6CAA2B;AAC3B,8CAA4B;AAC5B,wCAAsB;AACtB,6CAA2B;AAC3B,0CAAwB;AACxB,8CAA4B;AAC5B,4CAA0B;AAC1B,yCAAuB","file":"index.js","sourcesContent":["// 导出版本号\nexport const version = \"0.21.0-vstory.1\";\n\nexport * from './core/base';\nexport * from './core/type';\nexport * from './scrollbar';\nexport * from './tag';\nexport * from './poptip';\nexport * from './crosshair';\nexport * from './label';\nexport * from './axis';\nexport * from './axis/grid';\nexport * from './segment';\nexport * from './data-zoom';\nexport * from './marker';\nexport * from './pager';\nexport * from './legend';\nexport * from './title';\nexport * from './indicator';\nexport * from './slider';\nexport * from './link-path';\nexport * from './player';\nexport * from './brush';\nexport * from './tooltip';\nexport * from './timeline';\nexport * from './interface';\nexport * from './jsx';\nexport * from './checkbox';\nexport * from './radio';\nexport * from './empty-tip';\nexport * from './weather';\nexport * from './util';\n"]}
@@ -1,4 +1,4 @@
1
- import type { ICustomPath2D, IGraphicAttribute, IGroup, IRectGraphicAttribute } from '@visactor/vrender-core';
1
+ import type { ICustomPath2D, IGraphicAttribute, IGroup, IRectGraphicAttribute, ITimeline } from '@visactor/vrender-core';
2
2
  export type Direction = 'horizontal' | 'vertical';
3
3
  export type OrientType = 'top' | 'right' | 'bottom' | 'left';
4
4
  export type BackgroundAttributes = {
@@ -9,4 +9,5 @@ export type IDelayType = 'debounce' | 'throttle';
9
9
  export interface ComponentOptions {
10
10
  skipDefault?: boolean;
11
11
  mode?: '2d' | '3d';
12
+ timeline?: ITimeline;
12
13
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/interface.ts"],"names":[],"mappings":"","file":"interface.js","sourcesContent":["import type {\n ICustomPath2D,\n IGraphicAttribute,\n IGroup,\n IRectGraphicAttribute,\n IRichText,\n IText\n} from '@visactor/vrender-core';\nimport type { TextContent } from './core/type';\n\nexport type Direction = 'horizontal' | 'vertical';\n\nexport type OrientType = 'top' | 'right' | 'bottom' | 'left';\n\nexport type BackgroundAttributes = {\n /**\n * 是否绘制背景层\n */\n visible: boolean;\n /**\n * 自定义路径\n * @since 0.19.19\n */\n customShape?: (container: IGroup, attrs: Partial<IGraphicAttribute>, path: ICustomPath2D) => ICustomPath2D;\n} & Partial<IRectGraphicAttribute>;\n\nexport type IDelayType = 'debounce' | 'throttle';\n\nexport interface ComponentOptions {\n /** skip default attributes of component */\n skipDefault?: boolean;\n /** the mode of component, only axis support 3d mode now */\n mode?: '2d' | '3d';\n}\n"]}
1
+ {"version":3,"sources":["../src/interface.ts"],"names":[],"mappings":"","file":"interface.js","sourcesContent":["import type {\n ICustomPath2D,\n IGraphicAttribute,\n IGroup,\n IRectGraphicAttribute,\n IRichText,\n IText,\n ITimeline\n} from '@visactor/vrender-core';\nimport type { TextContent } from './core/type';\n\nexport type Direction = 'horizontal' | 'vertical';\n\nexport type OrientType = 'top' | 'right' | 'bottom' | 'left';\n\nexport type BackgroundAttributes = {\n /**\n * 是否绘制背景层\n */\n visible: boolean;\n /**\n * 自定义路径\n * @since 0.19.19\n */\n customShape?: (container: IGroup, attrs: Partial<IGraphicAttribute>, path: ICustomPath2D) => ICustomPath2D;\n} & Partial<IRectGraphicAttribute>;\n\nexport type IDelayType = 'debounce' | 'throttle';\n\nexport interface ComponentOptions {\n /** skip default attributes of component */\n skipDefault?: boolean;\n /** the mode of component, only axis support 3d mode now */\n mode?: '2d' | '3d';\n /* 传递一个独立的timeline */\n timeline?: ITimeline;\n}\n"]}
@@ -2,9 +2,9 @@ import type { IGroup, IGraphic, IText, ILine, IRichText } from '@visactor/vrende
2
2
  import type { IAABBBounds, IBoundsLike, IPointLike } from '@visactor/vutils';
3
3
  import { AbstractComponent } from '../core/base';
4
4
  import type { PointLocationCfg } from '../core/type';
5
- import type { Bitmap } from './overlap';
5
+ import type { Bitmap, BitmapTool } from './overlap';
6
6
  import { bitmapTool } from './overlap';
7
- import type { BaseLabelAttrs, ILabelAnimation, LabelItem, ILabelEnterAnimation, ILabelExitAnimation, ILabelUpdateAnimation, LabelContent } from './type';
7
+ import type { BaseLabelAttrs, OverlapAttrs, ILabelAnimation, LabelItem, ILabelEnterAnimation, ILabelExitAnimation, ILabelUpdateAnimation, LabelContent } from './type';
8
8
  import type { ComponentOptions } from '../interface';
9
9
  export declare class LabelBase<T extends BaseLabelAttrs> extends AbstractComponent<T> {
10
10
  name: string;
@@ -49,6 +49,8 @@ export declare class LabelBase<T extends BaseLabelAttrs> extends AbstractCompone
49
49
  protected _initText(data?: LabelItem[]): (IText | IRichText)[];
50
50
  protected _layout(texts: (IText | IRichText)[]): (IText | IRichText)[];
51
51
  protected _overlapping(labels: (IText | IRichText)[]): (IRichText | IText)[];
52
+ protected _overlapGlobal(labels: (IText | IRichText)[], option: OverlapAttrs, bmpTool: BitmapTool, bitmap: Bitmap): (IRichText | IText)[];
53
+ protected _overlapByStrategy(labels: (IText | IRichText)[], option: OverlapAttrs, bmpTool: BitmapTool, bitmap: Bitmap): (IRichText | IText)[];
52
54
  protected getBaseMarkGroup(): IGroup;
53
55
  protected getGraphicBounds(graphic?: IGraphic, point?: Partial<PointLocationCfg>, position?: string): IBoundsLike;
54
56
  protected _renderLabels(labels: (IText | IRichText)[]): void;
package/cjs/label/base.js CHANGED
@@ -14,7 +14,7 @@ Object.defineProperty(exports, "__esModule", {
14
14
  value: !0
15
15
  }), exports.LabelBase = void 0;
16
16
 
17
- const vrender_core_1 = require("@visactor/vrender-core"), vutils_1 = require("@visactor/vutils"), base_1 = require("../core/base"), label_smartInvert_1 = require("../util/label-smartInvert"), util_1 = require("../util"), constant_1 = require("../constant"), overlap_1 = require("./overlap"), animate_1 = require("./animate/animate"), util_2 = require("./util"), register_1 = require("./register");
17
+ const vrender_core_1 = require("@visactor/vrender-core"), vutils_1 = require("@visactor/vutils"), base_1 = require("../core/base"), label_smartInvert_1 = require("../util/label-smartInvert"), util_1 = require("../util"), constant_1 = require("../constant"), overlap_1 = require("./overlap"), animate_1 = require("./animate/animate"), util_2 = require("./util"), register_1 = require("./register"), shiftY_1 = require("./overlap/shiftY");
18
18
 
19
19
  (0, register_1.loadLabelComponent)();
20
20
 
@@ -197,16 +197,43 @@ class LabelBase extends base_1.AbstractComponent {
197
197
  return texts;
198
198
  }
199
199
  _overlapping(labels) {
200
- var _a, _b, _c, _d;
200
+ var _a, _b, _c;
201
201
  if (0 === labels.length) return [];
202
- const option = (0, vutils_1.isObject)(this.attribute.overlap) ? this.attribute.overlap : {}, result = [], baseMarkGroup = this.getBaseMarkGroup(), size = null !== (_a = option.size) && void 0 !== _a ? _a : {
202
+ const option = (0, vutils_1.isObject)(this.attribute.overlap) ? this.attribute.overlap : {}, baseMarkGroup = this.getBaseMarkGroup(), size = null !== (_a = option.size) && void 0 !== _a ? _a : {
203
203
  width: null !== (_b = null == baseMarkGroup ? void 0 : baseMarkGroup.AABBBounds.width()) && void 0 !== _b ? _b : 0,
204
204
  height: null !== (_c = null == baseMarkGroup ? void 0 : baseMarkGroup.AABBBounds.height()) && void 0 !== _c ? _c : 0
205
205
  };
206
206
  if (0 === size.width || 0 === size.height) return labels;
207
- const {avoidBaseMark: avoidBaseMark, strategy: strategy = [], hideOnHit: hideOnHit = !0, clampForce: clampForce = !0, avoidMarks: avoidMarks = [], overlapPadding: overlapPadding} = option, bmpTool = this._bmpTool || (0,
208
- overlap_1.bitmapTool)(size.width, size.height), bitmap = this._bitmap || bmpTool.bitmap(), checkBounds = strategy.some((s => "bound" === s.type));
209
- avoidBaseMark && (null === (_d = this._baseMarks) || void 0 === _d || _d.forEach((mark => {
207
+ const {strategy: strategy, priority: priority} = option, bmpTool = this._bmpTool || (0,
208
+ overlap_1.bitmapTool)(size.width, size.height), bitmap = this._bitmap || bmpTool.bitmap();
209
+ return priority && (labels = labels.sort(((a, b) => priority(b.attribute.data) - priority(a.attribute.data)))),
210
+ "shiftY" === (null == strategy ? void 0 : strategy.type) ? this._overlapGlobal(labels, option, bmpTool, bitmap) : this._overlapByStrategy(labels, option, bmpTool, bitmap);
211
+ }
212
+ _overlapGlobal(labels, option, bmpTool, bitmap) {
213
+ let result = labels.filter((label => label.attribute.visible && 0 !== label.attribute.opacity));
214
+ const {clampForce: clampForce = !0, hideOnHit: hideOnHit = !0, overlapPadding: overlapPadding, strategy: strategy} = option;
215
+ if (clampForce) for (let i = 0; i < result.length; i++) {
216
+ const text = labels[i], {dx: dx = 0, dy: dy = 0} = (0, overlap_1.clampText)(text, bmpTool.width, bmpTool.height);
217
+ 0 === dx && 0 === dy || text.setAttributes({
218
+ x: text.attribute.x + dx,
219
+ y: text.attribute.y + dy
220
+ });
221
+ }
222
+ result = (0, shiftY_1.shiftY)(result, Object.assign({
223
+ maxY: bmpTool.height
224
+ }, strategy));
225
+ for (let i = 0; i < result.length; i++) {
226
+ const text = result[i], bounds = text.AABBBounds, range = (0, overlap_1.boundToRange)(bmpTool, bounds, !0);
227
+ (0, overlap_1.canPlace)(bmpTool, bitmap, bounds, clampForce, overlapPadding) ? bitmap.setRange(range) : hideOnHit ? text.setAttributes({
228
+ visible: !1
229
+ }) : bitmap.setRange(range);
230
+ }
231
+ return result;
232
+ }
233
+ _overlapByStrategy(labels, option, bmpTool, bitmap) {
234
+ var _a;
235
+ const {avoidBaseMark: avoidBaseMark, strategy: strategy = [], hideOnHit: hideOnHit = !0, clampForce: clampForce = !0, avoidMarks: avoidMarks = [], overlapPadding: overlapPadding} = option, result = [], checkBounds = strategy.some((s => "bound" === s.type));
236
+ avoidBaseMark && (null === (_a = this._baseMarks) || void 0 === _a || _a.forEach((mark => {
210
237
  mark.AABBBounds && bitmap.setRange((0, overlap_1.boundToRange)(bmpTool, mark.AABBBounds, !0));
211
238
  }))), avoidMarks.length > 0 && avoidMarks.forEach((avoid => {
212
239
  (0, vutils_1.isString)(avoid) ? (0, util_1.getNoneGroupMarksByName)(this.getRootNode(), avoid).forEach((avoidMark => {
@@ -214,7 +241,7 @@ class LabelBase extends base_1.AbstractComponent {
214
241
  })) : avoid.AABBBounds && bitmap.setRange((0, overlap_1.boundToRange)(bmpTool, avoid.AABBBounds, !0));
215
242
  }));
216
243
  for (let i = 0; i < labels.length; i++) {
217
- if (!1 === labels[i].visible) continue;
244
+ if (!1 === labels[i].attribute.visible) continue;
218
245
  const text = labels[i], baseMark = this.getRelatedGraphic(text.attribute);
219
246
  if (text.update(), !(0, vutils_1.isRectIntersect)(baseMark.AABBBounds, {
220
247
  x1: 0,