@visactor/vchart 1.7.0-alpha.2 → 1.7.0

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 (73) hide show
  1. package/build/es5/index.js +1 -1
  2. package/build/index.js +35 -44
  3. package/build/index.min.js +1 -1
  4. package/build/tsconfig.tsbuildinfo +1 -1
  5. package/cjs/component/axis/base-axis.d.ts +1 -25
  6. package/cjs/component/axis/base-axis.js +2 -2
  7. package/cjs/component/axis/base-axis.js.map +1 -1
  8. package/cjs/component/axis/interface/spec.d.ts +5 -2
  9. package/cjs/component/axis/interface/spec.js.map +1 -1
  10. package/cjs/component/indicator/indicator.js.map +1 -1
  11. package/cjs/component/indicator/interface.d.ts +5 -1
  12. package/cjs/component/indicator/interface.js.map +1 -1
  13. package/cjs/component/label/interface.d.ts +3 -1
  14. package/cjs/component/label/interface.js.map +1 -1
  15. package/cjs/component/label/util.js +3 -1
  16. package/cjs/component/label/util.js.map +1 -1
  17. package/cjs/component/marker/interface.d.ts +4 -3
  18. package/cjs/component/marker/interface.js.map +1 -1
  19. package/cjs/component/marker/mark-point/interface/theme.js.map +1 -1
  20. package/cjs/component/title/interface/spec.d.ts +4 -2
  21. package/cjs/component/title/interface/spec.js.map +1 -1
  22. package/cjs/component/title/title.d.ts +3 -3
  23. package/cjs/component/title/title.js +12 -10
  24. package/cjs/component/title/title.js.map +1 -1
  25. package/cjs/component/tooltip/handler/base.d.ts +1 -1
  26. package/cjs/component/tooltip/handler/utils/common.d.ts +3 -2
  27. package/cjs/component/tooltip/handler/utils/common.js +7 -6
  28. package/cjs/component/tooltip/handler/utils/common.js.map +1 -1
  29. package/cjs/core/index.d.ts +1 -1
  30. package/cjs/core/index.js +1 -1
  31. package/cjs/core/index.js.map +1 -1
  32. package/cjs/mark/text.d.ts +3 -1
  33. package/cjs/mark/text.js +9 -3
  34. package/cjs/mark/text.js.map +1 -1
  35. package/cjs/typings/tooltip/line.d.ts +3 -2
  36. package/cjs/typings/tooltip/line.js.map +1 -1
  37. package/cjs/typings/visual.d.ts +3 -1
  38. package/cjs/typings/visual.js.map +1 -1
  39. package/esm/component/axis/base-axis.d.ts +1 -25
  40. package/esm/component/axis/base-axis.js +2 -2
  41. package/esm/component/axis/base-axis.js.map +1 -1
  42. package/esm/component/axis/interface/spec.d.ts +5 -2
  43. package/esm/component/axis/interface/spec.js.map +1 -1
  44. package/esm/component/indicator/indicator.js.map +1 -1
  45. package/esm/component/indicator/interface.d.ts +5 -1
  46. package/esm/component/indicator/interface.js.map +1 -1
  47. package/esm/component/label/interface.d.ts +3 -1
  48. package/esm/component/label/interface.js.map +1 -1
  49. package/esm/component/label/util.js +3 -1
  50. package/esm/component/label/util.js.map +1 -1
  51. package/esm/component/marker/interface.d.ts +4 -3
  52. package/esm/component/marker/interface.js.map +1 -1
  53. package/esm/component/marker/mark-point/interface/theme.js.map +1 -1
  54. package/esm/component/title/interface/spec.d.ts +4 -2
  55. package/esm/component/title/interface/spec.js.map +1 -1
  56. package/esm/component/title/title.d.ts +3 -3
  57. package/esm/component/title/title.js +17 -15
  58. package/esm/component/title/title.js.map +1 -1
  59. package/esm/component/tooltip/handler/base.d.ts +1 -1
  60. package/esm/component/tooltip/handler/utils/common.d.ts +3 -2
  61. package/esm/component/tooltip/handler/utils/common.js +7 -6
  62. package/esm/component/tooltip/handler/utils/common.js.map +1 -1
  63. package/esm/core/index.d.ts +1 -1
  64. package/esm/core/index.js +1 -1
  65. package/esm/core/index.js.map +1 -1
  66. package/esm/mark/text.d.ts +3 -1
  67. package/esm/mark/text.js +10 -2
  68. package/esm/mark/text.js.map +1 -1
  69. package/esm/typings/tooltip/line.d.ts +3 -2
  70. package/esm/typings/tooltip/line.js.map +1 -1
  71. package/esm/typings/visual.d.ts +3 -1
  72. package/esm/typings/visual.js.map +1 -1
  73. package/package.json +4 -4
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/component/marker/mark-point/interface/theme.ts"],"names":[],"mappings":"","file":"theme.js","sourcesContent":["import type { IImageGraphicAttribute, IRichTextGraphicAttribute } from '@visactor/vrender-core';\nimport type { IMarkPointItemPosition } from '@visactor/vrender-components';\nimport type { ILineMarkSpec, ISymbolMarkSpec } from '../../../../typings';\nimport type { IMarkerLabelSpec, IMarkerRef, IMarkerSymbol } from '../../interface';\n\nexport interface IItemContent extends IMarkerRef {\n /**\n * 标注类型\n */\n type?: 'symbol' | 'text' | 'image' | 'richText';\n /**\n * 标注内容相对于定位点的位置\n */\n position?: IMarkPointItemPosition;\n /**\n * x 方向偏移量\n */\n offsetX?: number;\n /**\n * y 方向偏移量\n */\n offsetY?: number;\n /**\n * type为symbol时, symbol的样式\n */\n symbol?: {\n style?: ISymbolMarkSpec;\n };\n /**\n * type为image时, image的样式\n */\n image?: {\n style?: IImageGraphicAttribute;\n };\n /**\n * type为text时, text的样式\n */\n text?: IMarkerLabelSpec;\n /**\n * type为rich text时, rich text的样式\n */\n richText?: {\n style?: IRichTextGraphicAttribute;\n };\n}\n\nexport type IItemLine<T extends Partial<IMarkerSymbol> = IMarkerSymbol> = {\n /** TODO:'type-opo' */\n /**\n * 引导线类型\n * 'type-s'表示起点和终点直接连线; 'type-do'表示包含一个折点,且折点x坐标为起点到终点的 1/2 x坐标,折点y坐标为起点y坐标;'type-op' 表示包含一个折点,且折点x坐标为起点x坐标,折点y坐标为终点y坐标;'type-po' 表示包含一个折点,且折点x坐标为终点x坐标,折点y坐标为起点y坐标\n * 引导线类型的具体形式参考:https://journals.sagepub.com/doi/10.1177/1473871618799500\n */\n type?: 'type-s' | 'type-do' | 'type-po' | 'type-op';\n /**\n * 引导线可见性\n */\n visible?: boolean;\n /**\n * 垂直于引导线的装饰线,参考案例: https://observablehq.com/@mikelotis/edmonton-population-history-line-chart\n */\n decorativeLine?: {\n /**\n * 装饰线可见性\n */\n visible?: boolean;\n /**\n * 装饰线的长度\n */\n length?: number;\n };\n /**\n * 引导线起点symbol样式\n */\n startSymbol?: T;\n /**\n * 引导线终点symbol样式\n */\n endSymbol?: T;\n /**\n * 引导线样式\n */\n line?: {\n style?: Omit<ILineMarkSpec, 'visible'>;\n };\n};\n\nexport interface IMarkPointTheme<T extends Partial<IMarkerSymbol> = Partial<IMarkerSymbol>> {\n /**\n * 标注引导线\n */\n itemLine?: IItemLine<T>;\n\n /**\n * 标注内容\n */\n itemContent?: IItemContent;\n}\n"]}
1
+ {"version":3,"sources":["../src/component/marker/mark-point/interface/theme.ts"],"names":[],"mappings":"","file":"theme.js","sourcesContent":["import type { IImageGraphicAttribute, IRichTextGraphicAttribute } from '@visactor/vrender-core';\nimport type { IMarkPointItemPosition } from '@visactor/vrender-components';\nimport type { ILineMarkSpec, ISymbolMarkSpec } from '../../../../typings';\nimport type { IMarkerLabelSpec, IMarkerRef, IMarkerSymbol } from '../../interface';\n\nexport interface IItemContent extends IMarkerRef {\n /**\n * 标注类型\n */\n type?: 'symbol' | 'text' | 'image' | 'richText';\n /**\n * 标注内容相对于定位点的位置\n */\n position?: IMarkPointItemPosition;\n /**\n * x 方向偏移量\n */\n offsetX?: number;\n /**\n * y 方向偏移量\n */\n offsetY?: number;\n /**\n * type为symbol时, symbol的样式\n */\n symbol?: {\n style?: ISymbolMarkSpec;\n };\n /**\n * type为image时, image的样式\n */\n image?: {\n style?: IImageGraphicAttribute;\n };\n /**\n * type为text时, text的样式\n * 'text'类型的ItemContent新增三种子类型:'text','rich','html'。配置在textStyle.type上。\n */\n text?: IMarkerLabelSpec;\n /**\n * type为rich text时, rich text的样式\n */\n richText?: {\n style?: IRichTextGraphicAttribute;\n };\n}\n\nexport type IItemLine<T extends Partial<IMarkerSymbol> = IMarkerSymbol> = {\n /** TODO:'type-opo' */\n /**\n * 引导线类型\n * 'type-s'表示起点和终点直接连线; 'type-do'表示包含一个折点,且折点x坐标为起点到终点的 1/2 x坐标,折点y坐标为起点y坐标;'type-op' 表示包含一个折点,且折点x坐标为起点x坐标,折点y坐标为终点y坐标;'type-po' 表示包含一个折点,且折点x坐标为终点x坐标,折点y坐标为起点y坐标\n * 引导线类型的具体形式参考:https://journals.sagepub.com/doi/10.1177/1473871618799500\n */\n type?: 'type-s' | 'type-do' | 'type-po' | 'type-op';\n /**\n * 引导线可见性\n */\n visible?: boolean;\n /**\n * 垂直于引导线的装饰线,参考案例: https://observablehq.com/@mikelotis/edmonton-population-history-line-chart\n */\n decorativeLine?: {\n /**\n * 装饰线可见性\n */\n visible?: boolean;\n /**\n * 装饰线的长度\n */\n length?: number;\n };\n /**\n * 引导线起点symbol样式\n */\n startSymbol?: T;\n /**\n * 引导线终点symbol样式\n */\n endSymbol?: T;\n /**\n * 引导线样式\n */\n line?: {\n style?: Omit<ILineMarkSpec, 'visible'>;\n };\n};\n\nexport interface IMarkPointTheme<T extends Partial<IMarkerSymbol> = Partial<IMarkerSymbol>> {\n /**\n * 标注引导线\n */\n itemLine?: IItemLine<T>;\n\n /**\n * 标注内容\n */\n itemContent?: IItemContent;\n}\n"]}
@@ -5,8 +5,10 @@ import type { IComponentSpec } from '../../base/interface';
5
5
  export interface ITitleSpec extends Omit<IComponentSpec, 'orient'> {
6
6
  visible?: boolean;
7
7
  orient?: IOrientType;
8
- text: Text | Text[];
9
- subtext?: Text | Text[];
8
+ text?: string | number | string[] | number[] | IRichTextCharacter[];
9
+ textType?: string;
10
+ subtext?: string | number | string[] | number[] | IRichTextCharacter[];
11
+ subtextType?: string;
10
12
  x?: number;
11
13
  y?: number;
12
14
  width?: number;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/component/title/interface/spec.ts"],"names":[],"mappings":"","file":"spec.js","sourcesContent":["import type { IComponent } from '../../interface';\nimport type { ITextGraphicAttribute, IRichTextCharacter, RichTextWordBreak } from '@visactor/vrender-core';\nimport type { IOrientType, IPadding, StringOrNumber } from '../../../typings';\nimport type { IComponentSpec } from '../../base/interface';\n\nexport interface ITitleSpec extends Omit<IComponentSpec, 'orient'> {\n /**\n * 是否显示标题\n */\n visible?: boolean;\n /**\n * Title位置\n * @default 'top'\n */\n orient?: IOrientType;\n /**\n * 主标题内容\n */\n text: Text | Text[];\n /**\n * 副标题内容\n */\n subtext?: Text | Text[];\n /**\n * 标题左上角x坐标像素值\n */\n x?: number;\n /**\n * 标题左上角y坐标像素值\n */\n y?: number;\n /**\n * 标题宽度\n */\n width?: number;\n /**\n * 标题高度\n */\n height?: number;\n /**\n * 最小宽度,像素值\n */\n minWidth?: number;\n /**\n * 最大宽度,像素值。当文字超过最大宽度时,会自动省略。\n */\n maxWidth?: number;\n /**\n * 最小高度,像素值\n */\n minHeight?: number;\n /**\n * 最大高度,像素值\n */\n maxHeight?: number;\n /**\n * 标题的边距留白\n */\n innerPadding?: IPadding | number | number[];\n /**\n * 文字水平对齐方式\n * 'left' | 'center' | 'right'\n */\n align?: string;\n /**\n * 文字垂直对齐方式\n * 'top' | 'middle' | 'bottom'\n */\n verticalAlign?: string;\n /**\n * 主标题样式\n */\n textStyle?: {\n width?: number;\n height?: number;\n /**\n * 文字水平对齐方式\n * 'left' | 'center' | 'right'\n */\n align?: string;\n /**\n * 文字垂直对齐方式\n * 'top' | 'middle' | 'bottom'\n */\n verticalAlign?: string;\n /**\n * 折行方式\n * 'break-word' | 'break-all'\n */\n wordBreak?: RichTextWordBreak;\n /**\n * 按照宽度限制自动折行或显示省略号(maxLineWidth)\n * 默认设置为title宽度\n */\n maxLineWidth?: number;\n /**\n * 高度限制控制显示内容及省略号(heightLimit)\n */\n heightLimit?: number;\n /**\n * 按照行数限制显示内容及省略号(lineClamp)\n */\n lineClamp?: number;\n /**\n * 富文本配置\n */\n character?: IRichTextCharacter[];\n } & Partial<ITextGraphicAttribute>;\n /**\n * 副标题样式\n */\n subtextStyle?: {\n /** 指定宽度 */\n width?: number;\n /** 指定高度 */\n height?: number;\n /**\n * 文字水平对齐方式\n * 'left' | 'center' | 'right'\n */\n align?: string;\n /**\n * 文字垂直对齐方式\n * 'top' | 'middle' | 'bottom'\n */\n verticalAlign?: string;\n /**\n * 折行方式\n * 'break-word' | 'break-all'\n */\n wordBreak?: RichTextWordBreak;\n /**\n * 按照宽度限制自动折行或显示省略号(maxLineWidth)\n * 默认设置为title宽度\n */\n maxLineWidth?: number;\n /**\n * 高度限制控制显示内容及省略号(heightLimit)\n */\n heightLimit?: number;\n /**\n * 按照行数限制显示内容及省略号(lineClamp)\n */\n lineClamp?: number;\n /**\n * 富文本配置\n */\n character?: IRichTextCharacter[];\n } & Partial<ITextGraphicAttribute>;\n}\n\nexport type Text = StringOrNumber;\n\nexport type ITitle = IComponent;\n"]}
1
+ {"version":3,"sources":["../src/component/title/interface/spec.ts"],"names":[],"mappings":"","file":"spec.js","sourcesContent":["import type { IComponent } from '../../interface';\nimport type { ITextGraphicAttribute, IRichTextCharacter, RichTextWordBreak } from '@visactor/vrender-core';\nimport type { IOrientType, IPadding, StringOrNumber } from '../../../typings';\nimport type { IComponentSpec } from '../../base/interface';\n\nexport interface ITitleSpec extends Omit<IComponentSpec, 'orient'> {\n /**\n * 是否显示标题\n */\n visible?: boolean;\n /**\n * Title位置\n * @default 'top'\n */\n orient?: IOrientType;\n /**\n * 主标题文本内容\n * - 支持富文本配置\n */\n text?: string | number | string[] | number[] | IRichTextCharacter[];\n /**\n * 主标题文本类型(默认类型为text)\n * text, rich, html\n */\n textType?: string;\n /**\n * 副标题文本内容\n * - 支持富文本配置\n */\n subtext?: string | number | string[] | number[] | IRichTextCharacter[];\n /**\n * 副标题文本类型(默认类型为text)\n * text, rich, html\n */\n subtextType?: string;\n /**\n * 标题左上角x坐标像素值\n */\n x?: number;\n /**\n * 标题左上角y坐标像素值\n */\n y?: number;\n /**\n * 标题宽度\n */\n width?: number;\n /**\n * 标题高度\n */\n height?: number;\n /**\n * 最小宽度,像素值\n */\n minWidth?: number;\n /**\n * 最大宽度,像素值。当文字超过最大宽度时,会自动省略。\n */\n maxWidth?: number;\n /**\n * 最小高度,像素值\n */\n minHeight?: number;\n /**\n * 最大高度,像素值\n */\n maxHeight?: number;\n /**\n * 标题的边距留白\n */\n innerPadding?: IPadding | number | number[];\n /**\n * 文字水平对齐方式\n * 'left' | 'center' | 'right'\n */\n align?: string;\n /**\n * 文字垂直对齐方式\n * 'top' | 'middle' | 'bottom'\n */\n verticalAlign?: string;\n /**\n * 主标题样式\n */\n textStyle?: {\n width?: number;\n height?: number;\n /**\n * 文字水平对齐方式\n * 'left' | 'center' | 'right'\n */\n align?: string;\n /**\n * 文字垂直对齐方式\n * 'top' | 'middle' | 'bottom'\n */\n verticalAlign?: string;\n /**\n * 折行方式\n * 'break-word' | 'break-all'\n */\n wordBreak?: RichTextWordBreak;\n /**\n * 按照宽度限制自动折行或显示省略号(maxLineWidth)\n * 默认设置为title宽度\n */\n maxLineWidth?: number;\n /**\n * 高度限制控制显示内容及省略号(heightLimit)\n */\n heightLimit?: number;\n /**\n * 按照行数限制显示内容及省略号(lineClamp)\n */\n lineClamp?: number;\n /**\n * 富文本配置(暂时保留旧设置)\n * @deprecated use text & textType instead\n */\n character?: IRichTextCharacter[];\n } & Partial<ITextGraphicAttribute>;\n /**\n * 副标题样式\n */\n subtextStyle?: {\n /** 指定宽度 */\n width?: number;\n /** 指定高度 */\n height?: number;\n /**\n * 文字水平对齐方式\n * 'left' | 'center' | 'right'\n */\n align?: string;\n /**\n * 文字垂直对齐方式\n * 'top' | 'middle' | 'bottom'\n */\n verticalAlign?: string;\n /**\n * 折行方式\n * 'break-word' | 'break-all'\n */\n wordBreak?: RichTextWordBreak;\n /**\n * 按照宽度限制自动折行或显示省略号(maxLineWidth)\n * 默认设置为title宽度\n */\n maxLineWidth?: number;\n /**\n * 高度限制控制显示内容及省略号(heightLimit)\n */\n heightLimit?: number;\n /**\n * 按照行数限制显示内容及省略号(lineClamp)\n */\n lineClamp?: number;\n /**\n * 富文本配置(暂时保留旧设置)\n * @deprecated use subtext & subtextType instead\n */\n character?: IRichTextCharacter[];\n } & Partial<ITextGraphicAttribute>;\n}\n\nexport type Text = StringOrNumber;\n\nexport type ITitle = IComponent;\n"]}
@@ -1,10 +1,10 @@
1
+ import type { IRegion } from '../../region/interface';
2
+ import type { IPoint, IOrientType, ILayoutType, ILayoutRect } from '../../typings';
1
3
  import { BaseComponent } from '../base/base-component';
2
- import { ComponentTypeEnum } from '../interface/type';
3
4
  import type { IComponentOption } from '../interface';
5
+ import { ComponentTypeEnum } from '../interface/type';
4
6
  import type { ITitle, ITitleSpec, ITitleTheme } from './interface';
5
- import type { IRegion } from '../../region/interface';
6
7
  import type { IGraphic } from '@visactor/vrender-core';
7
- import type { IPoint, IOrientType, ILayoutType, ILayoutRect } from '../../typings';
8
8
  export declare class Title extends BaseComponent<ITitleSpec> implements ITitle {
9
9
  static type: ComponentTypeEnum;
10
10
  type: ComponentTypeEnum;
@@ -1,16 +1,16 @@
1
- import { BaseComponent } from "../base/base-component";
1
+ import { LayoutLevel, LayoutZIndex } from "../../constant";
2
2
 
3
- import { ComponentTypeEnum } from "../interface/type";
3
+ import { Factory } from "../../core/factory";
4
4
 
5
5
  import { isValidOrient } from "../../util/space";
6
6
 
7
- import { Title as TitleComponents } from "@visactor/vrender-components";
7
+ import { BaseComponent } from "../base/base-component";
8
8
 
9
- import { isEqual, isArray, isValidNumber } from "@visactor/vutils";
9
+ import { ComponentTypeEnum } from "../interface/type";
10
10
 
11
- import { LayoutLevel, LayoutZIndex } from "../../constant";
11
+ import { Title as TitleComponents } from "@visactor/vrender-components";
12
12
 
13
- import { Factory } from "../../core/factory";
13
+ import { isEqual, isArray, isValidNumber, pickWithout } from "@visactor/vutils";
14
14
 
15
15
  export class Title extends BaseComponent {
16
16
  get orient() {
@@ -71,13 +71,15 @@ export class Title extends BaseComponent {
71
71
  };
72
72
  }
73
73
  _getTitleAttrs() {
74
- var _a, _b, _c, _d, _e, _f, _g;
74
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
75
75
  const realWidth = Math.max(0, null !== (_a = this._spec.width) && void 0 !== _a ? _a : this.getLayoutRect().width);
76
- return {
77
- text: null !== (_b = this._spec.text) && void 0 !== _b ? _b : "",
78
- subtext: null !== (_c = this._spec.subtext) && void 0 !== _c ? _c : "",
79
- x: null !== (_d = this._spec.x) && void 0 !== _d ? _d : 0,
80
- y: null !== (_e = this._spec.y) && void 0 !== _e ? _e : 0,
76
+ return Object.assign(Object.assign({}, pickWithout(this._spec, [ "padding" ])), {
77
+ textType: null !== (_b = this._spec.textType) && void 0 !== _b ? _b : "text",
78
+ text: null !== (_c = this._spec.text) && void 0 !== _c ? _c : "",
79
+ subtextType: null !== (_d = this._spec.subtextType) && void 0 !== _d ? _d : "text",
80
+ subtext: null !== (_e = this._spec.subtext) && void 0 !== _e ? _e : "",
81
+ x: null !== (_f = this._spec.x) && void 0 !== _f ? _f : 0,
82
+ y: null !== (_g = this._spec.y) && void 0 !== _g ? _g : 0,
81
83
  width: realWidth,
82
84
  height: this._spec.height,
83
85
  minWidth: this._spec.minWidth,
@@ -85,15 +87,15 @@ export class Title extends BaseComponent {
85
87
  minHeight: this._spec.minHeight,
86
88
  maxHeight: this._spec.maxHeight,
87
89
  padding: this._spec.innerPadding,
88
- align: null !== (_f = this._spec.align) && void 0 !== _f ? _f : "left",
89
- verticalAlign: null !== (_g = this._spec.verticalAlign) && void 0 !== _g ? _g : "top",
90
+ align: null !== (_h = this._spec.align) && void 0 !== _h ? _h : "left",
91
+ verticalAlign: null !== (_j = this._spec.verticalAlign) && void 0 !== _j ? _j : "top",
90
92
  textStyle: Object.assign({
91
93
  width: realWidth
92
94
  }, this._spec.textStyle),
93
95
  subtextStyle: Object.assign({
94
96
  width: realWidth
95
97
  }, this._spec.subtextStyle)
96
- };
98
+ });
97
99
  }
98
100
  _createOrUpdateTitleComponent(attrs) {
99
101
  if (this._titleComponent) isEqual(attrs, this._cacheAttrs) || this._titleComponent.setAttributes(attrs); else {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/component/title/title.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,C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AAC,aAAa,CAAC,KAAK,CAAC,CAAC;aAC3C;SACF;aAAM;YACL,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;YACtC,MAAM,KAAK,GAAG,IAAI,eAAe,CAAC,KAAK,CAAC,CAAC;YACzC,KAAK,CAAC,IAAI,GAAG,OAAO,CAAC;YACrB,SAAS,CAAC,GAAG,CAAC,KAAyB,CAAC,CAAC;YACzC,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC;YAE7B,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,KAAU,EAAE,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,KAA4B,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;SAC7G;QACD,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;QACzB,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC;IAED,oBAAoB;QAClB,OAAO,CAAC,IAAI,CAAC,eAAe,CAAwB,CAAC;IACvD,CAAC;IAED,KAAK;QACH,KAAK,CAAC,KAAK,EAAE,CAAC;QACd,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC1B,CAAC;;AA1KM,UAAI,GAAG,iBAAiB,CAAC,KAAK,CAAC;AA6KxC,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,EAAE;IAChC,OAAO,CAAC,iBAAiB,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAC/C,CAAC,CAAC","file":"title.js","sourcesContent":["import { BaseComponent } from '../base/base-component';\nimport { ComponentTypeEnum } from '../interface/type';\n// eslint-disable-next-line no-duplicate-imports\nimport type { IComponentOption } from '../interface';\nimport { isValidOrient } from '../../util/space';\nimport type { ITitle, ITitleSpec, ITitleTheme } from './interface';\nimport type { IRegion } from '../../region/interface';\nimport { Title as TitleComponents } from '@visactor/vrender-components';\n// eslint-disable-next-line no-duplicate-imports\nimport type { TitleAttrs } from '@visactor/vrender-components';\nimport type { IGraphic, IGroup, INode } from '@visactor/vrender-core';\nimport type { IPoint, IOrientType, ILayoutType, ILayoutRect } from '../../typings';\nimport { isEqual, isArray, isValidNumber } from '@visactor/vutils';\nimport { LayoutLevel, LayoutZIndex } from '../../constant';\nimport { Factory } from '../../core/factory';\n\nexport class Title extends BaseComponent<ITitleSpec> implements ITitle {\n static type = ComponentTypeEnum.title;\n type = ComponentTypeEnum.title;\n\n layoutType: ILayoutType = 'normal';\n layoutZIndex: number = LayoutZIndex.Title;\n layoutLevel: number = LayoutLevel.Title;\n\n protected declare _theme: ITitleTheme;\n\n protected _orient: IOrientType = 'top';\n\n private _titleComponent: TitleComponents;\n private _cacheAttrs: TitleAttrs;\n\n get orient() {\n return this._orient;\n }\n\n constructor(spec: ITitleSpec, options: IComponentOption) {\n super(spec, options);\n this._orient = isValidOrient(spec.orient) ? spec.orient : 'top';\n }\n\n initLayout(): void {\n super.initLayout();\n this._layout && (this._layout.layoutOrient = this._orient);\n }\n\n static createComponent(spec: any, options: IComponentOption) {\n const titleSpec = spec.title;\n if (!titleSpec || titleSpec.visible === false) {\n return null;\n }\n if (!isArray(titleSpec)) {\n return new Title(titleSpec, options);\n }\n const titles: Title[] = [];\n titleSpec.forEach((s: any, i: number) => {\n if (s.visible !== false) {\n titles.push(new Title(s, { ...options, specIndex: i }));\n }\n });\n return titles;\n }\n\n onRender(ctx: any): void {\n // do nothing\n }\n\n /**\n * updateSpec\n */\n _compareSpec() {\n const result = super._compareSpec();\n if (this._originalSpec?.orient !== this._spec?.orient) {\n result.reMake = true;\n }\n\n result.change = true;\n result.reRender = true;\n return result;\n }\n\n // region\n changeRegions(regions: IRegion[]): void {\n // do nothing\n }\n\n update(ctx: IComponentOption) {\n // TODO\n }\n\n resize(ctx: IComponentOption) {\n // TODO\n }\n\n afterSetLayoutStartPoint(pos: IPoint): void {\n if (isValidNumber(pos.x)) {\n this._titleComponent && this._titleComponent.setAttribute('x', pos.x);\n }\n if (isValidNumber(pos.y)) {\n this._titleComponent && this._titleComponent.setAttribute('y', pos.y);\n }\n super.afterSetLayoutStartPoint(pos);\n }\n\n getBoundsInRect(rect: ILayoutRect) {\n let result: Partial<ILayoutRect> = {};\n this.setLayoutRect(rect);\n\n const attrs = this._getTitleAttrs();\n this._createOrUpdateTitleComponent(attrs);\n\n result = this._getTitleLayoutRect();\n const { x, y } = this.getLayoutStartPoint();\n return {\n x1: x,\n y1: y,\n x2: x + result.width,\n y2: y + result.height\n };\n }\n\n private _getTitleLayoutRect() {\n const titleBounds = this._titleComponent.AABBBounds;\n const width = this._spec.width ? this._spec.width : isValidNumber(titleBounds.width()) ? titleBounds.width() : 0;\n const height = this._spec.height\n ? this._spec.height\n : isValidNumber(titleBounds.height())\n ? titleBounds.height()\n : 0;\n return {\n width,\n height\n };\n }\n\n private _getTitleAttrs() {\n // 当 width 小于 0 时,设置为 0,负数场景容易引起不可预知的问题\n const realWidth = Math.max(0, this._spec.width ?? this.getLayoutRect().width);\n return {\n text: this._spec.text ?? '',\n subtext: this._spec.subtext ?? '',\n x: this._spec.x ?? 0,\n y: this._spec.y ?? 0,\n width: realWidth,\n height: this._spec.height,\n minWidth: this._spec.minWidth,\n maxWidth: this._spec.maxWidth,\n minHeight: this._spec.minHeight,\n maxHeight: this._spec.maxHeight,\n padding: this._spec.innerPadding,\n align: this._spec.align ?? 'left',\n verticalAlign: this._spec.verticalAlign ?? 'top',\n textStyle: {\n width: realWidth,\n ...this._spec.textStyle\n },\n subtextStyle: {\n width: realWidth,\n ...this._spec.subtextStyle\n }\n } as TitleAttrs;\n }\n\n private _createOrUpdateTitleComponent(attrs: TitleAttrs): TitleComponents {\n if (this._titleComponent) {\n if (!isEqual(attrs, this._cacheAttrs)) {\n this._titleComponent.setAttributes(attrs);\n }\n } else {\n const container = this.getContainer();\n const title = new TitleComponents(attrs);\n title.name = 'title';\n container.add(title as unknown as INode);\n this._titleComponent = title;\n // 代理 title 组件上的事件\n title.on('*', (event: any, type: string) => this._delegateEvent(title as unknown as IGraphic, event, type));\n }\n this._cacheAttrs = attrs;\n return this._titleComponent;\n }\n\n getVRenderComponents(): IGraphic[] {\n return [this._titleComponent] as unknown as IGroup[];\n }\n\n clear(): void {\n super.clear();\n this._cacheAttrs = null;\n }\n}\n\nexport const registerTitle = () => {\n Factory.registerComponent(Title.type, Title);\n};\n"]}
1
+ {"version":3,"sources":["../src/component/title/title.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAG7C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAGvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EAAE,KAAK,IAAI,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAIxE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEhF,MAAM,OAAO,KAAM,SAAQ,aAAyB;IAelD,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,YAAY,IAAgB,EAAE,OAAyB;QACrD,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAlBvB,SAAI,GAAG,iBAAiB,CAAC,KAAK,CAAC;QAE/B,eAAU,GAAgB,QAAQ,CAAC;QACnC,iBAAY,GAAW,YAAY,CAAC,KAAK,CAAC;QAC1C,gBAAW,GAAW,WAAW,CAAC,KAAK,CAAC;QAI9B,YAAO,GAAgB,KAAK,CAAC;QAWrC,IAAI,CAAC,OAAO,GAAG,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC;IAClE,CAAC;IAED,UAAU;QACR,KAAK,CAAC,UAAU,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d,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC1B,CAAC;;AA7KM,UAAI,GAAG,iBAAiB,CAAC,KAAK,CAAC;AAgLxC,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,EAAE;IAChC,OAAO,CAAC,iBAAiB,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAC/C,CAAC,CAAC","file":"title.js","sourcesContent":["import { LayoutLevel, LayoutZIndex } from '../../constant';\nimport { Factory } from '../../core/factory';\nimport type { IRegion } from '../../region/interface';\nimport type { IPoint, IOrientType, ILayoutType, ILayoutRect } from '../../typings';\nimport { isValidOrient } from '../../util/space';\nimport { BaseComponent } from '../base/base-component';\n// eslint-disable-next-line no-duplicate-imports\nimport type { IComponentOption } from '../interface';\nimport { ComponentTypeEnum } from '../interface/type';\nimport type { ITitle, ITitleSpec, ITitleTheme } from './interface';\nimport { Title as TitleComponents } from '@visactor/vrender-components';\n// eslint-disable-next-line no-duplicate-imports\nimport type { TitleAttrs } from '@visactor/vrender-components';\nimport type { IGraphic, IGroup, INode } from '@visactor/vrender-core';\nimport { isEqual, isArray, isValidNumber, pickWithout } from '@visactor/vutils';\n\nexport class Title extends BaseComponent<ITitleSpec> implements ITitle {\n static type = ComponentTypeEnum.title;\n type = ComponentTypeEnum.title;\n\n layoutType: ILayoutType = 'normal';\n layoutZIndex: number = LayoutZIndex.Title;\n layoutLevel: number = LayoutLevel.Title;\n\n protected declare _theme: ITitleTheme;\n\n protected _orient: IOrientType = 'top';\n\n private _titleComponent: TitleComponents;\n private _cacheAttrs: TitleAttrs;\n\n get orient() {\n return this._orient;\n }\n\n constructor(spec: ITitleSpec, options: IComponentOption) {\n super(spec, options);\n this._orient = isValidOrient(spec.orient) ? spec.orient : 'top';\n }\n\n initLayout(): void {\n super.initLayout();\n this._layout && (this._layout.layoutOrient = this._orient);\n }\n\n static createComponent(spec: any, options: IComponentOption) {\n const titleSpec = spec.title;\n if (!titleSpec || titleSpec.visible === false) {\n return null;\n }\n if (!isArray(titleSpec)) {\n return new Title(titleSpec, options);\n }\n const titles: Title[] = [];\n titleSpec.forEach((s: any, i: number) => {\n if (s.visible !== false) {\n titles.push(new Title(s, { ...options, specIndex: i }));\n }\n });\n return titles;\n }\n\n onRender(ctx: any): void {\n // do nothing\n }\n\n /**\n * updateSpec\n */\n _compareSpec() {\n const result = super._compareSpec();\n if (this._originalSpec?.orient !== this._spec?.orient) {\n result.reMake = true;\n }\n\n result.change = true;\n result.reRender = true;\n return result;\n }\n\n // region\n changeRegions(regions: IRegion[]): void {\n // do nothing\n }\n\n update(ctx: IComponentOption) {\n // TODO\n }\n\n resize(ctx: IComponentOption) {\n // TODO\n }\n\n afterSetLayoutStartPoint(pos: IPoint): void {\n if (isValidNumber(pos.x)) {\n this._titleComponent && this._titleComponent.setAttribute('x', pos.x);\n }\n if (isValidNumber(pos.y)) {\n this._titleComponent && this._titleComponent.setAttribute('y', pos.y);\n }\n super.afterSetLayoutStartPoint(pos);\n }\n\n getBoundsInRect(rect: ILayoutRect) {\n let result: Partial<ILayoutRect> = {};\n this.setLayoutRect(rect);\n\n const attrs = this._getTitleAttrs();\n this._createOrUpdateTitleComponent(attrs);\n\n result = this._getTitleLayoutRect();\n const { x, y } = this.getLayoutStartPoint();\n return {\n x1: x,\n y1: y,\n x2: x + result.width,\n y2: y + result.height\n };\n }\n\n private _getTitleLayoutRect() {\n const titleBounds = this._titleComponent.AABBBounds;\n const width = this._spec.width ? this._spec.width : isValidNumber(titleBounds.width()) ? titleBounds.width() : 0;\n const height = this._spec.height\n ? this._spec.height\n : isValidNumber(titleBounds.height())\n ? titleBounds.height()\n : 0;\n return {\n width,\n height\n };\n }\n\n private _getTitleAttrs() {\n // 当 width 小于 0 时,设置为 0,负数场景容易引起不可预知的问题\n const realWidth = Math.max(0, this._spec.width ?? this.getLayoutRect().width);\n return {\n ...pickWithout(this._spec, ['padding']),\n textType: this._spec.textType ?? 'text',\n text: this._spec.text ?? '',\n subtextType: this._spec.subtextType ?? 'text',\n subtext: this._spec.subtext ?? '',\n x: this._spec.x ?? 0,\n y: this._spec.y ?? 0,\n width: realWidth,\n height: this._spec.height,\n minWidth: this._spec.minWidth,\n maxWidth: this._spec.maxWidth,\n minHeight: this._spec.minHeight,\n maxHeight: this._spec.maxHeight,\n padding: this._spec.innerPadding,\n align: this._spec.align ?? 'left',\n verticalAlign: this._spec.verticalAlign ?? 'top',\n textStyle: {\n width: realWidth,\n ...this._spec.textStyle\n },\n subtextStyle: {\n width: realWidth,\n ...this._spec.subtextStyle\n }\n } as TitleAttrs;\n }\n\n private _createOrUpdateTitleComponent(attrs: TitleAttrs): TitleComponents {\n if (this._titleComponent) {\n if (!isEqual(attrs, this._cacheAttrs)) {\n this._titleComponent.setAttributes(attrs);\n }\n } else {\n const container = this.getContainer();\n const title = new TitleComponents(attrs);\n title.name = 'title';\n container.add(title as unknown as INode);\n this._titleComponent = title;\n // 代理 title 组件上的事件\n title.on('*', (event: any, type: string) => this._delegateEvent(title as unknown as IGraphic, event, type));\n }\n this._cacheAttrs = attrs;\n return this._titleComponent;\n }\n\n getVRenderComponents(): IGraphic[] {\n return [this._titleComponent] as unknown as IGroup[];\n }\n\n clear(): void {\n super.clear();\n this._cacheAttrs = null;\n }\n}\n\nexport const registerTitle = () => {\n Factory.registerComponent(Title.type, Title);\n};\n"]}
@@ -43,7 +43,7 @@ export declare abstract class BaseTooltipHandler implements ITooltipHandler {
43
43
  protected _getActualTooltipPosition: (actualTooltip: IToolTipActual, params: TooltipHandlerParams, tooltipBoxSize: IContainerSize | undefined) => ITooltipPositionActual;
44
44
  protected _getTooltipBoxSize(actualTooltip: IToolTipActual, changePositionOnly: boolean): IContainerSize | undefined;
45
45
  protected _getParentElement(spec: ITooltipSpec): HTMLElement;
46
- getTooltipContainer(): HTMLElement | IGroup;
46
+ getTooltipContainer(): IGroup | HTMLElement;
47
47
  protected _initFromSpec(): void;
48
48
  reInit(): void;
49
49
  }
@@ -2,6 +2,7 @@ import type { Datum } from '@visactor/vgrammar-core';
2
2
  import type { MaybeArray, TooltipContentProperty, TooltipData, TooltipPatternProperty } from '../../../../typings';
3
3
  import type { TooltipHandlerParams } from '../../interface';
4
4
  import type { ITooltipTextStyle } from '../interface/style';
5
+ import type { TooltipRichTextAttrs } from '@visactor/vrender-components';
5
6
  export declare function escapeHTML(value: any): string;
6
7
  export declare const getTooltipContentValue: <T>(field?: TooltipContentProperty<T>, datum?: any, params?: TooltipHandlerParams) => T;
7
8
  export declare const getTooltipPatternValue: <T>(field?: MaybeArray<TooltipPatternProperty<T>>, data?: TooltipData, params?: TooltipHandlerParams) => MaybeArray<TooltipPatternProperty<T>> extends TooltipPatternProperty<T>[] ? MaybeArray<T> : T;
@@ -12,7 +13,7 @@ export declare const getScale: (element: HTMLElement, boundingClientRect?: DOMRe
12
13
  interface ITooltipTextInfo {
13
14
  width: number;
14
15
  height: number;
15
- text: MaybeArray<number> | MaybeArray<string>;
16
+ text: MaybeArray<number> | MaybeArray<string> | TooltipRichTextAttrs;
16
17
  }
17
- export declare const measureTooltipText: (text: string, style: ITooltipTextStyle) => ITooltipTextInfo;
18
+ export declare const measureTooltipText: (text: string | TooltipRichTextAttrs, style: ITooltipTextStyle) => ITooltipTextInfo;
18
19
  export {};
@@ -44,17 +44,18 @@ element.offsetWidth > 0 ? boundingClientRect.width / element.offsetWidth : bound
44
44
 
45
45
  export const measureTooltipText = (text, style) => {
46
46
  var _a;
47
- let textLines;
48
- text = (null != text ? text : "").toString(), style.multiLine ? (textLines = text.split("\n"),
49
- textLines = textLines.map(((line, i) => i < textLines.length - 1 ? line + "\n" : line))) : textLines = [ text ];
47
+ let textLines, textConfig;
48
+ "rich" !== (null == text ? void 0 : text.type) && "html" !== (null == text ? void 0 : text.type) ? (text = (null != text ? text : "").toString(),
49
+ style.multiLine ? (textLines = text.split("\n"), textLines = textLines.map(((line, i) => i < textLines.length - 1 ? line + "\n" : line))) : textLines = [ text ],
50
+ textConfig = textLines.map((line => Object.assign(Object.assign({}, style), {
51
+ text: line
52
+ })))) : (textConfig = text.text, textLines = text);
50
53
  const bound = getRichTextBounds({
51
54
  wordBreak: null !== (_a = style.wordBreak) && void 0 !== _a ? _a : "break-word",
52
55
  maxWidth: style.maxWidth ? style.maxWidth : void 0,
53
56
  width: 0,
54
57
  height: 0,
55
- textConfig: textLines.map((line => Object.assign(Object.assign({}, style), {
56
- text: line
57
- })))
58
+ textConfig: textConfig
58
59
  });
59
60
  return {
60
61
  width: bound.width(),
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/component/tooltip/handler/utils/common.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAK3F,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAgB3D,MAAM,UAAU,UAAU,CAAC,KAAU;IACnC,OAAO,MAAM,CAAC,KAAK,CAAC;SACjB,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;SACtB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC;SACvB,OAAO,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;AAC/B,CAAC;AAED,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,KAAiC,EACjC,KAAW,EACX,MAA6B,EACd,EAAE;IACjB,IAAI,KAAK,CAAC,KAAK,CAAC,EAAE;QAChB,OAAO,KAAK,CAAC;KACd;IACD,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE;QACrB,OAAO,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;KAC7B;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,KAA6C,EAC7C,IAAkB,EAClB,MAA6B,EAC4D,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,CAAC;IACxB,IAAI,KAAK,CAAC,SAAS,EAAE;QACnB,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC7B,SAAS,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;KACzF;SAAM;QACL,SAAS,GAAG,CAAC,IAAI,CAAC,CAAC;KACpB;IAED,MAAM,KAAK,GAAG,iBAAiB,CAAC;QAC9B,SAAS,EAAE,MAAA,KAAK,CAAC,SAAS,mCAAI,YAAY;QAC1C,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;QACrD,KAAK,EAAE,CAAC;QACR,MAAM,EAAE,CAAC;QACT,UAAU,EAAE,SAAS,CAAC,GAAG,CACvB,IAAI,CAAC,EAAE,CACL,CAAC,gCACI,KAAK,KACR,IAAI,EAAE,IAAI,GACgC,CAAA,CAC/C;KACF,CAAC,CAAC;IACH,OAAO;QACL,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE;QACpB,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE;QACtB,IAAI,EAAE,SAAS;KAChB,CAAC;AACJ,CAAC,CAAC","file":"common.js","sourcesContent":["import type { Datum } from '@visactor/vgrammar-core';\nimport type { MaybeArray, TooltipContentProperty, TooltipData, TooltipPatternProperty } from '../../../../typings';\nimport { isFunction, isObject, isString, isNil, isArray, isValid } from '@visactor/vutils';\nimport type { TooltipHandlerParams } from '../../interface';\nimport type { IDimensionData, IDimensionInfo } from '../../../../event/events/dimension';\nimport type { IRichTextParagraphCharacter } from '@visactor/vrender-core';\n// eslint-disable-next-line no-duplicate-imports\nimport { getRichTextBounds } from '@visactor/vrender-core';\nimport type { ITooltipTextStyle } from '../interface/style';\n\ninterface IGradientColor {\n [key: string]: any;\n stops: {\n offset: number;\n color: string;\n }[];\n}\n\n/**\n * Escape special HTML characters.\n *\n * @param value A value to convert to string and HTML-escape.\n */\nexport function escapeHTML(value: any): string {\n return String(value)\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n .replace(/\\(/g, '&#40;')\n .replace(/ /g, ' &nbsp;'); // 转义符和真空格夹杂,在转义和正常换行之间取得平衡\n}\n\nexport const getTooltipContentValue = <T>(\n field?: TooltipContentProperty<T>,\n datum?: any,\n params?: TooltipHandlerParams\n): T | undefined => {\n if (isNil(field)) {\n return field;\n }\n if (isFunction(field)) {\n return field(datum, params);\n }\n return field;\n};\n\nexport const getTooltipPatternValue = <T>(\n field?: MaybeArray<TooltipPatternProperty<T>>,\n data?: TooltipData,\n params?: TooltipHandlerParams\n): (typeof field extends Array<TooltipPatternProperty<T>> ? MaybeArray<T> : T) | undefined => {\n if (isNil(field)) {\n return field;\n }\n if (isArray(field)) {\n const result: T[] = [];\n field.forEach(item => {\n if (isFunction(item)) {\n const value = item(data, params);\n if (isValid(value)) {\n result.push(value);\n }\n } else {\n result.push(item);\n }\n });\n return result as any;\n }\n if (isFunction(field)) {\n return field(data, params);\n }\n return field;\n};\n\nexport function getFirstDatumFromTooltipData(data: TooltipData): Datum {\n // 找到第一个可用的datum\n const dimInfoList: IDimensionInfo[] = (data as IDimensionData[])[0]?.series\n ? [{ data: data as IDimensionData[], value: '' }]\n : (data as IDimensionInfo[]);\n for (const { data: dataList } of dimInfoList) {\n for (const { datum: datumList } of dataList) {\n for (const datumItem of datumList ?? []) {\n if (datumItem) {\n return datumItem;\n }\n }\n }\n }\n}\n\nexport function pickFirstValidValue<T>(isValid: (element?: T) => any, ...elements: T[]): T | undefined {\n for (const ele of elements) {\n if (isValid(ele)) {\n return ele;\n }\n }\n return undefined;\n}\n\n// 针对渐变色,受底层渲染引擎影响,不一定都能绘制正确,所以这里取 colorStop 的第一个颜色作为 color\nexport function convertToColorString(color: any, defaultColor: string = '#000') {\n if (!color) {\n return defaultColor;\n }\n if (isString(color)) {\n return color;\n }\n\n if (isObject(color) && (color as IGradientColor).stops && (color as IGradientColor).stops[0]) {\n return (color as IGradientColor).stops[0].color || defaultColor;\n }\n\n return defaultColor;\n}\n\n/** 获取元素的绝对缩放因数(支持外部传入 boundingClientRect 提升性能) */\nexport const getScale = (element: HTMLElement, boundingClientRect?: DOMRect) => {\n if (!element) {\n return 1;\n }\n if (!boundingClientRect) {\n boundingClientRect = element.getBoundingClientRect();\n }\n if (element.offsetWidth > 0) {\n return boundingClientRect.width / element.offsetWidth;\n }\n return boundingClientRect.height / element.offsetHeight;\n};\n\ninterface ITooltipTextInfo {\n width: number;\n height: number;\n text: MaybeArray<number> | MaybeArray<string>;\n}\n\n/** 测量 tooltip 标签文本 */\nexport const measureTooltipText = (text: string, style: ITooltipTextStyle): ITooltipTextInfo => {\n text = (text ?? '').toString();\n let textLines: string[];\n if (style.multiLine) {\n textLines = text.split('\\n');\n textLines = textLines.map((line, i) => (i < textLines.length - 1 ? line + '\\n' : line));\n } else {\n textLines = [text];\n }\n\n const bound = getRichTextBounds({\n wordBreak: style.wordBreak ?? 'break-word',\n maxWidth: style.maxWidth ? style.maxWidth : undefined,\n width: 0,\n height: 0,\n textConfig: textLines.map(\n line =>\n ({\n ...style,\n text: line\n } as unknown as IRichTextParagraphCharacter)\n )\n });\n return {\n width: bound.width(),\n height: bound.height(),\n text: textLines\n };\n};\n"]}
1
+ {"version":3,"sources":["../src/component/tooltip/handler/utils/common.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAK3F,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAkB3D,MAAM,UAAU,UAAU,CAAC,KAAU;IACnC,OAA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G,SAAS,CAAC,GAAG,CACxB,IAAI,CAAC,EAAE,CACL,CAAC,gCACI,KAAK,KACR,IAAI,EAAE,IAAI,GACgC,CAAA,CAC/C,CAAC;KACH;SAAM;QACL,UAAU,GAAI,IAA6B,CAAC,IAA4B,CAAC;QACzE,SAAS,GAAG,IAA4B,CAAC;KAC1C;IAED,MAAM,KAAK,GAAG,iBAAiB,CAAC;QAC9B,SAAS,EAAE,MAAA,KAAK,CAAC,SAAS,mCAAI,YAAY;QAC1C,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;QACrD,KAAK,EAAE,CAAC;QACR,MAAM,EAAE,CAAC;QACT,UAAU,EAAE,UAAU;KACvB,CAAC,CAAC;IACH,OAAO;QACL,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE;QACpB,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE;QACtB,IAAI,EAAE,SAAS;KAChB,CAAC;AACJ,CAAC,CAAC","file":"common.js","sourcesContent":["import type { Datum } from '@visactor/vgrammar-core';\nimport type { MaybeArray, TooltipContentProperty, TooltipData, TooltipPatternProperty } from '../../../../typings';\nimport { isFunction, isObject, isString, isNil, isArray, isValid } from '@visactor/vutils';\nimport type { TooltipHandlerParams } from '../../interface';\nimport type { IDimensionData, IDimensionInfo } from '../../../../event/events/dimension';\nimport type { IRichTextParagraphCharacter } from '@visactor/vrender-core';\n// eslint-disable-next-line no-duplicate-imports\nimport { getRichTextBounds } from '@visactor/vrender-core';\nimport type { ITooltipTextStyle } from '../interface/style';\nimport type { TooltipRichTextAttrs } from '@visactor/vrender-components';\nimport type { IRichTextCharacter } from '@visactor/vrender-core';\n\ninterface IGradientColor {\n [key: string]: any;\n stops: {\n offset: number;\n color: string;\n }[];\n}\n\n/**\n * Escape special HTML characters.\n *\n * @param value A value to convert to string and HTML-escape.\n */\nexport function escapeHTML(value: any): string {\n return String(value)\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n .replace(/\\(/g, '&#40;')\n .replace(/ /g, ' &nbsp;'); // 转义符和真空格夹杂,在转义和正常换行之间取得平衡\n}\n\nexport const getTooltipContentValue = <T>(\n field?: TooltipContentProperty<T>,\n datum?: any,\n params?: TooltipHandlerParams\n): T | undefined => {\n if (isNil(field)) {\n return field;\n }\n if (isFunction(field)) {\n return field(datum, params);\n }\n return field;\n};\n\nexport const getTooltipPatternValue = <T>(\n field?: MaybeArray<TooltipPatternProperty<T>>,\n data?: TooltipData,\n params?: TooltipHandlerParams\n): (typeof field extends Array<TooltipPatternProperty<T>> ? MaybeArray<T> : T) | undefined => {\n if (isNil(field)) {\n return field;\n }\n if (isArray(field)) {\n const result: T[] = [];\n field.forEach(item => {\n if (isFunction(item)) {\n const value = item(data, params);\n if (isValid(value)) {\n result.push(value);\n }\n } else {\n result.push(item);\n }\n });\n return result as any;\n }\n if (isFunction(field)) {\n return field(data, params);\n }\n return field;\n};\n\nexport function getFirstDatumFromTooltipData(data: TooltipData): Datum {\n // 找到第一个可用的datum\n const dimInfoList: IDimensionInfo[] = (data as IDimensionData[])[0]?.series\n ? [{ data: data as IDimensionData[], value: '' }]\n : (data as IDimensionInfo[]);\n for (const { data: dataList } of dimInfoList) {\n for (const { datum: datumList } of dataList) {\n for (const datumItem of datumList ?? []) {\n if (datumItem) {\n return datumItem;\n }\n }\n }\n }\n}\n\nexport function pickFirstValidValue<T>(isValid: (element?: T) => any, ...elements: T[]): T | undefined {\n for (const ele of elements) {\n if (isValid(ele)) {\n return ele;\n }\n }\n return undefined;\n}\n\n// 针对渐变色,受底层渲染引擎影响,不一定都能绘制正确,所以这里取 colorStop 的第一个颜色作为 color\nexport function convertToColorString(color: any, defaultColor: string = '#000') {\n if (!color) {\n return defaultColor;\n }\n if (isString(color)) {\n return color;\n }\n\n if (isObject(color) && (color as IGradientColor).stops && (color as IGradientColor).stops[0]) {\n return (color as IGradientColor).stops[0].color || defaultColor;\n }\n\n return defaultColor;\n}\n\n/** 获取元素的绝对缩放因数(支持外部传入 boundingClientRect 提升性能) */\nexport const getScale = (element: HTMLElement, boundingClientRect?: DOMRect) => {\n if (!element) {\n return 1;\n }\n if (!boundingClientRect) {\n boundingClientRect = element.getBoundingClientRect();\n }\n if (element.offsetWidth > 0) {\n return boundingClientRect.width / element.offsetWidth;\n }\n return boundingClientRect.height / element.offsetHeight;\n};\n\ninterface ITooltipTextInfo {\n width: number;\n height: number;\n text: MaybeArray<number> | MaybeArray<string> | TooltipRichTextAttrs;\n}\n\n/** 测量 tooltip 标签文本 */\nexport const measureTooltipText = (text: string | TooltipRichTextAttrs, style: ITooltipTextStyle): ITooltipTextInfo => {\n let textLines: string[] | TooltipRichTextAttrs;\n let textConfig: IRichTextCharacter[];\n if (!((text as TooltipRichTextAttrs)?.type === 'rich' || (text as TooltipRichTextAttrs)?.type === 'html')) {\n text = (text ?? '').toString();\n if (style.multiLine) {\n textLines = text.split('\\n');\n textLines = textLines.map((line, i) => (i < (textLines as string[]).length - 1 ? line + '\\n' : line));\n } else {\n textLines = [text];\n }\n textConfig = textLines.map(\n line =>\n ({\n ...style,\n text: line\n } as unknown as IRichTextParagraphCharacter)\n );\n } else {\n textConfig = (text as TooltipRichTextAttrs).text as IRichTextCharacter[];\n textLines = text as TooltipRichTextAttrs;\n }\n\n const bound = getRichTextBounds({\n wordBreak: style.wordBreak ?? 'break-word',\n maxWidth: style.maxWidth ? style.maxWidth : undefined,\n width: 0,\n height: 0,\n textConfig: textConfig\n });\n return {\n width: bound.width(),\n height: bound.height(),\n text: textLines\n };\n};\n"]}
@@ -1,7 +1,7 @@
1
1
  import { VChart } from './vchart';
2
2
  import { Factory } from './factory';
3
3
  export { VChart, Factory };
4
- export declare const version = "1.7.0-alpha.2";
4
+ export declare const version = "1.7.0";
5
5
  export type { IVChart } from './interface';
6
6
  export type { IStateSpec, StateValueType } from '../compile/mark';
7
7
  export * from '../typings/spec/common';
package/esm/core/index.js CHANGED
@@ -4,7 +4,7 @@ import { Factory } from "./factory";
4
4
 
5
5
  export { VChart, Factory };
6
6
 
7
- export const version = "1.7.0-alpha.2";
7
+ export const version = "1.7.0";
8
8
 
9
9
  export * from "../typings/spec/common";
10
10
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/core/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AAG3B,MAAM,CAAC,MAAM,OAAO,GAAG,eAAe,CAAC;AAMvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAK5B,cAAc,uBAAuB,CAAC;AAGtC,cAAc,gBAAgB,CAAC;AAG/B,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC","file":"index.js","sourcesContent":["/**\n * @description The core module of VChart, containing the necessary interfaces for using VChart.\n */\n\nimport { VChart } from './vchart';\nimport { Factory } from './factory';\n\nexport { VChart, Factory };\n\n// export the version\nexport const version = \"1.7.0-alpha.2\";\n\n// export necessary types\nexport type { IVChart } from './interface';\nexport type { IStateSpec, StateValueType } from '../compile/mark';\n\nexport * from '../typings/spec/common';\nexport * from '../event/interface';\nexport * from '../theme/interface';\nexport * from '../constant';\n\n/**\n * spec\n */\nexport * from '../typings/spec/index';\n\n// theme\nexport * from '../theme/index';\n\n// vrender\nexport { vglobal } from '@visactor/vrender-core';\n"]}
1
+ {"version":3,"sources":["../src/core/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AAG3B,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC;AAM/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAK5B,cAAc,uBAAuB,CAAC;AAGtC,cAAc,gBAAgB,CAAC;AAG/B,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC","file":"index.js","sourcesContent":["/**\n * @description The core module of VChart, containing the necessary interfaces for using VChart.\n */\n\nimport { VChart } from './vchart';\nimport { Factory } from './factory';\n\nexport { VChart, Factory };\n\n// export the version\nexport const version = \"1.7.0\";\n\n// export necessary types\nexport type { IVChart } from './interface';\nexport type { IStateSpec, StateValueType } from '../compile/mark';\n\nexport * from '../typings/spec/common';\nexport * from '../event/interface';\nexport * from '../theme/interface';\nexport * from '../constant';\n\n/**\n * spec\n */\nexport * from '../typings/spec/index';\n\n// theme\nexport * from '../theme/index';\n\n// vrender\nexport { vglobal } from '@visactor/vrender-core';\n"]}
@@ -1,10 +1,12 @@
1
1
  import type { ITextMarkSpec } from '../typings/visual';
2
2
  import { BaseMark } from './base/base-mark';
3
3
  import type { IMarkRaw, IMarkStyle } from './interface';
4
- import { MarkTypeEnum } from './interface/type';
4
+ import { MarkTypeEnum } from './interface';
5
+ import type { IGroupMark } from '@visactor/vgrammar-core';
5
6
  export type ITextMark = IMarkRaw<ITextMarkSpec>;
6
7
  export declare class TextMark extends BaseMark<ITextMarkSpec> implements ITextMark {
7
8
  static readonly type = MarkTypeEnum.text;
8
9
  readonly type = MarkTypeEnum.text;
9
10
  protected _getDefaultStyle(): IMarkStyle<ITextMarkSpec>;
11
+ protected _initProduct(group?: string | IGroupMark): void;
10
12
  }
package/esm/mark/text.js CHANGED
@@ -1,6 +1,8 @@
1
1
  import { BaseMark } from "./base/base-mark";
2
2
 
3
- import { MarkTypeEnum } from "./interface/type";
3
+ import { MarkTypeEnum } from "./interface";
4
+
5
+ import { GrammarMarkType } from "@visactor/vgrammar-core";
4
6
 
5
7
  export class TextMark extends BaseMark {
6
8
  constructor() {
@@ -10,9 +12,15 @@ export class TextMark extends BaseMark {
10
12
  return Object.assign(Object.assign({}, super._getDefaultStyle()), {
11
13
  angle: 0,
12
14
  textAlign: "center",
13
- lineWidth: 0
15
+ lineWidth: 0,
16
+ textConfig: []
14
17
  });
15
18
  }
19
+ _initProduct(group) {
20
+ const view = this.getVGrammarView(), id = this.getProductId();
21
+ "rich" === this.getStyle("textType") ? this._product = view.mark(GrammarMarkType.richtext, null != group ? group : view.rootMark).id(id) : this._product = view.mark(GrammarMarkType.text, null != group ? group : view.rootMark).id(id),
22
+ this._compiledProductId = id;
23
+ }
16
24
  }
17
25
 
18
26
  TextMark.type = MarkTypeEnum.text;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/mark/text.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG5C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAIhD,MAAM,OAAO,QAAS,SAAQ,QAAuB;IAArD;;QAEW,SAAI,GAAG,QAAQ,CAAC,IAAI,CAAC;IAYhC,CAAC;IAVW,gBAAgB;QACxB,MAAM,YAAY,mCACb,KAAK,CAAC,gBAAgB,EAAE,KAE3B,KAAK,EAAE,CAAC,EACR,SAAS,EAAE,QAAQ,EACnB,SAAS,EAAE,CAAC,GACb,CAAC;QACF,OAAO,YAAY,CAAC;IACtB,CAAC;;AAZe,aAAI,GAAG,YAAY,CAAC,IAAI,CAAC","file":"text.js","sourcesContent":["import type { ITextMarkSpec } from '../typings/visual';\nimport { BaseMark } from './base/base-mark';\nimport type { IMarkRaw, IMarkStyle } from './interface';\n// eslint-disable-next-line no-duplicate-imports\nimport { MarkTypeEnum } from './interface/type';\n\nexport type ITextMark = IMarkRaw<ITextMarkSpec>;\n\nexport class TextMark extends BaseMark<ITextMarkSpec> implements ITextMark {\n static readonly type = MarkTypeEnum.text;\n readonly type = TextMark.type;\n\n protected _getDefaultStyle() {\n const defaultStyle: IMarkStyle<ITextMarkSpec> = {\n ...super._getDefaultStyle(),\n // TODO: 删除后会有显示问题,待排查\n angle: 0,\n textAlign: 'center',\n lineWidth: 0\n };\n return defaultStyle;\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/mark/text.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG5C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAK1D,MAAM,OAAO,QAAS,SAAQ,QAAuB;IAArD;;QAEW,SAAI,GAAG,QAAQ,CAAC,IAAI,CAAC;IA4BhC,CAAC;IA1BW,gBAAgB;QACxB,MAAM,YAAY,mCACb,KAAK,CAAC,gBAAgB,EAAE,KAE3B,KAAK,EAAE,CAAC,EACR,SAAS,EAAE,QAAQ,EACnB,SAAS,EAAE,CAAC,EACZ,UAAU,EAAE,EAAE,GACf,CAAC;QACF,OAAO,YAAY,CAAC;IACtB,CAAC;IAES,YAAY,CAAC,KAA2B;QAChD,MAAM,IAAI,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;QAGpC,MAAM,EAAE,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QAE/B,IAAI,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,MAAM,EAAE;YACxC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,QAA2B,EAAE,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;SACvG;aAAM;YACL,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,IAAuB,EAAE,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;SACnG;QAED,IAAI,CAAC,kBAAkB,GAAG,EAAE,CAAC;IAC/B,CAAC;;AA5Be,aAAI,GAAG,YAAY,CAAC,IAAI,CAAC","file":"text.js","sourcesContent":["import type { ITextMarkSpec } from '../typings/visual';\nimport { BaseMark } from './base/base-mark';\nimport type { IMarkRaw, IMarkStyle, IMarkOption } from './interface';\n// eslint-disable-next-line no-duplicate-imports\nimport { MarkTypeEnum } from './interface';\nimport { GrammarMarkType } from '@visactor/vgrammar-core';\nimport type { IGroupMark } from '@visactor/vgrammar-core';\n\nexport type ITextMark = IMarkRaw<ITextMarkSpec>;\n\nexport class TextMark extends BaseMark<ITextMarkSpec> implements ITextMark {\n static readonly type = MarkTypeEnum.text;\n readonly type = TextMark.type;\n\n protected _getDefaultStyle() {\n const defaultStyle: IMarkStyle<ITextMarkSpec> = {\n ...super._getDefaultStyle(),\n // TODO: 删除后会有显示问题,待排查\n angle: 0,\n textAlign: 'center',\n lineWidth: 0,\n textConfig: []\n };\n return defaultStyle;\n }\n\n protected _initProduct(group?: string | IGroupMark) {\n const view = this.getVGrammarView();\n\n // 声明语法元素\n const id = this.getProductId();\n\n if (this.getStyle('textType') === 'rich') {\n this._product = view.mark(GrammarMarkType.richtext as GrammarMarkType, group ?? view.rootMark).id(id);\n } else {\n this._product = view.mark(GrammarMarkType.text as GrammarMarkType, group ?? view.rootMark).id(id);\n }\n\n this._compiledProductId = id;\n }\n}\n"]}
@@ -1,16 +1,17 @@
1
1
  import type { TooltipContentProperty } from './common';
2
2
  import type { ITooltipLabelActual, ITooltipLabelPattern } from './label';
3
3
  import type { ITooltipShapeActual, ITooltipShapePattern } from './shape';
4
+ import type { TooltipRichTextAttrs } from '@visactor/vrender-components';
4
5
  export interface IToolTipLinePattern extends ITooltipShapePattern, ITooltipLabelPattern {
5
6
  key?: TooltipContentProperty<string>;
6
- value?: TooltipContentProperty<string>;
7
+ value?: TooltipContentProperty<string | TooltipRichTextAttrs>;
7
8
  visible?: TooltipContentProperty<boolean>;
8
9
  isKeyAdaptive?: TooltipContentProperty<boolean>;
9
10
  spaceRow?: TooltipContentProperty<number>;
10
11
  }
11
12
  export interface IToolTipLineActual extends ITooltipShapeActual, ITooltipLabelActual {
12
13
  key?: string;
13
- value?: string;
14
+ value?: string | TooltipRichTextAttrs;
14
15
  visible?: boolean;
15
16
  isKeyAdaptive?: boolean;
16
17
  spaceRow?: number;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/typings/tooltip/line.ts"],"names":[],"mappings":"","file":"line.js","sourcesContent":["import type { TooltipContentProperty } from './common';\nimport type { ITooltipLabelActual, ITooltipLabelPattern } from './label';\nimport type { ITooltipShapeActual, ITooltipShapePattern } from './shape';\n\nexport interface IToolTipLinePattern extends ITooltipShapePattern, ITooltipLabelPattern {\n /** tooltip key 值内容 */\n key?: TooltipContentProperty<string>;\n /** tooltip value 值内容 */\n value?: TooltipContentProperty<string>;\n /** 该行是否可见 */\n visible?: TooltipContentProperty<boolean>;\n /** key 列是否适应内容 */\n isKeyAdaptive?: TooltipContentProperty<boolean>;\n /**\n * 该行行间距\n * @since 1.4.0\n */\n spaceRow?: TooltipContentProperty<number>;\n}\n\nexport interface IToolTipLineActual extends ITooltipShapeActual, ITooltipLabelActual {\n /** tooltip key 值内容 */\n key?: string;\n /** tooltip value 值内容 */\n value?: string;\n /** 该行是否可见 */\n visible?: boolean;\n /** key 列是否适应内容 */\n isKeyAdaptive?: boolean;\n /**\n * 该行行间距\n * @since 1.4.0\n */\n spaceRow?: number;\n /**\n * 该行对应的原始数据\n * @since 1.5.1\n */\n datum?: any;\n}\n"]}
1
+ {"version":3,"sources":["../src/typings/tooltip/line.ts"],"names":[],"mappings":"","file":"line.js","sourcesContent":["import type { TooltipContentProperty } from './common';\nimport type { ITooltipLabelActual, ITooltipLabelPattern } from './label';\nimport type { ITooltipShapeActual, ITooltipShapePattern } from './shape';\nimport type { TooltipRichTextAttrs } from '@visactor/vrender-components';\n\nexport interface IToolTipLinePattern extends ITooltipShapePattern, ITooltipLabelPattern {\n /** tooltip key 值内容 */\n key?: TooltipContentProperty<string>;\n /** tooltip value 值内容\n * 支持富文本配置\n * - type 文本类型:text, rich, html\n * - text 文本内容:string | string[] | number | number[] | IRichTextCharacter[];\n */\n value?: TooltipContentProperty<string | TooltipRichTextAttrs>;\n /** 该行是否可见 */\n visible?: TooltipContentProperty<boolean>;\n /** key 列是否适应内容 */\n isKeyAdaptive?: TooltipContentProperty<boolean>;\n /**\n * 该行行间距\n * @since 1.4.0\n */\n spaceRow?: TooltipContentProperty<number>;\n}\n\nexport interface IToolTipLineActual extends ITooltipShapeActual, ITooltipLabelActual {\n /** tooltip key 值内容 */\n key?: string;\n /** tooltip value 值内容 */\n value?: string | TooltipRichTextAttrs;\n /** 该行是否可见 */\n visible?: boolean;\n /** key 列是否适应内容 */\n isKeyAdaptive?: boolean;\n /**\n * 该行行间距\n * @since 1.4.0\n */\n spaceRow?: number;\n /**\n * 该行对应的原始数据\n * @since 1.5.1\n */\n datum?: any;\n}\n"]}
@@ -10,6 +10,7 @@ import type { Datum, StringOrNumber } from './common';
10
10
  import type { IPadding } from '@visactor/vutils';
11
11
  import type { IColorKey } from '../theme/color-scheme/interface';
12
12
  import type { IRepeatType, TextAlignType, TextBaselineType } from '@visactor/vrender-core';
13
+ import type { IRichTextCharacter } from '@visactor/vrender-core';
13
14
  export interface IVisualSpecBase<D, T> {
14
15
  type: ScaleType;
15
16
  domain: D[];
@@ -115,7 +116,8 @@ export interface IRuleMarkSpec extends ILineMarkSpec {
115
116
  y1?: number;
116
117
  }
117
118
  export interface ITextMarkSpec extends IFillMarkSpec {
118
- text?: StringOrNumber | string[];
119
+ type?: 'html' | 'rich' | 'text';
120
+ text?: StringOrNumber | string[] | IRichTextCharacter[] | Function;
119
121
  dx?: number;
120
122
  dy?: number;
121
123
  fontSize?: number;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/typings/visual.ts"],"names":[],"mappings":"","file":"visual.js","sourcesContent":["import type { PopTipAttributes } from '@visactor/vrender-components';\nimport type { DataView } from '@visactor/vdataset';\nimport type { Cursor } from './cursor';\nimport type { InterpolateType } from './interpolate';\nimport type { ScaleType } from './scale';\nimport type { ShapeType } from './shape';\nimport type { IPoint } from './coordinate';\nimport type { IAttributeOpt, IModelMarkAttributeContext } from '../compile/mark';\nimport type { Datum, StringOrNumber } from './common';\nimport type { IPadding } from '@visactor/vutils';\nimport type { IColorKey } from '../theme/color-scheme/interface';\nimport type { IRepeatType, TextAlignType, TextBaselineType } from '@visactor/vrender-core';\n\n// 基础的visual 对应 scale 的属性\nexport interface IVisualSpecBase<D, T> {\n /**\n * type of scale\n */\n type: ScaleType;\n /**\n * will set to scale.domain, it means input of scale\n */\n domain: D[];\n /**\n * will set to scale.range, it means output of scale\n */\n range: T[];\n /**\n * will set to scale.specified if scale support, as a key-value pair matching capability\n * @since 1.1.0\n */\n specified?: { [key: string]: unknown };\n}\n// 用来给用户进行mark.style上的映射配置。所以要配置数据维度\nexport interface IVisualSpecStyle<D, T> extends IVisualSpecBase<D, T> {\n field?: string;\n}\n\nexport type IDataDomainSpec = {\n dataId: string;\n fields: string[];\n};\n\n// 用来提供给用户进行 scale 配置 所以名字是必选的 对用户配置\nexport interface IVisualSpecScale<D, T> extends Omit<IVisualSpecBase<D, T>, 'domain'> {\n id: string;\n domain:\n | IVisualSpecBase<D, T>['domain']\n // 使用数据的字段值,如果 scale 是连续的,就取区间,如果是离散的就使用 values 。\n // 不考虑图表内的交互等数据筛选,这里只用原始数据的统计信息\n | IDataDomainSpec[];\n}\n// 对用户配置\nexport type IVisual<D = any, R = any> = IVisualSpecStyle<D, R> | IVisualScale;\n\nexport interface IVisualScale {\n /**\n * 对应 IVisualSpecScale 的用户配置 scale-id\n */\n scale: string;\n /**\n * 指定参与映射的数据字段\n */\n field?: string;\n /**\n * 当用户指定 field 后,用该属性来控制值域。\n * @default 'none'\n */\n changeDomain?: 'none' | 'replace' | 'expand';\n}\n\nexport type FunctionType<T> = (\n datum: Datum,\n context: IModelMarkAttributeContext,\n opt?: IAttributeOpt,\n source?: DataView\n) => T;\nexport type ValueType<T> = T;\nexport type VisualType<T> = ValueType<T> | FunctionType<T> | IVisual<unknown, T>;\n\nexport type TextureType =\n | 'circle'\n | 'dimond'\n | 'rect'\n | 'vertical-line'\n | 'horizontal-line'\n | 'bias-lr'\n | 'bias-rl'\n | 'grid';\n\n/**\n * style格式转换\n */\nexport type ConvertToMarkStyleSpec<T extends Record<string, any>> = {\n [key in keyof T]: VisualType<T[key]>;\n};\n\n/**\n * border\n */\n\nexport interface IBorder {\n distance: number | string;\n stroke?: string | IGradient;\n strokeOpacity?: number;\n lineWidth?: number;\n lineDash?: number[];\n lineDashOffset?: number;\n}\n\nexport interface ICommonSpec {\n visible?: boolean;\n x?: number;\n y?: number;\n z?: number;\n /**\n * @todo 隔离主题和 spec 配置\n * IColorKey 类型只适用于主题\n */\n stroke?: string | IGradient | false | (number | boolean)[] | IColorKey;\n strokeOpacity?: number;\n opacity?: number;\n lineWidth?: number;\n lineDash?: number[];\n lineDashOffset?: number;\n\n cursor?: Cursor;\n zIndex?: number;\n angle?: number;\n anchor?: [number, number];\n\n // 缩放属性\n scaleX?: number;\n scaleY?: number;\n /**\n * 图形缩放中心\n * @since 1.4.0\n * 可以配置固定坐标,例如 [100, 100];或者百分比坐标,例如 ['50%', '50%'],代表以图元中心为缩放中心\n * */\n scaleCenter?: [number | string, number | string];\n\n // 3d旋转的属性\n beta?: number;\n alpha?: number;\n anchor3d?: [number, number];\n\n /**\n * 选择模式,精确模式,粗糙模式(包围盒模式),自定义模式\n */\n pickMode?: 'accurate' | 'imprecise' | 'custom';\n boundsMode?: 'accurate' | 'imprecise';\n\n // 以下是纹理相关的属性\n /**\n * 纹理的类型\n */\n texture?: TextureType | string;\n /**\n * 纹理的颜色\n */\n textureColor?: string;\n /**\n * 纹理单元的大小\n */\n textureSize?: number; // 纹理大小\n /**\n * 纹理之间空隙的大小\n */\n texturePadding?: number;\n\n /**\n * 外边框\n */\n outerBorder?: IBorder;\n /**\n * 内边框\n */\n innerBorder?: IBorder;\n\n [key: string]: any;\n}\n\nexport interface IFillMarkSpec extends ICommonSpec {\n /**\n * @todo 隔离主题和 spec 配置\n * IColorKey 类型只适用于主题\n */\n fill?: VisualType<string> | IGradient | false | IColorKey;\n fillOpacity?: number;\n // TODO:waite VRender support this api\n // backgroundMode: number; // 填充模式(与具体图元有关)\n // can coexist with fill\n background?: string | HTMLImageElement | HTMLCanvasElement | null;\n}\n\n// export interface IFillImageMarkSpec {\n// fillImage?: string;\n// repeatX?: RepeatXYType;\n// repeatY?: RepeatXYType;\n// imageOrigin?: ImageOriginType;\n// }\n\nexport interface ISymbolMarkSpec extends IFillMarkSpec {\n dx?: number;\n dy?: number;\n size?: number | number[];\n /** 对外声明使用shape,vrender图形属性对应的是shape */\n shape?: ShapeType | string;\n /** FIXME: vrender Symbol接收的图形属性,暂时都申明一下 */\n symbolType?: ShapeType | string;\n scaleX?: number;\n scaleY?: number;\n}\n\n// lineMark 和 areaMark 共同配置\nexport interface ILineLikeMarkSpec extends IFillMarkSpec {\n curveType?: InterpolateType;\n defined?: boolean;\n}\n\nexport interface IAreaMarkSpec extends ILineLikeMarkSpec {\n x1?: number;\n y1?: number;\n\n orient?: 'horizontal' | 'vertical';\n}\n\nexport interface ILineMarkSpec extends ILineLikeMarkSpec {\n lineCap?: LineStrokeCap;\n lineJoin?: LineStrokeJoin;\n miterLimit?: number;\n strokeBoundsBuffer?: number;\n}\n\nexport interface IRuleMarkSpec extends ILineMarkSpec {\n x1?: number;\n y1?: number;\n}\n\nexport interface ITextMarkSpec extends IFillMarkSpec {\n /**\n * 文字内容\n */\n text?: StringOrNumber | string[];\n /**\n * x 方向偏移\n */\n dx?: number;\n /**\n * y 方向偏移\n */\n dy?: number;\n /**\n * 字号\n */\n fontSize?: number;\n /**\n * 文字对齐方式\n */\n textAlign?: TextAlign;\n /**\n * 文字居中方式\n */\n textBaseline?: TextBaseLine;\n /**\n * 字体\n */\n fontFamily?: string;\n /**\n * 字重\n */\n fontWeight?: FontWeight;\n /**\n * 字体样式\n */\n fontStyle?: FontStyle;\n /**\n * 文字的最大长度\n */\n maxLineWidth?: number;\n /**\n * 文字超出 maxLineWidth 后的省略符\n */\n ellipsis?: string;\n // TODO: 这些不是常规的文字mark属性,待确认需求背景\n lineBreak?: string;\n /**\n * 下划线\n */\n underline?: boolean;\n /**\n * 中划线\n */\n lineThrough?: boolean;\n /**\n * 行高(1.3.1 版本新增字符串类型表示比例值,如\"150%\")\n * @since 1.3.1\n */\n lineHeight?: number | string;\n /**\n * poptip 相关配置\n */\n poptip?: PopTipAttributes;\n /**\n * 文本的排布方向,如果需要文本纵向排布,可以配置为 'vertical'\n * @default 'horizontal'\n */\n direction?: 'horizontal' | 'vertical';\n}\n\nexport type IPositionedTextMarkSpec = Omit<ITextMarkSpec, 'align' | 'textAlign' | 'baseline' | 'textBaseline'>;\n\nexport interface IRectMarkSpec extends IFillMarkSpec {\n /**\n * 圆角配置。\n * 1. 如果传入数值,则统一为四个角设置圆角\n * 2. 如果传入数组,则分别为 [上左, 上右, 下右, 下左]\n */\n cornerRadius?: number | number[];\n width?: number;\n height?: number;\n x1?: number;\n y1?: number;\n}\n\n// 3d rect,支持length表示长宽高中的长属性(深度属性)\nexport interface IRect3dMarkSpec extends IRectMarkSpec {\n length?: number;\n}\n\nexport interface IBoxPlotMarkSpec extends ICommonSpec {\n /**\n * box描边宽度\n */\n lineWidth?: number;\n /**\n * box宽度\n */\n boxWidth?: number;\n /**\n * 最大最小值宽度\n */\n shaftWidth?: number;\n /**\n * 中轴线类型\n */\n shaftShape?: BoxPlotShaftShape;\n /**\n * 盒子填充颜色,为空则不填充\n */\n boxFill?: string;\n // /**\n // * 描边颜色\n // */\n // stroke?: string;\n /**\n * 中轴线透明度,仅当shaftType=bar时生效\n */\n shaftFillOpacity?: number;\n\n min?: (datum: Datum) => number;\n q1?: (datum: Datum) => number;\n median?: (datum: Datum) => number;\n q3?: (datum: Datum) => number;\n max?: (datum: Datum) => number;\n}\n\nexport interface IRippleMarkSpec extends ICommonSpec {\n /**\n * 波纹密度ripple\n * ripple 取值范为[0,1]\n */\n ripple?: number;\n /**\n * 水波纹最大半径\n */\n size?: number;\n}\n\nexport interface IOutlierMarkSpec {\n //异常点填充颜色\n fill?: string;\n //异常点大小\n size?: number;\n}\n\nexport interface IPathMarkSpec extends IFillMarkSpec {\n path?: string;\n // TODO: 该属性后续可能会删除,未定\n // 平滑缩放,不然会发生跳变,在地图交互场景需要配置为true;常规path缩放不需要\n smoothScale?: boolean;\n}\n\nexport interface ILinkPathMarkSpec extends IFillMarkSpec {\n x0?: number;\n y0?: number;\n x1?: number;\n y1?: number;\n thickness?: number;\n curvature?: number;\n /** round all the coordinates */\n round?: boolean;\n /** the ratio of normal style path */\n ratio?: number;\n align?: 'start' | 'end' | 'center';\n pathType?: 'line' | 'smooth' | 'polyline';\n endArrow?: boolean;\n startArrow?: boolean;\n backgroundStyle?: any;\n direction?: 'horizontal' | 'vertical' | 'LR' | 'RL' | 'TB' | 'BL' | 'radial';\n}\n\nexport interface IArcMarkSpec extends IFillMarkSpec {\n startAngle?: number;\n endAngle?: number;\n padAngle?: number;\n\n outerRadius?: number;\n innerRadius?: number;\n cornerRadius?: number;\n\n /** arc的中心点偏移距离 */\n centerOffset?: number;\n\n /** arc 的 roundCap 属性,即圆角是否伸出 startAngle 和 endAngle 之外 */\n cap?: boolean | [boolean, boolean];\n /** arc 在 roundCap 打开且应用环形渐变时是否对 cap 部分生效 */\n autoCapConical?: boolean;\n}\n\n// 3d arc,有高度配置\nexport interface IArc3dMarkSpec extends IArcMarkSpec {\n height?: number;\n}\n\nexport interface IProgressArcMarkSpec extends IArcMarkSpec {\n /** 进度条内侧 padding(接受负值) */\n innerPadding?: number;\n /** 进度条外侧 padding(接受负值) */\n outerPadding?: number;\n}\n\nexport interface ICellMarkSpec extends ISymbolMarkSpec {\n padding?: number | number[] | IPadding;\n}\n\nexport interface IGroupMarkSpec extends IFillMarkSpec {\n clip?: boolean;\n width?: number;\n height?: number;\n /**\n * 圆角配置。\n * 1. 如果传入数值,则统一为四个角设置圆角\n * 2. 如果传入数组,则分别为 [上左, 上右, 下右, 下左]\n */\n cornerRadius?: number | number[];\n}\n\nexport interface IPolygonMarkSpec extends ICommonSpec, IFillMarkSpec {\n points?: IPoint[];\n /**\n * 圆角配置,支持数组配置,数组的顺序同组成 polygon 的顺序对应\n */\n cornerRadius?: number | number[];\n scaleX?: number;\n scaleY?: number;\n}\n\nexport interface IPyramid3dMarkSpec extends IPolygonMarkSpec {\n // 只能有4个顶点\n points?: IPoint[];\n}\n\n/**\n * ImageFill\n */\nexport type RepeatType = 'no-repeat' | 'repeat-x' | 'repeat-y' | 'repeat';\nexport type RepeatXYType = 'no-repeat' | 'repeat' | 'stretch';\nexport type ImageOriginType = 'top' | 'bottom';\n\n/**\n * gradient\n */\nexport type GradientPropValue<T> = ValueType<T> | FunctionType<T>;\nexport type GradientStop = {\n offset: GradientPropValue<number>;\n color?: GradientPropValue<string>;\n opacity?: number;\n};\nexport interface IGradientLinear {\n x0?: GradientPropValue<number>;\n y0?: GradientPropValue<number>;\n x1?: GradientPropValue<number>;\n y1?: GradientPropValue<number>;\n stops: GradientStop[];\n gradient: 'linear';\n}\n\nexport interface IGradientRadial {\n r0?: GradientPropValue<number>;\n x0?: GradientPropValue<number>;\n y0?: GradientPropValue<number>;\n x1?: GradientPropValue<number>;\n y1?: GradientPropValue<number>;\n r1?: GradientPropValue<number>;\n stops: GradientStop[];\n gradient: 'radial';\n}\n\nexport interface IGradientConical {\n x?: GradientPropValue<number>;\n y?: GradientPropValue<number>;\n startAngle?: GradientPropValue<number>;\n endAngle?: GradientPropValue<number>;\n stops: GradientStop[];\n gradient: 'conical';\n}\n\nexport type GradientType = 'linear' | 'radial' | 'conical';\nexport type IGradient = IGradientLinear | IGradientRadial | IGradientConical;\n\nexport type LineStrokeCap = 'butt' | 'round' | 'square';\nexport type LineStrokeJoin = 'arcs' | 'bevel' | 'miter' | 'miter-clip' | 'round';\n\nexport type BoxPlotShaftShape = 'line' | 'bar';\n/**\n * threshold\n */\nexport interface IThresholdStyle extends IVisualSpecStyle<number, string> {\n domain: number[];\n field: string;\n range: string[];\n type: 'threshold';\n}\n\n// FIXME: For some tool methods that need to use common configuration types\nexport interface IUnknownMarkSpec extends ICommonSpec {\n [key: string]: unknown;\n}\n\nexport interface IImageMarkSpec extends IFillMarkSpec {\n /**\n * 圆角配置。\n * 1. 如果传入数值,则统一为四个角设置圆角\n * 2. 如果传入数组,则分别为 [上左, 上右, 下右, 下左]\n */\n cornerRadius?: number | number[];\n width?: number;\n height?: number;\n repeatX?: IRepeatType;\n repeatY?: IRepeatType;\n image: string | HTMLImageElement | HTMLCanvasElement;\n}\n\n/**\n * text\n */\nexport type TextAlign = TextAlignType;\nexport type TextBaseLine = TextBaselineType;\nexport type FontStyle = 'normal' | 'italic' | 'oblique' | string;\nexport type FontWeight = 'normal' | 'bold' | 'lighter' | 'bolder' | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900;\n"]}
1
+ {"version":3,"sources":["../src/typings/visual.ts"],"names":[],"mappings":"","file":"visual.js","sourcesContent":["import type { PopTipAttributes } from '@visactor/vrender-components';\nimport type { DataView } from '@visactor/vdataset';\nimport type { Cursor } from './cursor';\nimport type { InterpolateType } from './interpolate';\nimport type { ScaleType } from './scale';\nimport type { ShapeType } from './shape';\nimport type { IPoint } from './coordinate';\nimport type { IAttributeOpt, IModelMarkAttributeContext } from '../compile/mark';\nimport type { Datum, StringOrNumber } from './common';\nimport type { IPadding } from '@visactor/vutils';\nimport type { IColorKey } from '../theme/color-scheme/interface';\nimport type { IRepeatType, TextAlignType, TextBaselineType } from '@visactor/vrender-core';\nimport type { IRichTextCharacter } from '@visactor/vrender-core';\n\n// 基础的visual 对应 scale 的属性\nexport interface IVisualSpecBase<D, T> {\n /**\n * type of scale\n */\n type: ScaleType;\n /**\n * will set to scale.domain, it means input of scale\n */\n domain: D[];\n /**\n * will set to scale.range, it means output of scale\n */\n range: T[];\n /**\n * will set to scale.specified if scale support, as a key-value pair matching capability\n * @since 1.1.0\n */\n specified?: { [key: string]: unknown };\n}\n// 用来给用户进行mark.style上的映射配置。所以要配置数据维度\nexport interface IVisualSpecStyle<D, T> extends IVisualSpecBase<D, T> {\n field?: string;\n}\n\nexport type IDataDomainSpec = {\n dataId: string;\n fields: string[];\n};\n\n// 用来提供给用户进行 scale 配置 所以名字是必选的 对用户配置\nexport interface IVisualSpecScale<D, T> extends Omit<IVisualSpecBase<D, T>, 'domain'> {\n id: string;\n domain:\n | IVisualSpecBase<D, T>['domain']\n // 使用数据的字段值,如果 scale 是连续的,就取区间,如果是离散的就使用 values 。\n // 不考虑图表内的交互等数据筛选,这里只用原始数据的统计信息\n | IDataDomainSpec[];\n}\n// 对用户配置\nexport type IVisual<D = any, R = any> = IVisualSpecStyle<D, R> | IVisualScale;\n\nexport interface IVisualScale {\n /**\n * 对应 IVisualSpecScale 的用户配置 scale-id\n */\n scale: string;\n /**\n * 指定参与映射的数据字段\n */\n field?: string;\n /**\n * 当用户指定 field 后,用该属性来控制值域。\n * @default 'none'\n */\n changeDomain?: 'none' | 'replace' | 'expand';\n}\n\nexport type FunctionType<T> = (\n datum: Datum,\n context: IModelMarkAttributeContext,\n opt?: IAttributeOpt,\n source?: DataView\n) => T;\nexport type ValueType<T> = T;\nexport type VisualType<T> = ValueType<T> | FunctionType<T> | IVisual<unknown, T>;\n\nexport type TextureType =\n | 'circle'\n | 'dimond'\n | 'rect'\n | 'vertical-line'\n | 'horizontal-line'\n | 'bias-lr'\n | 'bias-rl'\n | 'grid';\n\n/**\n * style格式转换\n */\nexport type ConvertToMarkStyleSpec<T extends Record<string, any>> = {\n [key in keyof T]: VisualType<T[key]>;\n};\n\n/**\n * border\n */\n\nexport interface IBorder {\n distance: number | string;\n stroke?: string | IGradient;\n strokeOpacity?: number;\n lineWidth?: number;\n lineDash?: number[];\n lineDashOffset?: number;\n}\n\nexport interface ICommonSpec {\n visible?: boolean;\n x?: number;\n y?: number;\n z?: number;\n /**\n * @todo 隔离主题和 spec 配置\n * IColorKey 类型只适用于主题\n */\n stroke?: string | IGradient | false | (number | boolean)[] | IColorKey;\n strokeOpacity?: number;\n opacity?: number;\n lineWidth?: number;\n lineDash?: number[];\n lineDashOffset?: number;\n\n cursor?: Cursor;\n zIndex?: number;\n angle?: number;\n anchor?: [number, number];\n\n // 缩放属性\n scaleX?: number;\n scaleY?: number;\n /**\n * 图形缩放中心\n * @since 1.4.0\n * 可以配置固定坐标,例如 [100, 100];或者百分比坐标,例如 ['50%', '50%'],代表以图元中心为缩放中心\n * */\n scaleCenter?: [number | string, number | string];\n\n // 3d旋转的属性\n beta?: number;\n alpha?: number;\n anchor3d?: [number, number];\n\n /**\n * 选择模式,精确模式,粗糙模式(包围盒模式),自定义模式\n */\n pickMode?: 'accurate' | 'imprecise' | 'custom';\n boundsMode?: 'accurate' | 'imprecise';\n\n // 以下是纹理相关的属性\n /**\n * 纹理的类型\n */\n texture?: TextureType | string;\n /**\n * 纹理的颜色\n */\n textureColor?: string;\n /**\n * 纹理单元的大小\n */\n textureSize?: number; // 纹理大小\n /**\n * 纹理之间空隙的大小\n */\n texturePadding?: number;\n\n /**\n * 外边框\n */\n outerBorder?: IBorder;\n /**\n * 内边框\n */\n innerBorder?: IBorder;\n\n [key: string]: any;\n}\n\nexport interface IFillMarkSpec extends ICommonSpec {\n /**\n * @todo 隔离主题和 spec 配置\n * IColorKey 类型只适用于主题\n */\n fill?: VisualType<string> | IGradient | false | IColorKey;\n fillOpacity?: number;\n // TODO:waite VRender support this api\n // backgroundMode: number; // 填充模式(与具体图元有关)\n // can coexist with fill\n background?: string | HTMLImageElement | HTMLCanvasElement | null;\n}\n\n// export interface IFillImageMarkSpec {\n// fillImage?: string;\n// repeatX?: RepeatXYType;\n// repeatY?: RepeatXYType;\n// imageOrigin?: ImageOriginType;\n// }\n\nexport interface ISymbolMarkSpec extends IFillMarkSpec {\n dx?: number;\n dy?: number;\n size?: number | number[];\n /** 对外声明使用shape,vrender图形属性对应的是shape */\n shape?: ShapeType | string;\n /** FIXME: vrender Symbol接收的图形属性,暂时都申明一下 */\n symbolType?: ShapeType | string;\n scaleX?: number;\n scaleY?: number;\n}\n\n// lineMark 和 areaMark 共同配置\nexport interface ILineLikeMarkSpec extends IFillMarkSpec {\n curveType?: InterpolateType;\n defined?: boolean;\n}\n\nexport interface IAreaMarkSpec extends ILineLikeMarkSpec {\n x1?: number;\n y1?: number;\n\n orient?: 'horizontal' | 'vertical';\n}\n\nexport interface ILineMarkSpec extends ILineLikeMarkSpec {\n lineCap?: LineStrokeCap;\n lineJoin?: LineStrokeJoin;\n miterLimit?: number;\n strokeBoundsBuffer?: number;\n}\n\nexport interface IRuleMarkSpec extends ILineMarkSpec {\n x1?: number;\n y1?: number;\n}\n\nexport interface ITextMarkSpec extends IFillMarkSpec {\n /**\n * 文字类型\n * 可选,'html', 'rich', 'text'\n * @default 'text'\n */\n type?: 'html' | 'rich' | 'text';\n /**\n * 文字内容\n */\n text?: StringOrNumber | string[] | IRichTextCharacter[] | Function;\n /**\n * x 方向偏移\n */\n dx?: number;\n /**\n * y 方向偏移\n */\n dy?: number;\n /**\n * 字号\n */\n fontSize?: number;\n /**\n * 文字对齐方式\n */\n textAlign?: TextAlign;\n /**\n * 文字居中方式\n */\n textBaseline?: TextBaseLine;\n /**\n * 字体\n */\n fontFamily?: string;\n /**\n * 字重\n */\n fontWeight?: FontWeight;\n /**\n * 字体样式\n */\n fontStyle?: FontStyle;\n /**\n * 文字的最大长度\n */\n maxLineWidth?: number;\n /**\n * 文字超出 maxLineWidth 后的省略符\n */\n ellipsis?: string;\n // TODO: 这些不是常规的文字mark属性,待确认需求背景\n lineBreak?: string;\n /**\n * 下划线\n */\n underline?: boolean;\n /**\n * 中划线\n */\n lineThrough?: boolean;\n /**\n * 行高(1.3.1 版本新增字符串类型表示比例值,如\"150%\")\n * @since 1.3.1\n */\n lineHeight?: number | string;\n /**\n * poptip 相关配置\n */\n poptip?: PopTipAttributes;\n /**\n * 文本的排布方向,如果需要文本纵向排布,可以配置为 'vertical'\n * @default 'horizontal'\n */\n direction?: 'horizontal' | 'vertical';\n}\n\nexport type IPositionedTextMarkSpec = Omit<ITextMarkSpec, 'align' | 'textAlign' | 'baseline' | 'textBaseline'>;\n\nexport interface IRectMarkSpec extends IFillMarkSpec {\n /**\n * 圆角配置。\n * 1. 如果传入数值,则统一为四个角设置圆角\n * 2. 如果传入数组,则分别为 [上左, 上右, 下右, 下左]\n */\n cornerRadius?: number | number[];\n width?: number;\n height?: number;\n x1?: number;\n y1?: number;\n}\n\n// 3d rect,支持length表示长宽高中的长属性(深度属性)\nexport interface IRect3dMarkSpec extends IRectMarkSpec {\n length?: number;\n}\n\nexport interface IBoxPlotMarkSpec extends ICommonSpec {\n /**\n * box描边宽度\n */\n lineWidth?: number;\n /**\n * box宽度\n */\n boxWidth?: number;\n /**\n * 最大最小值宽度\n */\n shaftWidth?: number;\n /**\n * 中轴线类型\n */\n shaftShape?: BoxPlotShaftShape;\n /**\n * 盒子填充颜色,为空则不填充\n */\n boxFill?: string;\n // /**\n // * 描边颜色\n // */\n // stroke?: string;\n /**\n * 中轴线透明度,仅当shaftType=bar时生效\n */\n shaftFillOpacity?: number;\n\n min?: (datum: Datum) => number;\n q1?: (datum: Datum) => number;\n median?: (datum: Datum) => number;\n q3?: (datum: Datum) => number;\n max?: (datum: Datum) => number;\n}\n\nexport interface IRippleMarkSpec extends ICommonSpec {\n /**\n * 波纹密度ripple\n * ripple 取值范为[0,1]\n */\n ripple?: number;\n /**\n * 水波纹最大半径\n */\n size?: number;\n}\n\nexport interface IOutlierMarkSpec {\n //异常点填充颜色\n fill?: string;\n //异常点大小\n size?: number;\n}\n\nexport interface IPathMarkSpec extends IFillMarkSpec {\n path?: string;\n // TODO: 该属性后续可能会删除,未定\n // 平滑缩放,不然会发生跳变,在地图交互场景需要配置为true;常规path缩放不需要\n smoothScale?: boolean;\n}\n\nexport interface ILinkPathMarkSpec extends IFillMarkSpec {\n x0?: number;\n y0?: number;\n x1?: number;\n y1?: number;\n thickness?: number;\n curvature?: number;\n /** round all the coordinates */\n round?: boolean;\n /** the ratio of normal style path */\n ratio?: number;\n align?: 'start' | 'end' | 'center';\n pathType?: 'line' | 'smooth' | 'polyline';\n endArrow?: boolean;\n startArrow?: boolean;\n backgroundStyle?: any;\n direction?: 'horizontal' | 'vertical' | 'LR' | 'RL' | 'TB' | 'BL' | 'radial';\n}\n\nexport interface IArcMarkSpec extends IFillMarkSpec {\n startAngle?: number;\n endAngle?: number;\n padAngle?: number;\n\n outerRadius?: number;\n innerRadius?: number;\n cornerRadius?: number;\n\n /** arc的中心点偏移距离 */\n centerOffset?: number;\n\n /** arc 的 roundCap 属性,即圆角是否伸出 startAngle 和 endAngle 之外 */\n cap?: boolean | [boolean, boolean];\n /** arc 在 roundCap 打开且应用环形渐变时是否对 cap 部分生效 */\n autoCapConical?: boolean;\n}\n\n// 3d arc,有高度配置\nexport interface IArc3dMarkSpec extends IArcMarkSpec {\n height?: number;\n}\n\nexport interface IProgressArcMarkSpec extends IArcMarkSpec {\n /** 进度条内侧 padding(接受负值) */\n innerPadding?: number;\n /** 进度条外侧 padding(接受负值) */\n outerPadding?: number;\n}\n\nexport interface ICellMarkSpec extends ISymbolMarkSpec {\n padding?: number | number[] | IPadding;\n}\n\nexport interface IGroupMarkSpec extends IFillMarkSpec {\n clip?: boolean;\n width?: number;\n height?: number;\n /**\n * 圆角配置。\n * 1. 如果传入数值,则统一为四个角设置圆角\n * 2. 如果传入数组,则分别为 [上左, 上右, 下右, 下左]\n */\n cornerRadius?: number | number[];\n}\n\nexport interface IPolygonMarkSpec extends ICommonSpec, IFillMarkSpec {\n points?: IPoint[];\n /**\n * 圆角配置,支持数组配置,数组的顺序同组成 polygon 的顺序对应\n */\n cornerRadius?: number | number[];\n scaleX?: number;\n scaleY?: number;\n}\n\nexport interface IPyramid3dMarkSpec extends IPolygonMarkSpec {\n // 只能有4个顶点\n points?: IPoint[];\n}\n\n/**\n * ImageFill\n */\nexport type RepeatType = 'no-repeat' | 'repeat-x' | 'repeat-y' | 'repeat';\nexport type RepeatXYType = 'no-repeat' | 'repeat' | 'stretch';\nexport type ImageOriginType = 'top' | 'bottom';\n\n/**\n * gradient\n */\nexport type GradientPropValue<T> = ValueType<T> | FunctionType<T>;\nexport type GradientStop = {\n offset: GradientPropValue<number>;\n color?: GradientPropValue<string>;\n opacity?: number;\n};\nexport interface IGradientLinear {\n x0?: GradientPropValue<number>;\n y0?: GradientPropValue<number>;\n x1?: GradientPropValue<number>;\n y1?: GradientPropValue<number>;\n stops: GradientStop[];\n gradient: 'linear';\n}\n\nexport interface IGradientRadial {\n r0?: GradientPropValue<number>;\n x0?: GradientPropValue<number>;\n y0?: GradientPropValue<number>;\n x1?: GradientPropValue<number>;\n y1?: GradientPropValue<number>;\n r1?: GradientPropValue<number>;\n stops: GradientStop[];\n gradient: 'radial';\n}\n\nexport interface IGradientConical {\n x?: GradientPropValue<number>;\n y?: GradientPropValue<number>;\n startAngle?: GradientPropValue<number>;\n endAngle?: GradientPropValue<number>;\n stops: GradientStop[];\n gradient: 'conical';\n}\n\nexport type GradientType = 'linear' | 'radial' | 'conical';\nexport type IGradient = IGradientLinear | IGradientRadial | IGradientConical;\n\nexport type LineStrokeCap = 'butt' | 'round' | 'square';\nexport type LineStrokeJoin = 'arcs' | 'bevel' | 'miter' | 'miter-clip' | 'round';\n\nexport type BoxPlotShaftShape = 'line' | 'bar';\n/**\n * threshold\n */\nexport interface IThresholdStyle extends IVisualSpecStyle<number, string> {\n domain: number[];\n field: string;\n range: string[];\n type: 'threshold';\n}\n\n// FIXME: For some tool methods that need to use common configuration types\nexport interface IUnknownMarkSpec extends ICommonSpec {\n [key: string]: unknown;\n}\n\nexport interface IImageMarkSpec extends IFillMarkSpec {\n /**\n * 圆角配置。\n * 1. 如果传入数值,则统一为四个角设置圆角\n * 2. 如果传入数组,则分别为 [上左, 上右, 下右, 下左]\n */\n cornerRadius?: number | number[];\n width?: number;\n height?: number;\n repeatX?: IRepeatType;\n repeatY?: IRepeatType;\n image: string | HTMLImageElement | HTMLCanvasElement;\n}\n\n/**\n * text\n */\nexport type TextAlign = TextAlignType;\nexport type TextBaseLine = TextBaselineType;\nexport type FontStyle = 'normal' | 'italic' | 'oblique' | string;\nexport type FontWeight = 'normal' | 'bold' | 'lighter' | 'bolder' | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visactor/vchart",
3
- "version": "1.7.0-alpha.2",
3
+ "version": "1.7.0",
4
4
  "description": "charts lib based @visactor/VGrammar",
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.js",
@@ -76,9 +76,9 @@
76
76
  "size-limit": "9.0.0",
77
77
  "@size-limit/file": "9.0.0",
78
78
  "@internal/typescript-json-schema": "0.0.1",
79
- "@internal/ts-config": "0.0.1",
80
79
  "@internal/bundler": "0.0.1",
81
- "@internal/eslint-config": "0.0.1"
80
+ "@internal/eslint-config": "0.0.1",
81
+ "@internal/ts-config": "0.0.1"
82
82
  },
83
83
  "dependencies": {
84
84
  "@visactor/vutils": "~0.16.18",
@@ -94,7 +94,7 @@
94
94
  "@visactor/vgrammar-hierarchy": "~0.9.2",
95
95
  "@visactor/vgrammar-sankey": "~0.9.2",
96
96
  "@visactor/vgrammar-util": "~0.9.2",
97
- "@visactor/vutils-extension": "1.7.0-alpha.2"
97
+ "@visactor/vutils-extension": "1.7.0"
98
98
  },
99
99
  "publishConfig": {
100
100
  "access": "public",