mdt-charts 1.9.11 → 1.10.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/lib/config/config.d.ts +148 -0
- package/lib/config/config.js +1 -0
- package/lib/designer/designerConfig.d.ts +71 -0
- package/lib/designer/designerConfig.js +1 -0
- package/lib/engine/block/block.d.ts +35 -0
- package/lib/engine/block/block.js +110 -0
- package/lib/engine/block/blockHelper.d.ts +12 -0
- package/lib/engine/block/blockHelper.js +19 -0
- package/lib/engine/colorReader/colorReader.d.ts +10 -0
- package/lib/engine/colorReader/colorReader.js +21 -0
- package/lib/engine/contentManager.d.ts +9 -0
- package/lib/engine/contentManager.js +29 -0
- package/lib/engine/elementHighlighter/elementHighlighter.d.ts +30 -0
- package/lib/engine/elementHighlighter/elementHighlighter.js +198 -0
- package/lib/engine/elementHighlighter/selectHighlighter.d.ts +11 -0
- package/lib/engine/elementHighlighter/selectHighlighter.js +95 -0
- package/lib/engine/engine.d.ts +20 -0
- package/lib/engine/engine.js +64 -0
- package/lib/engine/features/aggregator/aggregator.d.ts +22 -0
- package/lib/engine/features/aggregator/aggregator.js +95 -0
- package/lib/engine/features/axis/axis.d.ts +12 -0
- package/lib/engine/features/axis/axis.js +118 -0
- package/lib/engine/features/axis/axisDomHelper.d.ts +7 -0
- package/lib/engine/features/axis/axisDomHelper.js +24 -0
- package/lib/engine/features/axis/axisHelper.d.ts +9 -0
- package/lib/engine/features/axis/axisHelper.js +53 -0
- package/lib/engine/features/axis/axisLabelDomHelper.d.ts +17 -0
- package/lib/engine/features/axis/axisLabelDomHelper.js +143 -0
- package/lib/engine/features/axis/axisLabelsEventManager.d.ts +6 -0
- package/lib/engine/features/axis/axisLabelsEventManager.js +36 -0
- package/lib/engine/features/embeddedLabels/embeddedLabels.d.ts +23 -0
- package/lib/engine/features/embeddedLabels/embeddedLabels.js +147 -0
- package/lib/engine/features/embeddedLabels/embeddedLabelsDomHelper.d.ts +8 -0
- package/lib/engine/features/embeddedLabels/embeddedLabelsDomHelper.js +30 -0
- package/lib/engine/features/embeddedLabels/embeddedLabelsHelper.d.ts +27 -0
- package/lib/engine/features/embeddedLabels/embeddedLabelsHelper.js +65 -0
- package/lib/engine/features/gridLine/gidLineHelper.d.ts +13 -0
- package/lib/engine/features/gridLine/gidLineHelper.js +30 -0
- package/lib/engine/features/gridLine/gridLine.d.ts +11 -0
- package/lib/engine/features/gridLine/gridLine.js +67 -0
- package/lib/engine/features/legend/legend.d.ts +22 -0
- package/lib/engine/features/legend/legend.js +112 -0
- package/lib/engine/features/legend/legendDomHelper.d.ts +8 -0
- package/lib/engine/features/legend/legendDomHelper.js +48 -0
- package/lib/engine/features/legend/legendEventsManager.d.ts +12 -0
- package/lib/engine/features/legend/legendEventsManager.js +47 -0
- package/lib/engine/features/legend/legendHelper.d.ts +21 -0
- package/lib/engine/features/legend/legendHelper.js +99 -0
- package/lib/engine/features/markDots/markDot.d.ts +20 -0
- package/lib/engine/features/markDots/markDot.js +68 -0
- package/lib/engine/features/markDots/markDotsHelper.d.ts +6 -0
- package/lib/engine/features/markDots/markDotsHelper.js +16 -0
- package/lib/engine/features/recordOverflowAlert/recordOverflowAlert.d.ts +14 -0
- package/lib/engine/features/recordOverflowAlert/recordOverflowAlert.js +97 -0
- package/lib/engine/features/scale/scale.d.ts +16 -0
- package/lib/engine/features/scale/scale.js +74 -0
- package/lib/engine/features/tipBox/tipBox.d.ts +11 -0
- package/lib/engine/features/tipBox/tipBox.js +32 -0
- package/lib/engine/features/tipBox/tipBoxHelper.d.ts +16 -0
- package/lib/engine/features/tipBox/tipBoxHelper.js +48 -0
- package/lib/engine/features/title/title.d.ts +9 -0
- package/lib/engine/features/title/title.js +35 -0
- package/lib/engine/features/tolltip/newTooltip/newTooltip.d.ts +16 -0
- package/lib/engine/features/tolltip/newTooltip/newTooltip.js +26 -0
- package/lib/engine/features/tolltip/newTooltip/newTooltip.test.d.ts +1 -0
- package/lib/engine/features/tolltip/newTooltip/newTooltip.test.js +186 -0
- package/lib/engine/features/tolltip/newTooltip/newTooltipService.d.ts +17 -0
- package/lib/engine/features/tolltip/newTooltip/newTooltipService.js +26 -0
- package/lib/engine/features/tolltip/tooltip.d.ts +19 -0
- package/lib/engine/features/tolltip/tooltip.js +181 -0
- package/lib/engine/features/tolltip/tooltipComponentsManager.d.ts +17 -0
- package/lib/engine/features/tolltip/tooltipComponentsManager.js +125 -0
- package/lib/engine/features/tolltip/tooltipDomHelper.d.ts +30 -0
- package/lib/engine/features/tolltip/tooltipDomHelper.js +103 -0
- package/lib/engine/features/tolltip/tooltipHelper.d.ts +18 -0
- package/lib/engine/features/tolltip/tooltipHelper.js +93 -0
- package/lib/engine/filterManager/filterEventManager.d.ts +33 -0
- package/lib/engine/filterManager/filterEventManager.js +127 -0
- package/lib/engine/helpers/domHelper.d.ts +30 -0
- package/lib/engine/helpers/domHelper.js +68 -0
- package/lib/engine/helpers/helper.d.ts +30 -0
- package/lib/engine/helpers/helper.js +89 -0
- package/lib/engine/helpers/namesHelper.d.ts +5 -0
- package/lib/engine/helpers/namesHelper.js +9 -0
- package/lib/engine/intervalNotation/gantt.d.ts +10 -0
- package/lib/engine/intervalNotation/gantt.js +62 -0
- package/lib/engine/intervalNotation/intervalManager.d.ts +7 -0
- package/lib/engine/intervalNotation/intervalManager.js +30 -0
- package/lib/engine/polarNotation/donut/DonutHelper.d.ts +15 -0
- package/lib/engine/polarNotation/donut/DonutHelper.js +60 -0
- package/lib/engine/polarNotation/donut/donut.d.ts +32 -0
- package/lib/engine/polarNotation/donut/donut.js +125 -0
- package/lib/engine/polarNotation/polarManager.d.ts +10 -0
- package/lib/engine/polarNotation/polarManager.js +55 -0
- package/lib/engine/transitionManager.d.ts +19 -0
- package/lib/engine/transitionManager.js +64 -0
- package/lib/engine/twoDimensionalNotation/area/area.d.ts +17 -0
- package/lib/engine/twoDimensionalNotation/area/area.js +131 -0
- package/lib/engine/twoDimensionalNotation/area/areaHelper.d.ts +9 -0
- package/lib/engine/twoDimensionalNotation/area/areaHelper.js +40 -0
- package/lib/engine/twoDimensionalNotation/bar/bar.d.ts +34 -0
- package/lib/engine/twoDimensionalNotation/bar/bar.js +216 -0
- package/lib/engine/twoDimensionalNotation/bar/barHelper.d.ts +24 -0
- package/lib/engine/twoDimensionalNotation/bar/barHelper.js +103 -0
- package/lib/engine/twoDimensionalNotation/line/line.d.ts +17 -0
- package/lib/engine/twoDimensionalNotation/line/line.js +132 -0
- package/lib/engine/twoDimensionalNotation/line/lineHelper.d.ts +8 -0
- package/lib/engine/twoDimensionalNotation/line/lineHelper.js +28 -0
- package/lib/engine/twoDimensionalNotation/twoDimensionalManager.d.ts +11 -0
- package/lib/engine/twoDimensionalNotation/twoDimensionalManager.js +101 -0
- package/lib/engine/valueFormatter.d.ts +6 -0
- package/lib/engine/valueFormatter.js +8 -0
- package/lib/main.d.ts +79 -0
- package/lib/main.js +88 -0
- package/lib/model/chartStyleModel.d.ts +16 -0
- package/lib/model/chartStyleModel.js +67 -0
- package/lib/model/configsValidator/configValidator.d.ts +5 -0
- package/lib/model/configsValidator/configValidator.js +7 -0
- package/lib/model/dataManagerModel.d.ts +22 -0
- package/lib/model/dataManagerModel.js +137 -0
- package/lib/model/featuresModel/axisModel.d.ts +18 -0
- package/lib/model/featuresModel/axisModel.js +111 -0
- package/lib/model/featuresModel/legendModel/legendCanvasModel.d.ts +7 -0
- package/lib/model/featuresModel/legendModel/legendCanvasModel.js +86 -0
- package/lib/model/featuresModel/legendModel/legendModel.d.ts +13 -0
- package/lib/model/featuresModel/legendModel/legendModel.js +78 -0
- package/lib/model/featuresModel/otherComponents.d.ts +6 -0
- package/lib/model/featuresModel/otherComponents.js +12 -0
- package/lib/model/featuresModel/scaleModel.d.ts +17 -0
- package/lib/model/featuresModel/scaleModel.js +100 -0
- package/lib/model/featuresModel/titleModel.d.ts +4 -0
- package/lib/model/featuresModel/titleModel.js +14 -0
- package/lib/model/featuresModel/tooltipModel.d.ts +4 -0
- package/lib/model/featuresModel/tooltipModel.js +7 -0
- package/lib/model/marginModel.d.ts +19 -0
- package/lib/model/marginModel.js +126 -0
- package/lib/model/model.d.ts +221 -0
- package/lib/model/model.js +1 -0
- package/lib/model/modelBuilder.d.ts +16 -0
- package/lib/model/modelBuilder.js +128 -0
- package/lib/model/modelHelper.d.ts +7 -0
- package/lib/model/modelHelper.js +41 -0
- package/lib/model/notations/intervalModel.d.ts +8 -0
- package/lib/model/notations/intervalModel.js +93 -0
- package/lib/model/notations/polarModel.d.ts +7 -0
- package/lib/model/notations/polarModel.js +27 -0
- package/lib/model/notations/twoDimensionalModel.d.ts +19 -0
- package/lib/model/notations/twoDimensionalModel.js +85 -0
- package/lib/optionsServices/publicOptionsService.d.ts +6 -0
- package/lib/optionsServices/publicOptionsService.js +8 -0
- package/lib/optionsServices/validators/sizeValidator.d.ts +5 -0
- package/lib/optionsServices/validators/sizeValidator.js +13 -0
- package/lib/style/charts-main.css +243 -0
- package/lib/style/charts-main.less +243 -0
- package/package.json +1 -1
- package/dist/index.html +0 -363
- package/dist/listeners.89e1e272264c0e680de8.js +0 -278
- package/dist/main.f8b6bc6fee33cef1116c.js +0 -228
- package/dist/src_engine_engine_ts.ccee2a280374e0083541.js +0 -759
- package/dist/vendors-node_modules_chroma-js_chroma_js-node_modules_d3-array_src_max_js-node_modules_d3-arr-c3fc24.b32acc465b8557229277.js +0 -1869
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { select, pointer, } from 'd3-selection';
|
|
2
|
+
import { TooltipDomHelper } from "./tooltipDomHelper";
|
|
3
|
+
import { Donut } from "../../polarNotation/donut/donut";
|
|
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
|
+
export class Tooltip {
|
|
14
|
+
static render(block, model, data, tooltipOptions, scales) {
|
|
15
|
+
TooltipComponentsManager.renderTooltipWrapper(block);
|
|
16
|
+
const withTooltipIndex = model.options.charts.findIndex((chart) => chart.tooltip.show);
|
|
17
|
+
if (withTooltipIndex !== -1) {
|
|
18
|
+
if (model.options.type === '2d') {
|
|
19
|
+
this.renderTooltipFor2DCharts(block, data, model.blockCanvas.size, model.chartBlock.margin, scales, model.options, tooltipOptions);
|
|
20
|
+
}
|
|
21
|
+
else if (model.options.type === 'polar') {
|
|
22
|
+
this.renderTooltipForPolar(block, model.options, data, model.blockCanvas.size, model.chartBlock.margin, DonutHelper.getThickness(model.chartSettings.donut, model.blockCanvas.size, model.chartBlock.margin), model.otherComponents.tooltipBlock);
|
|
23
|
+
}
|
|
24
|
+
else if (model.options.type === 'interval') {
|
|
25
|
+
this.renderTooltipForIntervalCharts(block, data, model.blockCanvas.size, model.chartBlock.margin, scales, model.options, tooltipOptions);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
static hide(block) {
|
|
30
|
+
TooltipComponentsManager.hideComponent(block.getWrapper().select(`.${this.tooltipBlockClass}`));
|
|
31
|
+
TooltipComponentsManager.hideComponent(block.getSvg().select(`.${this.tooltipLineClass}`));
|
|
32
|
+
}
|
|
33
|
+
static renderTooltipFor2DCharts(block, data, blockSize, margin, scales, options, tooltipOptions) {
|
|
34
|
+
if (scales.key.domain().length === 0)
|
|
35
|
+
return;
|
|
36
|
+
const tooltipParams = {
|
|
37
|
+
type: '2d',
|
|
38
|
+
scales,
|
|
39
|
+
margin,
|
|
40
|
+
blockSize,
|
|
41
|
+
charts: options.charts,
|
|
42
|
+
chartOrientation: options.orient,
|
|
43
|
+
keyAxisOrient: options.axis.key.orient,
|
|
44
|
+
dataOptions: options.data,
|
|
45
|
+
scaleKeyModel: options.scale.key,
|
|
46
|
+
tooltipSettings: tooltipOptions,
|
|
47
|
+
tooltipOptions: options.tooltip
|
|
48
|
+
};
|
|
49
|
+
this.renderLineTooltip(block, data, tooltipParams);
|
|
50
|
+
}
|
|
51
|
+
static renderTooltipForIntervalCharts(block, data, blockSize, margin, scales, options, tooltipOptions) {
|
|
52
|
+
if (scales.key.domain().length === 0)
|
|
53
|
+
return;
|
|
54
|
+
const tooltipParams = {
|
|
55
|
+
type: 'interval',
|
|
56
|
+
scales,
|
|
57
|
+
margin,
|
|
58
|
+
blockSize,
|
|
59
|
+
charts: options.charts,
|
|
60
|
+
chartOrientation: options.orient,
|
|
61
|
+
keyAxisOrient: options.axis.key.orient,
|
|
62
|
+
dataOptions: options.data,
|
|
63
|
+
scaleKeyModel: options.scale.key,
|
|
64
|
+
tooltipSettings: tooltipOptions,
|
|
65
|
+
tooltipOptions: options.tooltip
|
|
66
|
+
};
|
|
67
|
+
this.renderLineTooltip(block, data, tooltipParams);
|
|
68
|
+
}
|
|
69
|
+
static renderTooltipForPolar(block, options, data, blockSize, margin, chartThickness, tooltipOptions) {
|
|
70
|
+
const attrTransform = block.getSvg().select(`.${Donut.donutBlockClass}`).attr('transform');
|
|
71
|
+
const translateNums = Helper.getTranslateNumbers(attrTransform);
|
|
72
|
+
const arcItems = Donut.getAllArcGroups(block);
|
|
73
|
+
this.renderTooltipForDonut(block, arcItems, data, options.data, options.charts[0], blockSize, margin, chartThickness, tooltipOptions, options.tooltip, { x: translateNums[0], y: translateNums[1] });
|
|
74
|
+
}
|
|
75
|
+
static renderLineTooltip(block, data, args) {
|
|
76
|
+
const tooltipBlock = TooltipComponentsManager.renderTooltipBlock(block);
|
|
77
|
+
const tooltipContent = TooltipComponentsManager.renderTooltipContentBlock(tooltipBlock);
|
|
78
|
+
const tooltipLine = TooltipComponentsManager.renderTooltipLine(block);
|
|
79
|
+
const tipBox = TipBox.renderOrGet(block, args.margin, args.blockSize);
|
|
80
|
+
let currentKey = null;
|
|
81
|
+
tipBox.on('mousemove', function (e) {
|
|
82
|
+
var _a, _b;
|
|
83
|
+
const keyValue = e.detail.keyValue || TipBoxHelper.getKeyValueByPointer(pointer(e, this), args.chartOrientation, args.margin, args.blockSize, args.scales.key, args.scaleKeyModel.type);
|
|
84
|
+
if (args.tooltipSettings.position === 'followCursor') {
|
|
85
|
+
const tooltipCoordinate = TooltipHelper.getTooltipCursorCoordinate(e.detail.pointer || pointer(e, this), block.getSvg().node().getBoundingClientRect(), tooltipBlock.getEl().node().getBoundingClientRect());
|
|
86
|
+
TooltipComponentsManager.setLineTooltipCoordinate(tooltipBlock, tooltipCoordinate, args.chartOrientation, 0);
|
|
87
|
+
}
|
|
88
|
+
if (!currentKey || currentKey !== keyValue) {
|
|
89
|
+
TooltipComponentsManager.showComponent(tooltipBlock.getEl());
|
|
90
|
+
if (args.type === '2d')
|
|
91
|
+
TooltipDomHelper.fillForMulty2DCharts(tooltipContent, args.charts.filter(ch => ch.tooltip.show), data, args.dataOptions, keyValue, (_a = args.tooltipOptions) === null || _a === void 0 ? void 0 : _a.html);
|
|
92
|
+
else
|
|
93
|
+
TooltipDomHelper.fillForIntervalChart(tooltipContent, args.charts.filter(ch => ch.tooltip.show), data, args.dataOptions, keyValue, (_b = args.tooltipOptions) === null || _b === void 0 ? void 0 : _b.html);
|
|
94
|
+
if (args.tooltipSettings.position === 'fixed') {
|
|
95
|
+
const tooltipCoordinate = TooltipHelper.getTooltipFixedCoordinate(args.scales.key, args.margin, keyValue, block.getSvg().node().getBoundingClientRect(), tooltipContent.node().getBoundingClientRect(), args.keyAxisOrient, window.innerWidth, window.innerHeight);
|
|
96
|
+
TooltipComponentsManager.setLineTooltipCoordinate(tooltipBlock, tooltipCoordinate, args.chartOrientation, block.transitionManager.durations.tooltipSlide);
|
|
97
|
+
}
|
|
98
|
+
const tooltipLineAttributes = TooltipHelper.getTooltipLineAttributes(args.scales.key, args.margin, keyValue, args.chartOrientation, args.blockSize);
|
|
99
|
+
TooltipComponentsManager.setTooltipLineAttributes(tooltipLine, tooltipLineAttributes, block.transitionManager.durations.tooltipSlide);
|
|
100
|
+
TooltipComponentsManager.showComponent(tooltipLine);
|
|
101
|
+
//TODO: append highlight for interval / Extract this highlighting in method
|
|
102
|
+
if (args.type === '2d') {
|
|
103
|
+
args.charts.forEach(chart => {
|
|
104
|
+
const elements = DomHelper.get2DChartElements(block, chart);
|
|
105
|
+
if (!block.filterEventManager.isSelected(currentKey)) {
|
|
106
|
+
const oldElements = DomHelper.getChartElementsByKeys(elements, chart.isSegmented, args.dataOptions.keyField.name, [currentKey]);
|
|
107
|
+
if (chart.type !== 'bar' && !chart.markersOptions.show)
|
|
108
|
+
ElementHighlighter.toggleMarkDotVisible(oldElements, false);
|
|
109
|
+
ElementHighlighter.toggle2DElements(oldElements, false, chart.type, block.transitionManager.durations.markerHover);
|
|
110
|
+
if (block.filterEventManager.getSelectedKeys().length > 0) {
|
|
111
|
+
ElementHighlighter.toggleActivityStyle(oldElements, false);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
const selectedElements = DomHelper.getChartElementsByKeys(elements, chart.isSegmented, args.dataOptions.keyField.name, [keyValue]);
|
|
115
|
+
if (chart.type !== 'bar' && !chart.markersOptions.show)
|
|
116
|
+
ElementHighlighter.toggleMarkDotVisible(selectedElements, true);
|
|
117
|
+
ElementHighlighter.toggleActivityStyle(selectedElements, true);
|
|
118
|
+
if (block.filterEventManager.getSelectedKeys().length === 0 || block.filterEventManager.isSelected(keyValue)) {
|
|
119
|
+
ElementHighlighter.toggle2DElements(selectedElements, true, chart.type, block.transitionManager.durations.markerHover);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
currentKey = keyValue;
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
tipBox.on('mouseleave', function () {
|
|
127
|
+
TooltipComponentsManager.hideComponent(tooltipBlock.getEl());
|
|
128
|
+
TooltipComponentsManager.hideComponent(tooltipLine);
|
|
129
|
+
if (args.type === '2d')
|
|
130
|
+
ElementHighlighter.removeUnselected2DHighlight(block, args.dataOptions.keyField.name, args.charts, block.transitionManager.durations.markerHover);
|
|
131
|
+
currentKey = null;
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
static renderTooltipForDonut(block, elements, data, dataOptions, chart, blockSize, margin, donutThickness, tooltipSettings, tooltipOptions, translate) {
|
|
135
|
+
const tooltipBlock = TooltipComponentsManager.renderTooltipBlock(block);
|
|
136
|
+
const tooltipContent = TooltipComponentsManager.renderTooltipContentBlock(tooltipBlock);
|
|
137
|
+
let tooltipArrow;
|
|
138
|
+
if (tooltipSettings.position === 'fixed')
|
|
139
|
+
tooltipArrow = TooltipComponentsManager.renderTooltipArrow(tooltipBlock.getEl());
|
|
140
|
+
if (tooltipSettings.position === 'followCursor') {
|
|
141
|
+
elements.on('mousemove', function (e) {
|
|
142
|
+
const pointerCoordinate = !pointer(e, block.getSvg().node())[0] ? e.detail.pointer : pointer(e, block.getSvg().node());
|
|
143
|
+
const tooltipCoordinate = TooltipHelper.getTooltipCursorCoordinate(pointerCoordinate, block.getSvg().node().getBoundingClientRect(), tooltipBlock.getEl().node().getBoundingClientRect());
|
|
144
|
+
tooltipBlock.setCoordinate(tooltipCoordinate);
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
elements.on('mouseover', function (e, dataRow) {
|
|
148
|
+
TooltipComponentsManager.showComponent(tooltipBlock.getEl());
|
|
149
|
+
TooltipDomHelper.fillForPolarChart(tooltipContent, chart, data, dataOptions, dataRow.data[dataOptions.keyField.name], select(this).select('path').style('fill'), tooltipOptions === null || tooltipOptions === void 0 ? void 0 : tooltipOptions.html);
|
|
150
|
+
if (tooltipSettings.position === 'fixed') {
|
|
151
|
+
const coordinatePointer = TooltipDomHelper.getRecalcedCoordinateByArrow(DonutHelper.getArcCentroid(blockSize, margin, dataRow, donutThickness), tooltipBlock.getEl(), blockSize, tooltipArrow, translate.x, translate.y);
|
|
152
|
+
coordinatePointer[0] = coordinatePointer[0] + translate.x;
|
|
153
|
+
coordinatePointer[1] = coordinatePointer[1] + translate.y;
|
|
154
|
+
const tooltipCoordinate = TooltipHelper.getCoordinateByPointer(coordinatePointer);
|
|
155
|
+
tooltipBlock.setCoordinate(tooltipCoordinate);
|
|
156
|
+
}
|
|
157
|
+
ElementHighlighter.toggleActivityStyle(select(this), true);
|
|
158
|
+
const clones = Donut.getAllArcClones(block)
|
|
159
|
+
.filter((d) => d.data[dataOptions.keyField.name] === dataRow.data[dataOptions.keyField.name]);
|
|
160
|
+
if (clones.nodes().length === 0 && (block.filterEventManager.getSelectedKeys().length === 0 || block.filterEventManager.isSelected(dataRow.data[dataOptions.keyField.name]))) {
|
|
161
|
+
ElementHighlighter.renderArcCloneAndHighlight(block, margin, select(this), blockSize, donutThickness);
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
elements.on('mouseleave', function (e, dataRow) {
|
|
165
|
+
TooltipComponentsManager.hideComponent(tooltipBlock.getEl());
|
|
166
|
+
if (!block.filterEventManager.isSelected(dataRow.data[dataOptions.keyField.name])) {
|
|
167
|
+
ElementHighlighter.removeCloneForElem(block, dataOptions.keyField.name, select(this));
|
|
168
|
+
ElementHighlighter.removeShadowClone(block, dataOptions.keyField.name, select(this), margin, blockSize, donutThickness);
|
|
169
|
+
ElementHighlighter.toggleDonutHighlightState(select(this), margin, blockSize, donutThickness, block.transitionManager.durations.higlightedScale, false);
|
|
170
|
+
if (block.filterEventManager.getSelectedKeys().length > 0) {
|
|
171
|
+
ElementHighlighter.toggleActivityStyle(select(this), false);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
Tooltip.tooltipBlockClass = NewTooltip.tooltipBlockClass;
|
|
178
|
+
Tooltip.tooltipLineClass = 'tooltip-line';
|
|
179
|
+
Tooltip.tooltipWrapperClass = 'tooltip-wrapper';
|
|
180
|
+
Tooltip.tooltipContentClass = 'tooltip-content';
|
|
181
|
+
Tooltip.tooltipArrowClass = 'tooltip-arrow';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Selection, BaseType } from 'd3-selection';
|
|
2
|
+
import { Block } from "../../block/block";
|
|
3
|
+
import { TooltipLineAttributes } from "./tooltipDomHelper";
|
|
4
|
+
import { ChartOrientation } from "../../../config/config";
|
|
5
|
+
import { NewTooltip, TooltipCoordinate } from './newTooltip/newTooltip';
|
|
6
|
+
export declare class TooltipComponentsManager {
|
|
7
|
+
static showComponent(tooltipBlock: Selection<BaseType, unknown, HTMLElement, any>): void;
|
|
8
|
+
static hideComponent(tooltipBlock: Selection<BaseType, unknown, HTMLElement, any>): void;
|
|
9
|
+
static renderTooltipWrapper(block: Block): void;
|
|
10
|
+
static renderTooltipBlock(block: Block, translateX?: number, translateY?: number): NewTooltip;
|
|
11
|
+
static renderTooltipContentBlock(tooltipBlock: NewTooltip): Selection<HTMLDivElement, unknown, HTMLElement, any>;
|
|
12
|
+
static renderTooltipLine(block: Block): Selection<SVGLineElement, unknown, HTMLElement, any>;
|
|
13
|
+
static setTooltipLineAttributes(tooltipLine: Selection<SVGLineElement, unknown, HTMLElement, any>, attributes: TooltipLineAttributes, transition: number): void;
|
|
14
|
+
static getLineWidth(tooltipLine: Selection<BaseType, any, BaseType, any>): number;
|
|
15
|
+
static renderTooltipArrow(tooltipBlock: Selection<BaseType, unknown, HTMLElement, any>): Selection<BaseType, unknown, HTMLElement, any>;
|
|
16
|
+
static setLineTooltipCoordinate(tooltip: NewTooltip, tooltipCoordinate: TooltipCoordinate, chartOrientation: ChartOrientation, transition?: number): void;
|
|
17
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { select } from 'd3-selection';
|
|
2
|
+
import { ARROW_DEFAULT_POSITION, ARROW_SIZE } from "./tooltipDomHelper";
|
|
3
|
+
import { easeLinear } from 'd3-ease';
|
|
4
|
+
import { interrupt } from 'd3-transition';
|
|
5
|
+
import { Tooltip } from './tooltip';
|
|
6
|
+
import { NewTooltip } from './newTooltip/newTooltip';
|
|
7
|
+
export class TooltipComponentsManager {
|
|
8
|
+
static showComponent(tooltipBlock) {
|
|
9
|
+
tooltipBlock.style('display', 'block');
|
|
10
|
+
}
|
|
11
|
+
static hideComponent(tooltipBlock) {
|
|
12
|
+
tooltipBlock.style('display', 'none');
|
|
13
|
+
}
|
|
14
|
+
static renderTooltipWrapper(block) {
|
|
15
|
+
let tooltipWrapper = block.getWrapper()
|
|
16
|
+
.select(`.${Tooltip.tooltipWrapperClass}`);
|
|
17
|
+
if (tooltipWrapper.empty())
|
|
18
|
+
block.getWrapper()
|
|
19
|
+
.append('div')
|
|
20
|
+
.attr('class', Tooltip.tooltipWrapperClass);
|
|
21
|
+
}
|
|
22
|
+
static renderTooltipBlock(block, translateX = 0, translateY = 0) {
|
|
23
|
+
const wrapper = block.getWrapper().select(`.${Tooltip.tooltipWrapperClass}`);
|
|
24
|
+
const tooltipService = new NewTooltip();
|
|
25
|
+
let tooltipBlock = tooltipService.findInWrapper(wrapper);
|
|
26
|
+
if (tooltipBlock.empty()) {
|
|
27
|
+
tooltipBlock = tooltipService.render(wrapper);
|
|
28
|
+
tooltipBlock
|
|
29
|
+
.style('position', 'absolute')
|
|
30
|
+
.style('display', 'none');
|
|
31
|
+
}
|
|
32
|
+
if (translateX !== 0 || translateY !== 0)
|
|
33
|
+
tooltipBlock.style('transform', `translate(${translateX}px, ${translateY}px)`);
|
|
34
|
+
return tooltipService;
|
|
35
|
+
}
|
|
36
|
+
static renderTooltipContentBlock(tooltipBlock) {
|
|
37
|
+
let tooltipContentBlock = tooltipBlock.getEl().select(`.${Tooltip.tooltipContentClass}`);
|
|
38
|
+
if (tooltipContentBlock.empty()) {
|
|
39
|
+
tooltipContentBlock = select(document.createElement("div"))
|
|
40
|
+
.attr("class", Tooltip.tooltipContentClass);
|
|
41
|
+
tooltipBlock.appendContent(tooltipContentBlock.node());
|
|
42
|
+
}
|
|
43
|
+
return tooltipContentBlock;
|
|
44
|
+
}
|
|
45
|
+
static renderTooltipLine(block) {
|
|
46
|
+
let tooltipLine = block.getChartBlock()
|
|
47
|
+
.select(`.${Tooltip.tooltipLineClass}`);
|
|
48
|
+
if (tooltipLine.empty())
|
|
49
|
+
tooltipLine = block.getChartBlock()
|
|
50
|
+
.append('line')
|
|
51
|
+
.attr('class', Tooltip.tooltipLineClass)
|
|
52
|
+
.lower();
|
|
53
|
+
return tooltipLine;
|
|
54
|
+
}
|
|
55
|
+
static setTooltipLineAttributes(tooltipLine, attributes, transition) {
|
|
56
|
+
interrupt(tooltipLine.node());
|
|
57
|
+
if (transition > 0 && tooltipLine.style('display') === 'block') {
|
|
58
|
+
tooltipLine
|
|
59
|
+
.interrupt()
|
|
60
|
+
.transition()
|
|
61
|
+
.duration(transition)
|
|
62
|
+
.ease(easeLinear)
|
|
63
|
+
.attr('x1', attributes.x1)
|
|
64
|
+
.attr('x2', attributes.x2)
|
|
65
|
+
.attr('y1', attributes.y1)
|
|
66
|
+
.attr('y2', attributes.y2);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
tooltipLine
|
|
70
|
+
.attr('x1', attributes.x1)
|
|
71
|
+
.attr('x2', attributes.x2)
|
|
72
|
+
.attr('y1', attributes.y1)
|
|
73
|
+
.attr('y2', attributes.y2);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
static getLineWidth(tooltipLine) {
|
|
77
|
+
return parseFloat(tooltipLine.style('stroke-width'));
|
|
78
|
+
}
|
|
79
|
+
static renderTooltipArrow(tooltipBlock) {
|
|
80
|
+
let arrowSize = ARROW_SIZE / 2;
|
|
81
|
+
let tooltipArrow = tooltipBlock.select(`.${Tooltip.tooltipArrowClass}`);
|
|
82
|
+
if (tooltipArrow.empty())
|
|
83
|
+
tooltipArrow = tooltipBlock
|
|
84
|
+
.append('div')
|
|
85
|
+
.attr('class', Tooltip.tooltipArrowClass)
|
|
86
|
+
.style('position', 'absolute')
|
|
87
|
+
.style('left', `${ARROW_DEFAULT_POSITION}px`)
|
|
88
|
+
.style('border-top-width', `${arrowSize}px`)
|
|
89
|
+
.style('border-right-width', `${arrowSize}px`)
|
|
90
|
+
.style('border-bottom-width', `0px`)
|
|
91
|
+
.style('border-left-width', `${arrowSize}px`);
|
|
92
|
+
return tooltipArrow;
|
|
93
|
+
}
|
|
94
|
+
static setLineTooltipCoordinate(tooltip, tooltipCoordinate, chartOrientation, transition = null) {
|
|
95
|
+
const tooltipBlock = tooltip.getEl();
|
|
96
|
+
interrupt(tooltipBlock.node());
|
|
97
|
+
if (!transition || transition <= 0)
|
|
98
|
+
tooltip.setCoordinate(tooltipCoordinate);
|
|
99
|
+
if (chartOrientation === 'vertical' && tooltipBlock.style('left') !== '0px' && tooltipBlock.style('right') !== '0px' && tooltipCoordinate.right !== '0px' && tooltipCoordinate.left !== null) {
|
|
100
|
+
tooltipBlock
|
|
101
|
+
.style('right', tooltipCoordinate.right)
|
|
102
|
+
.style('bottom', tooltipCoordinate.bottom)
|
|
103
|
+
.style('top', tooltipCoordinate.top)
|
|
104
|
+
.interrupt()
|
|
105
|
+
.transition()
|
|
106
|
+
.duration(transition)
|
|
107
|
+
.ease(easeLinear)
|
|
108
|
+
.style('left', tooltipCoordinate.left);
|
|
109
|
+
}
|
|
110
|
+
else if (chartOrientation === 'horizontal' && tooltipBlock.style('top') !== '0px' && parseInt(tooltipBlock.style('bottom')) > 0 && tooltipCoordinate.bottom === null) {
|
|
111
|
+
tooltipBlock
|
|
112
|
+
.style('right', tooltipCoordinate.right)
|
|
113
|
+
.style('bottom', tooltipCoordinate.bottom)
|
|
114
|
+
.style('left', tooltipCoordinate.left)
|
|
115
|
+
.interrupt()
|
|
116
|
+
.transition()
|
|
117
|
+
.duration(transition)
|
|
118
|
+
.ease(easeLinear)
|
|
119
|
+
.style('top', tooltipCoordinate.top);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
tooltip.setCoordinate(tooltipCoordinate);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Selection, BaseType } from 'd3-selection';
|
|
2
|
+
import { MdtChartsDataSource, TooltipHtml } from "../../../config/config";
|
|
3
|
+
import { IntervalChartModel, OptionsModelData, PolarChartModel, TwoDimensionalChartModel } from "../../../model/model";
|
|
4
|
+
import { Size } from "../../../config/config";
|
|
5
|
+
export interface TooltipLineAttributes {
|
|
6
|
+
x1: number;
|
|
7
|
+
x2: number;
|
|
8
|
+
y1: number;
|
|
9
|
+
y2: number;
|
|
10
|
+
}
|
|
11
|
+
export declare const ARROW_SIZE = 20;
|
|
12
|
+
export declare const ARROW_DEFAULT_POSITION = 9;
|
|
13
|
+
export declare const TOOLTIP_ARROW_PADDING_X: number;
|
|
14
|
+
export declare const TOOLTIP_ARROW_PADDING_Y = 13;
|
|
15
|
+
export declare class TooltipDomHelper {
|
|
16
|
+
private static readonly groupClass;
|
|
17
|
+
private static readonly headClass;
|
|
18
|
+
private static readonly textItemClass;
|
|
19
|
+
private static readonly maxContentWidth;
|
|
20
|
+
static fillForMulty2DCharts(contentBlock: Selection<HTMLElement, unknown, BaseType, unknown>, charts: TwoDimensionalChartModel[], data: MdtChartsDataSource, dataOptions: OptionsModelData, keyValue: string, htmlHandler?: TooltipHtml): void;
|
|
21
|
+
static fillForPolarChart(contentBlock: Selection<HTMLElement, unknown, BaseType, unknown>, chart: PolarChartModel, data: MdtChartsDataSource, dataOptions: OptionsModelData, keyValue: string, markColor: string, htmlHandler?: TooltipHtml): void;
|
|
22
|
+
static fillForIntervalChart(contentBlock: Selection<HTMLElement, unknown, BaseType, unknown>, charts: IntervalChartModel[], data: MdtChartsDataSource, dataOptions: OptionsModelData, keyValue: string, htmlHandler?: TooltipHtml): void;
|
|
23
|
+
static getRecalcedCoordinateByArrow(coordinate: [number, number], tooltipBlock: Selection<HTMLElement, unknown, HTMLElement, any>, blockSize: Size, tooltipArrow: Selection<BaseType, unknown, HTMLElement, any>, translateX?: number, translateY?: number): [number, number];
|
|
24
|
+
private static renderHead;
|
|
25
|
+
private static fillValuesContent;
|
|
26
|
+
private static getTooltipItemHtml;
|
|
27
|
+
private static setTooltipArrowCoordinate;
|
|
28
|
+
private static fillContentByFunction;
|
|
29
|
+
private static setWhiteSpaceForTextBlocks;
|
|
30
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { ValueFormatter, } from "../../valueFormatter";
|
|
2
|
+
import { TooltipHelper } from './tooltipHelper';
|
|
3
|
+
import { Helper } from '../../helpers/helper';
|
|
4
|
+
export const ARROW_SIZE = 20;
|
|
5
|
+
export const ARROW_DEFAULT_POSITION = 9;
|
|
6
|
+
export const TOOLTIP_ARROW_PADDING_X = ARROW_DEFAULT_POSITION - (ARROW_SIZE * Math.sqrt(2) - ARROW_SIZE) / 2 + 14;
|
|
7
|
+
export const TOOLTIP_ARROW_PADDING_Y = 13;
|
|
8
|
+
export class TooltipDomHelper {
|
|
9
|
+
static fillForMulty2DCharts(contentBlock, charts, data, dataOptions, keyValue, htmlHandler) {
|
|
10
|
+
contentBlock.html('');
|
|
11
|
+
if (!htmlHandler) {
|
|
12
|
+
this.renderHead(contentBlock, keyValue);
|
|
13
|
+
charts.forEach(chart => {
|
|
14
|
+
chart.data.valueFields.forEach((field, index) => {
|
|
15
|
+
const html = this.getTooltipItemHtml(data, dataOptions, keyValue, field);
|
|
16
|
+
this.fillValuesContent(contentBlock, chart.style.elementColors[index % chart.style.elementColors.length], html);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
this.fillContentByFunction(contentBlock, data, dataOptions, keyValue, htmlHandler);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
static fillForPolarChart(contentBlock, chart, data, dataOptions, keyValue, markColor, htmlHandler) {
|
|
25
|
+
contentBlock.html('');
|
|
26
|
+
if (!htmlHandler) {
|
|
27
|
+
this.renderHead(contentBlock, keyValue);
|
|
28
|
+
const html = this.getTooltipItemHtml(data, dataOptions, keyValue, chart.data.valueField);
|
|
29
|
+
this.fillValuesContent(contentBlock, markColor, html);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
this.fillContentByFunction(contentBlock, data, dataOptions, keyValue, htmlHandler);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
static fillForIntervalChart(contentBlock, charts, data, dataOptions, keyValue, htmlHandler) {
|
|
36
|
+
contentBlock.html('');
|
|
37
|
+
if (!htmlHandler) {
|
|
38
|
+
this.renderHead(contentBlock, keyValue);
|
|
39
|
+
charts.forEach(chart => {
|
|
40
|
+
let html = this.getTooltipItemHtml(data, dataOptions, keyValue, chart.data.valueField1);
|
|
41
|
+
this.fillValuesContent(contentBlock, chart.style.elementColors[0 % chart.style.elementColors.length], html);
|
|
42
|
+
html = this.getTooltipItemHtml(data, dataOptions, keyValue, chart.data.valueField2);
|
|
43
|
+
this.fillValuesContent(contentBlock, chart.style.elementColors[0 % chart.style.elementColors.length], html);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
this.fillContentByFunction(contentBlock, data, dataOptions, keyValue, htmlHandler);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
static getRecalcedCoordinateByArrow(coordinate, tooltipBlock, blockSize, tooltipArrow, translateX = 0, translateY = 0) {
|
|
51
|
+
const tooltipBlockNode = tooltipBlock.node();
|
|
52
|
+
const horizontalPad = TooltipHelper.getHorizontalPad(coordinate[0], tooltipBlockNode.getBoundingClientRect().width, blockSize, translateX);
|
|
53
|
+
const verticalPad = TooltipHelper.getVerticalPad(coordinate[1], tooltipBlockNode.getBoundingClientRect().height, translateY);
|
|
54
|
+
this.setTooltipArrowCoordinate(tooltipArrow, TooltipHelper.getTooltipArrowPadding(tooltipBlockNode.getBoundingClientRect().width, horizontalPad));
|
|
55
|
+
return [coordinate[0] - TOOLTIP_ARROW_PADDING_X - horizontalPad,
|
|
56
|
+
coordinate[1] - TOOLTIP_ARROW_PADDING_Y - tooltipBlockNode.getBoundingClientRect().height - verticalPad];
|
|
57
|
+
}
|
|
58
|
+
static renderHead(contentBlock, keyValue) {
|
|
59
|
+
contentBlock.append('div')
|
|
60
|
+
.attr('class', `${this.groupClass} ${this.headClass}`)
|
|
61
|
+
.text(keyValue);
|
|
62
|
+
}
|
|
63
|
+
static fillValuesContent(contentBlock, markColor, tooltipHtml) {
|
|
64
|
+
const group = contentBlock.append('div')
|
|
65
|
+
.attr('class', this.groupClass);
|
|
66
|
+
if (markColor)
|
|
67
|
+
group.append('div')
|
|
68
|
+
.attr('class', 'tooltip-color')
|
|
69
|
+
.append('span')
|
|
70
|
+
.attr('class', 'tooltip-circle')
|
|
71
|
+
.style('background-color', markColor);
|
|
72
|
+
group.append('div')
|
|
73
|
+
.attr('class', 'tooltip-texts')
|
|
74
|
+
.append('div')
|
|
75
|
+
.attr('class', this.textItemClass)
|
|
76
|
+
.html(tooltipHtml);
|
|
77
|
+
}
|
|
78
|
+
static getTooltipItemHtml(data, dataOptions, keyValue, valueField) {
|
|
79
|
+
const row = data[dataOptions.dataSource].find(d => d[dataOptions.keyField.name] === keyValue);
|
|
80
|
+
const text = `<span class="tooltip-field-title">${valueField.title}</span>
|
|
81
|
+
<span class="tooltip-field-value">${ValueFormatter.formatField(valueField.format, row[valueField.name])}</span>`;
|
|
82
|
+
return text;
|
|
83
|
+
}
|
|
84
|
+
static setTooltipArrowCoordinate(tooltipArrow, horizontalPad) {
|
|
85
|
+
if (horizontalPad !== 0)
|
|
86
|
+
tooltipArrow.style('left', `${ARROW_DEFAULT_POSITION + Math.floor(horizontalPad)}px`);
|
|
87
|
+
else
|
|
88
|
+
tooltipArrow.style('left', `${ARROW_DEFAULT_POSITION}px`);
|
|
89
|
+
}
|
|
90
|
+
static fillContentByFunction(contentBlock, data, dataOptions, keyValue, htmlHandler) {
|
|
91
|
+
const row = Helper.getRowsByKeys([keyValue], dataOptions.keyField.name, data[dataOptions.dataSource])[0];
|
|
92
|
+
contentBlock.html(htmlHandler(row));
|
|
93
|
+
this.setWhiteSpaceForTextBlocks(contentBlock);
|
|
94
|
+
contentBlock.selectAll('.tooltip-text-item').style('display', 'block');
|
|
95
|
+
}
|
|
96
|
+
static setWhiteSpaceForTextBlocks(contentBlock) {
|
|
97
|
+
contentBlock.selectAll(`.${this.textItemClass}`).style('white-space', 'pre-wrap');
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
TooltipDomHelper.groupClass = 'tooltip-group';
|
|
101
|
+
TooltipDomHelper.headClass = 'tooltip-head';
|
|
102
|
+
TooltipDomHelper.textItemClass = 'tooltip-text-item';
|
|
103
|
+
TooltipDomHelper.maxContentWidth = 500;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AxisScale } from "d3-axis";
|
|
2
|
+
import { ChartOrientation } from "../../../config/config";
|
|
3
|
+
import { BlockMargin, Orient } from "../../../model/model";
|
|
4
|
+
import { TooltipLineAttributes } from "./tooltipDomHelper";
|
|
5
|
+
import { Size } from "../../../config/config";
|
|
6
|
+
import { TooltipCoordinate } from "./newTooltip/newTooltip";
|
|
7
|
+
import { TooltipPreCoordinate } from "./newTooltip/newTooltipService";
|
|
8
|
+
export declare class TooltipHelper {
|
|
9
|
+
private static convexsize;
|
|
10
|
+
static getHorizontalPad(coordinateX: number, tooltipBlockWidth: number, blockSize: Size, translateX: number): number;
|
|
11
|
+
static getVerticalPad(coordinateY: number, tooltipBlockHeight: number, translateY: number): number;
|
|
12
|
+
static getTooltipArrowPadding(tooltipBlockWidth: number, horizontalPad: number): number;
|
|
13
|
+
static getCoordinateByPointer(pointer: [number, number]): TooltipCoordinate;
|
|
14
|
+
static getTooltipFixedCoordinate(scaleKey: AxisScale<any>, margin: BlockMargin, keyValue: string, blockBoundingRect: DOMRect, tooltipBoundingRect: DOMRect, keyAxisOrient: Orient, winWidth: number, winHeight: number): TooltipCoordinate;
|
|
15
|
+
static getTooltipCursorCoordinate(pointer: [number, number], blockBoundingRect: DOMRect, tooltipBoundingRect: DOMRect): TooltipCoordinate;
|
|
16
|
+
static getTooltipLineAttributes(scaleKey: AxisScale<any>, margin: BlockMargin, key: string, chartOrientation: ChartOrientation, blockSize: Size): TooltipLineAttributes;
|
|
17
|
+
static recalcToolTipCoordinateByViewPort(blockBounding: DOMRect, tooltipBounding: DOMRect, preCoordinate: TooltipPreCoordinate, winWidth: number, winHeight: number): TooltipCoordinate;
|
|
18
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { Scale } from "../scale/scale";
|
|
2
|
+
import { ARROW_DEFAULT_POSITION, TOOLTIP_ARROW_PADDING_X, TOOLTIP_ARROW_PADDING_Y } from "./tooltipDomHelper";
|
|
3
|
+
import { TooltipService } from "./newTooltip/newTooltipService";
|
|
4
|
+
export class TooltipHelper {
|
|
5
|
+
static getHorizontalPad(coordinateX, tooltipBlockWidth, blockSize, translateX) {
|
|
6
|
+
let pad = 0;
|
|
7
|
+
if (tooltipBlockWidth + coordinateX - TOOLTIP_ARROW_PADDING_X + translateX > blockSize.width)
|
|
8
|
+
pad = tooltipBlockWidth + coordinateX - TOOLTIP_ARROW_PADDING_X + translateX - blockSize.width;
|
|
9
|
+
return pad;
|
|
10
|
+
}
|
|
11
|
+
static getVerticalPad(coordinateY, tooltipBlockHeight, translateY) {
|
|
12
|
+
let pad = 0;
|
|
13
|
+
if (coordinateY - TOOLTIP_ARROW_PADDING_Y - tooltipBlockHeight + translateY < -tooltipBlockHeight - TOOLTIP_ARROW_PADDING_Y)
|
|
14
|
+
pad = coordinateY;
|
|
15
|
+
return pad; // return zero or sub zero
|
|
16
|
+
}
|
|
17
|
+
static getTooltipArrowPadding(tooltipBlockWidth, horizontalPad) {
|
|
18
|
+
return horizontalPad > tooltipBlockWidth
|
|
19
|
+
? tooltipBlockWidth - ARROW_DEFAULT_POSITION - 20 * Math.sqrt(2)
|
|
20
|
+
: horizontalPad; // If tooltip arrow has coordinate outside svg, it take X position in end of tooltip block
|
|
21
|
+
}
|
|
22
|
+
static getCoordinateByPointer(pointer) {
|
|
23
|
+
const coordinate = {
|
|
24
|
+
left: null,
|
|
25
|
+
top: null,
|
|
26
|
+
right: null,
|
|
27
|
+
bottom: null
|
|
28
|
+
};
|
|
29
|
+
coordinate.left = pointer[0] + 'px';
|
|
30
|
+
coordinate.top = pointer[1] + 'px';
|
|
31
|
+
return coordinate;
|
|
32
|
+
}
|
|
33
|
+
static getTooltipFixedCoordinate(scaleKey, margin, keyValue, blockBoundingRect, tooltipBoundingRect, keyAxisOrient, winWidth, winHeight) {
|
|
34
|
+
const coordinate = {
|
|
35
|
+
top: null,
|
|
36
|
+
left: null
|
|
37
|
+
};
|
|
38
|
+
if (keyAxisOrient === 'bottom' || keyAxisOrient === 'top') {
|
|
39
|
+
coordinate.left = Scale.getScaledValue(scaleKey, keyValue) + margin.left - tooltipBoundingRect.width / 2;
|
|
40
|
+
if (keyAxisOrient === 'bottom')
|
|
41
|
+
coordinate.top = margin.top - 5 - tooltipBoundingRect.height;
|
|
42
|
+
else
|
|
43
|
+
coordinate.top = blockBoundingRect.height - margin.bottom;
|
|
44
|
+
}
|
|
45
|
+
if (keyAxisOrient === 'left' || keyAxisOrient === 'right') {
|
|
46
|
+
coordinate.top = Scale.getScaledValue(scaleKey, keyValue) + margin.top - tooltipBoundingRect.height / 2;
|
|
47
|
+
if (keyAxisOrient === 'left')
|
|
48
|
+
coordinate.left = blockBoundingRect.width - margin.right;
|
|
49
|
+
else
|
|
50
|
+
coordinate.left = margin.left - tooltipBoundingRect.width;
|
|
51
|
+
}
|
|
52
|
+
return this.recalcToolTipCoordinateByViewPort(blockBoundingRect, tooltipBoundingRect, coordinate, winWidth, winHeight);
|
|
53
|
+
}
|
|
54
|
+
static getTooltipCursorCoordinate(pointer, blockBoundingRect, tooltipBoundingRect) {
|
|
55
|
+
const pad = 10;
|
|
56
|
+
const coordinate = {
|
|
57
|
+
top: pointer[1] + pad,
|
|
58
|
+
left: pointer[0] + pad
|
|
59
|
+
};
|
|
60
|
+
return this.recalcToolTipCoordinateByViewPort(blockBoundingRect, tooltipBoundingRect, coordinate, window.innerWidth, window.innerHeight);
|
|
61
|
+
}
|
|
62
|
+
static getTooltipLineAttributes(scaleKey, margin, key, chartOrientation, blockSize) {
|
|
63
|
+
const attributes = {
|
|
64
|
+
x1: 0, x2: 0, y1: 0, y2: 0
|
|
65
|
+
};
|
|
66
|
+
if (chartOrientation === 'vertical') {
|
|
67
|
+
attributes.x1 = Math.ceil(Scale.getScaledValue(scaleKey, key) + margin.left) - 0.5;
|
|
68
|
+
attributes.x2 = Math.ceil(Scale.getScaledValue(scaleKey, key) + margin.left) - 0.5;
|
|
69
|
+
attributes.y1 = margin.top - this.convexsize;
|
|
70
|
+
attributes.y2 = blockSize.height - margin.bottom + this.convexsize * 2;
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
attributes.x1 = margin.left - this.convexsize;
|
|
74
|
+
attributes.x2 = blockSize.width - margin.right + this.convexsize * 2;
|
|
75
|
+
attributes.y1 = Scale.getScaledValue(scaleKey, key) + margin.top;
|
|
76
|
+
attributes.y2 = Scale.getScaledValue(scaleKey, key) + margin.top;
|
|
77
|
+
}
|
|
78
|
+
return attributes;
|
|
79
|
+
}
|
|
80
|
+
static recalcToolTipCoordinateByViewPort(blockBounding, tooltipBounding, preCoordinate, winWidth, winHeight) {
|
|
81
|
+
const res = TooltipService.getTooltipByWindow(tooltipBounding, preCoordinate, {
|
|
82
|
+
width: winWidth,
|
|
83
|
+
height: winHeight
|
|
84
|
+
}, blockBounding);
|
|
85
|
+
return {
|
|
86
|
+
left: res.left + 'px',
|
|
87
|
+
top: res.top + 'px',
|
|
88
|
+
right: null,
|
|
89
|
+
bottom: null
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
TooltipHelper.convexsize = 5;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { AxisScale } from "d3-axis";
|
|
2
|
+
import { MdtChartsDataRow, Size } from "../../config/config";
|
|
3
|
+
import { BlockMargin, TwoDimensionalOptionsModel, PolarOptionsModel, DonutChartSettings } from "../../model/model";
|
|
4
|
+
import { Block } from "../block/block";
|
|
5
|
+
export declare type FilterCallback = (rows: MdtChartsDataRow[]) => void;
|
|
6
|
+
export interface SelectDetails {
|
|
7
|
+
multySelect: boolean;
|
|
8
|
+
keyValue?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare class FilterEventManager {
|
|
11
|
+
private callback;
|
|
12
|
+
private fullDataset;
|
|
13
|
+
private filterable;
|
|
14
|
+
private block;
|
|
15
|
+
private selectedKeys;
|
|
16
|
+
constructor(callback: FilterCallback, fullDataset: MdtChartsDataRow[], filtrable: boolean, keyFieldName: string, selectedIds?: number[]);
|
|
17
|
+
setBlock(block: Block): void;
|
|
18
|
+
getSelectedKeys(): string[];
|
|
19
|
+
updateData(newDataset: MdtChartsDataRow[]): void;
|
|
20
|
+
isSelected(keyValue: string): boolean;
|
|
21
|
+
clearKeysFor2D(options: TwoDimensionalOptionsModel): void;
|
|
22
|
+
clearKeysForPolar(margin: BlockMargin, blockSize: Size, options: PolarOptionsModel, donutSettings: DonutChartSettings): void;
|
|
23
|
+
private setKey;
|
|
24
|
+
private addId;
|
|
25
|
+
private removeId;
|
|
26
|
+
private processKey;
|
|
27
|
+
setListenerPolar(margin: BlockMargin, blockSize: Size, options: PolarOptionsModel, donutSettings: DonutChartSettings): void;
|
|
28
|
+
event2DUpdate(options: TwoDimensionalOptionsModel): void;
|
|
29
|
+
registerEventFor2D(scaleKey: AxisScale<any>, margin: BlockMargin, blockSize: Size, options: TwoDimensionalOptionsModel): void;
|
|
30
|
+
private registerEventToDonut;
|
|
31
|
+
private getMultyParamByEvent;
|
|
32
|
+
private getMultySelectParam;
|
|
33
|
+
}
|