mdt-charts 1.27.0 → 1.27.2
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/.prettierrc +6 -0
- package/lib/config/config.d.ts +13 -13
- package/lib/designer/designerConfig.d.ts +1 -1
- package/lib/engine/block/block.js +14 -14
- package/lib/engine/block/blockHelper.js +2 -2
- package/lib/engine/block/blockSvg.js +25 -28
- package/lib/engine/block/defs/LinearGradientDef.js +9 -8
- package/lib/engine/contentManager/contentManagerFactory.js +1 -1
- package/lib/engine/elementHighlighter/elementHighlighter.d.ts +3 -3
- package/lib/engine/elementHighlighter/elementHighlighter.js +52 -54
- package/lib/engine/elementHighlighter/selectHighlighter.js +7 -7
- package/lib/engine/engine.d.ts +4 -4
- package/lib/engine/engine.js +5 -5
- package/lib/engine/features/aggregator/aggregator.d.ts +1 -1
- package/lib/engine/features/aggregator/aggregator.js +43 -45
- package/lib/engine/features/axis/axis.d.ts +1 -1
- package/lib/engine/features/axis/axis.js +53 -48
- package/lib/engine/features/axis/axisDomHelper.d.ts +3 -3
- package/lib/engine/features/axis/axisDomHelper.js +6 -8
- package/lib/engine/features/axis/axisHelper.d.ts +2 -2
- package/lib/engine/features/axis/axisHelper.js +14 -21
- package/lib/engine/features/axis/axisLabelDomHelper.d.ts +3 -3
- package/lib/engine/features/axis/axisLabelDomHelper.js +74 -66
- package/lib/engine/features/axis/axisLabelsEventManager.js +11 -11
- package/lib/engine/features/embeddedLabels/embeddedLabels.d.ts +3 -3
- package/lib/engine/features/embeddedLabels/embeddedLabels.js +44 -44
- package/lib/engine/features/embeddedLabels/embeddedLabelsDomHelper.d.ts +1 -1
- package/lib/engine/features/embeddedLabels/embeddedLabelsDomHelper.js +3 -6
- package/lib/engine/features/embeddedLabels/embeddedLabelsHelper.d.ts +2 -2
- package/lib/engine/features/embeddedLabels/embeddedLabelsHelper.js +22 -20
- package/lib/engine/features/gridLine/gidLineHelper.d.ts +1 -1
- package/lib/engine/features/gridLine/gidLineHelper.js +5 -5
- package/lib/engine/features/gridLine/gridLine.js +14 -23
- package/lib/engine/features/legend/legend.js +27 -36
- package/lib/engine/features/legend/legendDomHelper.js +18 -9
- package/lib/engine/features/legend/legendEventsManager.js +18 -13
- package/lib/engine/features/legend/legendHelper.js +19 -19
- package/lib/engine/features/legend/legendHelperService.js +5 -5
- package/lib/engine/features/legend/legendMarkerCreator.js +23 -22
- package/lib/engine/features/legend/legendWidthCalculator.js +5 -7
- package/lib/engine/features/markDots/markDot.d.ts +2 -2
- package/lib/engine/features/markDots/markDot.js +35 -34
- package/lib/engine/features/markDots/markDotsHelper.js +6 -6
- package/lib/engine/features/recordOverflowAlert/recordOverflowAlertCore.js +11 -11
- package/lib/engine/features/scale/scale.d.ts +4 -5
- package/lib/engine/features/scale/scale.js +16 -25
- package/lib/engine/features/tipBox/tipBox.d.ts +2 -2
- package/lib/engine/features/tipBox/tipBox.js +13 -17
- package/lib/engine/features/tipBox/tipBoxHelper.js +5 -5
- package/lib/engine/features/title/title.d.ts +1 -1
- package/lib/engine/features/title/title.js +8 -11
- package/lib/engine/features/tolltip/newTooltip/newTooltip.d.ts +1 -1
- package/lib/engine/features/tolltip/newTooltip/newTooltip.js +6 -8
- package/lib/engine/features/tolltip/tooltip.d.ts +2 -2
- package/lib/engine/features/tolltip/tooltip.js +47 -42
- package/lib/engine/features/tolltip/tooltipComponentsManager.d.ts +2 -2
- package/lib/engine/features/tolltip/tooltipComponentsManager.js +49 -52
- package/lib/engine/features/tolltip/tooltipDomHelper.d.ts +1 -1
- package/lib/engine/features/tolltip/tooltipDomHelper.js +41 -33
- package/lib/engine/features/tolltip/tooltipHelper.js +15 -11
- package/lib/engine/features/valueLabels/valueLabels.js +24 -37
- package/lib/engine/features/valueLabels/valueLabelsHelper.js +6 -6
- package/lib/engine/features/valueLabelsCollision/valueLabelsCollision.js +9 -10
- package/lib/engine/features/valueLabelsCollision/valueLabelsCollisionHelper.js +4 -4
- package/lib/engine/filterManager/filterEventManager.js +18 -15
- package/lib/engine/helpers/domHelper.d.ts +3 -4
- package/lib/engine/helpers/domHelper.js +9 -13
- package/lib/engine/helpers/fontResizer/fontResizer.js +2 -2
- package/lib/engine/helpers/helper.js +14 -9
- package/lib/engine/helpers/namesHelper.js +2 -2
- package/lib/engine/polarNotation/donut/DonutHelper.js +6 -8
- package/lib/engine/polarNotation/donut/donut.d.ts +3 -3
- package/lib/engine/polarNotation/donut/donut.js +47 -58
- package/lib/engine/polarNotation/extenders/polarRecordOverflowAlert.js +11 -11
- package/lib/engine/polarNotation/polarManager.js +3 -5
- package/lib/engine/transitionManager.js +4 -7
- package/lib/engine/twoDimensionalNotation/area/area.d.ts +1 -1
- package/lib/engine/twoDimensionalNotation/area/area.js +77 -62
- package/lib/engine/twoDimensionalNotation/area/areaGenerator.js +4 -10
- package/lib/engine/twoDimensionalNotation/area/areaHelper.d.ts +3 -3
- package/lib/engine/twoDimensionalNotation/area/areaHelper.js +21 -13
- package/lib/engine/twoDimensionalNotation/bar/bar.d.ts +2 -2
- package/lib/engine/twoDimensionalNotation/bar/bar.js +70 -67
- package/lib/engine/twoDimensionalNotation/bar/barHelper.js +40 -35
- package/lib/engine/twoDimensionalNotation/dot/dotChart.js +60 -42
- package/lib/engine/twoDimensionalNotation/extenders/twoDimRecordOverflowAlert.js +7 -7
- package/lib/engine/twoDimensionalNotation/line/line.d.ts +4 -4
- package/lib/engine/twoDimensionalNotation/line/line.js +45 -28
- package/lib/engine/twoDimensionalNotation/line/lineBuilder.js +18 -16
- package/lib/engine/twoDimensionalNotation/line/lineGenerator.js +2 -4
- package/lib/engine/twoDimensionalNotation/line/lineHelper.d.ts +6 -6
- package/lib/engine/twoDimensionalNotation/line/lineHelper.js +26 -17
- package/lib/engine/twoDimensionalNotation/lineLike/generatorMiddleware/lineLikeGeneratorDefineMiddleware.js +1 -1
- package/lib/engine/twoDimensionalNotation/twoDimensionalManager.js +25 -21
- package/lib/engine/valueFormatter.d.ts +1 -1
- package/lib/main.d.ts +1 -0
- package/lib/main.js +8 -7
- package/lib/model/chartStyleModel/chartStyleModel.js +5 -3
- package/lib/model/chartStyleModel/colorRange.js +1 -3
- package/lib/model/chartStyleModel/twoDimensionalChartStyleModel.js +9 -7
- package/lib/model/dataManagerModel/dataManagerModel.js +28 -16
- package/lib/model/featuresModel/axisModel.d.ts +6 -3
- package/lib/model/featuresModel/axisModel.js +59 -32
- package/lib/model/featuresModel/axisModelService.js +2 -2
- package/lib/model/featuresModel/legendModel/legendCanvasModel.d.ts +1 -1
- package/lib/model/featuresModel/legendModel/legendCanvasModel.js +12 -12
- package/lib/model/featuresModel/legendModel/legendModel.js +2 -2
- package/lib/model/featuresModel/legendModel/polarMarginCalculator.js +1 -1
- package/lib/model/featuresModel/legendModel/twoDimLegendModel.js +4 -5
- package/lib/model/featuresModel/scaleModel/scaleAxisRecalcer.d.ts +4 -5
- package/lib/model/featuresModel/scaleModel/scaleAxisRecalcer.js +3 -5
- package/lib/model/featuresModel/scaleModel/scaleDomainService.js +10 -12
- package/lib/model/featuresModel/scaleModel/scaleModel.d.ts +8 -4
- package/lib/model/featuresModel/scaleModel/scaleModel.js +20 -12
- package/lib/model/featuresModel/scaleModel/scaleModelServices.js +5 -5
- package/lib/model/featuresModel/tooltipModel.js +1 -1
- package/lib/model/featuresModel/valueLabelsModel/valueLabelsModel.js +5 -5
- package/lib/model/helpers/modelHelper.js +6 -4
- package/lib/model/helpers/twoDimensionalModelHelper.d.ts +1 -1
- package/lib/model/helpers/twoDimensionalModelHelper.js +23 -23
- package/lib/model/helpers/unitsReader.js +1 -1
- package/lib/model/margin/marginModel.js +1 -1
- package/lib/model/margin/twoDim/twoDimMarginModel.d.ts +1 -0
- package/lib/model/margin/twoDim/twoDimMarginModel.js +38 -28
- package/lib/model/model.d.ts +17 -4
- package/lib/model/modelBuilder.d.ts +4 -4
- package/lib/model/modelBuilder.js +19 -18
- package/lib/model/modelInstance/canvasModel/canvasSizesModel/marginModelService.js +1 -1
- package/lib/model/modelInstance/chartBlockVersion/chartBlockVersion.d.ts +5 -0
- package/lib/model/modelInstance/chartBlockVersion/chartBlockVersion.js +8 -0
- package/lib/model/modelInstance/configReader.d.ts +2 -1
- package/lib/model/modelInstance/configReader.js +14 -10
- package/lib/model/modelInstance/dataModel/dataRepository.js +5 -5
- package/lib/model/modelInstance/modelInstance.d.ts +4 -2
- package/lib/model/modelInstance/modelInstance.js +5 -3
- package/lib/model/modelInstance/titleConfigReader.js +5 -5
- package/lib/model/notations/polar/donut/donutModel.js +1 -1
- package/lib/model/notations/polar/polarModel.js +6 -6
- package/lib/model/notations/twoDimensional/styles.d.ts +2 -2
- package/lib/model/notations/twoDimensional/styles.js +8 -8
- package/lib/model/notations/twoDimensionalModel.d.ts +0 -1
- package/lib/model/notations/twoDimensionalModel.js +32 -29
- package/package.json +59 -59
- package/tsconfig.production.json +14 -24
- package/README.md +0 -2
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { select, pointer
|
|
1
|
+
import { select, pointer } from "d3-selection";
|
|
2
2
|
import { TooltipDomHelper } from "./tooltipDomHelper";
|
|
3
3
|
import { Donut } from "../../polarNotation/donut/donut";
|
|
4
|
-
import { TooltipComponentsManager } from
|
|
5
|
-
import { ElementHighlighter } from
|
|
6
|
-
import { DonutHelper } from
|
|
7
|
-
import { TipBox } from
|
|
8
|
-
import { TipBoxHelper } from
|
|
9
|
-
import { Helper } from
|
|
10
|
-
import { TooltipHelper } from
|
|
11
|
-
import { DomHelper } from
|
|
12
|
-
import { NewTooltip } from
|
|
4
|
+
import { TooltipComponentsManager } from "./tooltipComponentsManager";
|
|
5
|
+
import { ElementHighlighter } from "../../elementHighlighter/elementHighlighter";
|
|
6
|
+
import { DonutHelper } from "../../polarNotation/donut/DonutHelper";
|
|
7
|
+
import { TipBox } from "../tipBox/tipBox";
|
|
8
|
+
import { TipBoxHelper } from "../tipBox/tipBoxHelper";
|
|
9
|
+
import { Helper } from "../../helpers/helper";
|
|
10
|
+
import { TooltipHelper } from "./tooltipHelper";
|
|
11
|
+
import { DomHelper } from "../../helpers/domHelper";
|
|
12
|
+
import { NewTooltip } from "./newTooltip/newTooltip";
|
|
13
13
|
import { MarkDot } from "../../../engine/features/markDots/markDot";
|
|
14
14
|
export class Tooltip {
|
|
15
15
|
static render(block, model, data, tooltipOptions, scales) {
|
|
16
16
|
TooltipComponentsManager.renderTooltipWrapper(block);
|
|
17
17
|
const withTooltipIndex = model.options.charts.findIndex((chart) => chart.tooltip.show);
|
|
18
18
|
if (withTooltipIndex !== -1) {
|
|
19
|
-
if (model.options.type ===
|
|
19
|
+
if (model.options.type === "2d") {
|
|
20
20
|
this.renderTooltipFor2DCharts(block, data, model.blockCanvas.size, model.chartBlock.margin, scales, model.options, tooltipOptions);
|
|
21
21
|
}
|
|
22
|
-
else if (model.options.type ===
|
|
22
|
+
else if (model.options.type === "polar") {
|
|
23
23
|
this.renderTooltipForPolar(block, model.options, data, model.blockCanvas.size, model.chartBlock.margin, DonutHelper.getThickness(model.options.chartCanvas, model.blockCanvas.size, model.chartBlock.margin), model.otherComponents.tooltipBlock);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
@@ -32,7 +32,7 @@ export class Tooltip {
|
|
|
32
32
|
if (scales.key.domain().length === 0)
|
|
33
33
|
return;
|
|
34
34
|
const tooltipParams = {
|
|
35
|
-
type:
|
|
35
|
+
type: "2d",
|
|
36
36
|
scales,
|
|
37
37
|
margin,
|
|
38
38
|
blockSize,
|
|
@@ -47,7 +47,7 @@ export class Tooltip {
|
|
|
47
47
|
this.renderLineTooltip(block, data, tooltipParams);
|
|
48
48
|
}
|
|
49
49
|
static renderTooltipForPolar(block, options, data, blockSize, margin, chartThickness, tooltipOptions) {
|
|
50
|
-
const attrTransform = block.getSvg().select(`.${Donut.donutBlockClass}`).attr(
|
|
50
|
+
const attrTransform = block.getSvg().select(`.${Donut.donutBlockClass}`).attr("transform");
|
|
51
51
|
const translateNums = Helper.getTranslateNumbers(attrTransform);
|
|
52
52
|
const arcItems = Donut.getAllArcGroups(block);
|
|
53
53
|
this.renderTooltipForDonut(block, arcItems, data, options.data, options.charts[0], blockSize, margin, chartThickness, tooltipOptions, options.tooltip, { x: translateNums[0], y: translateNums[1] });
|
|
@@ -58,29 +58,30 @@ export class Tooltip {
|
|
|
58
58
|
const tooltipLine = TooltipComponentsManager.renderTooltipLine(block);
|
|
59
59
|
const tipBox = TipBox.renderOrGet(block, args.margin, args.blockSize);
|
|
60
60
|
let currentKey = null;
|
|
61
|
-
tipBox.on(
|
|
62
|
-
const keyValue = e.detail.keyValue ||
|
|
63
|
-
|
|
61
|
+
tipBox.on("mousemove", function (e) {
|
|
62
|
+
const keyValue = e.detail.keyValue ||
|
|
63
|
+
TipBoxHelper.getKeyValueByPointer(pointer(e, this), args.chartOrientation, args.margin, args.blockSize, args.scales.key, args.scaleKeyModel.type);
|
|
64
|
+
if (args.tooltipSettings.position === "followCursor") {
|
|
64
65
|
const tooltipCoordinate = TooltipHelper.getTooltipCursorCoordinate(e.detail.pointer || pointer(e, this), block.getSvg().node().getBoundingClientRect(), tooltipBlock.getEl().node().getBoundingClientRect());
|
|
65
66
|
TooltipComponentsManager.setLineTooltipCoordinate(tooltipBlock, tooltipCoordinate, args.chartOrientation, 0);
|
|
66
67
|
}
|
|
67
68
|
if (!currentKey || currentKey !== keyValue) {
|
|
68
69
|
TooltipComponentsManager.showComponent(tooltipBlock.getEl());
|
|
69
|
-
if (args.type ===
|
|
70
|
-
TooltipDomHelper.fillForMulti2DCharts(tooltipContent, args.charts.filter(ch => ch.tooltip.show), data, args.dataOptions, keyValue, args.tooltipOptions);
|
|
71
|
-
if (args.tooltipSettings.position ===
|
|
70
|
+
if (args.type === "2d")
|
|
71
|
+
TooltipDomHelper.fillForMulti2DCharts(tooltipContent, args.charts.filter((ch) => ch.tooltip.show), data, args.dataOptions, keyValue, args.tooltipOptions);
|
|
72
|
+
if (args.tooltipSettings.position === "fixed") {
|
|
72
73
|
const tooltipCoordinate = TooltipHelper.getTooltipFixedCoordinate(args.scales.key, args.margin, keyValue, block.getSvg().node().getBoundingClientRect(), tooltipContent.node().getBoundingClientRect(), args.keyAxisOrient, window.innerWidth, window.innerHeight);
|
|
73
74
|
TooltipComponentsManager.setLineTooltipCoordinate(tooltipBlock, tooltipCoordinate, args.chartOrientation, block.transitionManager.durations.tooltipSlide);
|
|
74
75
|
}
|
|
75
76
|
const tooltipLineAttributes = TooltipHelper.getTooltipLineAttributes(args.scales.key, args.margin, keyValue, args.chartOrientation, args.blockSize);
|
|
76
77
|
TooltipComponentsManager.setTooltipLineAttributes(tooltipLine, tooltipLineAttributes, block.transitionManager.durations.tooltipSlide);
|
|
77
78
|
TooltipComponentsManager.showComponent(tooltipLine);
|
|
78
|
-
if (args.type ===
|
|
79
|
-
args.charts.forEach(chart => {
|
|
79
|
+
if (args.type === "2d") {
|
|
80
|
+
args.charts.forEach((chart) => {
|
|
80
81
|
const elements = DomHelper.get2DChartElements(block, chart);
|
|
81
82
|
if (!block.filterEventManager.isSelected(currentKey)) {
|
|
82
83
|
const oldElements = DomHelper.getChartElementsByKeys(elements, chart.isSegmented, args.dataOptions.keyField.name, [currentKey]);
|
|
83
|
-
if (chart.type !==
|
|
84
|
+
if (chart.type !== "bar")
|
|
84
85
|
MarkDot.tryMakeMarkDotVisible(oldElements, chart.markersOptions, false);
|
|
85
86
|
ElementHighlighter.toggle2DElements(oldElements, false, chart, block.transitionManager.durations.markerHover);
|
|
86
87
|
if (block.filterEventManager.getSelectedKeys().length > 0) {
|
|
@@ -88,10 +89,11 @@ export class Tooltip {
|
|
|
88
89
|
}
|
|
89
90
|
}
|
|
90
91
|
const selectedElements = DomHelper.getChartElementsByKeys(elements, chart.isSegmented, args.dataOptions.keyField.name, [keyValue]);
|
|
91
|
-
if (chart.type !==
|
|
92
|
+
if (chart.type !== "bar")
|
|
92
93
|
MarkDot.tryMakeMarkDotVisible(selectedElements, chart.markersOptions, true);
|
|
93
94
|
ElementHighlighter.toggleActivityStyle(selectedElements, true);
|
|
94
|
-
if (block.filterEventManager.getSelectedKeys().length === 0 ||
|
|
95
|
+
if (block.filterEventManager.getSelectedKeys().length === 0 ||
|
|
96
|
+
block.filterEventManager.isSelected(keyValue)) {
|
|
95
97
|
ElementHighlighter.toggle2DElements(selectedElements, true, chart, block.transitionManager.durations.markerHover);
|
|
96
98
|
}
|
|
97
99
|
});
|
|
@@ -99,10 +101,10 @@ export class Tooltip {
|
|
|
99
101
|
currentKey = keyValue;
|
|
100
102
|
}
|
|
101
103
|
});
|
|
102
|
-
tipBox.on(
|
|
104
|
+
tipBox.on("mouseleave", function () {
|
|
103
105
|
TooltipComponentsManager.hideComponent(tooltipBlock.getEl());
|
|
104
106
|
TooltipComponentsManager.hideComponent(tooltipLine);
|
|
105
|
-
if (args.type ===
|
|
107
|
+
if (args.type === "2d")
|
|
106
108
|
ElementHighlighter.removeUnselected2DHighlight(block, args.dataOptions.keyField.name, args.charts, block.transitionManager.durations.markerHover);
|
|
107
109
|
currentKey = null;
|
|
108
110
|
});
|
|
@@ -111,19 +113,21 @@ export class Tooltip {
|
|
|
111
113
|
const tooltipBlock = TooltipComponentsManager.renderTooltipBlock(block);
|
|
112
114
|
const tooltipContent = TooltipComponentsManager.renderTooltipContentBlock(tooltipBlock);
|
|
113
115
|
let tooltipArrow;
|
|
114
|
-
if (tooltipSettings.position ===
|
|
116
|
+
if (tooltipSettings.position === "fixed")
|
|
115
117
|
tooltipArrow = TooltipComponentsManager.renderTooltipArrow(tooltipBlock.getEl());
|
|
116
|
-
if (tooltipSettings.position ===
|
|
117
|
-
elements.on(
|
|
118
|
-
const pointerCoordinate = !pointer(e, block.getSvg().node())[0]
|
|
118
|
+
if (tooltipSettings.position === "followCursor") {
|
|
119
|
+
elements.on("mousemove", function (e) {
|
|
120
|
+
const pointerCoordinate = !pointer(e, block.getSvg().node())[0]
|
|
121
|
+
? e.detail.pointer
|
|
122
|
+
: pointer(e, block.getSvg().node());
|
|
119
123
|
const tooltipCoordinate = TooltipHelper.getTooltipCursorCoordinate(pointerCoordinate, block.getSvg().node().getBoundingClientRect(), tooltipBlock.getEl().node().getBoundingClientRect());
|
|
120
124
|
tooltipBlock.setCoordinate(tooltipCoordinate);
|
|
121
125
|
});
|
|
122
126
|
}
|
|
123
|
-
elements.on(
|
|
127
|
+
elements.on("mouseover", function (e, dataRow) {
|
|
124
128
|
TooltipComponentsManager.showComponent(tooltipBlock.getEl());
|
|
125
|
-
TooltipDomHelper.fillForPolarChart(tooltipContent, chart, data, dataOptions, dataRow.data[dataOptions.keyField.name], select(this).select(
|
|
126
|
-
if (tooltipSettings.position ===
|
|
129
|
+
TooltipDomHelper.fillForPolarChart(tooltipContent, chart, data, dataOptions, dataRow.data[dataOptions.keyField.name], select(this).select("path").style("fill"), tooltipOptions);
|
|
130
|
+
if (tooltipSettings.position === "fixed") {
|
|
127
131
|
const coordinatePointer = TooltipDomHelper.getRecalcedCoordinateByArrow(DonutHelper.getArcCentroid(blockSize, margin, dataRow, donutThickness), tooltipBlock.getEl(), blockSize, tooltipArrow, translate.x, translate.y);
|
|
128
132
|
coordinatePointer[0] = coordinatePointer[0] + translate.x;
|
|
129
133
|
coordinatePointer[1] = coordinatePointer[1] + translate.y;
|
|
@@ -131,13 +135,14 @@ export class Tooltip {
|
|
|
131
135
|
tooltipBlock.setCoordinate(tooltipCoordinate);
|
|
132
136
|
}
|
|
133
137
|
ElementHighlighter.toggleActivityStyle(select(this), true);
|
|
134
|
-
const clones = Donut.getAllArcClones(block)
|
|
135
|
-
|
|
136
|
-
|
|
138
|
+
const clones = Donut.getAllArcClones(block).filter((d) => d.data[dataOptions.keyField.name] === dataRow.data[dataOptions.keyField.name]);
|
|
139
|
+
if (clones.nodes().length === 0 &&
|
|
140
|
+
(block.filterEventManager.getSelectedKeys().length === 0 ||
|
|
141
|
+
block.filterEventManager.isSelected(dataRow.data[dataOptions.keyField.name]))) {
|
|
137
142
|
ElementHighlighter.renderArcCloneAndHighlight(block, margin, select(this), blockSize, donutThickness);
|
|
138
143
|
}
|
|
139
144
|
});
|
|
140
|
-
elements.on(
|
|
145
|
+
elements.on("mouseleave", function (e, dataRow) {
|
|
141
146
|
TooltipComponentsManager.hideComponent(tooltipBlock.getEl());
|
|
142
147
|
if (!block.filterEventManager.isSelected(dataRow.data[dataOptions.keyField.name])) {
|
|
143
148
|
ElementHighlighter.removeCloneForElem(block, dataOptions.keyField.name, select(this));
|
|
@@ -151,7 +156,7 @@ export class Tooltip {
|
|
|
151
156
|
}
|
|
152
157
|
}
|
|
153
158
|
Tooltip.tooltipBlockClass = NewTooltip.tooltipBlockClass;
|
|
154
|
-
Tooltip.tooltipLineClass =
|
|
155
|
-
Tooltip.tooltipWrapperClass =
|
|
156
|
-
Tooltip.tooltipContentClass =
|
|
157
|
-
Tooltip.tooltipArrowClass =
|
|
159
|
+
Tooltip.tooltipLineClass = "mdt-charts-tooltip-line";
|
|
160
|
+
Tooltip.tooltipWrapperClass = "mdt-charts-tooltip-wrapper";
|
|
161
|
+
Tooltip.tooltipContentClass = "mdt-charts-tooltip-content";
|
|
162
|
+
Tooltip.tooltipArrowClass = "mdt-charts-tooltip-arrow";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Selection, BaseType } from
|
|
1
|
+
import { Selection, BaseType } from "d3-selection";
|
|
2
2
|
import { Block } from "../../block/block";
|
|
3
3
|
import { TooltipLineAttributes } from "./tooltipDomHelper";
|
|
4
4
|
import { ChartOrientation } from "../../../config/config";
|
|
5
|
-
import { NewTooltip, TooltipCoordinate } from
|
|
5
|
+
import { NewTooltip, TooltipCoordinate } from "./newTooltip/newTooltip";
|
|
6
6
|
export declare class TooltipComponentsManager {
|
|
7
7
|
static showComponent(tooltipBlock: Selection<BaseType, unknown, HTMLElement, any>): void;
|
|
8
8
|
static hideComponent(tooltipBlock: Selection<BaseType, unknown, HTMLElement, any>): void;
|
|
@@ -1,23 +1,20 @@
|
|
|
1
|
-
import { select } from
|
|
1
|
+
import { select } from "d3-selection";
|
|
2
2
|
import { ARROW_DEFAULT_POSITION, ARROW_SIZE } from "./tooltipDomHelper";
|
|
3
|
-
import { easeLinear } from
|
|
4
|
-
import { interrupt } from
|
|
5
|
-
import { Tooltip } from
|
|
6
|
-
import { NewTooltip } from
|
|
3
|
+
import { easeLinear } from "d3-ease";
|
|
4
|
+
import { interrupt } from "d3-transition";
|
|
5
|
+
import { Tooltip } from "./tooltip";
|
|
6
|
+
import { NewTooltip } from "./newTooltip/newTooltip";
|
|
7
7
|
export class TooltipComponentsManager {
|
|
8
8
|
static showComponent(tooltipBlock) {
|
|
9
|
-
tooltipBlock.style(
|
|
9
|
+
tooltipBlock.style("display", "block");
|
|
10
10
|
}
|
|
11
11
|
static hideComponent(tooltipBlock) {
|
|
12
|
-
tooltipBlock.style(
|
|
12
|
+
tooltipBlock.style("display", "none");
|
|
13
13
|
}
|
|
14
14
|
static renderTooltipWrapper(block) {
|
|
15
|
-
let tooltipWrapper = block.getWrapper()
|
|
16
|
-
.select(`.${Tooltip.tooltipWrapperClass}`);
|
|
15
|
+
let tooltipWrapper = block.getWrapper().select(`.${Tooltip.tooltipWrapperClass}`);
|
|
17
16
|
if (tooltipWrapper.empty())
|
|
18
|
-
block.getWrapper()
|
|
19
|
-
.append('div')
|
|
20
|
-
.attr('class', Tooltip.tooltipWrapperClass);
|
|
17
|
+
block.getWrapper().append("div").attr("class", Tooltip.tooltipWrapperClass);
|
|
21
18
|
}
|
|
22
19
|
static renderTooltipBlock(block, translateX = 0, translateY = 0) {
|
|
23
20
|
const wrapper = block.getWrapper().select(`.${Tooltip.tooltipWrapperClass}`);
|
|
@@ -25,70 +22,63 @@ export class TooltipComponentsManager {
|
|
|
25
22
|
let tooltipBlock = tooltipService.findInWrapper(wrapper);
|
|
26
23
|
if (tooltipBlock.empty()) {
|
|
27
24
|
tooltipBlock = tooltipService.render(wrapper);
|
|
28
|
-
tooltipBlock
|
|
29
|
-
.style('position', 'absolute')
|
|
30
|
-
.style('display', 'none');
|
|
25
|
+
tooltipBlock.style("position", "absolute").style("display", "none");
|
|
31
26
|
}
|
|
32
27
|
if (translateX !== 0 || translateY !== 0)
|
|
33
|
-
tooltipBlock.style(
|
|
28
|
+
tooltipBlock.style("transform", `translate(${translateX}px, ${translateY}px)`);
|
|
34
29
|
return tooltipService;
|
|
35
30
|
}
|
|
36
31
|
static renderTooltipContentBlock(tooltipBlock) {
|
|
37
32
|
let tooltipContentBlock = tooltipBlock.getEl().select(`.${Tooltip.tooltipContentClass}`);
|
|
38
33
|
if (tooltipContentBlock.empty()) {
|
|
39
|
-
tooltipContentBlock = select(document.createElement("div"))
|
|
40
|
-
.attr("class", Tooltip.tooltipContentClass);
|
|
34
|
+
tooltipContentBlock = select(document.createElement("div")).attr("class", Tooltip.tooltipContentClass);
|
|
41
35
|
tooltipBlock.appendContent(tooltipContentBlock.node());
|
|
42
36
|
}
|
|
43
37
|
return tooltipContentBlock;
|
|
44
38
|
}
|
|
45
39
|
static renderTooltipLine(block) {
|
|
46
|
-
let tooltipLine = block.svg.getChartBlock()
|
|
47
|
-
.select(`.${Tooltip.tooltipLineClass}`);
|
|
40
|
+
let tooltipLine = block.svg.getChartBlock().select(`.${Tooltip.tooltipLineClass}`);
|
|
48
41
|
if (tooltipLine.empty())
|
|
49
|
-
tooltipLine = block.svg.getChartBlock()
|
|
50
|
-
.append('line')
|
|
51
|
-
.attr('class', Tooltip.tooltipLineClass)
|
|
52
|
-
.lower();
|
|
42
|
+
tooltipLine = block.svg.getChartBlock().append("line").attr("class", Tooltip.tooltipLineClass).lower();
|
|
53
43
|
return tooltipLine;
|
|
54
44
|
}
|
|
55
45
|
static setTooltipLineAttributes(tooltipLine, attributes, transition) {
|
|
56
46
|
interrupt(tooltipLine.node());
|
|
57
|
-
if (transition > 0 && tooltipLine.style(
|
|
47
|
+
if (transition > 0 && tooltipLine.style("display") === "block") {
|
|
58
48
|
tooltipLine
|
|
59
49
|
.interrupt()
|
|
60
50
|
.transition()
|
|
61
51
|
.duration(transition)
|
|
62
52
|
.ease(easeLinear)
|
|
63
|
-
.attr(
|
|
64
|
-
.attr(
|
|
65
|
-
.attr(
|
|
66
|
-
.attr(
|
|
53
|
+
.attr("x1", attributes.x1)
|
|
54
|
+
.attr("x2", attributes.x2)
|
|
55
|
+
.attr("y1", attributes.y1)
|
|
56
|
+
.attr("y2", attributes.y2);
|
|
67
57
|
}
|
|
68
58
|
else {
|
|
69
59
|
tooltipLine
|
|
70
|
-
.attr(
|
|
71
|
-
.attr(
|
|
72
|
-
.attr(
|
|
73
|
-
.attr(
|
|
60
|
+
.attr("x1", attributes.x1)
|
|
61
|
+
.attr("x2", attributes.x2)
|
|
62
|
+
.attr("y1", attributes.y1)
|
|
63
|
+
.attr("y2", attributes.y2);
|
|
74
64
|
}
|
|
75
65
|
}
|
|
76
66
|
static getLineWidth(tooltipLine) {
|
|
77
|
-
return parseFloat(tooltipLine.style(
|
|
67
|
+
return parseFloat(tooltipLine.style("stroke-width"));
|
|
78
68
|
}
|
|
79
69
|
static renderTooltipArrow(tooltipBlock) {
|
|
80
70
|
let arrowSize = ARROW_SIZE / 2;
|
|
81
71
|
let tooltipArrow = tooltipBlock.select(`.${Tooltip.tooltipArrowClass}`);
|
|
82
72
|
if (tooltipArrow.empty())
|
|
83
73
|
tooltipArrow = tooltipBlock
|
|
84
|
-
.append(
|
|
85
|
-
.attr(
|
|
86
|
-
.style(
|
|
87
|
-
.style(
|
|
88
|
-
.style(
|
|
89
|
-
.style(
|
|
90
|
-
.style(
|
|
91
|
-
.style(
|
|
74
|
+
.append("div")
|
|
75
|
+
.attr("class", Tooltip.tooltipArrowClass)
|
|
76
|
+
.style("position", "absolute")
|
|
77
|
+
.style("left", `${ARROW_DEFAULT_POSITION}px`)
|
|
78
|
+
.style("border-top-width", `${arrowSize}px`)
|
|
79
|
+
.style("border-right-width", `${arrowSize}px`)
|
|
80
|
+
.style("border-bottom-width", `0px`)
|
|
81
|
+
.style("border-left-width", `${arrowSize}px`);
|
|
92
82
|
return tooltipArrow;
|
|
93
83
|
}
|
|
94
84
|
static setLineTooltipCoordinate(tooltip, tooltipCoordinate, chartOrientation, transition = null) {
|
|
@@ -96,27 +86,34 @@ export class TooltipComponentsManager {
|
|
|
96
86
|
interrupt(tooltipBlock.node());
|
|
97
87
|
if (!transition || transition <= 0)
|
|
98
88
|
tooltip.setCoordinate(tooltipCoordinate);
|
|
99
|
-
if (chartOrientation ===
|
|
89
|
+
if (chartOrientation === "vertical" &&
|
|
90
|
+
tooltipBlock.style("left") !== "0px" &&
|
|
91
|
+
tooltipBlock.style("right") !== "0px" &&
|
|
92
|
+
tooltipCoordinate.right !== "0px" &&
|
|
93
|
+
tooltipCoordinate.left !== null) {
|
|
100
94
|
tooltipBlock
|
|
101
|
-
.style(
|
|
102
|
-
.style(
|
|
103
|
-
.style(
|
|
95
|
+
.style("right", tooltipCoordinate.right)
|
|
96
|
+
.style("bottom", tooltipCoordinate.bottom)
|
|
97
|
+
.style("top", tooltipCoordinate.top)
|
|
104
98
|
.interrupt()
|
|
105
99
|
.transition()
|
|
106
100
|
.duration(transition)
|
|
107
101
|
.ease(easeLinear)
|
|
108
|
-
.style(
|
|
102
|
+
.style("left", tooltipCoordinate.left);
|
|
109
103
|
}
|
|
110
|
-
else if (chartOrientation ===
|
|
104
|
+
else if (chartOrientation === "horizontal" &&
|
|
105
|
+
tooltipBlock.style("top") !== "0px" &&
|
|
106
|
+
parseInt(tooltipBlock.style("bottom")) > 0 &&
|
|
107
|
+
tooltipCoordinate.bottom === null) {
|
|
111
108
|
tooltipBlock
|
|
112
|
-
.style(
|
|
113
|
-
.style(
|
|
114
|
-
.style(
|
|
109
|
+
.style("right", tooltipCoordinate.right)
|
|
110
|
+
.style("bottom", tooltipCoordinate.bottom)
|
|
111
|
+
.style("left", tooltipCoordinate.left)
|
|
115
112
|
.interrupt()
|
|
116
113
|
.transition()
|
|
117
114
|
.duration(transition)
|
|
118
115
|
.ease(easeLinear)
|
|
119
|
-
.style(
|
|
116
|
+
.style("top", tooltipCoordinate.top);
|
|
120
117
|
}
|
|
121
118
|
else {
|
|
122
119
|
tooltip.setCoordinate(tooltipCoordinate);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Selection, BaseType } from
|
|
1
|
+
import { Selection, BaseType } from "d3-selection";
|
|
2
2
|
import { MdtChartsDataSource, TooltipOptions } from "../../../config/config";
|
|
3
3
|
import { OptionsModelData, PolarChartModel, TwoDimensionalChartModel } from "../../../model/model";
|
|
4
4
|
import { Size } from "../../../config/config";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ValueFormatter
|
|
2
|
-
import { TooltipHelper } from
|
|
3
|
-
import { Helper } from
|
|
4
|
-
import { getMarkerCreator } from
|
|
1
|
+
import { ValueFormatter } from "../../valueFormatter";
|
|
2
|
+
import { TooltipHelper } from "./tooltipHelper";
|
|
3
|
+
import { Helper } from "../../helpers/helper";
|
|
4
|
+
import { getMarkerCreator } from "../legend/legendMarkerCreator";
|
|
5
5
|
export const ARROW_SIZE = 20;
|
|
6
6
|
export const ARROW_DEFAULT_POSITION = 9;
|
|
7
7
|
export const TOOLTIP_ARROW_PADDING_X = ARROW_DEFAULT_POSITION - (ARROW_SIZE * Math.sqrt(2) - ARROW_SIZE) / 2 + 14;
|
|
@@ -9,7 +9,7 @@ export const TOOLTIP_ARROW_PADDING_Y = 13;
|
|
|
9
9
|
export class TooltipDomHelper {
|
|
10
10
|
static fillForMulti2DCharts(contentBlock, charts, data, dataOptions, keyValue, tooltipOptions) {
|
|
11
11
|
const chartDataRows = [];
|
|
12
|
-
charts.forEach(chart => {
|
|
12
|
+
charts.forEach((chart) => {
|
|
13
13
|
chart.data.valueFields.forEach((field, index) => {
|
|
14
14
|
chartDataRows.push({
|
|
15
15
|
field,
|
|
@@ -21,11 +21,13 @@ export class TooltipDomHelper {
|
|
|
21
21
|
this.fillCharts(contentBlock, chartDataRows, data, dataOptions, keyValue, tooltipOptions);
|
|
22
22
|
}
|
|
23
23
|
static fillForPolarChart(contentBlock, chart, data, dataOptions, keyValue, markColor, tooltipOptions) {
|
|
24
|
-
const chartDataRows = [
|
|
24
|
+
const chartDataRows = [
|
|
25
|
+
{
|
|
25
26
|
field: chart.data.valueField,
|
|
26
27
|
markColor,
|
|
27
28
|
markerCreator: this.getMarkerCreator(chart.legend)
|
|
28
|
-
}
|
|
29
|
+
}
|
|
30
|
+
];
|
|
29
31
|
this.fillCharts(contentBlock, chartDataRows, data, dataOptions, keyValue, tooltipOptions);
|
|
30
32
|
}
|
|
31
33
|
static getRecalcedCoordinateByArrow(coordinate, tooltipBlock, blockSize, tooltipArrow, translateX = 0, translateY = 0) {
|
|
@@ -33,25 +35,25 @@ export class TooltipDomHelper {
|
|
|
33
35
|
const horizontalPad = TooltipHelper.getHorizontalPad(coordinate[0], tooltipBlockNode.getBoundingClientRect().width, blockSize, translateX);
|
|
34
36
|
const verticalPad = TooltipHelper.getVerticalPad(coordinate[1], tooltipBlockNode.getBoundingClientRect().height, translateY);
|
|
35
37
|
this.setTooltipArrowCoordinate(tooltipArrow, TooltipHelper.getTooltipArrowPadding(tooltipBlockNode.getBoundingClientRect().width, horizontalPad));
|
|
36
|
-
return [
|
|
37
|
-
coordinate[
|
|
38
|
+
return [
|
|
39
|
+
coordinate[0] - TOOLTIP_ARROW_PADDING_X - horizontalPad,
|
|
40
|
+
coordinate[1] - TOOLTIP_ARROW_PADDING_Y - tooltipBlockNode.getBoundingClientRect().height - verticalPad
|
|
41
|
+
];
|
|
38
42
|
}
|
|
39
43
|
static renderHead(contentBlock, keyValue) {
|
|
40
|
-
contentBlock.append(
|
|
41
|
-
.attr('class', `${this.groupClass} ${this.headClass}`)
|
|
42
|
-
.text(keyValue);
|
|
44
|
+
contentBlock.append("div").attr("class", `${this.groupClass} ${this.headClass}`).text(keyValue);
|
|
43
45
|
}
|
|
44
46
|
static fillValuesContent(contentBlock, { markColor, tooltipHtml, markerCreator }) {
|
|
45
|
-
const group = contentBlock.append(
|
|
46
|
-
.attr('class', this.groupClass);
|
|
47
|
+
const group = contentBlock.append("div").attr("class", this.groupClass);
|
|
47
48
|
if (markColor) {
|
|
48
|
-
const colorBlock = group.append(
|
|
49
|
+
const colorBlock = group.append("div").attr("class", "tooltip-color");
|
|
49
50
|
markerCreator === null || markerCreator === void 0 ? void 0 : markerCreator.renderMarker(colorBlock, markColor);
|
|
50
51
|
}
|
|
51
|
-
group
|
|
52
|
-
.
|
|
53
|
-
.
|
|
54
|
-
.
|
|
52
|
+
group
|
|
53
|
+
.append("div")
|
|
54
|
+
.attr("class", "tooltip-texts")
|
|
55
|
+
.append("div")
|
|
56
|
+
.attr("class", this.textItemClass)
|
|
55
57
|
.html(tooltipHtml);
|
|
56
58
|
}
|
|
57
59
|
static getTooltipItemHtml(row, valueField, tooltipOptions) {
|
|
@@ -70,18 +72,18 @@ export class TooltipDomHelper {
|
|
|
70
72
|
}
|
|
71
73
|
static setTooltipArrowCoordinate(tooltipArrow, horizontalPad) {
|
|
72
74
|
if (horizontalPad !== 0)
|
|
73
|
-
tooltipArrow.style(
|
|
75
|
+
tooltipArrow.style("left", `${ARROW_DEFAULT_POSITION + Math.floor(horizontalPad)}px`);
|
|
74
76
|
else
|
|
75
|
-
tooltipArrow.style(
|
|
77
|
+
tooltipArrow.style("left", `${ARROW_DEFAULT_POSITION}px`);
|
|
76
78
|
}
|
|
77
79
|
static fillContentByFunction(contentBlock, data, dataOptions, keyValue, htmlHandler) {
|
|
78
80
|
const row = Helper.getRowsByKeys([keyValue], dataOptions.keyField.name, data[dataOptions.dataSource])[0];
|
|
79
81
|
contentBlock.html(htmlHandler(row));
|
|
80
82
|
this.setWhiteSpaceForTextBlocks(contentBlock);
|
|
81
|
-
contentBlock.selectAll(
|
|
83
|
+
contentBlock.selectAll(".tooltip-text-item").style("display", "block");
|
|
82
84
|
}
|
|
83
85
|
static setWhiteSpaceForTextBlocks(contentBlock) {
|
|
84
|
-
contentBlock.selectAll(`.${this.textItemClass}`).style(
|
|
86
|
+
contentBlock.selectAll(`.${this.textItemClass}`).style("white-space", "pre-wrap");
|
|
85
87
|
}
|
|
86
88
|
static getMarkerCreator(options) {
|
|
87
89
|
return getMarkerCreator(options, { default: { cssClass: TooltipDomHelper.tooltipLegendDefaultMarker } });
|
|
@@ -89,19 +91,23 @@ export class TooltipDomHelper {
|
|
|
89
91
|
static addAggregatorTooltipItem(tooltipOptions, data, tooltipItems) {
|
|
90
92
|
if (tooltipOptions === null || tooltipOptions === void 0 ? void 0 : tooltipOptions.aggregator) {
|
|
91
93
|
const aggregatorContent = tooltipOptions.aggregator.content({ row: data });
|
|
92
|
-
const aggregatorHtml = aggregatorContent.type ===
|
|
94
|
+
const aggregatorHtml = aggregatorContent.type === "plainText"
|
|
93
95
|
? aggregatorContent.textContent
|
|
94
96
|
: this.getTooltipContentItemHtml(aggregatorContent.caption, aggregatorContent.value);
|
|
95
|
-
const tooltipAggregatorItem = {
|
|
96
|
-
|
|
97
|
+
const tooltipAggregatorItem = {
|
|
98
|
+
markColor: undefined,
|
|
99
|
+
tooltipHtml: aggregatorHtml,
|
|
100
|
+
markerCreator: undefined
|
|
101
|
+
};
|
|
102
|
+
if (tooltipOptions.aggregator.position === "underValues")
|
|
97
103
|
tooltipItems.push(tooltipAggregatorItem);
|
|
98
104
|
else
|
|
99
105
|
tooltipItems.unshift(tooltipAggregatorItem);
|
|
100
106
|
}
|
|
101
107
|
}
|
|
102
108
|
static fillCharts(contentBlock, chartDataRows, data, dataOptions, keyValue, tooltipOptions) {
|
|
103
|
-
const row = data[dataOptions.dataSource].find(d => d[dataOptions.keyField.name] === keyValue);
|
|
104
|
-
contentBlock.html(
|
|
109
|
+
const row = data[dataOptions.dataSource].find((d) => d[dataOptions.keyField.name] === keyValue);
|
|
110
|
+
contentBlock.html("");
|
|
105
111
|
if (!(tooltipOptions === null || tooltipOptions === void 0 ? void 0 : tooltipOptions.html)) {
|
|
106
112
|
const tooltipItems = [];
|
|
107
113
|
this.renderHead(contentBlock, keyValue);
|
|
@@ -114,14 +120,16 @@ export class TooltipDomHelper {
|
|
|
114
120
|
});
|
|
115
121
|
});
|
|
116
122
|
this.addAggregatorTooltipItem(tooltipOptions, row, tooltipItems);
|
|
117
|
-
tooltipItems.forEach(item => {
|
|
123
|
+
tooltipItems.forEach((item) => {
|
|
124
|
+
this.fillValuesContent(contentBlock, item);
|
|
125
|
+
});
|
|
118
126
|
}
|
|
119
127
|
else {
|
|
120
128
|
this.fillContentByFunction(contentBlock, data, dataOptions, keyValue, tooltipOptions.html);
|
|
121
129
|
}
|
|
122
130
|
}
|
|
123
131
|
}
|
|
124
|
-
TooltipDomHelper.groupClass =
|
|
125
|
-
TooltipDomHelper.headClass =
|
|
126
|
-
TooltipDomHelper.textItemClass =
|
|
127
|
-
TooltipDomHelper.tooltipLegendDefaultMarker =
|
|
132
|
+
TooltipDomHelper.groupClass = "tooltip-group";
|
|
133
|
+
TooltipDomHelper.headClass = "tooltip-head";
|
|
134
|
+
TooltipDomHelper.textItemClass = "tooltip-text-item";
|
|
135
|
+
TooltipDomHelper.tooltipLegendDefaultMarker = "tooltip-circle";
|
|
@@ -10,7 +10,8 @@ export class TooltipHelper {
|
|
|
10
10
|
}
|
|
11
11
|
static getVerticalPad(coordinateY, tooltipBlockHeight, translateY) {
|
|
12
12
|
let pad = 0;
|
|
13
|
-
if (coordinateY - TOOLTIP_ARROW_PADDING_Y - tooltipBlockHeight + translateY <
|
|
13
|
+
if (coordinateY - TOOLTIP_ARROW_PADDING_Y - tooltipBlockHeight + translateY <
|
|
14
|
+
-tooltipBlockHeight - TOOLTIP_ARROW_PADDING_Y)
|
|
14
15
|
pad = coordinateY;
|
|
15
16
|
return pad; // return zero or sub zero
|
|
16
17
|
}
|
|
@@ -26,8 +27,8 @@ export class TooltipHelper {
|
|
|
26
27
|
right: null,
|
|
27
28
|
bottom: null
|
|
28
29
|
};
|
|
29
|
-
coordinate.left = pointer[0] +
|
|
30
|
-
coordinate.top = pointer[1] +
|
|
30
|
+
coordinate.left = pointer[0] + "px";
|
|
31
|
+
coordinate.top = pointer[1] + "px";
|
|
31
32
|
return coordinate;
|
|
32
33
|
}
|
|
33
34
|
static getTooltipFixedCoordinate(scaleKey, margin, keyValue, blockBoundingRect, tooltipBoundingRect, keyAxisOrient, winWidth, winHeight) {
|
|
@@ -35,16 +36,16 @@ export class TooltipHelper {
|
|
|
35
36
|
top: null,
|
|
36
37
|
left: null
|
|
37
38
|
};
|
|
38
|
-
if (keyAxisOrient ===
|
|
39
|
+
if (keyAxisOrient === "bottom" || keyAxisOrient === "top") {
|
|
39
40
|
coordinate.left = Scale.getScaledValue(scaleKey, keyValue) + margin.left - tooltipBoundingRect.width / 2;
|
|
40
|
-
if (keyAxisOrient ===
|
|
41
|
+
if (keyAxisOrient === "bottom")
|
|
41
42
|
coordinate.top = margin.top - 5 - tooltipBoundingRect.height;
|
|
42
43
|
else
|
|
43
44
|
coordinate.top = blockBoundingRect.height - margin.bottom;
|
|
44
45
|
}
|
|
45
|
-
if (keyAxisOrient ===
|
|
46
|
+
if (keyAxisOrient === "left" || keyAxisOrient === "right") {
|
|
46
47
|
coordinate.top = Scale.getScaledValue(scaleKey, keyValue) + margin.top - tooltipBoundingRect.height / 2;
|
|
47
|
-
if (keyAxisOrient ===
|
|
48
|
+
if (keyAxisOrient === "left")
|
|
48
49
|
coordinate.left = blockBoundingRect.width - margin.right;
|
|
49
50
|
else
|
|
50
51
|
coordinate.left = margin.left - tooltipBoundingRect.width;
|
|
@@ -61,9 +62,12 @@ export class TooltipHelper {
|
|
|
61
62
|
}
|
|
62
63
|
static getTooltipLineAttributes(scaleKey, margin, key, chartOrientation, blockSize) {
|
|
63
64
|
const attributes = {
|
|
64
|
-
x1: 0,
|
|
65
|
+
x1: 0,
|
|
66
|
+
x2: 0,
|
|
67
|
+
y1: 0,
|
|
68
|
+
y2: 0
|
|
65
69
|
};
|
|
66
|
-
if (chartOrientation ===
|
|
70
|
+
if (chartOrientation === "vertical") {
|
|
67
71
|
attributes.x1 = Math.ceil(Scale.getScaledValue(scaleKey, key) + margin.left) - 0.5;
|
|
68
72
|
attributes.x2 = Math.ceil(Scale.getScaledValue(scaleKey, key) + margin.left) - 0.5;
|
|
69
73
|
attributes.y1 = margin.top - this.convexsize;
|
|
@@ -83,8 +87,8 @@ export class TooltipHelper {
|
|
|
83
87
|
height: winHeight
|
|
84
88
|
}, blockBounding);
|
|
85
89
|
return {
|
|
86
|
-
left: res.left +
|
|
87
|
-
top: res.top +
|
|
90
|
+
left: res.left + "px",
|
|
91
|
+
top: res.top + "px",
|
|
88
92
|
right: null,
|
|
89
93
|
bottom: null
|
|
90
94
|
};
|