@visactor/vchart 1.4.2-beta.1 → 1.4.3
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/build/es5/index.js +1 -1
- package/build/index.js +464 -302
- package/build/index.min.js +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/cjs/chart/base-chart.js +3 -1
- package/cjs/chart/base-chart.js.map +1 -1
- package/cjs/component/brush/brush.d.ts +1 -1
- package/cjs/component/brush/brush.js +32 -22
- package/cjs/component/brush/brush.js.map +1 -1
- package/cjs/component/custom-mark/custom-mark.js +2 -1
- package/cjs/component/custom-mark/custom-mark.js.map +1 -1
- package/cjs/component/data-zoom/data-filter-base-component.js +6 -4
- package/cjs/component/data-zoom/data-filter-base-component.js.map +1 -1
- package/cjs/component/legend/discrete/legend.js +12 -9
- package/cjs/component/legend/discrete/legend.js.map +1 -1
- package/cjs/component/marker/mark-area/mark-area.js +3 -3
- package/cjs/component/marker/mark-area/mark-area.js.map +1 -1
- package/cjs/component/marker/mark-line/mark-line.js +2 -2
- package/cjs/component/marker/mark-line/mark-line.js.map +1 -1
- package/cjs/component/marker/mark-point/mark-point.js +3 -3
- package/cjs/component/marker/mark-point/mark-point.js.map +1 -1
- package/cjs/component/tooltip/handler/base.d.ts +2 -4
- package/cjs/component/tooltip/handler/base.js +15 -38
- package/cjs/component/tooltip/handler/base.js.map +1 -1
- package/cjs/component/tooltip/handler/canvas/canvas-tooltip-handler.js +2 -2
- package/cjs/component/tooltip/handler/canvas/canvas-tooltip-handler.js.map +1 -1
- package/cjs/component/tooltip/handler/dom/dom-tooltip-handler.js +2 -2
- package/cjs/component/tooltip/handler/dom/dom-tooltip-handler.js.map +1 -1
- package/cjs/component/tooltip/handler/dom/util.d.ts +1 -2
- package/cjs/component/tooltip/handler/dom/util.js +14 -13
- package/cjs/component/tooltip/handler/dom/util.js.map +1 -1
- package/cjs/component/tooltip/handler/interface/style.d.ts +4 -23
- package/cjs/component/tooltip/handler/interface/style.js.map +1 -1
- package/cjs/component/tooltip/handler/utils/attribute.d.ts +9 -11
- package/cjs/component/tooltip/handler/utils/attribute.js +136 -126
- package/cjs/component/tooltip/handler/utils/attribute.js.map +1 -1
- package/cjs/component/tooltip/handler/utils/common.d.ts +8 -0
- package/cjs/component/tooltip/handler/utils/common.js +42 -2
- package/cjs/component/tooltip/handler/utils/common.js.map +1 -1
- package/cjs/component/tooltip/handler/utils/index.d.ts +0 -1
- package/cjs/component/tooltip/handler/utils/index.js +1 -2
- package/cjs/component/tooltip/handler/utils/index.js.map +1 -1
- package/cjs/component/tooltip/interface/common.d.ts +2 -2
- package/cjs/component/tooltip/interface/common.js.map +1 -1
- package/cjs/component/tooltip/interface/theme.d.ts +5 -3
- package/cjs/component/tooltip/interface/theme.js.map +1 -1
- package/cjs/component/tooltip/tooltip.d.ts +1 -0
- package/cjs/component/tooltip/tooltip.js +7 -4
- package/cjs/component/tooltip/tooltip.js.map +1 -1
- package/cjs/core/index.d.ts +1 -1
- package/cjs/core/index.js +1 -1
- package/cjs/core/index.js.map +1 -1
- package/cjs/core/util.d.ts +3 -0
- package/cjs/core/util.js +12 -0
- package/cjs/core/util.js.map +1 -0
- package/cjs/core/vchart.d.ts +3 -0
- package/cjs/core/vchart.js +2 -2
- package/cjs/core/vchart.js.map +1 -1
- package/cjs/interaction/trigger.js +1 -2
- package/cjs/layout/base-layout.js +2 -1
- package/cjs/mark/box-plot.js +1 -1
- package/cjs/model/base-model.d.ts +1 -0
- package/cjs/model/base-model.js +1 -0
- package/cjs/model/base-model.js.map +1 -1
- package/cjs/model/interface.d.ts +2 -1
- package/cjs/model/interface.js.map +1 -1
- package/cjs/series/area/area.d.ts +4 -1
- package/cjs/series/area/area.js +11 -0
- package/cjs/series/area/area.js.map +1 -1
- package/cjs/series/bar/bar.d.ts +2 -0
- package/cjs/series/bar/bar.js +3 -0
- package/cjs/series/bar/bar.js.map +1 -1
- package/cjs/series/base/base-series.d.ts +1 -0
- package/cjs/series/base/base-series.js +1 -1
- package/cjs/series/base/base-series.js.map +1 -1
- package/cjs/series/box-plot/box-plot.d.ts +2 -0
- package/cjs/series/box-plot/box-plot.js +3 -0
- package/cjs/series/box-plot/box-plot.js.map +1 -1
- package/cjs/series/circle-packing/circle-packing.d.ts +2 -0
- package/cjs/series/circle-packing/circle-packing.js +3 -0
- package/cjs/series/circle-packing/circle-packing.js.map +1 -1
- package/cjs/series/dot/dot.d.ts +1 -0
- package/cjs/series/dot/dot.js +3 -0
- package/cjs/series/dot/dot.js.map +1 -1
- package/cjs/series/funnel/funnel.d.ts +2 -0
- package/cjs/series/funnel/funnel.js +3 -0
- package/cjs/series/funnel/funnel.js.map +1 -1
- package/cjs/series/gauge/gauge-pointer.d.ts +2 -0
- package/cjs/series/gauge/gauge-pointer.js +3 -0
- package/cjs/series/gauge/gauge-pointer.js.map +1 -1
- package/cjs/series/gauge/gauge.d.ts +2 -0
- package/cjs/series/gauge/gauge.js +3 -0
- package/cjs/series/gauge/gauge.js.map +1 -1
- package/cjs/series/geo/geo.d.ts +2 -0
- package/cjs/series/geo/geo.js +3 -0
- package/cjs/series/geo/geo.js.map +1 -1
- package/cjs/series/heatmap/heatmap.d.ts +2 -0
- package/cjs/series/heatmap/heatmap.js +3 -0
- package/cjs/series/heatmap/heatmap.js.map +1 -1
- package/cjs/series/interface/series.d.ts +1 -0
- package/cjs/series/interface/series.js.map +1 -1
- package/cjs/series/line/line.d.ts +2 -0
- package/cjs/series/line/line.js +4 -1
- package/cjs/series/line/line.js.map +1 -1
- package/cjs/series/link/link.d.ts +1 -0
- package/cjs/series/link/link.js +3 -0
- package/cjs/series/link/link.js.map +1 -1
- package/cjs/series/map/map.d.ts +2 -0
- package/cjs/series/map/map.js +3 -0
- package/cjs/series/map/map.js.map +1 -1
- package/cjs/series/pie/pie.d.ts +1 -0
- package/cjs/series/pie/pie.js +3 -0
- package/cjs/series/pie/pie.js.map +1 -1
- package/cjs/series/polar/polar.js +1 -1
- package/cjs/series/polar/polar.js.map +1 -1
- package/cjs/series/progress/circular/circular.d.ts +2 -0
- package/cjs/series/progress/circular/circular.js +3 -0
- package/cjs/series/progress/circular/circular.js.map +1 -1
- package/cjs/series/progress/linear/linear.d.ts +2 -0
- package/cjs/series/progress/linear/linear.js +3 -0
- package/cjs/series/progress/linear/linear.js.map +1 -1
- package/cjs/series/radar/radar.d.ts +4 -2
- package/cjs/series/radar/radar.js +11 -0
- package/cjs/series/radar/radar.js.map +1 -1
- package/cjs/series/range-area/range-area.js.map +1 -1
- package/cjs/series/rose/rose.d.ts +2 -0
- package/cjs/series/rose/rose.js +3 -0
- package/cjs/series/rose/rose.js.map +1 -1
- package/cjs/series/sankey/sankey.d.ts +2 -0
- package/cjs/series/sankey/sankey.js +3 -0
- package/cjs/series/sankey/sankey.js.map +1 -1
- package/cjs/series/scatter/scatter.d.ts +2 -0
- package/cjs/series/scatter/scatter.js +3 -0
- package/cjs/series/scatter/scatter.js.map +1 -1
- package/cjs/series/sunburst/sunburst.d.ts +2 -0
- package/cjs/series/sunburst/sunburst.js +3 -0
- package/cjs/series/sunburst/sunburst.js.map +1 -1
- package/cjs/series/treemap/treemap.d.ts +2 -0
- package/cjs/series/treemap/treemap.js +3 -0
- package/cjs/series/treemap/treemap.js.map +1 -1
- package/cjs/series/word-cloud/base.d.ts +2 -0
- package/cjs/series/word-cloud/base.js +3 -0
- package/cjs/series/word-cloud/base.js.map +1 -1
- package/cjs/util/text.d.ts +3 -3
- package/cjs/util/text.js +5 -1
- package/cjs/util/text.js.map +1 -1
- package/esm/chart/base-chart.js +3 -1
- package/esm/chart/base-chart.js.map +1 -1
- package/esm/component/brush/brush.d.ts +1 -1
- package/esm/component/brush/brush.js +34 -21
- package/esm/component/brush/brush.js.map +1 -1
- package/esm/component/custom-mark/custom-mark.js +2 -1
- package/esm/component/custom-mark/custom-mark.js.map +1 -1
- package/esm/component/data-zoom/data-filter-base-component.js +6 -4
- package/esm/component/data-zoom/data-filter-base-component.js.map +1 -1
- package/esm/component/legend/discrete/legend.js +12 -9
- package/esm/component/legend/discrete/legend.js.map +1 -1
- package/esm/component/marker/mark-area/mark-area.js +5 -5
- package/esm/component/marker/mark-area/mark-area.js.map +1 -1
- package/esm/component/marker/mark-line/mark-line.js +4 -4
- package/esm/component/marker/mark-line/mark-line.js.map +1 -1
- package/esm/component/marker/mark-point/mark-point.js +5 -5
- package/esm/component/marker/mark-point/mark-point.js.map +1 -1
- package/esm/component/tooltip/handler/base.d.ts +2 -4
- package/esm/component/tooltip/handler/base.js +14 -39
- package/esm/component/tooltip/handler/base.js.map +1 -1
- package/esm/component/tooltip/handler/canvas/canvas-tooltip-handler.js +2 -2
- package/esm/component/tooltip/handler/canvas/canvas-tooltip-handler.js.map +1 -1
- package/esm/component/tooltip/handler/dom/dom-tooltip-handler.js +2 -2
- package/esm/component/tooltip/handler/dom/dom-tooltip-handler.js.map +1 -1
- package/esm/component/tooltip/handler/dom/util.d.ts +1 -2
- package/esm/component/tooltip/handler/dom/util.js +14 -14
- package/esm/component/tooltip/handler/dom/util.js.map +1 -1
- package/esm/component/tooltip/handler/interface/style.d.ts +4 -23
- package/esm/component/tooltip/handler/interface/style.js.map +1 -1
- package/esm/component/tooltip/handler/utils/attribute.d.ts +9 -11
- package/esm/component/tooltip/handler/utils/attribute.js +131 -123
- package/esm/component/tooltip/handler/utils/attribute.js.map +1 -1
- package/esm/component/tooltip/handler/utils/common.d.ts +8 -0
- package/esm/component/tooltip/handler/utils/common.js +41 -1
- package/esm/component/tooltip/handler/utils/common.js.map +1 -1
- package/esm/component/tooltip/handler/utils/index.d.ts +0 -1
- package/esm/component/tooltip/handler/utils/index.js +0 -2
- package/esm/component/tooltip/handler/utils/index.js.map +1 -1
- package/esm/component/tooltip/interface/common.d.ts +2 -2
- package/esm/component/tooltip/interface/common.js.map +1 -1
- package/esm/component/tooltip/interface/theme.d.ts +5 -3
- package/esm/component/tooltip/interface/theme.js.map +1 -1
- package/esm/component/tooltip/tooltip.d.ts +1 -0
- package/esm/component/tooltip/tooltip.js +7 -4
- package/esm/component/tooltip/tooltip.js.map +1 -1
- package/esm/core/index.d.ts +1 -1
- package/esm/core/index.js +1 -1
- package/esm/core/index.js.map +1 -1
- package/esm/core/util.d.ts +3 -0
- package/esm/core/util.js +6 -0
- package/esm/core/util.js.map +1 -0
- package/esm/core/vchart.d.ts +3 -0
- package/esm/core/vchart.js +3 -1
- package/esm/core/vchart.js.map +1 -1
- package/esm/interaction/trigger.js +1 -2
- package/esm/layout/base-layout.js +2 -1
- package/esm/mark/box-plot.js +1 -1
- package/esm/model/base-model.d.ts +1 -0
- package/esm/model/base-model.js +1 -0
- package/esm/model/base-model.js.map +1 -1
- package/esm/model/interface.d.ts +2 -1
- package/esm/model/interface.js.map +1 -1
- package/esm/series/area/area.d.ts +4 -1
- package/esm/series/area/area.js +12 -1
- package/esm/series/area/area.js.map +1 -1
- package/esm/series/bar/bar.d.ts +2 -0
- package/esm/series/bar/bar.js +3 -0
- package/esm/series/bar/bar.js.map +1 -1
- package/esm/series/base/base-series.d.ts +1 -0
- package/esm/series/base/base-series.js +1 -1
- package/esm/series/base/base-series.js.map +1 -1
- package/esm/series/box-plot/box-plot.d.ts +2 -0
- package/esm/series/box-plot/box-plot.js +3 -0
- package/esm/series/box-plot/box-plot.js.map +1 -1
- package/esm/series/circle-packing/circle-packing.d.ts +2 -0
- package/esm/series/circle-packing/circle-packing.js +3 -0
- package/esm/series/circle-packing/circle-packing.js.map +1 -1
- package/esm/series/dot/dot.d.ts +1 -0
- package/esm/series/dot/dot.js +3 -0
- package/esm/series/dot/dot.js.map +1 -1
- package/esm/series/funnel/funnel.d.ts +2 -0
- package/esm/series/funnel/funnel.js +3 -0
- package/esm/series/funnel/funnel.js.map +1 -1
- package/esm/series/gauge/gauge-pointer.d.ts +2 -0
- package/esm/series/gauge/gauge-pointer.js +3 -0
- package/esm/series/gauge/gauge-pointer.js.map +1 -1
- package/esm/series/gauge/gauge.d.ts +2 -0
- package/esm/series/gauge/gauge.js +3 -0
- package/esm/series/gauge/gauge.js.map +1 -1
- package/esm/series/geo/geo.d.ts +2 -0
- package/esm/series/geo/geo.js +3 -0
- package/esm/series/geo/geo.js.map +1 -1
- package/esm/series/heatmap/heatmap.d.ts +2 -0
- package/esm/series/heatmap/heatmap.js +3 -0
- package/esm/series/heatmap/heatmap.js.map +1 -1
- package/esm/series/interface/series.d.ts +1 -0
- package/esm/series/interface/series.js.map +1 -1
- package/esm/series/line/line.d.ts +2 -0
- package/esm/series/line/line.js +4 -1
- package/esm/series/line/line.js.map +1 -1
- package/esm/series/link/link.d.ts +1 -0
- package/esm/series/link/link.js +3 -0
- package/esm/series/link/link.js.map +1 -1
- package/esm/series/map/map.d.ts +2 -0
- package/esm/series/map/map.js +3 -0
- package/esm/series/map/map.js.map +1 -1
- package/esm/series/pie/pie.d.ts +1 -0
- package/esm/series/pie/pie.js +3 -0
- package/esm/series/pie/pie.js.map +1 -1
- package/esm/series/polar/polar.js +1 -1
- package/esm/series/polar/polar.js.map +1 -1
- package/esm/series/progress/circular/circular.d.ts +2 -0
- package/esm/series/progress/circular/circular.js +3 -0
- package/esm/series/progress/circular/circular.js.map +1 -1
- package/esm/series/progress/linear/linear.d.ts +2 -0
- package/esm/series/progress/linear/linear.js +3 -0
- package/esm/series/progress/linear/linear.js.map +1 -1
- package/esm/series/radar/radar.d.ts +4 -2
- package/esm/series/radar/radar.js +12 -1
- package/esm/series/radar/radar.js.map +1 -1
- package/esm/series/range-area/range-area.js.map +1 -1
- package/esm/series/rose/rose.d.ts +2 -0
- package/esm/series/rose/rose.js +3 -0
- package/esm/series/rose/rose.js.map +1 -1
- package/esm/series/sankey/sankey.d.ts +2 -0
- package/esm/series/sankey/sankey.js +3 -0
- package/esm/series/sankey/sankey.js.map +1 -1
- package/esm/series/scatter/scatter.d.ts +2 -0
- package/esm/series/scatter/scatter.js +3 -0
- package/esm/series/scatter/scatter.js.map +1 -1
- package/esm/series/sunburst/sunburst.d.ts +2 -0
- package/esm/series/sunburst/sunburst.js +3 -0
- package/esm/series/sunburst/sunburst.js.map +1 -1
- package/esm/series/treemap/treemap.d.ts +2 -0
- package/esm/series/treemap/treemap.js +3 -0
- package/esm/series/treemap/treemap.js.map +1 -1
- package/esm/series/word-cloud/base.d.ts +2 -0
- package/esm/series/word-cloud/base.js +3 -0
- package/esm/series/word-cloud/base.js.map +1 -1
- package/esm/util/text.d.ts +3 -3
- package/esm/util/text.js +2 -0
- package/esm/util/text.js.map +1 -1
- package/package.json +7 -7
- package/cjs/component/tooltip/handler/utils/style.d.ts +0 -4
- package/cjs/component/tooltip/handler/utils/style.js +0 -32
- package/cjs/component/tooltip/handler/utils/style.js.map +0 -1
- package/esm/component/tooltip/handler/utils/style.d.ts +0 -4
- package/esm/component/tooltip/handler/utils/style.js +0 -26
- package/esm/component/tooltip/handler/utils/style.js.map +0 -1
|
@@ -2,10 +2,61 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: !0
|
|
5
|
-
}), exports.
|
|
5
|
+
}), exports.getTooltipAttributes = exports.getPanelAttributes = exports.getTextAttributes = void 0;
|
|
6
6
|
|
|
7
|
-
const vutils_1 = require("@visactor/vutils"), util_1 = require("../../../../util"),
|
|
8
|
-
|
|
7
|
+
const vutils_1 = require("@visactor/vutils"), util_1 = require("../../../../util"), constants_1 = require("../../../../theme/builtin/common/constants"), common_1 = require("./common"), DEFAULT_TEXT_ATTRIBUTES = {
|
|
8
|
+
fontFamily: constants_1.THEME_CONSTANTS.defaultFontFamily,
|
|
9
|
+
spacing: 10,
|
|
10
|
+
wordBreak: "break-word"
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
function getTextAttributes(style = {}, globalTheme, defaultAttributes) {
|
|
14
|
+
var _a, _b;
|
|
15
|
+
return Object.assign(Object.assign({}, null != defaultAttributes ? defaultAttributes : DEFAULT_TEXT_ATTRIBUTES), {
|
|
16
|
+
fill: null !== (_a = style.fill) && void 0 !== _a ? _a : style.fontColor,
|
|
17
|
+
textAlign: style.textAlign,
|
|
18
|
+
textBaseline: style.textBaseline,
|
|
19
|
+
fontFamily: null !== (_b = style.fontFamily) && void 0 !== _b ? _b : null == globalTheme ? void 0 : globalTheme.fontFamily,
|
|
20
|
+
fontSize: style.fontSize,
|
|
21
|
+
fontWeight: style.fontWeight,
|
|
22
|
+
lineHeight: style.lineHeight,
|
|
23
|
+
spacing: style.spacing,
|
|
24
|
+
multiLine: style.multiLine,
|
|
25
|
+
maxWidth: style.maxWidth,
|
|
26
|
+
wordBreak: style.wordBreak,
|
|
27
|
+
autoWidth: style.autoWidth
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
exports.getTextAttributes = getTextAttributes;
|
|
32
|
+
|
|
33
|
+
const getPanelAttributes = style => {
|
|
34
|
+
var _a;
|
|
35
|
+
const {backgroundColor: backgroundColor, border: border, shadow: shadow} = style, panelAttrs = {
|
|
36
|
+
lineWidth: null !== (_a = null == border ? void 0 : border.width) && void 0 !== _a ? _a : 0,
|
|
37
|
+
shadow: !!shadow
|
|
38
|
+
};
|
|
39
|
+
(null == border ? void 0 : border.color) && (panelAttrs.stroke = border.color),
|
|
40
|
+
backgroundColor && (panelAttrs.fill = backgroundColor), shadow && (panelAttrs.shadowColor = shadow.color,
|
|
41
|
+
panelAttrs.shadowBlur = shadow.blur, panelAttrs.shadowOffsetX = shadow.x, panelAttrs.shadowOffsetY = shadow.y,
|
|
42
|
+
panelAttrs.shadowSpread = shadow.spread);
|
|
43
|
+
const {radius: radius} = null != border ? border : {};
|
|
44
|
+
return (0, vutils_1.isValid)(radius) && (panelAttrs.cornerRadius = [ radius, radius, radius, radius ]),
|
|
45
|
+
panelAttrs;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
exports.getPanelAttributes = getPanelAttributes;
|
|
49
|
+
|
|
50
|
+
const getTooltipAttributes = (actualTooltip, spec, globalTheme) => {
|
|
51
|
+
var _a, _b, _c, _d, _e;
|
|
52
|
+
const {style: style = {}, enterable: enterable, transitionDuration: transitionDuration} = spec, {panel: panel = {}, titleLabel: titleLabel, shape: shape, keyLabel: keyLabel, valueLabel: valueLabel, spaceRow: commonSpaceRow} = style, padding = (0,
|
|
53
|
+
vutils_1.normalizePadding)(panel.padding), paddingSpec = (0, util_1.normalizeLayoutPaddingSpec)(panel.padding), titleStyle = getTextAttributes(titleLabel, globalTheme), keyStyle = getTextAttributes(keyLabel, globalTheme), valueStyle = getTextAttributes(valueLabel, globalTheme), shapeStyle = {
|
|
54
|
+
fill: !0,
|
|
55
|
+
size: null !== (_a = null == shape ? void 0 : shape.size) && void 0 !== _a ? _a : 8,
|
|
56
|
+
spacing: null !== (_b = null == shape ? void 0 : shape.spacing) && void 0 !== _b ? _b : 6
|
|
57
|
+
}, attributes = {
|
|
58
|
+
panel: (0, exports.getPanelAttributes)(panel),
|
|
59
|
+
padding: padding,
|
|
9
60
|
title: {},
|
|
10
61
|
content: [],
|
|
11
62
|
titleStyle: {
|
|
@@ -20,133 +71,92 @@ const vutils_1 = require("@visactor/vutils"), util_1 = require("../../../../util
|
|
|
20
71
|
},
|
|
21
72
|
hasContentShape: !1,
|
|
22
73
|
keyWidth: 0,
|
|
23
|
-
valueWidth: 0
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
let
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
height: height
|
|
38
|
-
}, lineTitleStyle), {
|
|
39
|
-
text: text
|
|
40
|
-
}), maxWidth = width, titleMaxHeight = height, titleHasShape && vrender_1.builtinSymbolsMap[titleShapeType]) {
|
|
41
|
-
const titleShapeAttrs = {
|
|
42
|
-
symbolType: titleShapeType
|
|
74
|
+
valueWidth: 0,
|
|
75
|
+
enterable: enterable,
|
|
76
|
+
transitionDuration: transitionDuration
|
|
77
|
+
}, {title: title = {}, content: content = []} = actualTooltip;
|
|
78
|
+
let containerWidth = paddingSpec.left + paddingSpec.right, containerHeight = paddingSpec.top + paddingSpec.bottom, contentMaxWidth = 0;
|
|
79
|
+
const filteredContent = content.filter((item => (item.key || item.value) && !1 !== item.visible)), hasContent = !!filteredContent.length;
|
|
80
|
+
let maxKeyWidth = 0, maxAdaptiveKeyWidth = 0, maxValueWidth = 0, maxShapeWidth = 0;
|
|
81
|
+
if (hasContent) {
|
|
82
|
+
const keyWidths = [], adaptiveKeyWidths = [], valueWidths = [], shapeWidths = [];
|
|
83
|
+
attributes.content = filteredContent.map(((item, i) => {
|
|
84
|
+
let itemHeight = 0;
|
|
85
|
+
const {hasShape: actualHasShape, key: actualKey, shapeType: actualShapeType = "", shapeFill: actualShapeFill, shapeStroke: actualShapeStroke, shapeLineWidth: actualShapeLineWidth, shapeSize: actualShapeSize, value: actualValue, isKeyAdaptive: actualIsKeyAdaptive, spaceRow: actualSpaceRow, keyStyle: actualKeyStyle, valueStyle: actualValueStyle, shapeColor: actualShapeColor, shapeHollow: actualShapeHollow} = item, itemAttrs = {
|
|
86
|
+
height: 0,
|
|
87
|
+
spaceRow: null != actualSpaceRow ? actualSpaceRow : commonSpaceRow
|
|
43
88
|
};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}, adaptiveShapeFill = null != shapeFill ? shapeFill : shapeColor;
|
|
86
|
-
shapeHollow ? shape.stroke = adaptiveShapeFill : shape.fill = adaptiveShapeFill,
|
|
87
|
-
shape.stroke = null != shapeStroke ? shapeStroke : adaptiveShapeFill, shape.lineWidth = shapeLineWidth,
|
|
88
|
-
itemAttrs.shape = shape;
|
|
89
|
-
const shapeWidth = null != shapeSize ? shapeSize : shapeStyle.size;
|
|
90
|
-
itemHeight = Math.max(shapeWidth, itemHeight), shapeWidths.push(shapeWidth);
|
|
91
|
-
} else itemAttrs.shape = {
|
|
92
|
-
visible: !1
|
|
93
|
-
};
|
|
94
|
-
return itemAttrs.height = itemHeight, containerHeight += itemHeight, i < filteredContent.length - 1 && (containerHeight += itemAttrs.spaceRow),
|
|
95
|
-
itemAttrs;
|
|
96
|
-
}));
|
|
97
|
-
const maxKeyWidth = keyWidths.length ? Math.max(...keyWidths) : 0, maxAdaptiveKeyWidth = adaptiveKeyWidths.length ? Math.max(...adaptiveKeyWidths) : 0, maxValueWidth = valueWidths.length ? Math.max(...valueWidths) : 0, shapeWidth = shapeWidths.length ? Math.max(...shapeWidths) + shapeStyle.spacing : 0;
|
|
98
|
-
maxWidth = Math.max(maxKeyWidth + maxValueWidth + keyStyle.spacing + valueStyle.spacing + shapeWidth, maxAdaptiveKeyWidth + shapeWidth, maxWidth),
|
|
99
|
-
attribute.hasContentShape = !!shapeWidths.length, attribute.keyWidth = maxKeyWidth,
|
|
100
|
-
attribute.valueWidth = maxValueWidth;
|
|
101
|
-
}
|
|
89
|
+
if ((0, vutils_1.isValid)(actualKey)) {
|
|
90
|
+
const itemKeyStyle = (0, util_1.mergeSpec)({}, keyStyle, getTextAttributes(actualKeyStyle, void 0, {})), {width: width, height: height, text: text} = (0,
|
|
91
|
+
common_1.measureTooltipText)(actualKey, itemKeyStyle);
|
|
92
|
+
itemAttrs.key = Object.assign(Object.assign({
|
|
93
|
+
width: width,
|
|
94
|
+
height: height
|
|
95
|
+
}, itemKeyStyle), {
|
|
96
|
+
text: text
|
|
97
|
+
}), actualIsKeyAdaptive ? adaptiveKeyWidths.push(width) : keyWidths.push(width),
|
|
98
|
+
itemHeight = Math.max(itemHeight, height);
|
|
99
|
+
}
|
|
100
|
+
if ((0, vutils_1.isValid)(actualValue)) {
|
|
101
|
+
const itemValueStyle = (0, util_1.mergeSpec)({}, valueStyle, getTextAttributes(actualValueStyle, void 0, {})), {width: width, height: height, text: text} = (0,
|
|
102
|
+
common_1.measureTooltipText)(actualValue, itemValueStyle);
|
|
103
|
+
itemAttrs.value = Object.assign(Object.assign({
|
|
104
|
+
width: width,
|
|
105
|
+
height: height
|
|
106
|
+
}, itemValueStyle), {
|
|
107
|
+
text: text
|
|
108
|
+
}), valueWidths.push(width), itemHeight = Math.max(itemHeight, height);
|
|
109
|
+
}
|
|
110
|
+
if (actualHasShape) {
|
|
111
|
+
const shape = {
|
|
112
|
+
visible: !0,
|
|
113
|
+
symbolType: actualShapeType
|
|
114
|
+
}, adaptiveShapeFill = null != actualShapeFill ? actualShapeFill : actualShapeColor;
|
|
115
|
+
actualShapeHollow ? shape.stroke = adaptiveShapeFill : shape.fill = adaptiveShapeFill,
|
|
116
|
+
shape.stroke = null != actualShapeStroke ? actualShapeStroke : adaptiveShapeFill,
|
|
117
|
+
shape.lineWidth = actualShapeLineWidth, itemAttrs.shape = shape;
|
|
118
|
+
const shapeWidth = null != actualShapeSize ? actualShapeSize : shapeStyle.size;
|
|
119
|
+
itemHeight = Math.max(shapeWidth, itemHeight), shapeWidths.push(shapeWidth);
|
|
120
|
+
} else itemAttrs.shape = {
|
|
121
|
+
visible: !1
|
|
122
|
+
};
|
|
123
|
+
return itemAttrs.height = itemHeight, containerHeight += itemHeight, i < filteredContent.length - 1 && (containerHeight += itemAttrs.spaceRow),
|
|
124
|
+
itemAttrs;
|
|
125
|
+
})), maxKeyWidth = keyWidths.length ? Math.max(...keyWidths) : 0, maxAdaptiveKeyWidth = adaptiveKeyWidths.length ? Math.max(...adaptiveKeyWidths) : 0,
|
|
126
|
+
maxValueWidth = valueWidths.length ? Math.max(...valueWidths) : 0, maxShapeWidth = shapeWidths.length ? Math.max(...shapeWidths) + shapeStyle.spacing : 0,
|
|
127
|
+
contentMaxWidth = Math.max(maxShapeWidth + maxKeyWidth + keyStyle.spacing + maxValueWidth + valueStyle.spacing, maxShapeWidth + maxAdaptiveKeyWidth, contentMaxWidth),
|
|
128
|
+
attributes.hasContentShape = !!shapeWidths.length, attributes.keyWidth = maxKeyWidth,
|
|
129
|
+
attributes.valueWidth = maxValueWidth;
|
|
102
130
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
if (!style.multiLine) {
|
|
118
|
-
const {width: width, height: height} = measure.fullMeasure(text);
|
|
119
|
-
return {
|
|
120
|
-
width: width,
|
|
121
|
-
height: height,
|
|
131
|
+
let titleMaxWidth = 0, titleMaxHeight = 0;
|
|
132
|
+
const {visible: actualTitleVisible = !0, value: actualTitleValue = "", valueStyle: actualTitleValueStyle, spaceRow: actualTitleSpaceRow} = title;
|
|
133
|
+
attributes.title.visible = actualTitleVisible, attributes.title.spaceRow = null != actualTitleSpaceRow ? actualTitleSpaceRow : commonSpaceRow;
|
|
134
|
+
let titleValueStyle = {};
|
|
135
|
+
const isAutoWidthMode = () => titleValueStyle.autoWidth && !1 !== titleValueStyle.multiLine;
|
|
136
|
+
if (actualTitleVisible) {
|
|
137
|
+
titleValueStyle = (0, util_1.mergeSpec)({}, titleStyle, getTextAttributes(actualTitleValueStyle, void 0, {})),
|
|
138
|
+
isAutoWidthMode() && (titleValueStyle.multiLine = null === (_c = titleValueStyle.multiLine) || void 0 === _c || _c,
|
|
139
|
+
titleValueStyle.maxWidth = null !== (_d = titleValueStyle.maxWidth) && void 0 !== _d ? _d : hasContent ? Math.ceil(contentMaxWidth) : void 0);
|
|
140
|
+
const {text: text, width: width, height: height} = (0, common_1.measureTooltipText)(actualTitleValue, titleValueStyle);
|
|
141
|
+
attributes.title.value = Object.assign(Object.assign({
|
|
142
|
+
width: isAutoWidthMode() ? Math.min(width, null !== (_e = titleValueStyle.maxWidth) && void 0 !== _e ? _e : Number.MAX_VALUE) : width,
|
|
143
|
+
height: height
|
|
144
|
+
}, titleValueStyle), {
|
|
122
145
|
text: text
|
|
123
|
-
}
|
|
146
|
+
}), titleMaxWidth = attributes.title.value.width, titleMaxHeight = attributes.title.value.height,
|
|
147
|
+
containerHeight += titleMaxHeight + (hasContent ? attributes.title.spaceRow : 0);
|
|
124
148
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
text: line
|
|
136
|
-
})))
|
|
137
|
-
});
|
|
138
|
-
return {
|
|
139
|
-
width: bound.width(),
|
|
140
|
-
height: bound.height(),
|
|
141
|
-
text: textLines
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
return {
|
|
145
|
-
width: width,
|
|
146
|
-
height: height,
|
|
147
|
-
text: textLines
|
|
148
|
-
};
|
|
149
|
+
return attributes.title.width = titleMaxWidth, attributes.title.height = titleMaxHeight,
|
|
150
|
+
isAutoWidthMode() ? containerWidth += contentMaxWidth || titleMaxWidth : containerWidth += Math.max(titleMaxWidth, contentMaxWidth),
|
|
151
|
+
hasContent && attributes.content.forEach((item => {
|
|
152
|
+
var _a;
|
|
153
|
+
const value = item.value;
|
|
154
|
+
value && (null === (_a = value.autoWidth) || void 0 === _a || _a) && (value.width = containerWidth - paddingSpec.left - paddingSpec.right - maxShapeWidth - maxKeyWidth - keyStyle.spacing - valueStyle.spacing,
|
|
155
|
+
value.multiLine = !0, value.maxWidth || (value.maxWidth = Math.ceil(value.width)),
|
|
156
|
+
attributes.valueWidth = Math.max(attributes.valueWidth, value.width));
|
|
157
|
+
})), attributes.panel.width = containerWidth, attributes.panel.height = containerHeight,
|
|
158
|
+
attributes;
|
|
149
159
|
};
|
|
150
160
|
|
|
151
|
-
exports.
|
|
161
|
+
exports.getTooltipAttributes = getTooltipAttributes;
|
|
152
162
|
//# sourceMappingURL=attribute.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/component/tooltip/handler/utils/attribute.ts"],"names":[],"mappings":";;;AAQA,6CAA2C;AAC3C,2CAA8D;AAG9D,+CAAyE;AACzE,mCAA4C;AAErC,MAAM,oBAAoB,GAAG,CAClC,aAA6B,EAC7B,KAA6B,EACV,EAAE;IACrB,MAAM,EACJ,QAAQ,EAAE,cAAc,EACxB,OAAO,EACP,KAAK,EAAE,UAAU,EACjB,KAAK,EAAE,UAAU,EACjB,GAAG,EAAE,QAAQ,EACb,KAAK,EAAE,UAAU,EAClB,GAAG,KAAK,CAAC;IAEV,MAAM,SAAS,mCACV,KAAK,KAER,KAAK,EAAE,EAAE,EACT,OAAO,EAAE,EAAE,EAEX,UAAU,EAAE;YACV,KAAK,EAAE,UAAU;YACjB,QAAQ,EAAE,cAAc;SACzB,EACD,YAAY,EAAE;YACZ,KAAK,EAAE,UAAU;YACjB,GAAG,EAAE,QAAQ;YACb,KAAK,EAAE,UAAU;YACjB,QAAQ,EAAE,cAAc;SACzB,EAED,eAAe,EAAE,KAAK,EACtB,QAAQ,EAAE,CAAC,EACX,UAAU,EAAE,CAAC,GACd,CAAC;IACD,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAA6B,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QACnE,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC,CAAC,CAAC;IAEH,MAAM,EAAE,KAAK,GAAG,EAAE,EAAE,OAAO,GAAG,EAAE,EAAE,GAAG,aAAa,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S;KAChB,CAAC;AACJ,CAAC,CAAC;AA5CW,QAAA,kBAAkB,sBA4C7B","file":"attribute.js","sourcesContent":["import type {\n IContainerSize,\n TooltipAttributes,\n TooltipRowAttrs,\n TooltipSymbolAttrs\n} from '@visactor/vrender-components';\nimport type { IToolTipActual, MaybeArray } from '../../../../typings';\nimport type { ITooltipStyle, ITooltipTextStyle } from '../interface';\nimport { isValid } from '@visactor/vutils';\nimport { initTextMeasure, mergeSpec } from '../../../../util';\nimport type { IRichTextParagraphCharacter } from '@visactor/vrender';\n// eslint-disable-next-line no-duplicate-imports\nimport { builtinSymbolsMap, getRichTextBounds } from '@visactor/vrender';\nimport { getTextAttributes } from './style';\n\nexport const getTooltipAttributes = (\n actualTooltip: IToolTipActual,\n style: Partial<ITooltipStyle>\n): TooltipAttributes => {\n const {\n spaceRow: commonSpaceRow,\n padding,\n title: titleStyle,\n shape: shapeStyle,\n key: keyStyle,\n value: valueStyle\n } = style;\n\n const attribute: TooltipAttributes = {\n ...style,\n\n title: {},\n content: [],\n\n titleStyle: {\n value: titleStyle,\n spaceRow: commonSpaceRow\n },\n contentStyle: {\n shape: shapeStyle,\n key: keyStyle,\n value: valueStyle,\n spaceRow: commonSpaceRow\n },\n\n hasContentShape: false,\n keyWidth: 0,\n valueWidth: 0\n };\n (['key', 'value', 'shape'] as (keyof ITooltipStyle)[]).forEach(key => {\n delete attribute[key];\n });\n\n const { title = {}, content = [] } = actualTooltip;\n\n let maxWidth = 0;\n let containerHeight = padding.top + padding.bottom;\n\n // calculate title\n let titleMaxHeight = 0;\n const {\n visible: titleVisible = true,\n value: titleValue = '',\n valueStyle: titleValueStyle,\n hasShape: titleHasShape,\n shapeType: titleShapeType = '',\n shapeHollow: titleShapeHollow,\n shapeColor: titleShapeColor,\n spaceRow: titleSpaceRow\n } = title;\n attribute.title.visible = titleVisible;\n attribute.title.spaceRow = titleSpaceRow ?? commonSpaceRow;\n if (titleVisible) {\n const lineTitleStyle = mergeSpec({}, titleStyle, getTextAttributes(titleValueStyle, undefined, {}));\n const { text, width, height } = measureTooltipText(titleValue, lineTitleStyle);\n attribute.title.value = {\n width,\n height,\n ...lineTitleStyle,\n text\n };\n maxWidth = width;\n titleMaxHeight = height;\n\n if (titleHasShape && builtinSymbolsMap[titleShapeType]) {\n const titleShapeAttrs: TooltipSymbolAttrs = {\n symbolType: titleShapeType\n };\n if (titleShapeHollow) {\n titleShapeAttrs.stroke = titleShapeColor;\n } else {\n titleShapeAttrs.fill = titleShapeColor;\n }\n attribute.title.shape = titleShapeAttrs;\n maxWidth += shapeStyle.size + shapeStyle.spacing;\n titleMaxHeight = Math.max(shapeStyle.size, titleMaxHeight);\n }\n\n attribute.title.width = maxWidth;\n attribute.title.height = titleMaxHeight;\n\n containerHeight += titleMaxHeight;\n }\n\n // calculate content\n if (content.length) {\n // filter content\n const filteredContent = content.filter(item => {\n return (item.key || item.value) && item.visible !== false;\n });\n if (filteredContent.length) {\n if (titleVisible) {\n containerHeight += attribute.title.spaceRow; // title 与 content 之前的间隔\n }\n\n const keyWidths: number[] = [];\n const adaptiveKeyWidths: number[] = [];\n const valueWidths: number[] = [];\n const shapeWidths: number[] = [];\n\n attribute.content = filteredContent.map((item, i) => {\n let itemHeight = 0;\n const {\n hasShape,\n key,\n shapeColor,\n shapeHollow,\n shapeType = '',\n shapeFill,\n shapeStroke,\n shapeLineWidth,\n shapeSize,\n value,\n isKeyAdaptive,\n spaceRow: lineSpaceRow\n } = item;\n const itemAttrs: TooltipRowAttrs = { height: 0, spaceRow: lineSpaceRow ?? commonSpaceRow };\n if (isValid(key)) {\n const lineKeyStyle = mergeSpec({}, keyStyle, getTextAttributes(item.keyStyle, undefined, {}));\n const { width, height, text } = measureTooltipText(key, lineKeyStyle);\n itemAttrs.key = {\n width,\n height,\n ...lineKeyStyle,\n text\n };\n if (!isKeyAdaptive) {\n keyWidths.push(width);\n } else {\n adaptiveKeyWidths.push(width);\n }\n itemHeight = Math.max(itemHeight, height);\n }\n if (isValid(value)) {\n const lineValueStyle = mergeSpec({}, valueStyle, getTextAttributes(item.valueStyle, undefined, {}));\n const { width, height, text } = measureTooltipText(value, lineValueStyle);\n itemAttrs.value = {\n width,\n height,\n ...lineValueStyle,\n text\n };\n valueWidths.push(width);\n itemHeight = Math.max(itemHeight, height);\n }\n if (hasShape) {\n const shape: TooltipSymbolAttrs = {\n visible: true,\n symbolType: shapeType\n };\n const adaptiveShapeFill = shapeFill ?? shapeColor;\n if (shapeHollow) {\n shape.stroke = adaptiveShapeFill;\n } else {\n shape.fill = adaptiveShapeFill;\n }\n shape.stroke = shapeStroke ?? adaptiveShapeFill;\n shape.lineWidth = shapeLineWidth;\n itemAttrs.shape = shape;\n\n const shapeWidth = shapeSize ?? shapeStyle.size;\n itemHeight = Math.max(shapeWidth, itemHeight);\n shapeWidths.push(shapeWidth);\n } else {\n itemAttrs.shape = { visible: false };\n }\n\n itemAttrs.height = itemHeight;\n containerHeight += itemHeight;\n if (i < filteredContent.length - 1) {\n containerHeight += itemAttrs.spaceRow;\n }\n\n return itemAttrs;\n });\n\n const maxKeyWidth = keyWidths.length ? Math.max(...keyWidths) : 0; // name 需要对齐\n const maxAdaptiveKeyWidth = adaptiveKeyWidths.length ? Math.max(...adaptiveKeyWidths) : 0;\n const maxValueWidth = valueWidths.length ? Math.max(...valueWidths) : 0; // value 需要对齐\n const shapeWidth = shapeWidths.length ? Math.max(...shapeWidths) + shapeStyle.spacing : 0; // shape 列宽度\n maxWidth = Math.max(\n maxKeyWidth + maxValueWidth + keyStyle.spacing + valueStyle.spacing + shapeWidth,\n maxAdaptiveKeyWidth + shapeWidth,\n maxWidth\n );\n attribute.hasContentShape = !!shapeWidths.length;\n attribute.keyWidth = maxKeyWidth;\n attribute.valueWidth = maxValueWidth;\n }\n }\n\n const containerSize: IContainerSize = {\n width: maxWidth + padding.left + padding.right,\n height: containerHeight\n };\n\n attribute.panel.width = containerSize.width;\n attribute.panel.height = containerSize.height;\n return attribute;\n};\n\ninterface ITooltipTextInfo {\n width: number;\n height: number;\n text: MaybeArray<number> | MaybeArray<string>;\n}\n\nexport const measureTooltipText = (text: string, style: ITooltipTextStyle): ITooltipTextInfo => {\n text = (text ?? '').toString();\n const measure = initTextMeasure(style as any);\n if (!style.multiLine) {\n // 单行文本\n const { width, height } = measure.fullMeasure(text);\n return {\n width,\n height,\n text\n };\n }\n // 多行文本\n let textLines = text.split('\\n');\n textLines = textLines.map((line, i) => (i < textLines.length - 1 ? line + '\\n' : line));\n const { width, height } = measure.fullMeasure(textLines);\n\n if (style.maxWidth && style.maxWidth <= width) {\n // 允许自动换行的情况,改用 richText 测量\n const bound = getRichTextBounds({\n wordBreak: style.wordBreak ?? 'break-word',\n maxWidth: style.maxWidth,\n width: 0,\n height: 0,\n textConfig: textLines.map(\n (line, i) =>\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\n return {\n width,\n height,\n text: textLines\n };\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/component/tooltip/handler/utils/attribute.ts"],"names":[],"mappings":";;;AAWA,6CAA6D;AAC7D,2CAAyE;AAIzE,0EAA6E;AAC7E,qCAA8C;AAE9C,MAAM,uBAAuB,GAA+B;IAC1D,UAAU,EAAE,2BAAe,CAAC,iBAAiB;IAC7C,OAAO,EAAE,EAAE;IACX,SAAS,EAAE,YAAY;CACxB,CAAC;AAEF,SAAgB,iBAAiB,CAC/B,QAA2B,EAAE,EAC7B,WAAoB,EACpB,iBAA8C;;IAE9C,MAAM,KAAK,mCACN,CAAC,iBAAiB,aAAjB,iBAAiB,cAAjB,iBAAiB,GAAI,uBAAuB,CAAC,KACjD,IAAI,EAAE,CAAC,MAAA,KAAK,CAAC,IAAI,mCAAI,KAAK,CAAC,SAAS,CAAW,EAC/C,SAAS,EAAE,KAAK,CAAC,SAAS,EAC1B,YAAY,EAAE,KAAK,CAAC,YAAY,EAChC,UAAU,EAAE,MAAA,KAAK,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AC,GAAG,CAAC,UAAU,CAAC,UAAU,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;aACtE;QACH,CAAC,CAAC,CAAC;KACJ;IAED,UAAU,CAAC,KAAK,CAAC,KAAK,GAAG,cAAc,CAAC;IACxC,UAAU,CAAC,KAAK,CAAC,MAAM,GAAG,eAAe,CAAC;IAE1C,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AA/OW,QAAA,oBAAoB,wBA+O/B","file":"attribute.js","sourcesContent":["import type {\n IContainerSize,\n TooltipAttributes,\n TooltipPanelAttrs,\n TooltipRowAttrs,\n TooltipRowStyleAttrs,\n TooltipSymbolAttrs,\n TooltipTextAttrs\n} from '@visactor/vrender-components';\nimport type { IPadding, IToolTipActual } from '../../../../typings';\nimport type { ITooltipTextStyle } from '../interface';\nimport { isValid, normalizePadding } from '@visactor/vutils';\nimport { mergeSpec, normalizeLayoutPaddingSpec } from '../../../../util';\nimport type { ITooltipSpec } from '../../interface/spec';\nimport type { ITheme } from '../../../../theme';\nimport type { ITooltipTextTheme, ITooltipTheme } from '../../interface/theme';\nimport { THEME_CONSTANTS } from '../../../../theme/builtin/common/constants';\nimport { measureTooltipText } from './common';\n\nconst DEFAULT_TEXT_ATTRIBUTES: Partial<ITooltipTextStyle> = {\n fontFamily: THEME_CONSTANTS.defaultFontFamily,\n spacing: 10,\n wordBreak: 'break-word'\n};\n\nexport function getTextAttributes(\n style: ITooltipTextTheme = {},\n globalTheme?: ITheme,\n defaultAttributes?: Partial<ITooltipTextStyle>\n): ITooltipTextStyle {\n const attrs: ITooltipTextStyle = {\n ...(defaultAttributes ?? DEFAULT_TEXT_ATTRIBUTES),\n fill: (style.fill ?? style.fontColor) as string,\n textAlign: style.textAlign,\n textBaseline: style.textBaseline,\n fontFamily: style.fontFamily ?? globalTheme?.fontFamily,\n fontSize: style.fontSize,\n fontWeight: style.fontWeight,\n lineHeight: style.lineHeight as any, // FIXME: vrender 支持行高字符串后删除 any\n spacing: style.spacing,\n multiLine: style.multiLine,\n maxWidth: style.maxWidth,\n wordBreak: style.wordBreak,\n autoWidth: style.autoWidth\n };\n return attrs;\n}\n\nexport const getPanelAttributes = (style: ITooltipTheme['panel']): TooltipPanelAttrs => {\n const { backgroundColor, border, shadow } = style;\n const panelAttrs: TooltipPanelAttrs = {\n lineWidth: border?.width ?? 0,\n shadow: !!shadow\n };\n if (border?.color) {\n panelAttrs.stroke = border.color as string;\n }\n if (backgroundColor) {\n panelAttrs.fill = backgroundColor as string;\n }\n if (shadow) {\n panelAttrs.shadowColor = shadow.color as string;\n panelAttrs.shadowBlur = shadow.blur;\n panelAttrs.shadowOffsetX = shadow.x;\n panelAttrs.shadowOffsetY = shadow.y;\n panelAttrs.shadowSpread = shadow.spread;\n }\n const { radius } = border ?? {};\n if (isValid(radius)) {\n panelAttrs.cornerRadius = [radius, radius, radius, radius];\n }\n return panelAttrs;\n};\n\nexport const getTooltipAttributes = (\n actualTooltip: IToolTipActual,\n spec: ITooltipSpec,\n globalTheme: ITheme\n): TooltipAttributes => {\n const { style = {}, enterable, transitionDuration } = spec;\n const { panel = {}, titleLabel, shape, keyLabel, valueLabel, spaceRow: commonSpaceRow } = style;\n const padding = normalizePadding(panel.padding);\n const paddingSpec = normalizeLayoutPaddingSpec(panel.padding) as IPadding;\n\n const titleStyle = getTextAttributes(titleLabel, globalTheme);\n const keyStyle = getTextAttributes(keyLabel, globalTheme);\n const valueStyle = getTextAttributes(valueLabel, globalTheme);\n const shapeStyle: TooltipRowStyleAttrs['shape'] = {\n fill: true,\n size: shape?.size ?? 8,\n spacing: shape?.spacing ?? 6\n };\n\n const attributes: TooltipAttributes = {\n panel: getPanelAttributes(panel),\n padding,\n\n title: {},\n content: [],\n\n titleStyle: {\n value: titleStyle,\n spaceRow: commonSpaceRow\n },\n contentStyle: {\n shape: shapeStyle,\n key: keyStyle,\n value: valueStyle,\n spaceRow: commonSpaceRow\n },\n hasContentShape: false,\n keyWidth: 0,\n valueWidth: 0,\n\n enterable,\n transitionDuration\n };\n\n const { title = {}, content = [] } = actualTooltip;\n\n let containerWidth = paddingSpec.left + paddingSpec.right;\n let containerHeight = paddingSpec.top + paddingSpec.bottom;\n\n // calculate content\n let contentMaxWidth = 0;\n // filter content\n const filteredContent = content.filter(item => {\n return (item.key || item.value) && item.visible !== false;\n });\n const hasContent = !!filteredContent.length;\n let maxKeyWidth = 0;\n let maxAdaptiveKeyWidth = 0;\n let maxValueWidth = 0;\n let maxShapeWidth = 0;\n\n if (hasContent) {\n const keyWidths: number[] = [];\n const adaptiveKeyWidths: number[] = [];\n const valueWidths: number[] = [];\n const shapeWidths: number[] = [];\n\n attributes.content = filteredContent.map((item, i) => {\n let itemHeight = 0;\n const {\n hasShape: actualHasShape,\n key: actualKey,\n shapeType: actualShapeType = '',\n shapeFill: actualShapeFill,\n shapeStroke: actualShapeStroke,\n shapeLineWidth: actualShapeLineWidth,\n shapeSize: actualShapeSize,\n value: actualValue,\n isKeyAdaptive: actualIsKeyAdaptive,\n spaceRow: actualSpaceRow,\n keyStyle: actualKeyStyle,\n valueStyle: actualValueStyle,\n // 弃用的属性,做下兼容\n shapeColor: actualShapeColor,\n shapeHollow: actualShapeHollow\n } = item;\n const itemAttrs: TooltipRowAttrs = { height: 0, spaceRow: actualSpaceRow ?? commonSpaceRow };\n if (isValid(actualKey)) {\n const itemKeyStyle: ITooltipTextStyle = mergeSpec(\n {},\n keyStyle,\n getTextAttributes(actualKeyStyle, undefined, {})\n );\n const { width, height, text } = measureTooltipText(actualKey, itemKeyStyle);\n itemAttrs.key = {\n width,\n height,\n ...itemKeyStyle,\n text\n };\n if (!actualIsKeyAdaptive) {\n keyWidths.push(width);\n } else {\n adaptiveKeyWidths.push(width);\n }\n itemHeight = Math.max(itemHeight, height);\n }\n if (isValid(actualValue)) {\n const itemValueStyle: ITooltipTextStyle = mergeSpec(\n {},\n valueStyle,\n getTextAttributes(actualValueStyle, undefined, {})\n );\n const { width, height, text } = measureTooltipText(actualValue, itemValueStyle);\n itemAttrs.value = {\n width,\n height,\n ...itemValueStyle,\n text\n };\n valueWidths.push(width);\n itemHeight = Math.max(itemHeight, height);\n }\n if (actualHasShape) {\n const shape: TooltipSymbolAttrs = {\n visible: true,\n symbolType: actualShapeType\n };\n const adaptiveShapeFill = actualShapeFill ?? actualShapeColor;\n if (actualShapeHollow) {\n shape.stroke = adaptiveShapeFill;\n } else {\n shape.fill = adaptiveShapeFill;\n }\n shape.stroke = actualShapeStroke ?? adaptiveShapeFill;\n shape.lineWidth = actualShapeLineWidth;\n itemAttrs.shape = shape;\n\n const shapeWidth = actualShapeSize ?? shapeStyle.size;\n itemHeight = Math.max(shapeWidth, itemHeight);\n shapeWidths.push(shapeWidth);\n } else {\n itemAttrs.shape = { visible: false };\n }\n\n itemAttrs.height = itemHeight;\n containerHeight += itemHeight;\n if (i < filteredContent.length - 1) {\n containerHeight += itemAttrs.spaceRow;\n }\n\n return itemAttrs;\n });\n\n maxKeyWidth = keyWidths.length ? Math.max(...keyWidths) : 0; // name 需要对齐\n maxAdaptiveKeyWidth = adaptiveKeyWidths.length ? Math.max(...adaptiveKeyWidths) : 0;\n maxValueWidth = valueWidths.length ? Math.max(...valueWidths) : 0; // value 需要对齐\n maxShapeWidth = shapeWidths.length ? Math.max(...shapeWidths) + shapeStyle.spacing : 0; // shape 列宽度\n contentMaxWidth = Math.max(\n maxShapeWidth + maxKeyWidth + keyStyle.spacing + maxValueWidth + valueStyle.spacing,\n maxShapeWidth + maxAdaptiveKeyWidth,\n contentMaxWidth\n );\n attributes.hasContentShape = !!shapeWidths.length;\n attributes.keyWidth = maxKeyWidth;\n attributes.valueWidth = maxValueWidth;\n }\n\n // calculate title\n let titleMaxWidth = 0;\n let titleMaxHeight = 0;\n const {\n visible: actualTitleVisible = true,\n value: actualTitleValue = '',\n valueStyle: actualTitleValueStyle,\n spaceRow: actualTitleSpaceRow\n } = title;\n attributes.title.visible = actualTitleVisible;\n attributes.title.spaceRow = actualTitleSpaceRow ?? commonSpaceRow;\n\n let titleValueStyle: ITooltipTextStyle = {};\n // 当前是否处于自适应宽度模式\n const isAutoWidthMode = () => titleValueStyle.autoWidth && titleValueStyle.multiLine !== false;\n if (actualTitleVisible) {\n titleValueStyle = mergeSpec({}, titleStyle, getTextAttributes(actualTitleValueStyle, undefined, {}));\n // 标题默认优化策略:如果 autoWidth 为 true,则宽度默认跟随 content 宽度并开启自动换行\n if (isAutoWidthMode()) {\n titleValueStyle.multiLine = titleValueStyle.multiLine ?? true;\n titleValueStyle.maxWidth = titleValueStyle.maxWidth ?? (hasContent ? Math.ceil(contentMaxWidth) : undefined);\n }\n\n const { text, width, height } = measureTooltipText(actualTitleValue, titleValueStyle);\n attributes.title.value = {\n width: isAutoWidthMode() ? Math.min(width, titleValueStyle.maxWidth ?? Number.MAX_VALUE) : width,\n height,\n ...titleValueStyle,\n text\n };\n titleMaxWidth = attributes.title.value.width;\n titleMaxHeight = attributes.title.value.height;\n\n containerHeight += titleMaxHeight + (hasContent ? attributes.title.spaceRow : 0);\n }\n attributes.title.width = titleMaxWidth;\n attributes.title.height = titleMaxHeight;\n\n if (isAutoWidthMode()) {\n containerWidth += contentMaxWidth ? contentMaxWidth : titleMaxWidth;\n } else {\n containerWidth += Math.max(titleMaxWidth, contentMaxWidth);\n }\n\n // 处理 content 的自动宽度模式\n if (hasContent) {\n attributes.content.forEach(item => {\n const value = item.value as ITooltipTextStyle & TooltipTextAttrs;\n // 最后一列默认自适应宽度\n if (value && (value.autoWidth ?? true)) {\n value.width =\n containerWidth -\n paddingSpec.left -\n paddingSpec.right -\n maxShapeWidth -\n maxKeyWidth -\n keyStyle.spacing -\n valueStyle.spacing;\n value.multiLine = true;\n if (!value.maxWidth) {\n value.maxWidth = Math.ceil(value.width);\n }\n attributes.valueWidth = Math.max(attributes.valueWidth, value.width);\n }\n });\n }\n\n attributes.panel.width = containerWidth;\n attributes.panel.height = containerHeight;\n\n return attributes;\n};\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
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
|
+
import type { ITooltipTextStyle } from '../interface/style';
|
|
4
5
|
export declare function escapeHTML(value: any): string;
|
|
5
6
|
export declare const getTooltipContentValue: <T>(field?: TooltipContentProperty<T>, datum?: any, params?: TooltipHandlerParams) => T;
|
|
6
7
|
export declare const getTooltipPatternValue: <T>(field?: MaybeArray<TooltipPatternProperty<T>>, data?: TooltipData, params?: TooltipHandlerParams) => MaybeArray<TooltipPatternProperty<T>> extends TooltipPatternProperty<T>[] ? MaybeArray<T> : T;
|
|
@@ -8,3 +9,10 @@ export declare function getFirstDatumFromTooltipData(data: TooltipData): Datum;
|
|
|
8
9
|
export declare function pickFirstValidValue<T>(isValid: (element?: T) => any, ...elements: T[]): T | undefined;
|
|
9
10
|
export declare function convertToColorString(color: any, defaultColor?: string): string;
|
|
10
11
|
export declare const getScale: (element: HTMLElement, boundingClientRect?: DOMRect) => number;
|
|
12
|
+
interface ITooltipTextInfo {
|
|
13
|
+
width: number;
|
|
14
|
+
height: number;
|
|
15
|
+
text: MaybeArray<number> | MaybeArray<string>;
|
|
16
|
+
}
|
|
17
|
+
export declare const measureTooltipText: (text: string, style: ITooltipTextStyle) => ITooltipTextInfo;
|
|
18
|
+
export {};
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: !0
|
|
5
|
-
}), exports.getScale = exports.convertToColorString = exports.pickFirstValidValue = exports.getFirstDatumFromTooltipData = exports.getTooltipPatternValue = exports.getTooltipContentValue = exports.escapeHTML = void 0;
|
|
5
|
+
}), exports.measureTooltipText = exports.getScale = exports.convertToColorString = exports.pickFirstValidValue = exports.getFirstDatumFromTooltipData = exports.getTooltipPatternValue = exports.getTooltipContentValue = exports.escapeHTML = void 0;
|
|
6
6
|
|
|
7
|
-
const util_1 = require("../../../../util");
|
|
7
|
+
const util_1 = require("../../../../util"), vrender_1 = require("@visactor/vrender");
|
|
8
8
|
|
|
9
9
|
function escapeHTML(value) {
|
|
10
10
|
return String(value).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/\(/g, "(").replace(/ /g, " ");
|
|
@@ -55,4 +55,44 @@ const getScale = (element, boundingClientRect) => element ? (boundingClientRect
|
|
|
55
55
|
element.offsetWidth > 0 ? boundingClientRect.width / element.offsetWidth : boundingClientRect.height / element.offsetHeight) : 1;
|
|
56
56
|
|
|
57
57
|
exports.getScale = getScale;
|
|
58
|
+
|
|
59
|
+
const measureTooltipText = (text, style) => {
|
|
60
|
+
var _a;
|
|
61
|
+
text = (null != text ? text : "").toString();
|
|
62
|
+
const measure = (0, util_1.initTextMeasure)(style);
|
|
63
|
+
if (!style.multiLine) {
|
|
64
|
+
const {width: width, height: height} = measure.fullMeasure(text);
|
|
65
|
+
return {
|
|
66
|
+
width: width,
|
|
67
|
+
height: height,
|
|
68
|
+
text: text
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
let textLines = text.split("\n");
|
|
72
|
+
textLines = textLines.map(((line, i) => i < textLines.length - 1 ? line + "\n" : line));
|
|
73
|
+
const {width: width, height: height} = measure.fullMeasure(textLines);
|
|
74
|
+
if (style.maxWidth && style.maxWidth <= width) {
|
|
75
|
+
const bound = (0, vrender_1.getRichTextBounds)({
|
|
76
|
+
wordBreak: null !== (_a = style.wordBreak) && void 0 !== _a ? _a : "break-word",
|
|
77
|
+
maxWidth: style.maxWidth,
|
|
78
|
+
width: 0,
|
|
79
|
+
height: 0,
|
|
80
|
+
textConfig: textLines.map(((line, i) => Object.assign(Object.assign({}, style), {
|
|
81
|
+
text: line
|
|
82
|
+
})))
|
|
83
|
+
});
|
|
84
|
+
return {
|
|
85
|
+
width: bound.width(),
|
|
86
|
+
height: bound.height(),
|
|
87
|
+
text: textLines
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
width: width,
|
|
92
|
+
height: height,
|
|
93
|
+
text: textLines
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
exports.measureTooltipText = measureTooltipText;
|
|
58
98
|
//# sourceMappingURL=common.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/component/tooltip/handler/utils/common.ts"],"names":[],"mappings":";;;AAEA,
|
|
1
|
+
{"version":3,"sources":["../src/component/tooltip/handler/utils/common.ts"],"names":[],"mappings":";;;AAEA,2CAA4G;AAI5G,+CAAsD;AAgBtD,SAAgB,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;AAPD,gCAOC;AAEM,MAAM,sBAAsB,GAAG,CACpC,KAAiC,EACjC,KAAW,EACX,MAA6B,EACd,EAAE;IACjB,IAAI,IAAA,YAAK,EAAC,KAAK,CAAC,EAAE;QAChB,OAAO,KAAK,CAAC;KACd;IACD,IAAI,IAAA,iBAAU,EAAC,KAAK,CAAC,EAAE;QACrB,OAAO,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;KAC7B;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAZW,QAAA,sBAAsB,0BAYjC;AAEK,MAAM,sBAAsB,GAAG,CACpC,KAA6C,EAC7C,IAAkB,EAClB,MAA6B,EAC4D,EAAE;IAC3F,IAAI,IAAA,YAAK,EAAC,KAAK,CAAC,EAAE;QAChB,OAAO,KAAK,CAAC;KACd;IACD,IAAI,IAAA,cAAO,EAAC,KAAK,CAAC,EAAE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A,kBAAkB,sBA4C7B","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, initTextMeasure } from '../../../../util';\nimport type { TooltipHandlerParams } from '../../interface';\nimport type { IDimensionData, IDimensionInfo } from '../../../../event/events/dimension';\nimport type { IRichTextParagraphCharacter } from '@visactor/vrender';\nimport { getRichTextBounds } from '@visactor/vrender';\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, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/\\(/g, '(')\n .replace(/ /g, ' '); // 转义符和真空格夹杂,在转义和正常换行之间取得平衡\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 const measure = initTextMeasure(style as any);\n if (!style.multiLine) {\n // 单行文本\n const { width, height } = measure.fullMeasure(text);\n return {\n width,\n height,\n text\n };\n }\n // 多行文本\n let textLines = text.split('\\n');\n textLines = textLines.map((line, i) => (i < textLines.length - 1 ? line + '\\n' : line));\n const { width, height } = measure.fullMeasure(textLines);\n\n if (style.maxWidth && style.maxWidth <= width) {\n // 允许自动换行的情况,改用 richText 测量\n const bound = getRichTextBounds({\n wordBreak: style.wordBreak ?? 'break-word',\n maxWidth: style.maxWidth,\n width: 0,\n height: 0,\n textConfig: textLines.map(\n (line, i) =>\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\n return {\n width,\n height,\n text: textLines\n };\n};\n"]}
|
|
@@ -19,6 +19,5 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
19
19
|
value: !0
|
|
20
20
|
}), __exportStar(require("./common"), exports), __exportStar(require("./compose"), exports),
|
|
21
21
|
__exportStar(require("./pattern"), exports), __exportStar(require("./get-spec"), exports),
|
|
22
|
-
__exportStar(require("./position"), exports), __exportStar(require("./attribute"), exports)
|
|
23
|
-
__exportStar(require("./style"), exports);
|
|
22
|
+
__exportStar(require("./position"), exports), __exportStar(require("./attribute"), exports);
|
|
24
23
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/component/tooltip/handler/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,4CAA0B;AAC1B,4CAA0B;AAC1B,6CAA2B;AAC3B,6CAA2B;AAC3B,8CAA4B
|
|
1
|
+
{"version":3,"sources":["../src/component/tooltip/handler/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,4CAA0B;AAC1B,4CAA0B;AAC1B,6CAA2B;AAC3B,6CAA2B;AAC3B,8CAA4B","file":"index.js","sourcesContent":["export * from './common';\nexport * from './compose';\nexport * from './pattern';\nexport * from './get-spec';\nexport * from './position';\nexport * from './attribute';\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { IModel } from '../../../model/interface';
|
|
2
1
|
import type { DimensionEventParams } from '../../../event/events/dimension/interface';
|
|
3
2
|
import type { BaseEventParams } from '../../../event/interface';
|
|
4
3
|
import type { DimensionTooltipInfo, MarkTooltipInfo } from '../processor/interface';
|
|
5
4
|
import type { Datum, IShowTooltipOption } from '../../../typings';
|
|
5
|
+
import type { IComponent } from '../../interface';
|
|
6
6
|
export type TooltipHandlerParams = (BaseEventParams | DimensionEventParams) & {
|
|
7
7
|
changePositionOnly?: boolean;
|
|
8
8
|
};
|
|
@@ -18,7 +18,7 @@ export declare enum TooltipResult {
|
|
|
18
18
|
success = 0,
|
|
19
19
|
failed = 1
|
|
20
20
|
}
|
|
21
|
-
export interface ITooltip extends
|
|
21
|
+
export interface ITooltip extends IComponent {
|
|
22
22
|
getVisible: () => boolean;
|
|
23
23
|
showTooltip: (datum: Datum, options: IShowTooltipOption) => void;
|
|
24
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/component/tooltip/interface/common.ts"],"names":[],"mappings":";;;AAoBA,IAAY,aAKX;AALD,WAAY,aAAa;IAEvB,uDAAW,CAAA;IAEX,qDAAU,CAAA;AACZ,CAAC,EALW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAKxB","file":"common.js","sourcesContent":["import type {
|
|
1
|
+
{"version":3,"sources":["../src/component/tooltip/interface/common.ts"],"names":[],"mappings":";;;AAoBA,IAAY,aAKX;AALD,WAAY,aAAa;IAEvB,uDAAW,CAAA;IAEX,qDAAU,CAAA;AACZ,CAAC,EALW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAKxB","file":"common.js","sourcesContent":["import type { DimensionEventParams } from '../../../event/events/dimension/interface';\nimport type { BaseEventParams } from '../../../event/interface';\nimport type { DimensionTooltipInfo, MarkTooltipInfo } from '../processor/interface';\nimport type { Datum, IShowTooltipOption } from '../../../typings';\nimport type { IComponent } from '../../interface';\n\nexport type TooltipHandlerParams = (BaseEventParams | DimensionEventParams) & {\n changePositionOnly?: boolean;\n};\n\nexport interface ITooltipActiveTypeAsKeys<T, K> {\n mark: T;\n dimension: K;\n}\n\nexport type TotalMouseEventData = {\n tooltipInfo: Partial<ITooltipActiveTypeAsKeys<MarkTooltipInfo, DimensionTooltipInfo>>;\n ignore: Partial<ITooltipActiveTypeAsKeys<boolean, boolean>>;\n};\n\nexport enum TooltipResult {\n /** tooltip 显示成功 */\n success = 0,\n /** tooltip 未成功显示 */\n failed = 1\n}\n\nexport interface ITooltip extends IComponent {\n getVisible: () => boolean;\n showTooltip: (datum: Datum, options: IShowTooltipOption) => void;\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { RichTextWordBreak } from '@visactor/vrender';
|
|
2
|
-
import type {
|
|
2
|
+
import type { StringOrNumber, TextAlign, TextBaseLine } from '../../../typings';
|
|
3
3
|
import type { IColorKey } from '../../../theme/color-scheme/interface';
|
|
4
|
+
import type { Padding } from '@visactor/vrender-components/es/core/type';
|
|
4
5
|
export interface ITooltipTextTheme {
|
|
5
6
|
fontFamily?: string;
|
|
6
7
|
fontSize?: number;
|
|
@@ -14,10 +15,11 @@ export interface ITooltipTextTheme {
|
|
|
14
15
|
multiLine?: boolean;
|
|
15
16
|
maxWidth?: number;
|
|
16
17
|
wordBreak?: RichTextWordBreak;
|
|
18
|
+
autoWidth?: boolean;
|
|
17
19
|
}
|
|
18
20
|
export interface ITooltipTheme {
|
|
19
21
|
panel?: {
|
|
20
|
-
padding?:
|
|
22
|
+
padding?: Padding;
|
|
21
23
|
backgroundColor?: string | IColorKey;
|
|
22
24
|
border?: {
|
|
23
25
|
color?: string | IColorKey;
|
|
@@ -37,7 +39,7 @@ export interface ITooltipTheme {
|
|
|
37
39
|
spacing?: number;
|
|
38
40
|
};
|
|
39
41
|
titleLabel?: ITooltipTextTheme;
|
|
40
|
-
keyLabel?: ITooltipTextTheme
|
|
42
|
+
keyLabel?: Omit<ITooltipTextTheme, 'autoWidth'>;
|
|
41
43
|
valueLabel?: ITooltipTextTheme;
|
|
42
44
|
spaceRow?: number;
|
|
43
45
|
offset?: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/component/tooltip/interface/theme.ts"],"names":[],"mappings":"","file":"theme.js","sourcesContent":["import type { RichTextWordBreak } from '@visactor/vrender';\nimport type {
|
|
1
|
+
{"version":3,"sources":["../src/component/tooltip/interface/theme.ts"],"names":[],"mappings":"","file":"theme.js","sourcesContent":["import type { RichTextWordBreak } from '@visactor/vrender';\nimport type { StringOrNumber, TextAlign, TextBaseLine } from '../../../typings';\nimport type { IColorKey } from '../../../theme/color-scheme/interface';\nimport type { Padding } from '@visactor/vrender-components/es/core/type';\n\nexport interface ITooltipTextTheme {\n /** 字体 */\n fontFamily?: string;\n /** 字体大小 */\n fontSize?: number;\n /** 字体颜色 */\n fill?: string | IColorKey;\n /** @deprecated 字体颜色(兼容旧版本) */\n fontColor?: string | IColorKey;\n /** 字重 */\n fontWeight?: StringOrNumber;\n /** 对齐方式 */\n textAlign?: TextAlign;\n /** 字体基线 */\n textBaseline?: TextBaseLine;\n /** 行高 */\n lineHeight?: number | string;\n /** 与相邻元素的水平间距 */\n spacing?: number;\n /** 是否支持换行 */\n multiLine?: boolean;\n /** 最大宽度 */\n maxWidth?: number;\n /** 换行模式,默认为'break-word' */\n wordBreak?: RichTextWordBreak;\n /**\n * 是否开启自动宽度。效果分为以下几种情况:\n * - tooltip 标题:`autoWidth` 默认为 `false`。如果配置为 `true`,则 tooltip 标题会保持和 tooltip 内容一致的宽度\n * - tooltip key 标签:`autoWidth` 不适用\n * - tooltip value 标签:`autoWidth` 默认为 `true`。如果配置为 `true`,则 tooltip value 标签会自动占满 tooltip 整体宽度的剩余部分\n * @since 1.4.2\n */\n autoWidth?: boolean;\n}\n\nexport interface ITooltipTheme {\n /** 容器样式配置 */\n panel?: {\n /** tooltip 容器内边距 */\n padding?: Padding;\n /** 背景色 */\n backgroundColor?: string | IColorKey;\n /** tooltip边框 */\n border?: {\n color?: string | IColorKey;\n width?: number;\n /** 圆角 */\n radius?: number;\n };\n /** tooltip阴影 */\n shadow?: {\n x: number;\n y: number;\n blur: number;\n spread: number;\n color: string | IColorKey;\n };\n };\n shape?: {\n /** 标记大小 */\n size?: number;\n /** shape 与相邻元素的水平间距 */\n spacing?: number;\n };\n /** tooltip标题 */\n titleLabel?: ITooltipTextTheme;\n /** tooltip内容,key字段 */\n keyLabel?: Omit<ITooltipTextTheme, 'autoWidth'>;\n /** tooltip内容,value字段 */\n valueLabel?: ITooltipTextTheme;\n /** 内容项行间距 */\n spaceRow?: number;\n /** 偏移量 */\n offset?: {\n x?: number;\n y?: number;\n };\n}\n"]}
|
|
@@ -37,6 +37,7 @@ export declare class Tooltip extends BaseComponent<any> implements ITooltip {
|
|
|
37
37
|
onRender(ctx: IModelRenderOption): void;
|
|
38
38
|
created(): void;
|
|
39
39
|
release(): void;
|
|
40
|
+
beforeRelease(): void;
|
|
40
41
|
protected _initHandler(): void;
|
|
41
42
|
protected _initProcessor(): void;
|
|
42
43
|
protected _initEvent(): void;
|