@visactor/vrender-components 0.19.4-alpha.3 → 0.19.4-alpha.5

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 (103) hide show
  1. package/cjs/axis/index.d.ts +1 -0
  2. package/cjs/axis/index.js +2 -1
  3. package/cjs/axis/index.js.map +1 -1
  4. package/cjs/axis/tick-data/continuous.d.ts +4 -0
  5. package/cjs/axis/tick-data/continuous.js +61 -0
  6. package/cjs/axis/tick-data/continuous.js.map +1 -0
  7. package/cjs/axis/tick-data/discrete/linear.d.ts +6 -0
  8. package/cjs/axis/tick-data/discrete/linear.js +101 -0
  9. package/cjs/axis/tick-data/discrete/linear.js.map +1 -0
  10. package/cjs/axis/tick-data/discrete/polar-angle.d.ts +3 -0
  11. package/cjs/axis/tick-data/discrete/polar-angle.js +53 -0
  12. package/cjs/axis/tick-data/discrete/polar-angle.js.map +1 -0
  13. package/cjs/axis/tick-data/index.d.ts +5 -0
  14. package/cjs/axis/tick-data/index.js +26 -0
  15. package/cjs/axis/tick-data/index.js.map +1 -0
  16. package/cjs/axis/tick-data/util.d.ts +13 -0
  17. package/cjs/axis/tick-data/util.js +91 -0
  18. package/cjs/axis/tick-data/util.js.map +1 -0
  19. package/cjs/axis/type.d.ts +41 -1
  20. package/cjs/axis/type.js.map +1 -1
  21. package/cjs/axis/util.d.ts +11 -0
  22. package/cjs/axis/util.js +21 -2
  23. package/cjs/axis/util.js.map +1 -1
  24. package/cjs/constant.d.ts +2 -2
  25. package/cjs/constant.js +2 -2
  26. package/cjs/constant.js.map +1 -1
  27. package/cjs/index.d.ts +1 -1
  28. package/cjs/index.js +1 -1
  29. package/cjs/index.js.map +1 -1
  30. package/cjs/label/arc.js +2 -1
  31. package/cjs/label/line.js +1 -1
  32. package/cjs/label/polygon.js +1 -1
  33. package/cjs/legend/base.js +1 -1
  34. package/cjs/legend/constant.js +1 -1
  35. package/cjs/legend/index.js +1 -1
  36. package/cjs/legend/register.js +1 -1
  37. package/cjs/legend/type.js +1 -2
  38. package/cjs/legend/util.js +1 -1
  39. package/cjs/link-path/index.js +1 -1
  40. package/cjs/link-path/link-path.js +1 -1
  41. package/cjs/link-path/register.js +1 -1
  42. package/cjs/link-path/type.js +1 -1
  43. package/cjs/player/discrete-player.js +6 -2
  44. package/cjs/player/discrete-player.js.map +1 -1
  45. package/cjs/player/type/base.d.ts +1 -0
  46. package/cjs/player/type/base.js.map +1 -1
  47. package/cjs/tooltip/util.js +1 -1
  48. package/cjs/tooltip/util.js.map +1 -1
  49. package/cjs/util/text.d.ts +1 -1
  50. package/cjs/util/text.js +3 -3
  51. package/cjs/util/text.js.map +1 -1
  52. package/es/axis/index.d.ts +1 -0
  53. package/es/axis/index.js +2 -0
  54. package/es/axis/index.js.map +1 -1
  55. package/es/axis/tick-data/continuous.d.ts +4 -0
  56. package/es/axis/tick-data/continuous.js +56 -0
  57. package/es/axis/tick-data/continuous.js.map +1 -0
  58. package/es/axis/tick-data/discrete/linear.d.ts +6 -0
  59. package/es/axis/tick-data/discrete/linear.js +90 -0
  60. package/es/axis/tick-data/discrete/linear.js.map +1 -0
  61. package/es/axis/tick-data/discrete/polar-angle.d.ts +3 -0
  62. package/es/axis/tick-data/discrete/polar-angle.js +45 -0
  63. package/es/axis/tick-data/discrete/polar-angle.js.map +1 -0
  64. package/es/axis/tick-data/index.d.ts +5 -0
  65. package/es/axis/tick-data/index.js +21 -0
  66. package/es/axis/tick-data/index.js.map +1 -0
  67. package/es/axis/tick-data/util.d.ts +13 -0
  68. package/es/axis/tick-data/util.js +80 -0
  69. package/es/axis/tick-data/util.js.map +1 -0
  70. package/es/axis/type.d.ts +41 -1
  71. package/es/axis/type.js.map +1 -1
  72. package/es/axis/util.d.ts +11 -0
  73. package/es/axis/util.js +19 -1
  74. package/es/axis/util.js.map +1 -1
  75. package/es/constant.d.ts +2 -2
  76. package/es/constant.js +2 -2
  77. package/es/constant.js.map +1 -1
  78. package/es/index.d.ts +1 -1
  79. package/es/index.js +1 -1
  80. package/es/index.js.map +1 -1
  81. package/es/label/arc.js +2 -1
  82. package/es/label/line.js +1 -1
  83. package/es/label/polygon.js +1 -1
  84. package/es/legend/base.js +1 -1
  85. package/es/legend/constant.js +1 -1
  86. package/es/legend/index.js +1 -1
  87. package/es/legend/register.js +1 -1
  88. package/es/legend/type.js +1 -2
  89. package/es/legend/util.js +1 -1
  90. package/es/link-path/index.js +1 -1
  91. package/es/link-path/link-path.js +1 -1
  92. package/es/link-path/register.js +1 -1
  93. package/es/link-path/type.js +1 -1
  94. package/es/player/discrete-player.js +6 -2
  95. package/es/player/discrete-player.js.map +1 -1
  96. package/es/player/type/base.d.ts +1 -0
  97. package/es/player/type/base.js.map +1 -1
  98. package/es/tooltip/util.js +1 -1
  99. package/es/tooltip/util.js.map +1 -1
  100. package/es/util/text.d.ts +1 -1
  101. package/es/util/text.js +3 -3
  102. package/es/util/text.js.map +1 -1
  103. package/package.json +8 -8
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/axis/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAKvD,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAG/C,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAIxC,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,QAAgB,CAAC,EAAE,EAAE;IAC/C,IAAI,KAAK,GAAG,CAAC,EAAE;QACb,OAAO,KAAK,GAAG,CAAC,EAAE;YAChB,KAAK,IAAI,GAAG,CAAC;SACd;KACF;SAAM,IAAI,KAAK,GAAG,CAAC,EAAE;QACpB,OAAO,KAAK,GAAG,GAAG,EAAE;YAClB,KAAK,IAAI,GAAG,CAAC;SACd;KACF;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAGF,MA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E,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC;SACnB;IACH,CAAC,CAAC,CAAC;IACH,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,KAAY,EAAE,MAAe;IAC5D,OAAO;QACL,CAAC,EAAE,KAAK,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;QACtB,CAAC,EAAE,KAAK,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;KACvB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,uBAAuB,CACrC,MAAc,EACd,KAAY,EACZ,MAAa,EACb,MAAM,GAAG,KAAK,EACd,UAAU,GAAG,KAAK;IAElB,MAAM,MAAM,GAAqB,CAAC,KAAK,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IAC1E,OAAO,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;AAC9F,CAAC","file":"util.js","sourcesContent":["import { getTextBounds } from '@visactor/vrender-core';\n// eslint-disable-next-line no-duplicate-imports\nimport type { IGraphic, IGroup, ITextGraphicAttribute } from '@visactor/vrender-core';\nimport type { Dict } from '@visactor/vutils';\n// eslint-disable-next-line no-duplicate-imports\nimport { isGreater, isLess, tau } from '@visactor/vutils';\nimport { traverseGroup } from '../util/common';\nimport type { Vector2 } from '../util';\n// eslint-disable-next-line no-duplicate-imports\nimport { scale, length } from '../util';\nimport type { Point } from '../core/type';\n\n// 和 vutils 版本不同\nexport const clampRadian = (angle: number = 0) => {\n if (angle < 0) {\n while (angle < 0) {\n angle += tau;\n }\n } else if (angle > 0) {\n while (angle > tau) {\n angle -= tau;\n }\n }\n return angle;\n};\n\n// 判断数值是否在制定范围内,包含误差\nexport function isInRange(a: number, min: number, max: number) {\n return !isLess(a, min, 0, 1e-6) && !isGreater(a, max, 0, 1e-6);\n}\n\nexport function getCircleLabelPosition(\n tickPosition: Point,\n tickVector: [number, number],\n text: string | number,\n style: Partial<ITextGraphicAttribute>\n) {\n const labelBounds = getTextBounds({\n text,\n ...style\n });\n const width = labelBounds.width();\n const height = labelBounds.height();\n const angle = clampRadian(Math.atan2(tickVector[1], tickVector[0])) - Math.PI;\n\n const PI_3_4 = (Math.PI * 3) / 4;\n const PI_1_4 = Math.PI / 4;\n const PI_1_2 = Math.PI / 2;\n\n // x\n const baseX = tickPosition.x;\n let dx = 0;\n if (isInRange(angle, -PI_3_4, -PI_1_4)) {\n dx = ((angle + PI_3_4) / PI_1_2 - 0.5) * width;\n } else if (isInRange(angle, PI_1_4, PI_3_4)) {\n dx = (0.5 - (angle - PI_1_4) / PI_1_2) * width;\n } else if (Math.cos(angle) >= 0) {\n dx = width * 0.5;\n } else {\n dx = -width * 0.5;\n }\n const x = baseX - dx;\n\n const baseY = tickPosition.y;\n let dy = 0;\n if (isInRange(angle, -PI_3_4, -PI_1_4)) {\n dy = -height * 0.5;\n } else if (isInRange(angle, PI_1_4, PI_3_4)) {\n dy = height * 0.5;\n } else if (Math.cos(angle) >= 0) {\n dy = (0.5 - (PI_1_4 - angle) / PI_1_2) * height;\n } else {\n dy = (0.5 - clampRadian(angle - PI_3_4) / PI_1_2) * height;\n }\n const y = baseY - dy;\n\n return { x, y };\n}\n\nexport function getElMap(g: IGroup) {\n const elMap: Dict<IGraphic> = {};\n traverseGroup(g, (el: IGraphic) => {\n if ((el as IGraphic).type !== 'group' && el.id) {\n elMap[el.id] = el;\n }\n });\n return elMap;\n}\n\nexport function getVerticalCoord(point: Point, vector: Vector2): Point {\n return {\n x: point.x + vector[0],\n y: point.y + vector[1]\n };\n}\n\nexport function getCircleVerticalVector(\n offset: number,\n point: Point,\n center: Point,\n inside = false,\n axisInside = false\n): Vector2 {\n const vector: [number, number] = [point.x - center.x, point.y - center.y];\n return scale(vector, ((inside ? -1 : 1) * (axisInside ? -1 : 1) * offset) / length(vector));\n}\n"]}
1
+ {"version":3,"sources":["../src/axis/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAKvD,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC5F,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAG/C,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAIxC,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,QAAgB,CAAC,EAAE,EAAE;IAC/C,IAAI,KAAK,GAAG,CAAC,EAAE;QACb,OAAO,KAAK,GAAG,CAAC,EAAE;YAChB,KAAK,IAAI,GAAG,CAAC;SACd;KACF;SAAM,IAAI,KAAK,GAAG,CAAC,EAAE;QACpB,OAAO,KAAK,GAAG,GAAG,EAAE;YAClB,KAAK,IAAI,GAAG,CAAC;SACd;KACF;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAGF,MAAM,UAAU,SAAS,CAAC,CAAS,EAAE,GAAW,EAAE,GAAW;IAC3D,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;AACjE,CAAC;AAED,MAAM,UAAU,sBAAsB,CACpC,YAAmB,EACnB,UAA4B,EAC5B,IAAqB,EACrB,KAAqC;IAErC,MAAM,WAAW,GAAG,aAAa,iBAC/B,IAAI,IACD,KAAK,EACR,CAAC;IACH,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,EAAE,CA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AAC,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,IAAI,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE;QACnE,QAAQ,GAAG,KAAK,CAAC;KAClB;SAAM;QACL,QAAQ,GAAG,QAAQ,CAAC;KACrB;IAED,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,0BAA0B,CACxC,KAAa,EACb,MAAgC,EAChC,MAAc,EACd,WAAmB,EACnB,MAAe,EACf,IAAqB,EACrB,KAAqC;IAErC,MAAM,KAAK,GAAG,gBAAgB,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IAC9D,MAAM,UAAU,GAAG,gBAAgB,CAAC,KAAK,EAAE,uBAAuB,CAAC,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACxG,MAAM,MAAM,GAAG,uBAAuB,CAAC,WAAW,IAAI,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACrF,OAAO,sBAAsB,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;AACjE,CAAC","file":"util.js","sourcesContent":["import { getTextBounds } from '@visactor/vrender-core';\n// eslint-disable-next-line no-duplicate-imports\nimport type { IGraphic, IGroup, ITextGraphicAttribute, TextAlignType, TextBaselineType } from '@visactor/vrender-core';\nimport type { Dict } from '@visactor/vutils';\n// eslint-disable-next-line no-duplicate-imports\nimport { isGreater, isLess, tau, normalizeAngle, polarToCartesian } from '@visactor/vutils';\nimport { traverseGroup } from '../util/common';\nimport type { Vector2 } from '../util';\n// eslint-disable-next-line no-duplicate-imports\nimport { scale, length } from '../util';\nimport type { Point } from '../core/type';\n\n// 和 vutils 版本不同\nexport const clampRadian = (angle: number = 0) => {\n if (angle < 0) {\n while (angle < 0) {\n angle += tau;\n }\n } else if (angle > 0) {\n while (angle > tau) {\n angle -= tau;\n }\n }\n return angle;\n};\n\n// 判断数值是否在制定范围内,包含误差\nexport function isInRange(a: number, min: number, max: number) {\n return !isLess(a, min, 0, 1e-6) && !isGreater(a, max, 0, 1e-6);\n}\n\nexport function getCircleLabelPosition(\n tickPosition: Point,\n tickVector: [number, number],\n text: string | number,\n style: Partial<ITextGraphicAttribute>\n) {\n const labelBounds = getTextBounds({\n text,\n ...style\n });\n const width = labelBounds.width();\n const height = labelBounds.height();\n const angle = clampRadian(Math.atan2(tickVector[1], tickVector[0])) - Math.PI;\n\n const PI_3_4 = (Math.PI * 3) / 4;\n const PI_1_4 = Math.PI / 4;\n const PI_1_2 = Math.PI / 2;\n\n // x\n const baseX = tickPosition.x;\n let dx = 0;\n if (isInRange(angle, -PI_3_4, -PI_1_4)) {\n dx = ((angle + PI_3_4) / PI_1_2 - 0.5) * width;\n } else if (isInRange(angle, PI_1_4, PI_3_4)) {\n dx = (0.5 - (angle - PI_1_4) / PI_1_2) * width;\n } else if (Math.cos(angle) >= 0) {\n dx = width * 0.5;\n } else {\n dx = -width * 0.5;\n }\n const x = baseX - dx;\n\n const baseY = tickPosition.y;\n let dy = 0;\n if (isInRange(angle, -PI_3_4, -PI_1_4)) {\n dy = -height * 0.5;\n } else if (isInRange(angle, PI_1_4, PI_3_4)) {\n dy = height * 0.5;\n } else if (Math.cos(angle) >= 0) {\n dy = (0.5 - (PI_1_4 - angle) / PI_1_2) * height;\n } else {\n dy = (0.5 - clampRadian(angle - PI_3_4) / PI_1_2) * height;\n }\n const y = baseY - dy;\n\n return { x, y };\n}\n\nexport function getElMap(g: IGroup) {\n const elMap: Dict<IGraphic> = {};\n traverseGroup(g, (el: IGraphic) => {\n if ((el as IGraphic).type !== 'group' && el.id) {\n elMap[el.id] = el;\n }\n });\n return elMap;\n}\n\nexport function getVerticalCoord(point: Point, vector: Vector2): Point {\n return {\n x: point.x + vector[0],\n y: point.y + vector[1]\n };\n}\n\nexport function getCircleVerticalVector(\n offset: number,\n point: Point,\n center: Point,\n inside = false,\n axisInside = false\n): Vector2 {\n const vector: [number, number] = [point.x - center.x, point.y - center.y];\n return scale(vector, ((inside ? -1 : 1) * (axisInside ? -1 : 1) * offset) / length(vector));\n}\n\n/**\n * 计算对应角度下的角度轴标签定位属性\n * @param angle 弧度角,需要注意是逆时针计算的\n * @returns\n */\nexport function angleLabelOrientAttribute(angle: number) {\n let align: TextAlignType = 'center';\n let baseline: TextBaselineType = 'middle';\n\n angle = normalizeAngle(angle);\n\n // left: 5/3 - 1/3; right: 2/3 - 4/3; center: 5/3 - 1/3 & 2/3 - 4/3\n if (angle >= Math.PI * (5 / 3) || angle <= Math.PI * (1 / 3)) {\n align = 'left';\n } else if (angle >= Math.PI * (2 / 3) && angle <= Math.PI * (4 / 3)) {\n align = 'right';\n } else {\n align = 'center';\n }\n\n // bottom: 7/6 - 11/6; top: 1/6 - 5/6; middle: 11/6 - 1/6 & 5/6 - 7/6\n if (angle >= Math.PI * (7 / 6) && angle <= Math.PI * (11 / 6)) {\n baseline = 'bottom';\n } else if (angle >= Math.PI * (1 / 6) && angle <= Math.PI * (5 / 6)) {\n baseline = 'top';\n } else {\n baseline = 'middle';\n }\n\n return { align, baseline };\n}\n\nexport function getPolarAngleLabelPosition(\n angle: number,\n center: { x: number; y: number },\n radius: number,\n labelOffset: number,\n inside: boolean,\n text: string | number,\n style: Partial<ITextGraphicAttribute>\n) {\n const point = polarToCartesian({ x: 0, y: 0 }, radius, angle);\n const labelPoint = getVerticalCoord(point, getCircleVerticalVector(labelOffset, point, center, inside));\n const vector = getCircleVerticalVector(labelOffset || 1, labelPoint, center, inside);\n return getCircleLabelPosition(labelPoint, vector, text, style);\n}\n"]}
package/es/constant.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export declare const POLAR_START_ANGLE: number;
2
2
  export declare const POLAR_END_ANGLE: number;
3
- export declare const DEFAULT_TEXT_FONT_FAMILY = "PingFang SC,Microsoft Yahei,system-ui,-apple-system,segoe ui,Roboto,Helvetica,Arial,sans-serif, apple color emoji,segoe ui emoji,segoe ui symbol";
4
- export declare const DEFAULT_TEXT_FONT_SIZE = 11;
3
+ export declare const DEFAULT_TEXT_FONT_FAMILY = "PingFang SC,Helvetica Neue,Microsoft Yahei,system-ui,-apple-system,segoe ui,Roboto,Helvetica,Arial,sans-serif,apple color emoji,segoe ui emoji,segoe ui symbol";
4
+ export declare const DEFAULT_TEXT_FONT_SIZE = 14;
5
5
  export declare enum StateValue {
6
6
  selected = "selected",
7
7
  selectedReverse = "selected_reverse",
package/es/constant.js CHANGED
@@ -2,9 +2,9 @@ export const POLAR_START_ANGLE = -.5 * Math.PI;
2
2
 
3
3
  export const POLAR_END_ANGLE = 1.5 * Math.PI;
4
4
 
5
- export const DEFAULT_TEXT_FONT_FAMILY = "PingFang SC,Microsoft Yahei,system-ui,-apple-system,segoe ui,Roboto,Helvetica,Arial,sans-serif, apple color emoji,segoe ui emoji,segoe ui symbol";
5
+ export const DEFAULT_TEXT_FONT_FAMILY = "PingFang SC,Helvetica Neue,Microsoft Yahei,system-ui,-apple-system,segoe ui,Roboto,Helvetica,Arial,sans-serif,apple color emoji,segoe ui emoji,segoe ui symbol";
6
6
 
7
- export const DEFAULT_TEXT_FONT_SIZE = 11;
7
+ export const DEFAULT_TEXT_FONT_SIZE = 14;
8
8
 
9
9
  export var StateValue;
10
10
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/constant.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC;AAChD,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC;AAE7C,MAAM,CAAC,MAAM,wBAAwB,GAEnC,kJAAkJ,CAAC;AAErJ,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAEzC,MAAM,CAAN,IAAY,UAKX;AALD,WAAY,UAAU;IACpB,mCAAqB,CAAA;IACrB,kDAAoC,CAAA;IACpC,6BAAe,CAAA;IACf,4CAA8B,CAAA;AAChC,CAAC,EALW,UAAU,KAAV,UAAU,QAKrB;AAED,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE,EAAE;IAChC,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,EAAE;IACzB,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,EAAE;IACtB,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,EAAE;CAC9B,CAAC;AAEF,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,SAAS,EAAE,EAAE;IACb,KAAK,EAAE,EAAE;IACT,MAAM,EAAE,EAAE;IACV,KAAK,EAAE,EAAE;CACV,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,YAAY,CAAC","file":"constant.js","sourcesContent":["export const POLAR_START_ANGLE = -0.5 * Math.PI;\nexport const POLAR_END_ANGLE = 1.5 * Math.PI;\n\nexport const 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\nexport const DEFAULT_TEXT_FONT_SIZE = 11;\n\nexport enum StateValue {\n selected = 'selected',\n selectedReverse = 'selected_reverse',\n hover = 'hover',\n hoverReverse = 'hover_reverse'\n}\n\nexport const DEFAULT_STATES = {\n [StateValue.selectedReverse]: {},\n [StateValue.selected]: {},\n [StateValue.hover]: {},\n [StateValue.hoverReverse]: {}\n};\n\nexport const DEFAULT_HTML_TEXT_SPEC = {\n container: '',\n width: 30,\n height: 30,\n style: {}\n};\n\nexport const SCROLLBAR_EVENT = 'scrollDrag';\n"]}
1
+ {"version":3,"sources":["../src/constant.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC;AAChD,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC;AAE7C,MAAM,CAAC,MAAM,wBAAwB,GAEnC,gKAAgK,CAAC;AAEnK,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAEzC,MAAM,CAAN,IAAY,UAKX;AALD,WAAY,UAAU;IACpB,mCAAqB,CAAA;IACrB,kDAAoC,CAAA;IACpC,6BAAe,CAAA;IACf,4CAA8B,CAAA;AAChC,CAAC,EALW,UAAU,KAAV,UAAU,QAKrB;AAED,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE,EAAE;IAChC,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,EAAE;IACzB,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,EAAE;IACtB,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,EAAE;CAC9B,CAAC;AAEF,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,SAAS,EAAE,EAAE;IACb,KAAK,EAAE,EAAE;IACT,MAAM,EAAE,EAAE;IACV,KAAK,EAAE,EAAE;CACV,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,YAAY,CAAC","file":"constant.js","sourcesContent":["export const POLAR_START_ANGLE = -0.5 * Math.PI;\nexport const POLAR_END_ANGLE = 1.5 * Math.PI;\n\nexport const DEFAULT_TEXT_FONT_FAMILY =\n // eslint-disable-next-line max-len\n 'PingFang SC,Helvetica Neue,Microsoft Yahei,system-ui,-apple-system,segoe ui,Roboto,Helvetica,Arial,sans-serif,apple color emoji,segoe ui emoji,segoe ui symbol';\n\nexport const DEFAULT_TEXT_FONT_SIZE = 14;\n\nexport enum StateValue {\n selected = 'selected',\n selectedReverse = 'selected_reverse',\n hover = 'hover',\n hoverReverse = 'hover_reverse'\n}\n\nexport const DEFAULT_STATES = {\n [StateValue.selectedReverse]: {},\n [StateValue.selected]: {},\n [StateValue.hover]: {},\n [StateValue.hoverReverse]: {}\n};\n\nexport const DEFAULT_HTML_TEXT_SPEC = {\n container: '',\n width: 30,\n height: 30,\n style: {}\n};\n\nexport const SCROLLBAR_EVENT = 'scrollDrag';\n"]}
package/es/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const version = "0.19.4-alpha.3";
1
+ export declare const version = "0.19.4-alpha.5";
2
2
  export * from './core/base';
3
3
  export * from './core/type';
4
4
  export * from './scrollbar';
package/es/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export const version = "0.19.4-alpha.3";
1
+ export const version = "0.19.4-alpha.5";
2
2
 
3
3
  export * from "./core/base";
4
4
 
package/es/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,OAAO,GAAG,gBAAgB,CAAC;AAExC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC","file":"index.js","sourcesContent":["// 导出版本号\nexport const version = \"0.19.4-alpha.3\";\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 './interface';\nexport * from './jsx';\nexport * from './checkbox';\nexport * from './radio';\nexport * from './util';\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,OAAO,GAAG,gBAAgB,CAAC;AAExC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC","file":"index.js","sourcesContent":["// 导出版本号\nexport const version = \"0.19.4-alpha.5\";\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 './interface';\nexport * from './jsx';\nexport * from './checkbox';\nexport * from './radio';\nexport * from './util';\n"]}
package/es/label/arc.js CHANGED
@@ -463,4 +463,5 @@ ArcLabel.defaultAttributes = {
463
463
  strategy: "priority",
464
464
  tangentConstraint: !0
465
465
  }
466
- };
466
+ };
467
+ //# sourceMappingURL=arc.js.map
package/es/label/line.js CHANGED
@@ -31,4 +31,4 @@ LineLabel.defaultAttributes = {
31
31
  position: "end",
32
32
  offset: 6
33
33
  };
34
- //# sourceMappingURL=line.js.map
34
+ //# sourceMappingURL=line.js.map
@@ -24,4 +24,4 @@ PolygonLabel.defaultAttributes = {
24
24
  position: "center",
25
25
  offset: 6
26
26
  };
27
- //# sourceMappingURL=polygon.js.map
27
+ //# sourceMappingURL=polygon.js.map
package/es/legend/base.js CHANGED
@@ -53,4 +53,4 @@ export class LegendBase extends AbstractComponent {
53
53
  }
54
54
  }
