@visactor/vrender-components 0.16.17-alpha.4 → 0.16.17-alpha.8
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.
- package/cjs/axis/base.js +19 -12
- package/cjs/axis/base.js.map +1 -1
- package/cjs/axis/circle.d.ts +1 -2
- package/cjs/axis/circle.js.map +1 -1
- package/cjs/axis/line.js +1 -1
- package/cjs/axis/line.js.map +1 -1
- package/cjs/axis/type.d.ts +5 -6
- package/cjs/axis/type.js.map +1 -1
- package/cjs/constant.d.ts +6 -0
- package/cjs/constant.js +6 -1
- package/cjs/constant.js.map +1 -1
- package/cjs/core/type.d.ts +15 -0
- package/cjs/core/type.js.map +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/indicator/indicator.js +43 -7
- package/cjs/indicator/indicator.js.map +1 -1
- package/cjs/indicator/type.d.ts +2 -1
- package/cjs/indicator/type.js.map +1 -1
- package/cjs/label/arc.d.ts +4 -3
- package/cjs/label/arc.js.map +1 -1
- package/cjs/label/base.d.ts +11 -11
- package/cjs/label/base.js +15 -1
- package/cjs/label/base.js.map +1 -1
- package/cjs/label/type.d.ts +8 -4
- package/cjs/label/type.js.map +1 -1
- package/cjs/marker/area.js.map +1 -1
- package/cjs/marker/line.js.map +1 -1
- package/cjs/marker/point.d.ts +1 -1
- package/cjs/marker/point.js.map +1 -1
- package/cjs/marker/type.d.ts +14 -14
- package/cjs/marker/type.js.map +1 -1
- package/cjs/tag/tag.js +87 -41
- package/cjs/tag/tag.js.map +1 -1
- package/cjs/tag/type.d.ts +4 -5
- package/cjs/tag/type.js.map +1 -1
- package/cjs/title/title.js +85 -53
- package/cjs/title/title.js.map +1 -1
- package/cjs/title/type.d.ts +10 -5
- package/cjs/title/type.js.map +1 -1
- package/cjs/tooltip/tooltip.js +49 -12
- package/cjs/tooltip/tooltip.js.map +1 -1
- package/cjs/tooltip/type.d.ts +7 -2
- package/cjs/tooltip/type.js.map +1 -1
- package/cjs/tooltip/util.js +9 -1
- package/cjs/tooltip/util.js.map +1 -1
- package/dist/index.js +291 -163
- package/dist/index.min.js +1 -1
- package/es/axis/base.js +21 -11
- package/es/axis/base.js.map +1 -1
- package/es/axis/circle.d.ts +1 -2
- package/es/axis/circle.js.map +1 -1
- package/es/axis/line.js +1 -1
- package/es/axis/line.js.map +1 -1
- package/es/axis/type.d.ts +5 -6
- package/es/axis/type.js.map +1 -1
- package/es/constant.d.ts +6 -0
- package/es/constant.js +7 -0
- package/es/constant.js.map +1 -1
- package/es/core/type.d.ts +15 -0
- package/es/core/type.js.map +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/indicator/indicator.js +44 -6
- package/es/indicator/indicator.js.map +1 -1
- package/es/indicator/type.d.ts +2 -1
- package/es/indicator/type.js.map +1 -1
- package/es/label/arc.d.ts +4 -3
- package/es/label/arc.js.map +1 -1
- package/es/label/base.d.ts +11 -11
- package/es/label/base.js +17 -1
- package/es/label/base.js.map +1 -1
- package/es/label/type.d.ts +8 -4
- package/es/label/type.js.map +1 -1
- package/es/marker/area.js.map +1 -1
- package/es/marker/line.js.map +1 -1
- package/es/marker/point.d.ts +1 -1
- package/es/marker/point.js.map +1 -1
- package/es/marker/type.d.ts +14 -14
- package/es/marker/type.js.map +1 -1
- package/es/tag/tag.js +86 -38
- package/es/tag/tag.js.map +1 -1
- package/es/tag/type.d.ts +4 -5
- package/es/tag/type.js.map +1 -1
- package/es/title/title.js +84 -50
- package/es/title/title.js.map +1 -1
- package/es/title/type.d.ts +10 -5
- package/es/title/type.js.map +1 -1
- package/es/tooltip/tooltip.js +50 -11
- package/es/tooltip/tooltip.js.map +1 -1
- package/es/tooltip/type.d.ts +7 -2
- package/es/tooltip/type.js.map +1 -1
- package/es/tooltip/util.js +9 -1
- package/es/tooltip/util.js.map +1 -1
- package/package.json +6 -6
package/es/axis/type.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/axis/type.ts"],"names":[],"mappings":"","file":"type.js","sourcesContent":["import type {\n IGraphicAttribute,\n ILineGraphicAttribute,\n SymbolType,\n ITextGraphicAttribute,\n ISymbolGraphicAttribute,\n IRectGraphicAttribute,\n IGroupGraphicAttribute,\n IText,\n IGroup\n} from '@visactor/vrender-core';\nimport type { Dict } from '@visactor/vutils';\nimport type { Point } from '../core/type';\nimport type { SegmentAttributes } from '../segment';\nimport type { TagAttributes } from '../tag';\n\nexport type AxisItemStateStyle<T> = {\n hover?: T;\n hover_reverse?: T;\n selected?: T;\n selected_reverse?: T;\n};\n\nexport type callbackFunc<T> = (datum: Dict<any>, index: number, data?: Dict<any>[], layer?: number) => T;\n\n// 处理过的用于绘制的 tickLine 数据\nexport type TickLineItem = {\n start: Point;\n end: Point;\n /** 归一化后的数据 */\n value: number;\n // 3d数据\n anchor?: [number, number];\n alpha?: number;\n beta?: number;\n [key: string]: any;\n};\n\n// 处理过的用于绘制的数据\nexport type TransformedAxisItem = AxisItem & {\n point: Point;\n};\n\nexport type AxisItem = {\n /** 标识符,用于动画以及图形查找 */\n id?: string | number;\n /** 显示文本 */\n label: string | number;\n /** 归一化后的数据 */\n value: number;\n /** 对应原始数据 */\n rawValue: any;\n [key: string]: any;\n};\n\nexport interface AxisBaseAttributes extends IGroupGraphicAttribute {\n /**\n * 是否开启选中交互\n * @default false\n */\n select?: boolean;\n /**\n * 是否开启 hover 交互\n * @default false\n */\n hover?: boolean;\n /**\n * 垂直于坐标轴方向的因子,默认为 1\n */\n verticalFactor?: number;\n /**\n * 坐标轴的显示位置,用于文本的防重叠处理\n */\n orient?: string;\n /** 坐标轴数据 */\n items: AxisItem[][];\n /**\n * 轴标题配置\n */\n title?: TitleAttributes;\n /**\n * 轴标签配置\n */\n label?: LabelAttributes;\n /**\n * 轴刻度线配置\n */\n tick?: TickAttributes;\n /**\n * 自刻度线配置\n */\n subTick?: SubTickAttributes;\n /**\n * 轴线配置\n */\n line?: LineAttributes;\n /**\n * 关闭交互效果\n * @default false\n */\n disableTriggerEvent?: boolean;\n}\n\nexport interface ILine3dType {\n alpha: number;\n anchor3d?: [number, number];\n}\n\nexport interface LineAxisAttributes extends Omit<AxisBaseAttributes, 'label'> {\n /**\n * 起始点坐标\n */\n start: Point;\n /**\n * 结束点坐标\n */\n end: Point;\n /**\n * 坐标轴垂直方向的限制空间,该配置会影响文本的显示,\n * 即如果超出,文本则会进行自动旋转、自动隐藏等动作。\n */\n verticalLimitSize?: number;\n /**\n * 坐标轴垂直方向的最小空间,如果小于该值,则以该值占据显示空间。\n * 如果同时声明了 verticalLimitSize,请保证 verticalMinSize <= verticalLimitSize,否则会以 verticalLimitSize 为准。\n */\n verticalMinSize?: number;\n /**\n * 轴标签配置\n */\n label?: LabelAttributes & {\n /**\n * label 相对于容器整体的对齐方式\n * - `top`:整体向上对齐(垂直方向)\n * - `middle`:整体居中对齐(垂直方向)\n * - `bottom`:整体向下对齐(垂直方向)\n * - `left`:整体向左对齐(水平方向)\n * - `center`:整体居中对齐(水平方向)\n * - `right`:整体向右对齐(水平方向)\n */\n containerAlign?: 'left' | 'right' | 'center' | 'top' | 'bottom' | 'middle';\n /**\n * 坐标轴首尾文字向内收缩\n * @default false\n */\n flush?: boolean;\n };\n /**\n * 坐标轴背景配置\n */\n panel?: {\n /**\n * 是否绘制坐标轴背景\n */\n visible?: boolean;\n /**\n * 坐标轴背景配置\n */\n style?: Partial<IRectGraphicAttribute>;\n /**\n * 坐标轴背景交互状态样式配置\n */\n state?: AxisItemStateStyle<Partial<IRectGraphicAttribute>>;\n };\n}\n\nexport interface CircleAxisAttributes extends AxisBaseAttributes {\n /**\n * 当配置了 innerRadius 时,可以通过设置 inside: true,将坐标轴战士在内圆半径上。\n * @default false\n */\n inside?: boolean;\n /**\n * 圆心坐标\n */\n center: Point;\n /**\n * **弧度值**,起始弧度,默认 -0.5 * Math.PI\n *\n */\n startAngle?: number;\n /**\n * **弧度值**,结束弧度,默认 1.5 * Math.PI\n */\n endAngle?: number;\n /**\n * 半径\n */\n radius: number;\n /** 内半径 */\n innerRadius?: number;\n}\n\n// 坐标轴标题配置\nexport
|
|
1
|
+
{"version":3,"sources":["../src/axis/type.ts"],"names":[],"mappings":"","file":"type.js","sourcesContent":["import type {\n IGraphicAttribute,\n ILineGraphicAttribute,\n SymbolType,\n ITextGraphicAttribute,\n ISymbolGraphicAttribute,\n IRectGraphicAttribute,\n IGroupGraphicAttribute,\n IText,\n IGroup\n} from '@visactor/vrender-core';\nimport type { Dict } from '@visactor/vutils';\nimport type { Point, TextContent } from '../core/type';\nimport type { SegmentAttributes } from '../segment';\nimport type { TagAttributes } from '../tag';\n\nexport type AxisItemStateStyle<T> = {\n hover?: T;\n hover_reverse?: T;\n selected?: T;\n selected_reverse?: T;\n};\n\nexport type callbackFunc<T> = (datum: Dict<any>, index: number, data?: Dict<any>[], layer?: number) => T;\n\n// 处理过的用于绘制的 tickLine 数据\nexport type TickLineItem = {\n start: Point;\n end: Point;\n /** 归一化后的数据 */\n value: number;\n // 3d数据\n anchor?: [number, number];\n alpha?: number;\n beta?: number;\n [key: string]: any;\n};\n\n// 处理过的用于绘制的数据\nexport type TransformedAxisItem = AxisItem & {\n point: Point;\n};\n\nexport type AxisItem = {\n /** 标识符,用于动画以及图形查找 */\n id?: string | number;\n /** 显示文本 */\n label: string | number;\n /** 归一化后的数据 */\n value: number;\n /** 对应原始数据 */\n rawValue: any;\n [key: string]: any;\n};\n\nexport interface AxisBaseAttributes extends IGroupGraphicAttribute {\n /**\n * 是否开启选中交互\n * @default false\n */\n select?: boolean;\n /**\n * 是否开启 hover 交互\n * @default false\n */\n hover?: boolean;\n /**\n * 垂直于坐标轴方向的因子,默认为 1\n */\n verticalFactor?: number;\n /**\n * 坐标轴的显示位置,用于文本的防重叠处理\n */\n orient?: string;\n /** 坐标轴数据 */\n items: AxisItem[][];\n /**\n * 轴标题配置\n */\n title?: TitleAttributes;\n /**\n * 轴标签配置\n */\n label?: LabelAttributes;\n /**\n * 轴刻度线配置\n */\n tick?: TickAttributes;\n /**\n * 自刻度线配置\n */\n subTick?: SubTickAttributes;\n /**\n * 轴线配置\n */\n line?: LineAttributes;\n /**\n * 关闭交互效果\n * @default false\n */\n disableTriggerEvent?: boolean;\n}\n\nexport interface ILine3dType {\n alpha: number;\n anchor3d?: [number, number];\n}\n\nexport interface LineAxisAttributes extends Omit<AxisBaseAttributes, 'label'> {\n /**\n * 起始点坐标\n */\n start: Point;\n /**\n * 结束点坐标\n */\n end: Point;\n /**\n * 坐标轴垂直方向的限制空间,该配置会影响文本的显示,\n * 即如果超出,文本则会进行自动旋转、自动隐藏等动作。\n */\n verticalLimitSize?: number;\n /**\n * 坐标轴垂直方向的最小空间,如果小于该值,则以该值占据显示空间。\n * 如果同时声明了 verticalLimitSize,请保证 verticalMinSize <= verticalLimitSize,否则会以 verticalLimitSize 为准。\n */\n verticalMinSize?: number;\n /**\n * 轴标签配置\n */\n label?: LabelAttributes & {\n /**\n * label 相对于容器整体的对齐方式\n * - `top`:整体向上对齐(垂直方向)\n * - `middle`:整体居中对齐(垂直方向)\n * - `bottom`:整体向下对齐(垂直方向)\n * - `left`:整体向左对齐(水平方向)\n * - `center`:整体居中对齐(水平方向)\n * - `right`:整体向右对齐(水平方向)\n */\n containerAlign?: 'left' | 'right' | 'center' | 'top' | 'bottom' | 'middle';\n /**\n * 坐标轴首尾文字向内收缩\n * @default false\n */\n flush?: boolean;\n };\n /**\n * 坐标轴背景配置\n */\n panel?: {\n /**\n * 是否绘制坐标轴背景\n */\n visible?: boolean;\n /**\n * 坐标轴背景配置\n */\n style?: Partial<IRectGraphicAttribute>;\n /**\n * 坐标轴背景交互状态样式配置\n */\n state?: AxisItemStateStyle<Partial<IRectGraphicAttribute>>;\n };\n}\n\nexport interface CircleAxisAttributes extends AxisBaseAttributes {\n /**\n * 当配置了 innerRadius 时,可以通过设置 inside: true,将坐标轴战士在内圆半径上。\n * @default false\n */\n inside?: boolean;\n /**\n * 圆心坐标\n */\n center: Point;\n /**\n * **弧度值**,起始弧度,默认 -0.5 * Math.PI\n *\n */\n startAngle?: number;\n /**\n * **弧度值**,结束弧度,默认 1.5 * Math.PI\n */\n endAngle?: number;\n /**\n * 半径\n */\n radius: number;\n /** 内半径 */\n innerRadius?: number;\n}\n\n// 坐标轴标题配置\nexport type TitleAttributes = Omit<TagAttributes, 'shape' | 'space' | 'panel' | 'state'> & {\n /**\n * 是否展示标题\n */\n visible?: boolean;\n /**\n * 标题的显示位置,默认 'middle'\n */\n position?: 'start' | 'middle' | 'end';\n /**\n * 标题距离坐标轴(轴线、刻度、标签共同构成的包围盒)的距离\n */\n space?: number;\n /**\n * 标题是否自动旋转以和坐标轴平行\n */\n autoRotate?: boolean;\n shape?: {\n /**\n * 是否展示 shape\n */\n visible?: boolean;\n /**\n * shape 同 文本的间距\n */\n space?: number;\n style?: Omit<Partial<ISymbolGraphicAttribute>, 'visible'>;\n };\n /**\n * 背景设置\n */\n background?: {\n /**\n * 是否绘制背景层\n */\n visible?: boolean;\n /**\n * 背景层样式\n */\n style?: Omit<Partial<IRectGraphicAttribute>, 'visible' | 'width' | 'height'>;\n };\n\n /**\n * 交互状态样式配置\n */\n state?: {\n /**\n * text 文本的状态配置\n */\n text?: AxisItemStateStyle<Partial<ITextGraphicAttribute>>;\n /**\n * shape 标记的状态配置\n */\n shape?: AxisItemStateStyle<Partial<ISymbolGraphicAttribute>>;\n /**\n * panel 背景的状态配置\n */\n background?: AxisItemStateStyle<Partial<IRectGraphicAttribute>>;\n };\n};\n// 坐标轴线配置\nexport interface LineAttributes extends Pick<SegmentAttributes, 'startSymbol' | 'endSymbol'> {\n /**\n * 是否展示轴线\n */\n visible?: boolean;\n /**\n * TODO: 待支持\n * 坐标轴截断范围,当需要对坐标轴轴线截断时,可配置该属性\n */\n breakRange?: [number, number];\n /**\n * TODO: 待支持\n * 截断区域的形状\n */\n breakShape?: SymbolType | [SymbolType, SymbolType];\n /**\n * TODO: 待支持\n * 截断图形样式\n */\n breakShapeStyle?: Partial<IGraphicAttribute>;\n /**\n * 线的样式配置\n */\n style?: Partial<ILineGraphicAttribute>;\n state?: AxisItemStateStyle<Partial<ILineGraphicAttribute>>;\n}\n\n// 轴刻度线配置\nexport interface TickAttributes {\n /** 是否显示轴刻度线 */\n visible: boolean;\n /**\n * 刻度线朝向,默认朝外(坐标线包围盒外部)\n * @default false\n */\n inside?: boolean;\n /**\n * tick 是否与 label 对齐\n * @default true\n */\n alignWithLabel?: boolean;\n /**\n * 刻度线的长度\n */\n length?: number;\n /**\n * 刻度线样式配置\n */\n style?: Partial<ILineGraphicAttribute> | callbackFunc<Partial<ILineGraphicAttribute> | undefined>;\n /**\n * 刻度线状态样式配置\n */\n state?: AxisItemStateStyle<Partial<ILineGraphicAttribute> | callbackFunc<Partial<ILineGraphicAttribute> | undefined>>;\n /**\n * 用于 tick 的数据过滤\n * @param data\n * @returns\n */\n dataFilter?: (data: AxisItem[]) => AxisItem[];\n}\n\n// 子轴刻度线配置\nexport interface SubTickAttributes {\n /** 是否显示子轴刻度线 */\n visible: boolean;\n /**\n * TODO: 考虑下 log 轴,自刻度线之间的间距是不均匀的问题\n * 子刻度个数\n */\n count?: number;\n /**\n * 子刻度线朝向,默认朝外(坐标线包围盒外部)\n * @default false\n */\n inside?: boolean;\n /**\n * 子刻度线的长度\n */\n length?: number;\n /**\n * 子刻度线样式配置\n */\n style?: Partial<ILineGraphicAttribute> | callbackFunc<Partial<ILineGraphicAttribute> | undefined>;\n /**\n * 子刻度线状态样式配置\n */\n state?: AxisItemStateStyle<Partial<ILineGraphicAttribute> | callbackFunc<Partial<ILineGraphicAttribute> | undefined>>;\n}\n\nexport type CustomMethod = (items: IText[], separation: number) => IText[];\n\nexport interface AxisLabelOverlap {\n /**\n * 自动旋转配置\n * @default false\n */\n autoRotate?: boolean;\n /**\n * 仅当 `autoRotate` 为 true 时生效,可选的旋转范围,默认为 [0, 45, 90]\n * @default [0, 45, 90]\n */\n autoRotateAngle?: number[];\n /**\n * 自动隐藏配置\n * @default false\n */\n autoHide?: boolean;\n /**\n * 防重叠策略,默认为 'parity'。\n * - 'parity': 奇偶校验,使用删除所有其他标签的策略(这对于标准线性轴非常有效)。\n * - 'greedy': 将执行标签的线性扫描,并删除与最后一个可见标签重叠的所有标签。\n * - 也可以传入函数用于自定义策略\n * @default 'parity'\n */\n autoHideMethod?: 'parity' | 'greedy' | CustomMethod;\n /**\n * 仅当 `autoHide` 为 true 时生效,设置文本之间的间隔距离,单位 px\n * @default 0\n */\n autoHideSeparation?: number;\n /**\n * 自动隐藏配置\n * @default false\n */\n autoLimit?: boolean;\n /**\n * 仅当 `autoLimit` 为 true 时生效,省略占位符,默认为 '...'\n * @default '...'\n */\n limitEllipsis?: string;\n\n /**\n * 自定义布局配置,如果声明了 `layoutFunc`,则默认提供的防重叠相关的配置(`autoHide`, `autoRotate`, `autoLimit`)均不生效\n * @param labels 标签图形元素\n * @param labelData 标签数据\n * @param layer 当前轴的层级\n * @param axis 当前轴组件实例\n * @returns void\n */\n layoutFunc?: (labels: IText[], labelData: AxisItem[], layer: number, axis: IGroup) => void;\n}\n\nexport type LabelAttributes = Omit<AxisLabelOverlap, 'text'> &\n TextContent & {\n /** 是否展示标签 */\n visible: boolean;\n /**\n * 标签朝向,默认朝外(坐标线包围盒外部)\n * @default false\n */\n inside?: boolean;\n /** 标签同 tick 之间的间距 */\n space?: number;\n /**\n * 格式化文本回调\n * @param text 文本原始值\n * @param item 对应的图形元素\n * @param index 文本索引顺序\n * @returns 格式化文本\n */\n formatMethod?: (value: string, datum: Dict<any>, index: number, data?: Dict<any>[], layer?: number) => string;\n /**\n * 文本样式\n */\n style?: Partial<ITextGraphicAttribute> | callbackFunc<Partial<ITextGraphicAttribute> | undefined>;\n /**\n * 文本状态样式配置\n */\n state?: AxisItemStateStyle<\n Partial<ITextGraphicAttribute> | callbackFunc<Partial<ITextGraphicAttribute> | undefined>\n >;\n\n /**\n * 用于 label 的数据过滤\n * @param data\n * @param layer\n * @returns\n */\n dataFilter?: (data: AxisItem[], layer: number) => AxisItem[];\n };\n"]}
|
package/es/constant.d.ts
CHANGED
package/es/constant.js
CHANGED
package/es/constant.js.map
CHANGED
|
@@ -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","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"]}
|
|
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","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"]}
|
package/es/core/type.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { IRichTextCharacter } from '@visactor/vrender-core';
|
|
1
2
|
export type Point = {
|
|
2
3
|
x: number;
|
|
3
4
|
y: number;
|
|
@@ -26,3 +27,17 @@ export type Padding = number | number[] | {
|
|
|
26
27
|
left?: number;
|
|
27
28
|
right?: number;
|
|
28
29
|
};
|
|
30
|
+
type CommonTextContent = {
|
|
31
|
+
type?: 'text';
|
|
32
|
+
text?: string | string[] | number | number[];
|
|
33
|
+
};
|
|
34
|
+
type RichTextContent = {
|
|
35
|
+
type?: 'rich';
|
|
36
|
+
text?: IRichTextCharacter[];
|
|
37
|
+
};
|
|
38
|
+
type HtmlTextContent = {
|
|
39
|
+
type?: 'html';
|
|
40
|
+
text?: string | HTMLElement;
|
|
41
|
+
};
|
|
42
|
+
export type TextContent = CommonTextContent | RichTextContent | HtmlTextContent;
|
|
43
|
+
export {};
|
package/es/core/type.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/type.ts"],"names":[],"mappings":"","file":"type.js","sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../src/core/type.ts"],"names":[],"mappings":"","file":"type.js","sourcesContent":["import type { IRichTextCharacter } from '@visactor/vrender-core';\n\nexport type Point = {\n x: number;\n y: number;\n};\n\nexport interface LocationCfg {\n [key: string]: any;\n}\n\nexport interface PointLocationCfg extends LocationCfg {\n /**\n * 位置 x\n * @type {number}\n */\n x: number;\n /**\n * 位置 y\n * @type {number}\n */\n y: number;\n}\n\nexport interface RegionLocationCfg extends LocationCfg {\n /**\n * 起始点\n */\n start: Point;\n /**\n * 结束点\n */\n end: Point;\n}\n\nexport type State<T> = {\n [key: string]: T;\n};\n\nexport type BaseGraphicAttributes<T> = {\n /**\n * 基础样式设置\n */\n style?: T;\n /**\n * 状态样式设置\n */\n state?: State<T>;\n};\n\nexport type Padding =\n | number\n | number[]\n | {\n top?: number;\n bottom?: number;\n left?: number;\n right?: number;\n };\n\ntype CommonTextContent = {\n type?: 'text';\n text?: string | string[] | number | number[];\n};\n\ntype RichTextContent = {\n type?: 'rich';\n text?: IRichTextCharacter[];\n};\n\ntype HtmlTextContent = {\n type?: 'html';\n text?: string | HTMLElement;\n};\n\nexport type TextContent = CommonTextContent | RichTextContent | HtmlTextContent;\n"]}
|
package/es/index.d.ts
CHANGED
package/es/index.js
CHANGED
package/es/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,OAAO,GAAG,iBAAiB,CAAC;AAEzC,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","file":"index.js","sourcesContent":["// 导出版本号\nexport const version = \"0.16.17-alpha.
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,OAAO,GAAG,iBAAiB,CAAC;AAEzC,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","file":"index.js","sourcesContent":["// 导出版本号\nexport const version = \"0.16.17-alpha.8\";\n\nexport * from './core/base';\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';\n"]}
|
|
@@ -6,12 +6,14 @@ import { measureTextSize } from "../util";
|
|
|
6
6
|
|
|
7
7
|
import { DEFAULT_INDICATOR_THEME } from "./config";
|
|
8
8
|
|
|
9
|
+
import { DEFAULT_HTML_TEXT_SPEC } from "../constant";
|
|
10
|
+
|
|
9
11
|
export class Indicator extends AbstractComponent {
|
|
10
12
|
constructor() {
|
|
11
13
|
super(...arguments), this.name = "indicator";
|
|
12
14
|
}
|
|
13
15
|
render() {
|
|
14
|
-
var _a;
|
|
16
|
+
var _a, _b, _c;
|
|
15
17
|
const {visible: visible, title: title, content: content, size: size, limitRatio: limitRatio = 1 / 0} = this.attribute, limit = Math.min(size.width, size.height) * limitRatio, group = this.createOrUpdateChild("indicator-container", {
|
|
16
18
|
x: 0,
|
|
17
19
|
y: 0,
|
|
@@ -20,7 +22,24 @@ export class Indicator extends AbstractComponent {
|
|
|
20
22
|
if (!0 !== visible) return void (group && group.hideAll());
|
|
21
23
|
if (isValid(title)) if (!1 !== title.visible) {
|
|
22
24
|
const titleStyle = merge({}, get(DEFAULT_INDICATOR_THEME, "title.style"), title.style);
|
|
23
|
-
this._title = group.createOrUpdateChild("indicator-title", Object.assign(Object.assign({
|
|
25
|
+
"rich" === titleStyle.type ? this._title = group.createOrUpdateChild("indicator-title", Object.assign(Object.assign({
|
|
26
|
+
textConfig: titleStyle.text
|
|
27
|
+
}, titleStyle), {
|
|
28
|
+
visible: title.visible,
|
|
29
|
+
x: 0,
|
|
30
|
+
y: 0,
|
|
31
|
+
width: null !== (_a = titleStyle.width) && void 0 !== _a ? _a : 0,
|
|
32
|
+
height: null !== (_b = titleStyle.height) && void 0 !== _b ? _b : 0
|
|
33
|
+
}), "richtext") : "html" === titleStyle.type ? this._title = group.createOrUpdateChild("indicator-title", Object.assign(Object.assign({
|
|
34
|
+
textConfig: [],
|
|
35
|
+
html: Object.assign(Object.assign({
|
|
36
|
+
dom: titleStyle.text
|
|
37
|
+
}, DEFAULT_HTML_TEXT_SPEC), titleStyle)
|
|
38
|
+
}, titleStyle), {
|
|
39
|
+
visible: title.visible,
|
|
40
|
+
x: 0,
|
|
41
|
+
y: 0
|
|
42
|
+
}), "richtext") : this._title = group.createOrUpdateChild("indicator-title", Object.assign(Object.assign({}, titleStyle), {
|
|
24
43
|
lineHeight: isValid(titleStyle.lineHeight) ? titleStyle.lineHeight : titleStyle.fontSize,
|
|
25
44
|
visible: title.visible,
|
|
26
45
|
x: 0,
|
|
@@ -36,14 +55,33 @@ export class Indicator extends AbstractComponent {
|
|
|
36
55
|
const titleSpace = this._title && (null == title ? void 0 : title.space) ? title.space : 0, contents = array(content), contentComponents = [];
|
|
37
56
|
let lastContentHeight = 0;
|
|
38
57
|
contents.forEach(((contentItem, i) => {
|
|
58
|
+
var _a, _b;
|
|
39
59
|
if (!1 !== contentItem.visible) {
|
|
40
|
-
const contentStyle = merge({}, get(DEFAULT_INDICATOR_THEME, "content.style"), contentItem.style)
|
|
60
|
+
const contentStyle = merge({}, get(DEFAULT_INDICATOR_THEME, "content.style"), contentItem.style);
|
|
61
|
+
let contentComponent;
|
|
62
|
+
contentComponent = "rich" === contentStyle.type ? group.createOrUpdateChild("indicator-content-" + i, Object.assign(Object.assign({
|
|
63
|
+
textConfig: contentStyle.text
|
|
64
|
+
}, contentStyle), {
|
|
65
|
+
visible: title.visible,
|
|
66
|
+
x: 0,
|
|
67
|
+
y: titleHeight + titleSpace + lastContentHeight,
|
|
68
|
+
width: null !== (_a = contentStyle.width) && void 0 !== _a ? _a : 0,
|
|
69
|
+
height: null !== (_b = contentStyle.height) && void 0 !== _b ? _b : 0
|
|
70
|
+
}), "richtext") : "html" === contentStyle.type ? group.createOrUpdateChild("indicator-content-" + i, Object.assign(Object.assign({
|
|
71
|
+
textConfig: [],
|
|
72
|
+
html: Object.assign(Object.assign({
|
|
73
|
+
dom: contentStyle.text
|
|
74
|
+
}, DEFAULT_HTML_TEXT_SPEC), contentStyle)
|
|
75
|
+
}, contentStyle), {
|
|
76
|
+
visible: title.visible,
|
|
77
|
+
x: 0,
|
|
78
|
+
y: titleHeight + titleSpace + lastContentHeight
|
|
79
|
+
}), "richtext") : group.createOrUpdateChild("indicator-content-" + i, Object.assign(Object.assign({}, contentStyle), {
|
|
41
80
|
lineHeight: isValid(contentStyle.lineHeight) ? contentStyle.lineHeight : contentStyle.fontSize,
|
|
42
81
|
visible: contentItem.visible,
|
|
43
82
|
x: 0,
|
|
44
83
|
y: titleHeight + titleSpace + lastContentHeight
|
|
45
|
-
}), "text")
|
|
46
|
-
contentItem.autoFit && isValidNumber(limit) && this._setAutoFit(limit, contentComponent, contentItem),
|
|
84
|
+
}), "text"), contentItem.autoFit && isValidNumber(limit) && this._setAutoFit(limit, contentComponent, contentItem),
|
|
47
85
|
contentItem.autoLimit && isValidNumber(limitRatio) && contentComponent.setAttribute("maxLineWidth", limit),
|
|
48
86
|
contentComponents.push(contentComponent);
|
|
49
87
|
const contentSpace = (null == contentItem ? void 0 : contentItem.space) ? contentItem.space : 0;
|
|
@@ -54,7 +92,7 @@ export class Indicator extends AbstractComponent {
|
|
|
54
92
|
}
|
|
55
93
|
})), this._content = contentComponents;
|
|
56
94
|
}
|
|
57
|
-
const totalHeight = null !== (
|
|
95
|
+
const totalHeight = null !== (_c = null == group ? void 0 : group.AABBBounds.height()) && void 0 !== _c ? _c : 0;
|
|
58
96
|
group.setAttribute("y", size.height / 2 - totalHeight / 2), group.setAttribute("x", size.width / 2);
|
|
59
97
|
}
|
|
60
98
|
_setAutoFit(limit, indicatorItem, indicatorItemSpec) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/indicator/indicator.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAEnD,MAAM,OAAO,SAAU,SAAQ,iBAAgD;IAA/E;;QACE,SAAI,GAAG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UAAU,CAAC,MAAM,EAAE,mCAAI,CAAC,CAAC;QACpD,KAAK,CAAC,YAAY,CAAC,GAAG,EAAE,IAAI,CAAC,MAAM,GAAG,CAAC,GAAG,WAAW,GAAG,CAAC,CAAC,CAAC;QAC3D,KAAK,CAAC,YAAY,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;IAC1C,CAAC;IAEO,WAAW,CAAC,KAAa,EAAE,aAAoB,EAAE,iBAAoC;;QAC3F,MAAM,WAAW,GAAG,eAAe,CAAC,MAAA,MAAA,iBAAiB,CAAC,KAAK,0CAAE,IAAI,mCAAI,EAAE,EAAE,MAAA,iBAAiB,CAAC,KAAK,mCAAI,EAAE,CAAC,CAAC,KAAK,CAAC;QAC9G,IAAI,WAAW,GAAG,CAAC,EAAE;YACnB,MAAM,KAAK,GAAG,CAAC,KAAK,GAAG,CAAC,MAAA,iBAAiB,CAAC,UAAU,mCAAI,GAAG,CAAC,CAAC,GAAG,WAAW,CAAC;YAC5E,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,MAAA,MAAA,iBAAiB,CAAC,KAAK,0CAAE,QAAQ,mCAAI,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC;YAC/E,aAAa,CAAC,YAAY,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;YACjD,aAAa,CAAC,YAAY,CACxB,YAAY,EACZ,OAAO,CAAC,iBAAiB,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAC5F,CAAC;SACH;IACH,CAAC;CACF","file":"indicator.js","sourcesContent":["/**\n * @description 指标卡组件\n */\nimport type { IGroup, INode, IText } from '@visactor/vrender-core';\nimport { merge, isValid, array, isValidNumber, get } from '@visactor/vutils';\nimport { AbstractComponent } from '../core/base';\nimport { measureTextSize } from '../util';\nimport type { IndicatorAttributes, IndicatorItemSpec } from './type';\nimport { DEFAULT_INDICATOR_THEME } from './config';\n\nexport class Indicator extends AbstractComponent<Required<IndicatorAttributes>> {\n name = 'indicator';\n\n private _title?: IText;\n private _content?: IText | IText[];\n\n protected render() {\n const { visible, title, content, size, limitRatio = Infinity } = this.attribute as IndicatorAttributes;\n\n const limit = Math.min(size.width, size.height) * limitRatio;\n\n const group = this.createOrUpdateChild('indicator-container', { x: 0, y: 0, zIndex: 1 }, 'group') as IGroup;\n\n // 指标卡全部隐藏\n if (visible !== true) {\n group && group.hideAll();\n return;\n }\n\n if (isValid(title)) {\n if (title.visible !== false) {\n const titleStyle = merge({}, get(DEFAULT_INDICATOR_THEME, 'title.style'), title.style);\n this._title = group.createOrUpdateChild(\n 'indicator-title',\n {\n ...titleStyle,\n /**\n * 加入以下逻辑:如果没有声明lineHeight,默认 lineHeight 等于 fontSize\n * 因为如果不声明 vrender 底层会默认给文本加上 2px 的高度,会影响布局计算\n * 注意:在autoFit改变fontsize时,lineHeight也要同步修改\n */\n lineHeight: isValid(titleStyle.lineHeight) ? titleStyle.lineHeight : titleStyle.fontSize,\n visible: title.visible,\n x: 0,\n y: 0\n },\n 'text'\n ) as IText;\n\n // auto-fit\n if (title.autoFit && isValidNumber(limit)) {\n this._setAutoFit(limit, this._title, title);\n }\n\n //auto-limit\n if (title.autoLimit && isValidNumber(limitRatio)) {\n this._title.setAttribute('maxLineWidth', limit);\n }\n } else {\n /**\n * indicator部分隐藏\n * 例如title隐藏了,content还保留。直接设置visible:false 计算group.AABBounts是错的,影响上下居中。\n * 这里把隐藏的nodes删除后,group.AABBounts计算才正确。\n */\n const titleNode = group.find(node => node.name === 'indicator-title', false);\n titleNode && group.removeChild(titleNode as INode);\n this._title = undefined;\n }\n }\n\n const titleHeight = this._title ? this._title.AABBBounds.height() : 0;\n\n if (isValid(content)) {\n const titleSpace = this._title ? (title?.space ? title.space : 0) : 0;\n const contents: IndicatorItemSpec[] = array(content);\n const contentComponents: IText[] = [];\n let lastContentHeight = 0;\n contents.forEach((contentItem, i) => {\n if (contentItem.visible !== false) {\n const contentStyle = merge({}, get(DEFAULT_INDICATOR_THEME, 'content.style'), contentItem.style);\n const contentComponent = group.createOrUpdateChild(\n 'indicator-content-' + i,\n {\n ...contentStyle,\n lineHeight: isValid(contentStyle.lineHeight) ? contentStyle.lineHeight : contentStyle.fontSize,\n visible: contentItem.visible,\n x: 0,\n y: titleHeight + titleSpace + lastContentHeight\n },\n 'text'\n ) as IText;\n\n // auto-fit\n if (contentItem.autoFit && isValidNumber(limit)) {\n this._setAutoFit(limit, contentComponent, contentItem);\n }\n\n //auto-limit\n if (contentItem.autoLimit && isValidNumber(limitRatio)) {\n contentComponent.setAttribute('maxLineWidth', limit);\n }\n\n contentComponents.push(contentComponent);\n const contentSpace = contentItem?.space ? contentItem.space : 0;\n lastContentHeight += contentComponent.AABBBounds.height() + contentSpace;\n } else {\n /**\n * indicator部分隐藏\n */\n const contentItemNode = group.find(node => node.name === 'indicator-content-' + i, false);\n contentItemNode && group.removeChild(contentItemNode as INode);\n }\n });\n this._content = contentComponents;\n }\n\n const totalHeight = group?.AABBBounds.height() ?? 0;\n group.setAttribute('y', size.height / 2 - totalHeight / 2);\n group.setAttribute('x', size.width / 2);\n }\n\n private _setAutoFit(limit: number, indicatorItem: IText, indicatorItemSpec: IndicatorItemSpec) {\n const originWidth = measureTextSize(indicatorItemSpec.style?.text ?? '', indicatorItemSpec.style ?? {}).width;\n if (originWidth > 0) {\n const ratio = (limit * (indicatorItemSpec.fitPercent ?? 0.5)) / originWidth;\n const fontSize = Math.floor((indicatorItemSpec.style?.fontSize ?? 20) * ratio);\n indicatorItem.setAttribute('fontSize', fontSize);\n indicatorItem.setAttribute(\n 'lineHeight',\n isValid(indicatorItemSpec.style.lineHeight) ? indicatorItemSpec.style.lineHeight : fontSize\n );\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/indicator/indicator.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,OAA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AAG,CAAC,KAAK,GAAG,CAAC,MAAA,iBAAiB,CAAC,UAAU,mCAAI,GAAG,CAAC,CAAC,GAAG,WAAW,CAAC;YAC5E,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,MAAA,MAAA,iBAAiB,CAAC,KAAK,0CAAE,QAAQ,mCAAI,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC;YAC/E,aAAa,CAAC,YAAY,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;YACjD,aAAa,CAAC,YAAY,CACxB,YAAY,EACZ,OAAO,CAAC,iBAAiB,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAC5F,CAAC;SACH;IACH,CAAC;CACF","file":"indicator.js","sourcesContent":["/**\n * @description 指标卡组件\n */\nimport type { IGroup, INode, IText, ITextGraphicAttribute } from '@visactor/vrender-core';\nimport { merge, isValid, array, isValidNumber, get } from '@visactor/vutils';\nimport { AbstractComponent } from '../core/base';\nimport { measureTextSize } from '../util';\nimport type { IndicatorAttributes, IndicatorItemSpec } from './type';\nimport { DEFAULT_INDICATOR_THEME } from './config';\nimport { DEFAULT_HTML_TEXT_SPEC } from '../constant';\n\nexport class Indicator extends AbstractComponent<Required<IndicatorAttributes>> {\n name = 'indicator';\n\n private _title?: IText;\n private _content?: IText | IText[];\n\n protected render() {\n const { visible, title, content, size, limitRatio = Infinity } = this.attribute as IndicatorAttributes;\n\n const limit = Math.min(size.width, size.height) * limitRatio;\n\n const group = this.createOrUpdateChild('indicator-container', { x: 0, y: 0, zIndex: 1 }, 'group') as IGroup;\n\n // 指标卡全部隐藏\n if (visible !== true) {\n group && group.hideAll();\n return;\n }\n\n if (isValid(title)) {\n if (title.visible !== false) {\n const titleStyle = merge({}, get(DEFAULT_INDICATOR_THEME, 'title.style'), title.style);\n if (titleStyle.type === 'rich') {\n this._title = group.createOrUpdateChild(\n 'indicator-title',\n {\n textConfig: titleStyle.text,\n ...titleStyle,\n visible: title.visible,\n x: 0,\n y: 0,\n width: titleStyle.width ?? 0,\n height: titleStyle.height ?? 0\n },\n 'richtext'\n ) as IText;\n } else if (titleStyle.type === 'html') {\n this._title = group.createOrUpdateChild(\n 'indicator-title',\n {\n textConfig: [],\n html: {\n dom: titleStyle.text as string,\n ...DEFAULT_HTML_TEXT_SPEC,\n ...titleStyle\n },\n ...titleStyle,\n visible: title.visible,\n x: 0,\n y: 0\n },\n 'richtext'\n ) as IText;\n } else {\n this._title = group.createOrUpdateChild(\n 'indicator-title',\n {\n ...titleStyle,\n /**\n * 加入以下逻辑:如果没有声明lineHeight,默认 lineHeight 等于 fontSize\n * 因为如果不声明 vrender 底层会默认给文本加上 2px 的高度,会影响布局计算\n * 注意:在autoFit改变fontsize时,lineHeight也要同步修改\n */\n lineHeight: isValid(titleStyle.lineHeight) ? titleStyle.lineHeight : titleStyle.fontSize,\n visible: title.visible,\n x: 0,\n y: 0\n },\n 'text'\n ) as IText;\n }\n\n // auto-fit\n if (title.autoFit && isValidNumber(limit)) {\n this._setAutoFit(limit, this._title, title);\n }\n\n //auto-limit\n if (title.autoLimit && isValidNumber(limitRatio)) {\n this._title.setAttribute('maxLineWidth', limit);\n }\n } else {\n /**\n * indicator部分隐藏\n * 例如title隐藏了,content还保留。直接设置visible:false 计算group.AABBounts是错的,影响上下居中。\n * 这里把隐藏的nodes删除后,group.AABBounts计算才正确。\n */\n const titleNode = group.find(node => node.name === 'indicator-title', false);\n titleNode && group.removeChild(titleNode as INode);\n this._title = undefined;\n }\n }\n\n const titleHeight = this._title ? this._title.AABBBounds.height() : 0;\n\n if (isValid(content)) {\n const titleSpace = this._title ? (title?.space ? title.space : 0) : 0;\n const contents: IndicatorItemSpec[] = array(content);\n const contentComponents: IText[] = [];\n let lastContentHeight = 0;\n contents.forEach((contentItem, i) => {\n if (contentItem.visible !== false) {\n const contentStyle = merge({}, get(DEFAULT_INDICATOR_THEME, 'content.style'), contentItem.style);\n let contentComponent;\n if (contentStyle.type === 'rich') {\n contentComponent = group.createOrUpdateChild(\n 'indicator-content-' + i,\n {\n textConfig: contentStyle.text,\n ...contentStyle,\n visible: title.visible,\n x: 0,\n y: titleHeight + titleSpace + lastContentHeight,\n width: contentStyle.width ?? 0,\n height: contentStyle.height ?? 0\n },\n 'richtext'\n ) as IText;\n } else if (contentStyle.type === 'html') {\n contentComponent = group.createOrUpdateChild(\n 'indicator-content-' + i,\n {\n textConfig: [],\n html: {\n dom: contentStyle.text as string,\n ...DEFAULT_HTML_TEXT_SPEC,\n ...contentStyle\n },\n ...contentStyle,\n visible: title.visible,\n x: 0,\n y: titleHeight + titleSpace + lastContentHeight\n },\n 'richtext'\n ) as IText;\n } else {\n contentComponent = group.createOrUpdateChild(\n 'indicator-content-' + i,\n {\n ...contentStyle,\n lineHeight: isValid(contentStyle.lineHeight) ? contentStyle.lineHeight : contentStyle.fontSize,\n visible: contentItem.visible,\n x: 0,\n y: titleHeight + titleSpace + lastContentHeight\n },\n 'text'\n ) as IText;\n }\n\n // auto-fit\n if (contentItem.autoFit && isValidNumber(limit)) {\n this._setAutoFit(limit, contentComponent, contentItem);\n }\n\n //auto-limit\n if (contentItem.autoLimit && isValidNumber(limitRatio)) {\n contentComponent.setAttribute('maxLineWidth', limit);\n }\n\n contentComponents.push(contentComponent);\n const contentSpace = contentItem?.space ? contentItem.space : 0;\n lastContentHeight += contentComponent.AABBBounds.height() + contentSpace;\n } else {\n /**\n * indicator部分隐藏\n */\n const contentItemNode = group.find(node => node.name === 'indicator-content-' + i, false);\n contentItemNode && group.removeChild(contentItemNode as INode);\n }\n });\n this._content = contentComponents;\n }\n\n const totalHeight = group?.AABBBounds.height() ?? 0;\n group.setAttribute('y', size.height / 2 - totalHeight / 2);\n group.setAttribute('x', size.width / 2);\n }\n\n private _setAutoFit(limit: number, indicatorItem: IText, indicatorItemSpec: IndicatorItemSpec) {\n const originWidth = measureTextSize(\n (indicatorItemSpec.style?.text ?? '') as string | number | number[] | string[],\n (indicatorItemSpec.style ?? {}) as Partial<ITextGraphicAttribute>\n ).width;\n if (originWidth > 0) {\n const ratio = (limit * (indicatorItemSpec.fitPercent ?? 0.5)) / originWidth;\n const fontSize = Math.floor((indicatorItemSpec.style?.fontSize ?? 20) * ratio);\n indicatorItem.setAttribute('fontSize', fontSize);\n indicatorItem.setAttribute(\n 'lineHeight',\n isValid(indicatorItemSpec.style.lineHeight) ? indicatorItemSpec.style.lineHeight : fontSize\n );\n }\n }\n}\n"]}
|
package/es/indicator/type.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { IGroupGraphicAttribute, ITextGraphicAttribute } from '@visactor/vrender-core';
|
|
2
|
+
import type { TextContent } from '../core/type';
|
|
2
3
|
export interface IndicatorAttributes extends IGroupGraphicAttribute {
|
|
3
4
|
visible?: boolean;
|
|
4
5
|
size: {
|
|
@@ -17,5 +18,5 @@ export interface IndicatorItemSpec {
|
|
|
17
18
|
autoLimit?: boolean;
|
|
18
19
|
autoFit?: boolean;
|
|
19
20
|
fitPercent?: number;
|
|
20
|
-
style?: ITextGraphicAttribute;
|
|
21
|
+
style?: Omit<ITextGraphicAttribute, 'text'> & TextContent;
|
|
21
22
|
}
|
package/es/indicator/type.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/indicator/type.ts"],"names":[],"mappings":"","file":"type.js","sourcesContent":["import type { IGroupGraphicAttribute, ITextGraphicAttribute } from '@visactor/vrender-core';\n\nexport interface IndicatorAttributes extends IGroupGraphicAttribute {\n /**\n * 是否显示指标卡组件\n * @default true\n */\n visible?: boolean;\n /**\n * 内容尺寸\n */\n size: { width: number; height: number };\n /**\n * 指标卡 x 方向偏移\n * @default 0\n */\n dx?: number;\n /**\n * 指标卡 y 方向偏移\n * @default 0\n */\n dy?: number;\n /**\n * 指标卡宽度占内容区域的最大比值(从0到1)\n */\n limitRatio?: number;\n /**\n * 指标卡标题文字配置\n */\n title?: IndicatorItemSpec;\n /**\n * 指标卡内容文字配置\n */\n content?: IndicatorItemSpec[] | IndicatorItemSpec;\n}\n\nexport interface IndicatorItemSpec {\n /**\n * 是否显示当前项\n * @default true\n */\n visible?: boolean;\n /**\n * title.space: title 和 content 之间的间距\n * contentItem.space: content 之间的间距\n */\n space?: number;\n /**\n * 是否自适应文字空间进行缩略\n * 按照原字体大小,根据空间大小缩略文字\n * @default false\n */\n autoLimit?: boolean;\n /**\n * 是否自适应文字空间缩放文字大小\n * 不缩略文字,改变字体大小以适应空间\n * @default false\n */\n autoFit?: boolean;\n /**\n * 自适应文字宽度与可用空间的比例\n * @default 0.5\n */\n fitPercent?: number;\n /**\n * 文字样式\n */\n style?: ITextGraphicAttribute;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/indicator/type.ts"],"names":[],"mappings":"","file":"type.js","sourcesContent":["import type { IGroupGraphicAttribute, ITextGraphicAttribute, IRichTextCharacter } from '@visactor/vrender-core';\nimport type { TextContent } from '../core/type';\n\nexport interface IndicatorAttributes extends IGroupGraphicAttribute {\n /**\n * 是否显示指标卡组件\n * @default true\n */\n visible?: boolean;\n /**\n * 内容尺寸\n */\n size: { width: number; height: number };\n /**\n * 指标卡 x 方向偏移\n * @default 0\n */\n dx?: number;\n /**\n * 指标卡 y 方向偏移\n * @default 0\n */\n dy?: number;\n /**\n * 指标卡宽度占内容区域的最大比值(从0到1)\n */\n limitRatio?: number;\n /**\n * 指标卡标题文字配置\n */\n title?: IndicatorItemSpec;\n /**\n * 指标卡内容文字配置\n */\n content?: IndicatorItemSpec[] | IndicatorItemSpec;\n}\n\nexport interface IndicatorItemSpec {\n /**\n * 是否显示当前项\n * @default true\n */\n visible?: boolean;\n /**\n * title.space: title 和 content 之间的间距\n * contentItem.space: content 之间的间距\n */\n space?: number;\n /**\n * 是否自适应文字空间进行缩略\n * 按照原字体大小,根据空间大小缩略文字\n * @default false\n */\n autoLimit?: boolean;\n /**\n * 是否自适应文字空间缩放文字大小\n * 不缩略文字,改变字体大小以适应空间\n * @default false\n */\n autoFit?: boolean;\n /**\n * 自适应文字宽度与可用空间的比例\n * @default 0.5\n */\n fitPercent?: number;\n /**\n * 文字样式\n */\n style?: Omit<ITextGraphicAttribute, 'text'> & TextContent;\n}\n"]}
|
package/es/label/arc.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { IAABBBounds, IBoundsLike } from '@visactor/vutils';
|
|
2
2
|
import { LabelBase } from './base';
|
|
3
3
|
import type { ArcLabelAttrs, IPoint, Quadrant, BaseLabelAttrs, LabelItem, IArcLabelLineSpec } from './type';
|
|
4
|
+
import type { IRichText } from '@visactor/vrender-core';
|
|
4
5
|
import { type IText, type IGraphic, type ILine } from '@visactor/vrender-core';
|
|
5
6
|
export declare class ArcInfo {
|
|
6
7
|
key: string;
|
|
@@ -39,12 +40,12 @@ export declare class ArcLabel extends LabelBase<ArcLabelAttrs> {
|
|
|
39
40
|
private _arcLeft;
|
|
40
41
|
private _arcRight;
|
|
41
42
|
constructor(attributes: ArcLabelAttrs);
|
|
42
|
-
protected _overlapping(labels: IText[]): IText[];
|
|
43
|
+
protected _overlapping(labels: (IText | IRichText)[]): (IRichText | IText)[];
|
|
43
44
|
protected labeling(textBounds: IBoundsLike, graphicBounds: IBoundsLike, position?: string, offset?: number): {
|
|
44
45
|
x: number;
|
|
45
46
|
y: number;
|
|
46
47
|
} | undefined;
|
|
47
|
-
protected _layout(data?: LabelItem[]): IText[];
|
|
48
|
+
protected _layout(data?: LabelItem[]): (IRichText | IText)[];
|
|
48
49
|
protected layoutArcLabels(position: BaseLabelAttrs['position'], attribute: any, currentMarks?: IGraphic[], data?: LabelItem[], textBoundsArray?: any, ellipsisWidth?: number): ArcInfo[];
|
|
49
50
|
private _layoutInsideLabels;
|
|
50
51
|
private _layoutOutsideLabels;
|
|
@@ -63,7 +64,7 @@ export declare class ArcLabel extends LabelBase<ArcLabelAttrs> {
|
|
|
63
64
|
private _restoreY;
|
|
64
65
|
private _checkYRange;
|
|
65
66
|
private _coverLabels;
|
|
66
|
-
protected _labelLine(text:
|
|
67
|
+
protected _labelLine(text: LabelItem): ILine;
|
|
67
68
|
protected computeRadius(r: number, width?: number, height?: number, k?: number): number;
|
|
68
69
|
protected computeLayoutRadius(width: number, height: number): number;
|
|
69
70
|
protected _canPlaceInside(textBound: IBoundsLike, shapeBound: IAABBBounds): boolean;
|