55
55
  }
56
- //# sourceMappingURL=base.js.map
56
+ //# sourceMappingURL=base.js.map
@@ -37,4 +37,4 @@ export var LEGEND_ELEMENT_NAME;
37
37
  LEGEND_ELEMENT_NAME.itemLabel = "legendItemLabel", LEGEND_ELEMENT_NAME.itemValue = "legendItemValue",
38
38
  LEGEND_ELEMENT_NAME.focus = "legendItemFocus";
39
39
  }(LEGEND_ELEMENT_NAME || (LEGEND_ELEMENT_NAME = {}));
40
- //# sourceMappingURL=constant.js.map
40
+ //# sourceMappingURL=constant.js.map
@@ -15,4 +15,4 @@ export * from "./type";
15
15
  export * from "./constant";
16
16
 
17
17
  export * from "./util";
18
- //# sourceMappingURL=index.js.map
18
+ //# sourceMappingURL=index.js.map
@@ -23,4 +23,4 @@ export function loadColorContinuousLegendComponent() {
23
23
  export function loadSizeContinuousLegendComponent() {
24
24
  loadBaseLegend(), loadSliderComponent(), registerPath();
25
25
  }
26
- //# sourceMappingURL=register.js.map
26
+ //# sourceMappingURL=register.js.map
package/es/legend/type.js CHANGED
@@ -1,2 +1 @@
1
- export { };
2
- //# sourceMappingURL=type.js.map
1
+ export { };
package/es/legend/util.js CHANGED
@@ -4,4 +4,4 @@ export function getSizeHandlerPath(align = "bottom") {
4
4
  `\n M${centerX - 6},0L${centerX - 6 + 2.5},-3.5\n h5\n v7\n h-5\n Z\n`) : "right" === align ? (centerX = -1,
5
5
  `\n M${centerX + 6},0L${centerX + 6 - 2.5},-3.5\n h-5\n v7\n h5\n Z\n `) : `\n M${centerX},6L${centerX - 3.5},2.5\n v-5\n h7\n v5\n Z\n`;
6
6
  }
7
- //# sourceMappingURL=util.js.map
7
+ //# sourceMappingURL=util.js.map
@@ -1,4 +1,4 @@
1
1
  export * from "./link-path";
2
2
 
3
3
  export * from "./type";
4
- //# sourceMappingURL=index.js.map
4
+ //# sourceMappingURL=index.js.map
@@ -60,4 +60,4 @@ LinkPath.defaultAttributes = {
60
60
  direction: "horizontal",
61
61
  align: "start"
62
62
  };
63
- //# sourceMappingURL=link-path.js.map
63
+ //# sourceMappingURL=link-path.js.map
@@ -3,4 +3,4 @@ import { registerGroup, registerPath } from "@visactor/vrender-kits";
3
3
  export function loadLinkPathComponent() {
4
4
  registerGroup(), registerPath();
5
5
  }
6
- //# sourceMappingURL=register.js.map
6
+ //# sourceMappingURL=register.js.map
@@ -1,2 +1,2 @@
1
1
  export { };
2
- //# sourceMappingURL=type.js.map
2
+ //# sourceMappingURL=type.js.map
@@ -74,11 +74,15 @@ export class DiscretePlayer extends BasePlayer {
74
74
  this._isPlaying && (this._isPlaying = !1, vglobal.getCancelAnimationFrame()(this._rafId),
75
75
  this._controller.togglePlay(), this.dispatchCustomEvent(PlayerEventEnum.pause));
76
76
  }, this.backward = () => {
77
- const index = Math.max(this._dataIndex - 1, this._minIndex);
77
+ const {loop: loop = !1} = this.attribute;
78
+ let index;
79
+ index = loop ? this._dataIndex - 1 < this._minIndex ? this._maxIndex : this._dataIndex - 1 : Math.max(this._dataIndex - 1, this._minIndex),
78
80
  this._updateDataIndex(index), this.dispatchCustomEvent(PlayerEventEnum.change),
79
81
  this.dispatchCustomEvent(PlayerEventEnum.backward);
80
82
  }, this.forward = () => {
81
- const index = Math.min(this._dataIndex + 1, this._maxIndex);
83
+ const {loop: loop = !1} = this.attribute;
84
+ let index;
85
+ index = loop ? this._dataIndex + 1 > this._maxIndex ? this._minIndex : this._dataIndex + 1 : Math.min(this._dataIndex + 1, this._maxIndex),
82
86
  this._updateDataIndex(index), this.dispatchCustomEvent(PlayerEventEnum.change),
83
87
  this.dispatchCustomEvent(PlayerEventEnum.forward);
84
88
  }, this._initAttributes(), this._initDataIndex(), this._initEvents();
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/player/discrete-player.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAC;AASzD,2BAA2B,EAAE,CAAC;AAC9B,MAAM,OAAO,cAAe,SAAQ,UAAoC;IActE,YAAY,UAAoC,EAAE,OAA0B;QAC1E,KAAK,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,EAAC,CAAC,CA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AAS,CAAC,CAAC;YAC5D,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;YAE7B,IAAI,CAAC,mBAAmB,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;YACjD,IAAI,CAAC,mBAAmB,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QACpD,CAAC,CAAC;QAxNA,IAAI,CAAC,eAAe,EAAE,CAAC;QACvB,IAAI,CAAC,cAAc,EAAE,CAAC;QACtB,IAAI,CAAC,WAAW,EAAE,CAAC;IACrB,CAAC;IAED,aAAa,CAAC,MAA2C,EAAE,cAAwB;QACjF,KAAK,CAAC,aAAa,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;QAC5C,IAAI,CAAC,eAAe,EAAE,CAAC;IACzB,CAAC;IA4DD,mBAAmB,CAAC,KAAsB;QACxC,KAAK,CAAC,mBAAmB,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IACpD,CAAC;CAmJF","file":"discrete-player.js","sourcesContent":["import { isNil, merge } from '@visactor/vutils';\nimport type { FederatedPointerEvent } from '@visactor/vrender-core';\nimport { vglobal } from '@visactor/vrender-core';\nimport { BasePlayer } from './base-player';\nimport type { DirectionType, DiscretePlayerAttributes, PlayerAttributes } from './type';\nimport { DirectionEnum, PlayerEventEnum } from './type';\nimport { forwardStep, isReachEnd, isReachStart } from './utils';\nimport { ControllerEventEnum } from './controller/constant';\nimport type { ComponentOptions } from '../interface';\nimport { loadDiscretePlayerComponent } from './register';\n\nexport interface IDiscretePlayer {\n play: () => void;\n pause: () => void;\n backward: () => void;\n forward: () => void;\n}\n\nloadDiscretePlayerComponent();\nexport class DiscretePlayer extends BasePlayer<DiscretePlayerAttributes> implements IDiscretePlayer {\n declare attribute: DiscretePlayerAttributes;\n\n private _activeIndex = -1;\n\n protected _alternate: boolean;\n protected _interval: number;\n\n private _isPlaying: boolean;\n private _direction: DirectionType;\n private _tickTime: number;\n private _rafId: number;\n private _isReachEnd = false;\n\n constructor(attributes: DiscretePlayerAttributes, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, attributes));\n\n this._initAttributes();\n this._initDataIndex();\n this._initEvents();\n }\n\n setAttributes(params: Partial<Required<PlayerAttributes>>, forceUpdateTag?: boolean): void {\n super.setAttributes(params, forceUpdateTag);\n this._initAttributes();\n }\n\n /**\n * 初始化属性\n */\n _initAttributes = () => {\n super._initAttributes();\n this._alternate = this.attribute.alternate ?? false;\n this._interval = this.attribute.interval ?? 1000;\n this._direction = this.attribute.direction ?? DirectionEnum.Default;\n };\n\n /**\n * 初始化dataIndex\n */\n _initDataIndex = () => {\n this._dataIndex = isNil(this.attribute.dataIndex)\n ? this._direction === 'default'\n ? this._minIndex\n : this._maxIndex\n : this.attribute.dataIndex ?? 0;\n\n this._slider.setAttribute('value', this._dataIndex);\n };\n\n /**\n * 初始化事件\n */\n private _initEvents = () => {\n if (this.attribute.disableTriggerEvent) {\n return;\n }\n this._controller.addEventListener(ControllerEventEnum.OnPlay, (e: FederatedPointerEvent) => {\n e.stopPropagation();\n this.play();\n });\n this._controller.addEventListener(ControllerEventEnum.OnPause, (e: FederatedPointerEvent) => {\n e.stopPropagation();\n this.pause();\n });\n this._controller.addEventListener(ControllerEventEnum.OnForward, (e: FederatedPointerEvent) => {\n e.stopPropagation();\n this.forward();\n });\n this._controller.addEventListener(ControllerEventEnum.OnBackward, (e: FederatedPointerEvent) => {\n e.stopPropagation();\n this.backward();\n });\n\n this._slider.addEventListener('change', (e: FederatedPointerEvent & { detail: { value: number } }) => {\n const middle = Math.floor(e.detail.value) + 0.5;\n this._dataIndex = e.detail.value >= middle ? Math.ceil(e.detail.value) : Math.floor(e.detail.value);\n this._slider.setValue(this._dataIndex);\n this.dispatchCustomEvent(PlayerEventEnum.change);\n });\n };\n\n /**\n * 派遣事件\n */\n dispatchCustomEvent(event: PlayerEventEnum) {\n super.dispatchCustomEvent(event, this._dataIndex);\n }\n\n /**\n * 播放接口\n */\n play = () => {\n if (this._isPlaying) {\n return;\n }\n // 一条数据无需播放\n if (this._data.length === 1) {\n return;\n }\n // 图标切换\n this._controller.togglePause();\n // 播放状态更新\n this._isPlaying = true;\n // 若到达末尾, 则计算下一次播放的状态下标\n if (\n isReachEnd({\n dataIndex: this._dataIndex,\n maxIndex: this._maxIndex,\n minIndex: this._minIndex,\n direction: this._direction\n }) ||\n isReachStart({\n dataIndex: this._dataIndex,\n maxIndex: this._maxIndex,\n minIndex: this._minIndex,\n direction: this._direction\n })\n ) {\n // 根据方向恢复dataIndex\n if (this._direction === DirectionEnum.Default) {\n this._updateDataIndex(this._minIndex);\n } else {\n this._updateDataIndex(this._maxIndex);\n }\n }\n\n // 事件触发\n this.dispatchCustomEvent(PlayerEventEnum.play);\n // 重置结束状态\n this._isReachEnd = false;\n // 重置tick时间, 暂停后重新播放也会重新计时\n this._tickTime = Date.now();\n // 开启动画\n this._rafId = vglobal.getRequestAnimationFrame()(this._play.bind(this, true));\n };\n\n /**\n * 播放过程\n */\n private _play = (isFirstPlay: boolean) => {\n const now = Date.now();\n\n // 抵达终点, 延迟一个interval触发end\n if (this._isReachEnd && now - this._tickTime >= this._interval) {\n this._isReachEnd = false;\n this._playEnd();\n return;\n }\n // 未达终点\n\n // 第一个播放帧, 立即执行\n if (isFirstPlay && this._activeIndex !== this._dataIndex) {\n this.dispatchCustomEvent(PlayerEventEnum.change);\n this._activeIndex = this._dataIndex;\n }\n // 中间播放帧, 每一个interval执行一次\n else if (now - this._tickTime >= this._interval) {\n this._tickTime = now;\n this._updateDataIndex(forwardStep(this._direction, this._dataIndex, this._minIndex, this._maxIndex));\n this._activeIndex = this._dataIndex;\n this.dispatchCustomEvent(PlayerEventEnum.change);\n }\n\n // 终止条件\n if (\n (this._direction === 'default' && this._dataIndex >= this._maxIndex) ||\n (this._direction === 'reverse' && this._dataIndex <= this._minIndex)\n ) {\n this._isReachEnd = true;\n }\n\n this._rafId = vglobal.getRequestAnimationFrame()(this._play.bind(this, false));\n };\n\n /**\n * 更新数据\n */\n private _updateDataIndex = (dataIndex: number) => {\n this._dataIndex = dataIndex;\n this._slider.setValue(this._dataIndex);\n };\n\n /**\n * 播放结束\n */\n private _playEnd = () => {\n // 播放状态更新\n this._isPlaying = false;\n // 图标切换\n this._controller.togglePlay();\n // 取消播放动画\n vglobal.getCancelAnimationFrame()(this._rafId);\n // 重置ActiveIndex\n this._activeIndex = -1;\n // 播放结束时并且到达终点\n this.dispatchCustomEvent(PlayerEventEnum.end);\n };\n\n /**\n * 暂停接口\n */\n pause = () => {\n if (!this._isPlaying) {\n return;\n }\n this._isPlaying = false;\n vglobal.getCancelAnimationFrame()(this._rafId);\n this._controller.togglePlay();\n\n this.dispatchCustomEvent(PlayerEventEnum.pause);\n };\n\n /**\n * 后退接口\n */\n backward = () => {\n const index = Math.max(this._dataIndex - 1, this._minIndex);\n this._updateDataIndex(index);\n\n this.dispatchCustomEvent(PlayerEventEnum.change);\n this.dispatchCustomEvent(PlayerEventEnum.backward);\n };\n\n /**\n * 前进接口\n */\n forward = () => {\n const index = Math.min(this._dataIndex + 1, this._maxIndex);\n this._updateDataIndex(index);\n\n this.dispatchCustomEvent(PlayerEventEnum.change);\n this.dispatchCustomEvent(PlayerEventEnum.forward);\n };\n}\n"]}
1
+ {"version":3,"sources":["../src/player/discrete-player.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAC;AASzD,2BAA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,CAAC;IA4DD,mBAAmB,CAAC,KAAsB;QACxC,KAAK,CAAC,mBAAmB,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IACpD,CAAC;CA+JF","file":"discrete-player.js","sourcesContent":["import { isNil, merge } from '@visactor/vutils';\nimport type { FederatedPointerEvent } from '@visactor/vrender-core';\nimport { vglobal } from '@visactor/vrender-core';\nimport { BasePlayer } from './base-player';\nimport type { DirectionType, DiscretePlayerAttributes, PlayerAttributes } from './type';\nimport { DirectionEnum, PlayerEventEnum } from './type';\nimport { forwardStep, isReachEnd, isReachStart } from './utils';\nimport { ControllerEventEnum } from './controller/constant';\nimport type { ComponentOptions } from '../interface';\nimport { loadDiscretePlayerComponent } from './register';\n\nexport interface IDiscretePlayer {\n play: () => void;\n pause: () => void;\n backward: () => void;\n forward: () => void;\n}\n\nloadDiscretePlayerComponent();\nexport class DiscretePlayer extends BasePlayer<DiscretePlayerAttributes> implements IDiscretePlayer {\n declare attribute: DiscretePlayerAttributes;\n\n private _activeIndex = -1;\n\n protected _alternate: boolean;\n protected _interval: number;\n\n private _isPlaying: boolean;\n private _direction: DirectionType;\n private _tickTime: number;\n private _rafId: number;\n private _isReachEnd = false;\n\n constructor(attributes: DiscretePlayerAttributes, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, attributes));\n\n this._initAttributes();\n this._initDataIndex();\n this._initEvents();\n }\n\n setAttributes(params: Partial<Required<PlayerAttributes>>, forceUpdateTag?: boolean): void {\n super.setAttributes(params, forceUpdateTag);\n this._initAttributes();\n }\n\n /**\n * 初始化属性\n */\n _initAttributes = () => {\n super._initAttributes();\n this._alternate = this.attribute.alternate ?? false;\n this._interval = this.attribute.interval ?? 1000;\n this._direction = this.attribute.direction ?? DirectionEnum.Default;\n };\n\n /**\n * 初始化dataIndex\n */\n _initDataIndex = () => {\n this._dataIndex = isNil(this.attribute.dataIndex)\n ? this._direction === 'default'\n ? this._minIndex\n : this._maxIndex\n : this.attribute.dataIndex ?? 0;\n\n this._slider.setAttribute('value', this._dataIndex);\n };\n\n /**\n * 初始化事件\n */\n private _initEvents = () => {\n if (this.attribute.disableTriggerEvent) {\n return;\n }\n this._controller.addEventListener(ControllerEventEnum.OnPlay, (e: FederatedPointerEvent) => {\n e.stopPropagation();\n this.play();\n });\n this._controller.addEventListener(ControllerEventEnum.OnPause, (e: FederatedPointerEvent) => {\n e.stopPropagation();\n this.pause();\n });\n this._controller.addEventListener(ControllerEventEnum.OnForward, (e: FederatedPointerEvent) => {\n e.stopPropagation();\n this.forward();\n });\n this._controller.addEventListener(ControllerEventEnum.OnBackward, (e: FederatedPointerEvent) => {\n e.stopPropagation();\n this.backward();\n });\n\n this._slider.addEventListener('change', (e: FederatedPointerEvent & { detail: { value: number } }) => {\n const middle = Math.floor(e.detail.value) + 0.5;\n this._dataIndex = e.detail.value >= middle ? Math.ceil(e.detail.value) : Math.floor(e.detail.value);\n this._slider.setValue(this._dataIndex);\n this.dispatchCustomEvent(PlayerEventEnum.change);\n });\n };\n\n /**\n * 派遣事件\n */\n dispatchCustomEvent(event: PlayerEventEnum) {\n super.dispatchCustomEvent(event, this._dataIndex);\n }\n\n /**\n * 播放接口\n */\n play = () => {\n if (this._isPlaying) {\n return;\n }\n // 一条数据无需播放\n if (this._data.length === 1) {\n return;\n }\n // 图标切换\n this._controller.togglePause();\n // 播放状态更新\n this._isPlaying = true;\n // 若到达末尾, 则计算下一次播放的状态下标\n if (\n isReachEnd({\n dataIndex: this._dataIndex,\n maxIndex: this._maxIndex,\n minIndex: this._minIndex,\n direction: this._direction\n }) ||\n isReachStart({\n dataIndex: this._dataIndex,\n maxIndex: this._maxIndex,\n minIndex: this._minIndex,\n direction: this._direction\n })\n ) {\n // 根据方向恢复dataIndex\n if (this._direction === DirectionEnum.Default) {\n this._updateDataIndex(this._minIndex);\n } else {\n this._updateDataIndex(this._maxIndex);\n }\n }\n\n // 事件触发\n this.dispatchCustomEvent(PlayerEventEnum.play);\n // 重置结束状态\n this._isReachEnd = false;\n // 重置tick时间, 暂停后重新播放也会重新计时\n this._tickTime = Date.now();\n // 开启动画\n this._rafId = vglobal.getRequestAnimationFrame()(this._play.bind(this, true));\n };\n\n /**\n * 播放过程\n */\n private _play = (isFirstPlay: boolean) => {\n const now = Date.now();\n\n // 抵达终点, 延迟一个interval触发end\n if (this._isReachEnd && now - this._tickTime >= this._interval) {\n this._isReachEnd = false;\n this._playEnd();\n return;\n }\n // 未达终点\n\n // 第一个播放帧, 立即执行\n if (isFirstPlay && this._activeIndex !== this._dataIndex) {\n this.dispatchCustomEvent(PlayerEventEnum.change);\n this._activeIndex = this._dataIndex;\n }\n // 中间播放帧, 每一个interval执行一次\n else if (now - this._tickTime >= this._interval) {\n this._tickTime = now;\n this._updateDataIndex(forwardStep(this._direction, this._dataIndex, this._minIndex, this._maxIndex));\n this._activeIndex = this._dataIndex;\n this.dispatchCustomEvent(PlayerEventEnum.change);\n }\n\n // 终止条件\n if (\n (this._direction === 'default' && this._dataIndex >= this._maxIndex) ||\n (this._direction === 'reverse' && this._dataIndex <= this._minIndex)\n ) {\n this._isReachEnd = true;\n }\n\n this._rafId = vglobal.getRequestAnimationFrame()(this._play.bind(this, false));\n };\n\n /**\n * 更新数据\n */\n private _updateDataIndex = (dataIndex: number) => {\n this._dataIndex = dataIndex;\n this._slider.setValue(this._dataIndex);\n };\n\n /**\n * 播放结束\n */\n private _playEnd = () => {\n // 播放状态更新\n this._isPlaying = false;\n // 图标切换\n this._controller.togglePlay();\n // 取消播放动画\n vglobal.getCancelAnimationFrame()(this._rafId);\n // 重置ActiveIndex\n this._activeIndex = -1;\n // 播放结束时并且到达终点\n this.dispatchCustomEvent(PlayerEventEnum.end);\n };\n\n /**\n * 暂停接口\n */\n pause = () => {\n if (!this._isPlaying) {\n return;\n }\n this._isPlaying = false;\n vglobal.getCancelAnimationFrame()(this._rafId);\n this._controller.togglePlay();\n\n this.dispatchCustomEvent(PlayerEventEnum.pause);\n };\n\n /**\n * 后退接口\n */\n backward = () => {\n const { loop = false } = this.attribute as PlayerAttributes;\n let index;\n if (loop) {\n index = this._dataIndex - 1 < this._minIndex ? this._maxIndex : this._dataIndex - 1;\n } else {\n index = Math.max(this._dataIndex - 1, this._minIndex);\n }\n this._updateDataIndex(index);\n\n this.dispatchCustomEvent(PlayerEventEnum.change);\n this.dispatchCustomEvent(PlayerEventEnum.backward);\n };\n\n /**\n * 前进接口\n */\n forward = () => {\n const { loop = false } = this.attribute as PlayerAttributes;\n let index;\n if (loop) {\n index = this._dataIndex + 1 > this._maxIndex ? this._minIndex : this._dataIndex + 1;\n } else {\n index = Math.min(this._dataIndex + 1, this._maxIndex);\n }\n this._updateDataIndex(index);\n\n this.dispatchCustomEvent(PlayerEventEnum.change);\n this.dispatchCustomEvent(PlayerEventEnum.forward);\n };\n}\n"]}
@@ -5,4 +5,5 @@ export type BasePlayerAttributes = {
5
5
  data: Datum[];
6
6
  dataIndex?: number;
7
7
  disableTriggerEvent?: boolean;
8
+ loop?: boolean;
8
9
  } & IGroupGraphicAttribute;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/player/type/base.ts"],"names":[],"mappings":"","file":"base.js","sourcesContent":["import type { IGroupGraphicAttribute } from '@visactor/vrender-core';\n\nexport type Datum = any;\n\nexport type BasePlayerAttributes = {\n /**\n * 组件显隐配置\n * @default true\n */\n visible?: boolean;\n\n /**\n * 数据项\n */\n data: Datum[];\n\n /**\n * 数据下标\n */\n dataIndex?: number;\n /**\n * 关闭交互效果\n * @default false\n */\n disableTriggerEvent?: boolean;\n} & IGroupGraphicAttribute;\n"]}
1
+ {"version":3,"sources":["../src/player/type/base.ts"],"names":[],"mappings":"","file":"base.js","sourcesContent":["import type { IGroupGraphicAttribute } from '@visactor/vrender-core';\n\nexport type Datum = any;\n\nexport type BasePlayerAttributes = {\n /**\n * 组件显隐配置\n * @default true\n */\n visible?: boolean;\n\n /**\n * 数据项\n */\n data: Datum[];\n\n /**\n * 数据下标\n */\n dataIndex?: number;\n /**\n * 关闭交互效果\n * @default false\n */\n disableTriggerEvent?: boolean;\n\n /**\n * 是否循环播放\n * @default false\n * @description 在绘制时没有实际意义,但会用于判断前进后退时,index是否循环递进\n */\n loop?: boolean;\n} & IGroupGraphicAttribute;\n"]}
@@ -28,7 +28,7 @@ export const getRichTextAttribute = attr => {
28
28
  textAlign: textAlign,
29
29
  textBaseline: textBaseline,
30
30
  singleLine: !1,
31
- textConfig: text.text
31
+ textConfig: null == text ? void 0 : text.text
32
32
  };
33
33
  };
34
34
  //# sourceMappingURL=util.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/tooltip/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAKvD,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,MAA8C,EAC9C,GAAG,OAAmD,EACd,EAAE;IAC1C,MAAM,SAAS,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,KAAK,CAAC,CAAC,CAAC;IAChE,MAAM,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,GAAG,CAAC,CAAC,CAAC;IAC1D,MAAM,SAAS,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,KAAK,CAAC,CAAC,CAAC;IAEhE,OAAO,KAAK,CAAC,MAAM,EAAE,GAAG,OAAO,EAAE;QAC/B,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,GAAG,SAAS,CAAC;QACnE,GAAG,EAAE,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,GAAG,OAAO,CAAC;QAC7D,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,GAAG,SAAS,CAAC;KACpE,CAA2C,CAAC;AAC/C,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,IAAsB,EAA6B,EAAE;IACxF,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,GAAG,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;IACxF,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QACvB,OAAO;YACL,KAAK;YACL,MAAM;YACN,SAAS,EAAE,SAAgB;YAC3B,SAAS,EAAE,SAAgB;YAC3B,YAAY,EAAE,YAAmB;YACjC,UAAU,EAAE,KAAK;YACjB,UAAU,EAAE,KAAK,CAAC,IAAgB,CAAC,CAAC,GAAG,CACrC,IAAI,CAAC,EAAE,CACL,CAAC,gCACI,IAAI,KACP,IAAI,GACG,CAAA,CACZ;SACF,CAAC;KACH;IACD,OAAO;QACL,KAAK;QACL,MAAM;QACN,SAAS,EAAE,SAAgB;QAC3B,SAAS,EAAE,SAAgB;QAC3B,YAAY,EAAE,YAAmB;QACjC,UAAU,EAAE,KAAK;QACjB,UAAU,EAAG,IAA6B,CAAC,IAA4B;KACxE,CAAC;AACJ,CAAC,CAAC","file":"util.js","sourcesContent":["import { array, isNil, merge } from '@visactor/vutils';\nimport type { IRichTextGraphicAttribute } from '@visactor/vrender-core';\nimport type { TooltipRowAttrs, TooltipRowStyleAttrs, TooltipTextAttrs, TooltipRichTextAttrs } from './type';\nimport type { IRichTextCharacter } from '@visactor/vrender-core';\n\nexport const mergeRowAttrs = (\n target: TooltipRowAttrs | TooltipRowStyleAttrs,\n ...sources: (TooltipRowAttrs | TooltipRowStyleAttrs)[]\n): TooltipRowAttrs | TooltipRowStyleAttrs => {\n const shapeList = [target.shape, ...sources.map(s => s?.shape)];\n const keyList = [target.key, ...sources.map(s => s?.key)];\n const valueList = [target.value, ...sources.map(s => s?.value)];\n\n return merge(target, ...sources, {\n shape: shapeList.every(isNil) ? undefined : merge({}, ...shapeList),\n key: keyList.every(isNil) ? undefined : merge({}, ...keyList),\n value: valueList.every(isNil) ? undefined : merge({}, ...valueList)\n }) as TooltipRowAttrs | TooltipRowStyleAttrs;\n};\n\nexport const getRichTextAttribute = (attr: TooltipTextAttrs): IRichTextGraphicAttribute => {\n const { width, height, wordBreak = 'break-word', textAlign, textBaseline, text } = attr;\n if (Array.isArray(text)) {\n return {\n width,\n height,\n wordBreak: wordBreak as any,\n textAlign: textAlign as any,\n textBaseline: textBaseline as any,\n singleLine: false,\n textConfig: array(text as string[]).map(\n text =>\n ({\n ...attr,\n text\n } as any)\n )\n };\n }\n return {\n width,\n height,\n wordBreak: wordBreak as any,\n textAlign: textAlign as any,\n textBaseline: textBaseline as any,\n singleLine: false,\n textConfig: (text as TooltipRichTextAttrs).text as IRichTextCharacter[]\n };\n};\n"]}
1
+ {"version":3,"sources":["../src/tooltip/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAKvD,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,MAA8C,EAC9C,GAAG,OAAmD,EACd,EAAE;IAC1C,MAAM,SAAS,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,KAAK,CAAC,CAAC,CAAC;IAChE,MAAM,OAAO,G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AAC,IAAgB,CAAC,CAAC,GAAG,CACrC,IAAI,CAAC,EAAE,CACL,CAAC,gCACI,IAAI,KACP,IAAI,GACG,CAAA,CACZ;SACF,CAAC;KACH;IACD,OAAO;QACL,KAAK;QACL,MAAM;QACN,SAAS,EAAE,SAAgB;QAC3B,SAAS,EAAE,SAAgB;QAC3B,YAAY,EAAE,YAAmB;QACjC,UAAU,EAAE,KAAK;QACjB,UAAU,EAAG,IAA6B,aAA7B,IAAI,uBAAJ,IAAI,CAA2B,IAA4B;KACzE,CAAC;AACJ,CAAC,CAAC","file":"util.js","sourcesContent":["import { array, isNil, merge } from '@visactor/vutils';\nimport type { IRichTextGraphicAttribute } from '@visactor/vrender-core';\nimport type { TooltipRowAttrs, TooltipRowStyleAttrs, TooltipTextAttrs, TooltipRichTextAttrs } from './type';\nimport type { IRichTextCharacter } from '@visactor/vrender-core';\n\nexport const mergeRowAttrs = (\n target: TooltipRowAttrs | TooltipRowStyleAttrs,\n ...sources: (TooltipRowAttrs | TooltipRowStyleAttrs)[]\n): TooltipRowAttrs | TooltipRowStyleAttrs => {\n const shapeList = [target.shape, ...sources.map(s => s?.shape)];\n const keyList = [target.key, ...sources.map(s => s?.key)];\n const valueList = [target.value, ...sources.map(s => s?.value)];\n\n return merge(target, ...sources, {\n shape: shapeList.every(isNil) ? undefined : merge({}, ...shapeList),\n key: keyList.every(isNil) ? undefined : merge({}, ...keyList),\n value: valueList.every(isNil) ? undefined : merge({}, ...valueList)\n }) as TooltipRowAttrs | TooltipRowStyleAttrs;\n};\n\nexport const getRichTextAttribute = (attr: TooltipTextAttrs): IRichTextGraphicAttribute => {\n const { width, height, wordBreak = 'break-word', textAlign, textBaseline, text } = attr;\n if (Array.isArray(text)) {\n return {\n width,\n height,\n wordBreak: wordBreak as any,\n textAlign: textAlign as any,\n textBaseline: textBaseline as any,\n singleLine: false,\n textConfig: array(text as string[]).map(\n text =>\n ({\n ...attr,\n text\n } as any)\n )\n };\n }\n return {\n width,\n height,\n wordBreak: wordBreak as any,\n textAlign: textAlign as any,\n textBaseline: textBaseline as any,\n singleLine: false,\n textConfig: (text as TooltipRichTextAttrs)?.text as IRichTextCharacter[]\n };\n};\n"]}
package/es/util/text.d.ts CHANGED
@@ -2,7 +2,7 @@ import type { IRichTextAttribute, ITextGraphicAttribute } from '@visactor/vrende
2
2
  import type { ITextMeasureOption } from '@visactor/vutils';
3
3
  import { TextMeasure } from '@visactor/vutils';
4
4
  import type { TextContent } from '../core/type';
5
- export declare const initTextMeasure: (textSpec?: Partial<ITextGraphicAttribute>, option?: Partial<ITextMeasureOption>, useNaiveCanvas?: boolean) => TextMeasure<ITextGraphicAttribute>;
5
+ export declare const initTextMeasure: (textSpec?: Partial<ITextGraphicAttribute>, option?: Partial<ITextMeasureOption>, useNaiveCanvas?: boolean, defaultFontParams?: Partial<ITextGraphicAttribute>) => TextMeasure<ITextGraphicAttribute>;
6
6
  export declare function measureTextSize(text: string | number | string[] | number[], textSpec: Partial<ITextGraphicAttribute>, defaultTextTheme?: Partial<ITextGraphicAttribute>): {
7
7
  width: any;
8
8
  height: any;
package/es/util/text.js CHANGED
@@ -4,11 +4,11 @@ import { TextMeasure, isObject } from "@visactor/vutils";
4
4
 
5
5
  import { DEFAULT_TEXT_FONT_FAMILY, DEFAULT_TEXT_FONT_SIZE } from "../constant";
6
6
 
7
- export const initTextMeasure = (textSpec, option, useNaiveCanvas) => new TextMeasure(Object.assign({
8
- defaultFontParams: {
7
+ export const initTextMeasure = (textSpec, option, useNaiveCanvas, defaultFontParams) => new TextMeasure(Object.assign({
8
+ defaultFontParams: Object.assign({
9
9
  fontFamily: DEFAULT_TEXT_FONT_FAMILY,
10
10
  fontSize: DEFAULT_TEXT_FONT_SIZE
11
- },
11
+ }, defaultFontParams),
12
12
  getTextBounds: useNaiveCanvas ? void 0 : getTextBounds,
13
13
  specialCharSet: "-/: .,@%'\"~" + TextMeasure.ALPHABET_CHAR_SET + TextMeasure.ALPHABET_CHAR_SET.toUpperCase()
14
14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ender-core';\n// eslint-disable-next-line no-duplicate-imports\nimport { getTextBounds, graphicCreator } from '@visactor/vrender-core';\nimport type { ITextMeasureOption } from '@visactor/vutils';\n// eslint-disable-next-line no-duplicate-imports\nimport { TextMeasure, isObject } from '@visactor/vutils';\nimport { DEFAULT_TEXT_FONT_FAMILY, DEFAULT_TEXT_FONT_SIZE } from '../constant';\nimport type { HTMLTextContent, ReactTextContent, TextContent } from '../core/type';\n\nexport const initTextMeasure = (\n textSpec?: Partial<ITextGraphicAttribute>,\n option?: Partial<ITextMeasureOption>,\n useNaiveCanvas?: boolean\n): TextMeasure<ITextGraphicAttribute> => {\n return new TextMeasure<ITextGraphicAttribute>(\n {\n defaultFontParams: {\n fontFamily: DEFAULT_TEXT_FONT_FAMILY,\n fontSize: DEFAULT_TEXT_FONT_SIZE\n },\n getTextBounds: useNaiveCanvas ? undefined : getTextBounds,\n specialCharSet: '-/: .,@%\\'\"~' + TextMeasure.ALPHABET_CHAR_SET + TextMeasure.ALPHABET_CHAR_SET.toUpperCase(),\n ...(option ?? {})\n },\n textSpec\n );\n};\n\n// FIXME: 和上一个方法统一,使用 TextMeasure 类\nexport function measureTextSize(\n text: string | number | string[] | number[],\n textSpec: Partial<ITextGraphicAttribute>,\n defaultTextTheme: Partial<ITextGraphicAttribute> = {}\n) {\n if (!text) {\n return { width: 0, height: 0 };\n }\n const bounds = getTextBounds({\n text,\n fontFamily: textSpec.fontFamily || defaultTextTheme.fontFamily || DEFAULT_TEXT_FONT_FAMILY,\n fontSize: textSpec.fontSize || defaultTextTheme.fontSize || 12,\n fontWeight: textSpec.fontWeight || defaultTextTheme.fontWeight,\n textAlign: textSpec.textAlign || 'center',\n textBaseline: textSpec.textBaseline,\n ellipsis: !!textSpec.ellipsis,\n maxLineWidth: textSpec.maxLineWidth || Infinity,\n lineHeight: textSpec.fontSize || defaultTextTheme.fontSize || 12\n });\n\n return { width: bounds.width(), height: bounds.height() };\n}\n\nexport function isRichText(attributes: TextContent, typeKey = 'type') {\n return getTextType(attributes, typeKey) === 'rich';\n}\n\nexport function getTextType(attributes: TextContent, typeKey = 'type') {\n if (isObject(attributes.text) && 'type' in attributes.text) {\n return attributes.text.type ?? 'text';\n }\n\n if (typeKey in attributes) {\n return attributes[typeKey] ?? 'text';\n }\n\n return 'text';\n}\n\nexport function richTextAttributeTransform(attributes: ITextGraphicAttribute & IRichTextAttribute & TextContent) {\n attributes.width = attributes.width ?? 0;\n attributes.height = attributes.height ?? 0;\n attributes.maxWidth = attributes.maxLineWidth;\n attributes.textConfig = (attributes.text as unknown as any).text || attributes.text;\n return attributes;\n}\n\nexport function htmlAttributeTransform(attributes: ITextGraphicAttribute) {\n const { text, _originText } = attributes as unknown as HTMLTextContent;\n const { text: html } = text;\n\n attributes.html = html;\n attributes.text = _originText;\n attributes.renderable = false; // 文字图元配置了 html,则不绘制原始文字\n return attributes;\n}\n\nexport function reactAttributeTransform(attributes: ITextGraphicAttribute) {\n const { text, _originText } = attributes as unknown as ReactTextContent;\n const { text: react } = text;\n\n attributes.react = react;\n attributes.text = _originText;\n attributes.renderable = false; // 文字图元配置了 react,则不绘制原始文字\n\n return attributes;\n}\n\nexport function createTextGraphicByType(textAttributes: ITextGraphicAttribute, typeKey = 'type') {\n const textType = getTextType(textAttributes, typeKey);\n if (textType === 'rich') {\n return graphicCreator.richtext(richTextAttributeTransform(textAttributes as IRichTextAttribute));\n }\n\n if (textType === 'html') {\n textAttributes = htmlAttributeTransform(textAttributes);\n } else if (textType === 'react') {\n textAttributes = reactAttributeTransform(textAttributes);\n }\n\n return graphicCreator.text(textAttributes as ITextGraphicAttribute);\n}\n"]}
1
+ {"version":3,"sources":["../src/util/text.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAGvE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,aA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AG,WAAW,CAAC;IAC9B,UAAU,CAAC,UAAU,GAAG,KAAK,CAAC;IAC9B,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,UAAiC;IACvE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,UAAyC,CAAC;IACxE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;IAE7B,UAAU,CAAC,KAAK,GAAG,KAAK,CAAC;IACzB,UAAU,CAAC,IAAI,GAAG,WAAW,CAAC;IAC9B,UAAU,CAAC,UAAU,GAAG,KAAK,CAAC;IAE9B,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,cAAqC,EAAE,OAAO,GAAG,MAAM;IAC7F,MAAM,QAAQ,GAAG,WAAW,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IACtD,IAAI,QAAQ,KAAK,MAAM,EAAE;QACvB,OAAO,cAAc,CAAC,QAAQ,CAAC,0BAA0B,CAAC,cAAoC,CAAC,CAAC,CAAC;KAClG;IAED,IAAI,QAAQ,KAAK,MAAM,EAAE;QACvB,cAAc,GAAG,sBAAsB,CAAC,cAAc,CAAC,CAAC;KACzD;SAAM,IAAI,QAAQ,KAAK,OAAO,EAAE;QAC/B,cAAc,GAAG,uBAAuB,CAAC,cAAc,CAAC,CAAC;KAC1D;IAED,OAAO,cAAc,CAAC,IAAI,CAAC,cAAuC,CAAC,CAAC;AACtE,CAAC","file":"text.js","sourcesContent":["import type { IRichTextAttribute, ITextGraphicAttribute } from '@visactor/vrender-core';\n// eslint-disable-next-line no-duplicate-imports\nimport { getTextBounds, graphicCreator } from '@visactor/vrender-core';\nimport type { ITextMeasureOption } from '@visactor/vutils';\n// eslint-disable-next-line no-duplicate-imports\nimport { TextMeasure, isObject } from '@visactor/vutils';\nimport { DEFAULT_TEXT_FONT_FAMILY, DEFAULT_TEXT_FONT_SIZE } from '../constant';\nimport type { HTMLTextContent, ReactTextContent, TextContent } from '../core/type';\n\nexport const initTextMeasure = (\n textSpec?: Partial<ITextGraphicAttribute>,\n option?: Partial<ITextMeasureOption>,\n useNaiveCanvas?: boolean,\n defaultFontParams?: Partial<ITextGraphicAttribute>\n): TextMeasure<ITextGraphicAttribute> => {\n return new TextMeasure<ITextGraphicAttribute>(\n {\n defaultFontParams: {\n fontFamily: DEFAULT_TEXT_FONT_FAMILY,\n fontSize: DEFAULT_TEXT_FONT_SIZE,\n ...defaultFontParams\n },\n getTextBounds: useNaiveCanvas ? undefined : getTextBounds,\n specialCharSet: '-/: .,@%\\'\"~' + TextMeasure.ALPHABET_CHAR_SET + TextMeasure.ALPHABET_CHAR_SET.toUpperCase(),\n ...(option ?? {})\n },\n textSpec\n );\n};\n\n// FIXME: 和上一个方法统一,使用 TextMeasure 类\nexport function measureTextSize(\n text: string | number | string[] | number[],\n textSpec: Partial<ITextGraphicAttribute>,\n defaultTextTheme: Partial<ITextGraphicAttribute> = {}\n) {\n if (!text) {\n return { width: 0, height: 0 };\n }\n const bounds = getTextBounds({\n text,\n fontFamily: textSpec.fontFamily || defaultTextTheme.fontFamily || DEFAULT_TEXT_FONT_FAMILY,\n fontSize: textSpec.fontSize || defaultTextTheme.fontSize || 12,\n fontWeight: textSpec.fontWeight || defaultTextTheme.fontWeight,\n textAlign: textSpec.textAlign || 'center',\n textBaseline: textSpec.textBaseline,\n ellipsis: !!textSpec.ellipsis,\n maxLineWidth: textSpec.maxLineWidth || Infinity,\n lineHeight: textSpec.fontSize || defaultTextTheme.fontSize || 12\n });\n\n return { width: bounds.width(), height: bounds.height() };\n}\n\nexport function isRichText(attributes: TextContent, typeKey = 'type') {\n return getTextType(attributes, typeKey) === 'rich';\n}\n\nexport function getTextType(attributes: TextContent, typeKey = 'type') {\n if (isObject(attributes.text) && 'type' in attributes.text) {\n return attributes.text.type ?? 'text';\n }\n\n if (typeKey in attributes) {\n return attributes[typeKey] ?? 'text';\n }\n\n return 'text';\n}\n\nexport function richTextAttributeTransform(attributes: ITextGraphicAttribute & IRichTextAttribute & TextContent) {\n attributes.width = attributes.width ?? 0;\n attributes.height = attributes.height ?? 0;\n attributes.maxWidth = attributes.maxLineWidth;\n attributes.textConfig = (attributes.text as unknown as any).text || attributes.text;\n return attributes;\n}\n\nexport function htmlAttributeTransform(attributes: ITextGraphicAttribute) {\n const { text, _originText } = attributes as unknown as HTMLTextContent;\n const { text: html } = text;\n\n attributes.html = html;\n attributes.text = _originText;\n attributes.renderable = false; // 文字图元配置了 html,则不绘制原始文字\n return attributes;\n}\n\nexport function reactAttributeTransform(attributes: ITextGraphicAttribute) {\n const { text, _originText } = attributes as unknown as ReactTextContent;\n const { text: react } = text;\n\n attributes.react = react;\n attributes.text = _originText;\n attributes.renderable = false; // 文字图元配置了 react,则不绘制原始文字\n\n return attributes;\n}\n\nexport function createTextGraphicByType(textAttributes: ITextGraphicAttribute, typeKey = 'type') {\n const textType = getTextType(textAttributes, typeKey);\n if (textType === 'rich') {\n return graphicCreator.richtext(richTextAttributeTransform(textAttributes as IRichTextAttribute));\n }\n\n if (textType === 'html') {\n textAttributes = htmlAttributeTransform(textAttributes);\n } else if (textType === 'react') {\n textAttributes = reactAttributeTransform(textAttributes);\n }\n\n return graphicCreator.text(textAttributes as ITextGraphicAttribute);\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visactor/vrender-components",
3
- "version": "0.19.4-alpha.3",
3
+ "version": "0.19.4-alpha.5",
4
4
  "description": "components library for dp visualization",
5
5
  "sideEffects": false,
6
6
  "main": "cjs/index.js",
@@ -12,14 +12,14 @@
12
12
  "dist"
13
13
  ],
14
14
  "dependencies": {
15
- "@visactor/vrender-core": "0.19.4-alpha.3",
16
- "@visactor/vrender-kits": "0.19.4-alpha.3",
17
- "@visactor/vutils": "~0.18.4",
18
- "@visactor/vscale": "~0.17.3"
15
+ "@visactor/vrender-core": "0.19.4-alpha.5",
16
+ "@visactor/vrender-kits": "0.19.4-alpha.5",
17
+ "@visactor/vutils": "~0.18.7",
18
+ "@visactor/vscale": "~0.18.7"
19
19
  },
20
20
  "devDependencies": {
21
21
  "@rushstack/eslint-patch": "~1.1.4",
22
- "@visactor/vscale": "~0.17.3",
22
+ "@visactor/vscale": "~0.18.7",
23
23
  "@types/jest": "^26.0.0",
24
24
  "jest": "^26.0.0",
25
25
  "jest-electron": "^0.1.12",
@@ -29,8 +29,8 @@
29
29
  "vite": "3.2.6",
30
30
  "typescript": "4.9.5",
31
31
  "@internal/bundler": "0.0.1",
32
- "@internal/eslint-config": "0.0.1",
33
- "@internal/ts-config": "0.0.1"
32
+ "@internal/ts-config": "0.0.1",
33
+ "@internal/eslint-config": "0.0.1"
34
34
  },
35
35
  "keywords": [
36
36
  "VisActor",