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,97 @@
|
|
|
1
|
+
import { DomHelper } from '../../helpers/domHelper';
|
|
2
|
+
import { Legend } from '../legend/legend';
|
|
3
|
+
export class RecordOverflowAlert {
|
|
4
|
+
static render(block, hidedRecordsAmount, position, chartOrientation = null) {
|
|
5
|
+
const alertBlock = block.getWrapper()
|
|
6
|
+
.append('div')
|
|
7
|
+
.attr('class', this.blockClass)
|
|
8
|
+
.text(this.getAlertText(hidedRecordsAmount, chartOrientation));
|
|
9
|
+
const attrs = this.getBlockPositionAttrs(position, block);
|
|
10
|
+
this.setAlertPosition(alertBlock, attrs);
|
|
11
|
+
}
|
|
12
|
+
static update(block, hidedRecordsAmount, position, chartOrientation = null) {
|
|
13
|
+
let alertBlock = block.getWrapper()
|
|
14
|
+
.select(`div.${this.blockClass}`);
|
|
15
|
+
if (alertBlock.empty()) {
|
|
16
|
+
if (hidedRecordsAmount === 0)
|
|
17
|
+
return;
|
|
18
|
+
else
|
|
19
|
+
this.render(block, hidedRecordsAmount, position, chartOrientation);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
if (hidedRecordsAmount === 0)
|
|
23
|
+
alertBlock.remove();
|
|
24
|
+
else
|
|
25
|
+
alertBlock.text(this.getAlertText(hidedRecordsAmount, chartOrientation));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
static setAlertPosition(alertBlock, attrs) {
|
|
29
|
+
alertBlock
|
|
30
|
+
.style('position', 'absolute')
|
|
31
|
+
.style('left', attrs.left)
|
|
32
|
+
.style('right', attrs.right)
|
|
33
|
+
.style('top', attrs.top)
|
|
34
|
+
.style('bottom', attrs.bottom);
|
|
35
|
+
}
|
|
36
|
+
static getAlertText(hidedRecordsAmount, chartOrientation) {
|
|
37
|
+
return `+ ${hidedRecordsAmount} ${this.getWordTextEndingByAmount(hidedRecordsAmount, chartOrientation)}`;
|
|
38
|
+
}
|
|
39
|
+
static getWordTextEndingByAmount(hidedRecordsAmount, chartOrientation) {
|
|
40
|
+
const lastDigit = hidedRecordsAmount % 10;
|
|
41
|
+
if (chartOrientation === 'vertical') {
|
|
42
|
+
if (hidedRecordsAmount >= 10 && hidedRecordsAmount <= 20)
|
|
43
|
+
return 'столбцов';
|
|
44
|
+
if (lastDigit === 1)
|
|
45
|
+
return 'столбец';
|
|
46
|
+
if (lastDigit >= 2 && lastDigit <= 4)
|
|
47
|
+
return 'столбца';
|
|
48
|
+
return 'столбцов';
|
|
49
|
+
}
|
|
50
|
+
else if (chartOrientation === 'horizontal') {
|
|
51
|
+
if (hidedRecordsAmount >= 10 && hidedRecordsAmount <= 20)
|
|
52
|
+
return 'строк';
|
|
53
|
+
if (lastDigit === 1)
|
|
54
|
+
return 'строка';
|
|
55
|
+
if (lastDigit >= 2 && lastDigit <= 4)
|
|
56
|
+
return 'строки';
|
|
57
|
+
return 'строк';
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
if (hidedRecordsAmount >= 10 && hidedRecordsAmount <= 20)
|
|
61
|
+
return 'категорий';
|
|
62
|
+
if (lastDigit === 1)
|
|
63
|
+
return 'категория';
|
|
64
|
+
if (lastDigit >= 2 && lastDigit <= 4)
|
|
65
|
+
return 'категории';
|
|
66
|
+
return 'категорий';
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
static getBlockPositionAttrs(position, block) {
|
|
70
|
+
const attrs = {
|
|
71
|
+
bottom: null,
|
|
72
|
+
top: null,
|
|
73
|
+
right: null,
|
|
74
|
+
left: null
|
|
75
|
+
};
|
|
76
|
+
if (position === 'top') {
|
|
77
|
+
attrs.right = '17px';
|
|
78
|
+
attrs.top = '1rem';
|
|
79
|
+
}
|
|
80
|
+
if (position === 'right') {
|
|
81
|
+
attrs.bottom = '20px';
|
|
82
|
+
attrs.left = this.getLeftAttrForRightBlock(block) + 'px';
|
|
83
|
+
}
|
|
84
|
+
if (position === 'bottom') {
|
|
85
|
+
attrs.left = '20px';
|
|
86
|
+
attrs.bottom = '20px';
|
|
87
|
+
}
|
|
88
|
+
return attrs;
|
|
89
|
+
}
|
|
90
|
+
static getLeftAttrForRightBlock(block) {
|
|
91
|
+
const legendBlock = block.getSvg().select(`.${Legend.objectClass}`);
|
|
92
|
+
if (legendBlock.empty())
|
|
93
|
+
return null;
|
|
94
|
+
return DomHelper.getSelectionNumericAttr(legendBlock, 'x');
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
RecordOverflowAlert.blockClass = 'record-overflow-alert';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AxisScale } from 'd3-axis';
|
|
2
|
+
import { BarChartSettings, ScaleKeyModel, ScaleValueModel } from '../../../model/model';
|
|
3
|
+
export interface Scales {
|
|
4
|
+
key: AxisScale<any>;
|
|
5
|
+
value: AxisScale<any>;
|
|
6
|
+
}
|
|
7
|
+
export declare class Scale {
|
|
8
|
+
static getScales(scaleKey: ScaleKeyModel, scaleValue: ScaleValueModel, bandSettings: BarChartSettings): Scales;
|
|
9
|
+
static getScaleBandWidth(scale: AxisScale<any>): number;
|
|
10
|
+
static getScaleStep(scale: AxisScale<any>): number;
|
|
11
|
+
static getScaledValue(scale: AxisScale<any>, value: any): number;
|
|
12
|
+
private static getScaleBand;
|
|
13
|
+
private static getScaleLinear;
|
|
14
|
+
private static getScalePoint;
|
|
15
|
+
private static getScaleTime;
|
|
16
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { scaleBand, scaleLinear, scalePoint, scaleTime } from 'd3-scale';
|
|
2
|
+
export class Scale {
|
|
3
|
+
static getScales(scaleKey, scaleValue, bandSettings) {
|
|
4
|
+
const scales = {
|
|
5
|
+
key: null,
|
|
6
|
+
value: null
|
|
7
|
+
};
|
|
8
|
+
if (scaleKey.type === 'band')
|
|
9
|
+
scales.key = this.getScaleBand(scaleKey.domain, scaleKey.range, bandSettings, scaleKey.elementsAmount);
|
|
10
|
+
else if (scaleKey.type === 'point')
|
|
11
|
+
scales.key = this.getScalePoint(scaleKey.domain, scaleKey.range);
|
|
12
|
+
if (scaleValue.type === 'linear')
|
|
13
|
+
scales.value = this.getScaleLinear(scaleValue.domain, scaleValue.range);
|
|
14
|
+
else if (scaleValue.type === 'datetime')
|
|
15
|
+
scales.value = this.getScaleTime(scaleValue.domain, scaleValue.range);
|
|
16
|
+
return scales;
|
|
17
|
+
}
|
|
18
|
+
static getScaleBandWidth(scale) {
|
|
19
|
+
if (scale.bandwidth && scale.bandwidth() !== 0) {
|
|
20
|
+
return scale.bandwidth();
|
|
21
|
+
}
|
|
22
|
+
else if (scale.step) {
|
|
23
|
+
return scale.step();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
static getScaleStep(scale) {
|
|
27
|
+
if (scale.step) {
|
|
28
|
+
return scale.step();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
static getScaledValue(scale, value) {
|
|
32
|
+
if (scale.bandwidth && scale.bandwidth() !== 0) {
|
|
33
|
+
return scale(value) + this.getScaleBandWidth(scale) / 2;
|
|
34
|
+
}
|
|
35
|
+
return scale(value);
|
|
36
|
+
}
|
|
37
|
+
static getScaleBand(domain, range, bandSettings, elementsInGroupAmount) {
|
|
38
|
+
const scale = scaleBand()
|
|
39
|
+
.domain(domain)
|
|
40
|
+
.range([range.start, range.end]);
|
|
41
|
+
const bandSize = scale.bandwidth();
|
|
42
|
+
if (bandSettings.groupMinDistance < bandSize) {
|
|
43
|
+
scale.paddingInner(bandSettings.groupMinDistance / bandSize);
|
|
44
|
+
scale.paddingOuter(bandSettings.groupMinDistance / bandSize / 2);
|
|
45
|
+
}
|
|
46
|
+
// Padding inner = 10. If bandwidth more than needed, paddingInner is increased to number less than 35
|
|
47
|
+
let paddingInner = bandSettings.groupMinDistance;
|
|
48
|
+
while (scale.bandwidth() > bandSettings.maxBarWidth * elementsInGroupAmount + bandSettings.barDistance * (elementsInGroupAmount - 1) && paddingInner < bandSettings.groupMaxDistance) {
|
|
49
|
+
scale.paddingInner(++paddingInner / bandSize);
|
|
50
|
+
}
|
|
51
|
+
// if bandwidth more than all bars widths in group + distance between it + distance between groups
|
|
52
|
+
let paddingOuter = 1;
|
|
53
|
+
while (scale.step() > bandSettings.maxBarWidth * elementsInGroupAmount + bandSettings.groupMaxDistance + bandSettings.barDistance * (elementsInGroupAmount - 1)) {
|
|
54
|
+
scale.paddingOuter(++paddingOuter / bandSize);
|
|
55
|
+
}
|
|
56
|
+
return scale;
|
|
57
|
+
}
|
|
58
|
+
static getScaleLinear(domain, range) {
|
|
59
|
+
return scaleLinear()
|
|
60
|
+
.domain(domain)
|
|
61
|
+
.range([range.start, range.end]);
|
|
62
|
+
}
|
|
63
|
+
static getScalePoint(domain, range) {
|
|
64
|
+
return scalePoint()
|
|
65
|
+
.domain(domain)
|
|
66
|
+
.range([range.start, range.end]);
|
|
67
|
+
}
|
|
68
|
+
static getScaleTime(domain, range) {
|
|
69
|
+
return scaleTime()
|
|
70
|
+
.domain(domain)
|
|
71
|
+
.range([range.start, range.end])
|
|
72
|
+
.nice();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Selection } from 'd3-selection';
|
|
2
|
+
import { Block } from "../../block/block";
|
|
3
|
+
import { BlockMargin } from '../../../model/model';
|
|
4
|
+
import { Size } from "../../../config/config";
|
|
5
|
+
export declare class TipBox {
|
|
6
|
+
static readonly tipBoxClass = "tipbox";
|
|
7
|
+
static renderOrGet(block: Block, margin: BlockMargin, blockSize: Size): Selection<SVGRectElement, unknown, HTMLElement, any>;
|
|
8
|
+
static get(block: Block): Selection<SVGRectElement, unknown, HTMLElement, any>;
|
|
9
|
+
static clearEvents(block: Block): void;
|
|
10
|
+
private static renderBlock;
|
|
11
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { TipBoxHelper } from './tipBoxHelper';
|
|
2
|
+
export class TipBox {
|
|
3
|
+
static renderOrGet(block, margin, blockSize) {
|
|
4
|
+
const attributes = TipBoxHelper.getAttributes(margin, blockSize);
|
|
5
|
+
return this.renderBlock(block, attributes);
|
|
6
|
+
}
|
|
7
|
+
static get(block) {
|
|
8
|
+
return block.getSvg().select(`.${this.tipBoxClass}`);
|
|
9
|
+
}
|
|
10
|
+
static clearEvents(block) {
|
|
11
|
+
block.getSvg()
|
|
12
|
+
.select(`.${this.tipBoxClass}`)
|
|
13
|
+
.on('mousemove', null)
|
|
14
|
+
.on('mouseleave', null)
|
|
15
|
+
.on('click', null);
|
|
16
|
+
}
|
|
17
|
+
static renderBlock(block, attributes) {
|
|
18
|
+
let tipBox = block.getSvg()
|
|
19
|
+
.select(`rect.${this.tipBoxClass}`);
|
|
20
|
+
if (tipBox.empty())
|
|
21
|
+
tipBox = block.getSvg()
|
|
22
|
+
.append('rect')
|
|
23
|
+
.attr('class', this.tipBoxClass)
|
|
24
|
+
.attr('x', attributes.x)
|
|
25
|
+
.attr('y', attributes.y)
|
|
26
|
+
.attr('width', attributes.width)
|
|
27
|
+
.attr('height', attributes.height)
|
|
28
|
+
.style('opacity', 0);
|
|
29
|
+
return tipBox;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
TipBox.tipBoxClass = 'tipbox';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AxisScale } from "d3-axis";
|
|
2
|
+
import { ChartOrientation, Size } from "../../../config/config";
|
|
3
|
+
import { BlockMargin, ScaleKeyType } from "../../../model/model";
|
|
4
|
+
export interface TipBoxAttributes {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
}
|
|
10
|
+
export declare class TipBoxHelper {
|
|
11
|
+
static getKeyValueByPointer(pointer: [number, number], chartOrient: ChartOrientation, margin: BlockMargin, blockSize: Size, scaleKey: AxisScale<any>, scaleKeyType: ScaleKeyType): string;
|
|
12
|
+
static getAttributes(margin: BlockMargin, blockSize: Size): TipBoxAttributes;
|
|
13
|
+
private static getKeyIndex;
|
|
14
|
+
private static getKeyIndexOfPoint;
|
|
15
|
+
private static getKeyIndexOfBand;
|
|
16
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Scale } from "../scale/scale";
|
|
2
|
+
export class TipBoxHelper {
|
|
3
|
+
static getKeyValueByPointer(pointer, chartOrient, margin, blockSize, scaleKey, scaleKeyType) {
|
|
4
|
+
const index = TipBoxHelper.getKeyIndex(pointer, chartOrient, margin, blockSize, scaleKey, scaleKeyType);
|
|
5
|
+
let keyValue = scaleKey.domain()[index];
|
|
6
|
+
if (index >= scaleKey.domain().length)
|
|
7
|
+
keyValue = scaleKey.domain()[scaleKey.domain().length - 1];
|
|
8
|
+
return keyValue;
|
|
9
|
+
}
|
|
10
|
+
static getAttributes(margin, blockSize) {
|
|
11
|
+
const pad = 5;
|
|
12
|
+
return {
|
|
13
|
+
x: margin.left - pad,
|
|
14
|
+
y: margin.top - pad,
|
|
15
|
+
width: blockSize.width - margin.left - margin.right + pad * 2,
|
|
16
|
+
height: blockSize.height - margin.top - margin.bottom + pad * 2,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
static getKeyIndex(pointer, chartOrient, margin, blockSize, scaleKey, scaleKeyType) {
|
|
20
|
+
const pointerAxisType = chartOrient === 'vertical' ? 0 : 1; // 0 - координата поинтера по оси x, 1 - по оси y
|
|
21
|
+
const marginByOrient = chartOrient === 'vertical' ? margin.left : margin.top;
|
|
22
|
+
const scaleStep = Scale.getScaleStep(scaleKey);
|
|
23
|
+
if (scaleKeyType === 'point') {
|
|
24
|
+
return this.getKeyIndexOfPoint(pointer, scaleStep, marginByOrient, pointerAxisType);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
return this.getKeyIndexOfBand(pointer, scaleStep, marginByOrient, pointerAxisType, blockSize, margin, chartOrient, scaleKey);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
static getKeyIndexOfPoint(pointer, scaleStep, marginByOrient, pointerAxisType) {
|
|
31
|
+
const point = pointer[pointerAxisType] - marginByOrient + scaleStep / 2;
|
|
32
|
+
if (point < 0)
|
|
33
|
+
return 0;
|
|
34
|
+
return Math.floor(point / scaleStep);
|
|
35
|
+
}
|
|
36
|
+
static getKeyIndexOfBand(pointer, scaleStep, marginByOrient, pointerAxisType, blockSize, margin, chartOrient, scaleKey) {
|
|
37
|
+
const chartBlockSizeByDir = chartOrient === 'vertical'
|
|
38
|
+
? blockSize.width - margin.left - margin.right
|
|
39
|
+
: blockSize.height - margin.top - margin.bottom;
|
|
40
|
+
const outerPadding = chartBlockSizeByDir - scaleStep * scaleKey.domain().length;
|
|
41
|
+
if (pointer[pointerAxisType] - marginByOrient - 1 < outerPadding / 2)
|
|
42
|
+
return 0; // Самый первый элемент
|
|
43
|
+
if (pointer[pointerAxisType] - marginByOrient - 1 + outerPadding / 2 > chartBlockSizeByDir)
|
|
44
|
+
return scaleKey.domain().length - 1; // последний индекс
|
|
45
|
+
const point = pointer[pointerAxisType] - outerPadding / 2 - marginByOrient - 1;
|
|
46
|
+
return Math.floor(point / scaleStep);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Size } from '../../../config/config';
|
|
2
|
+
import { TitleBlockModel } from "../../../model/model";
|
|
3
|
+
import { Block } from "../../block/block";
|
|
4
|
+
export declare class Title {
|
|
5
|
+
static render(block: Block, text: string, titleBlockModel: TitleBlockModel, blockSize: Size): void;
|
|
6
|
+
private static fillTitleBlockAttributes;
|
|
7
|
+
private static getTitleAttributes;
|
|
8
|
+
private static setTitleTooltip;
|
|
9
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { DomHelper } from '../../helpers/domHelper';
|
|
2
|
+
export class Title {
|
|
3
|
+
static render(block, text, titleBlockModel, blockSize) {
|
|
4
|
+
const titleBlock = block.getSvg()
|
|
5
|
+
.append('text')
|
|
6
|
+
.attr('class', 'chart-title');
|
|
7
|
+
const titleCoordinate = this.getTitleAttributes(blockSize, titleBlockModel);
|
|
8
|
+
this.fillTitleBlockAttributes(titleBlock, titleCoordinate, text);
|
|
9
|
+
this.setTitleTooltip(titleBlock, text);
|
|
10
|
+
}
|
|
11
|
+
static fillTitleBlockAttributes(titleBlock, attributes, text) {
|
|
12
|
+
titleBlock
|
|
13
|
+
.attr('x', attributes.x)
|
|
14
|
+
.attr('y', attributes.y)
|
|
15
|
+
.attr('dominant-baseline', attributes.dominantBaseline)
|
|
16
|
+
.text(text);
|
|
17
|
+
DomHelper.cropSvgLabels(titleBlock, attributes.maxWidth);
|
|
18
|
+
}
|
|
19
|
+
static getTitleAttributes(blockSize, titleBlockModel) {
|
|
20
|
+
const coordinate = {
|
|
21
|
+
x: 0,
|
|
22
|
+
y: 0,
|
|
23
|
+
maxWidth: 0,
|
|
24
|
+
dominantBaseline: "hanging"
|
|
25
|
+
};
|
|
26
|
+
coordinate.x = titleBlockModel.margin.left;
|
|
27
|
+
coordinate.y = titleBlockModel.margin.top;
|
|
28
|
+
coordinate.maxWidth = blockSize.width - titleBlockModel.margin.left - titleBlockModel.margin.right;
|
|
29
|
+
return coordinate;
|
|
30
|
+
}
|
|
31
|
+
static setTitleTooltip(titleBlock, text) {
|
|
32
|
+
titleBlock.append('title')
|
|
33
|
+
.text(text);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Selection } from 'd3-selection';
|
|
2
|
+
export interface TooltipCoordinate {
|
|
3
|
+
left: string;
|
|
4
|
+
top: string;
|
|
5
|
+
right: string;
|
|
6
|
+
bottom: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class NewTooltip {
|
|
9
|
+
static tooltipBlockClass: string;
|
|
10
|
+
private elSelection;
|
|
11
|
+
getEl(): Selection<HTMLElement, unknown, HTMLElement, any>;
|
|
12
|
+
findInWrapper(wrapper: Selection<HTMLElement, unknown, HTMLElement, any>): Selection<HTMLElement, unknown, HTMLElement, any>;
|
|
13
|
+
render(wrapper: Selection<HTMLElement, unknown, HTMLElement, any>): Selection<HTMLElement, unknown, HTMLElement, any>;
|
|
14
|
+
appendContent(content: HTMLElement): void;
|
|
15
|
+
setCoordinate(coordinate: TooltipCoordinate): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export class NewTooltip {
|
|
2
|
+
getEl() {
|
|
3
|
+
return this.elSelection;
|
|
4
|
+
}
|
|
5
|
+
findInWrapper(wrapper) {
|
|
6
|
+
this.elSelection = wrapper.select(`.${NewTooltip.tooltipBlockClass}`);
|
|
7
|
+
return this.elSelection;
|
|
8
|
+
}
|
|
9
|
+
render(wrapper) {
|
|
10
|
+
this.elSelection = wrapper
|
|
11
|
+
.append('div')
|
|
12
|
+
.attr('class', NewTooltip.tooltipBlockClass);
|
|
13
|
+
return this.elSelection;
|
|
14
|
+
}
|
|
15
|
+
appendContent(content) {
|
|
16
|
+
this.elSelection.node().appendChild(content);
|
|
17
|
+
}
|
|
18
|
+
setCoordinate(coordinate) {
|
|
19
|
+
this.elSelection
|
|
20
|
+
.style('right', coordinate.right)
|
|
21
|
+
.style('bottom', coordinate.bottom)
|
|
22
|
+
.style('left', coordinate.left)
|
|
23
|
+
.style('top', coordinate.top);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
NewTooltip.tooltipBlockClass = 'tooltip-block';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { NewTooltipServiceClass } from "./newTooltipService";
|
|
2
|
+
const ignoredValue = 0;
|
|
3
|
+
const ignoredBigvalue = 1000000;
|
|
4
|
+
describe('newTooltipService', () => {
|
|
5
|
+
const getIgnoredSize = (big) => {
|
|
6
|
+
return {
|
|
7
|
+
height: big ? ignoredBigvalue : ignoredValue,
|
|
8
|
+
width: big ? ignoredBigvalue : ignoredValue
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
const getSizeWithOne = (key, value) => {
|
|
12
|
+
const size = getIgnoredSize();
|
|
13
|
+
size[key] = value;
|
|
14
|
+
return size;
|
|
15
|
+
};
|
|
16
|
+
const getPosWithOne = (key, value) => {
|
|
17
|
+
const coordinate = {
|
|
18
|
+
left: ignoredValue,
|
|
19
|
+
top: ignoredValue
|
|
20
|
+
};
|
|
21
|
+
coordinate[key] = value;
|
|
22
|
+
return coordinate;
|
|
23
|
+
};
|
|
24
|
+
const getBoundingWithOne = (key, value) => {
|
|
25
|
+
const blockBounding = {
|
|
26
|
+
left: ignoredValue,
|
|
27
|
+
bottom: ignoredValue,
|
|
28
|
+
height: ignoredValue,
|
|
29
|
+
top: ignoredValue,
|
|
30
|
+
width: ignoredValue
|
|
31
|
+
};
|
|
32
|
+
blockBounding[key] = value;
|
|
33
|
+
return blockBounding;
|
|
34
|
+
};
|
|
35
|
+
const service = new NewTooltipServiceClass();
|
|
36
|
+
describe('getTooltipByWindow with parentBlock', () => {
|
|
37
|
+
test('should return left point equal to `-(left of parent block)` if left of tooltip is less', () => {
|
|
38
|
+
const tooltipBounding = getIgnoredSize();
|
|
39
|
+
const preCoordinate = getPosWithOne("left", -50);
|
|
40
|
+
const windowSize = getIgnoredSize(true);
|
|
41
|
+
const blockBounding = getBoundingWithOne("left", 10);
|
|
42
|
+
const res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize, blockBounding);
|
|
43
|
+
expect(res.left).toBe(-blockBounding.left);
|
|
44
|
+
});
|
|
45
|
+
test('should return left point equal to left of preCoordinate if left of tooltip is less', () => {
|
|
46
|
+
const tooltipBounding = getIgnoredSize();
|
|
47
|
+
const preCoordinate = getPosWithOne("left", 20);
|
|
48
|
+
const windowSize = getIgnoredSize(true);
|
|
49
|
+
const blockBounding = getBoundingWithOne("left", 10);
|
|
50
|
+
const res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize, blockBounding);
|
|
51
|
+
expect(res.left).toBe(preCoordinate.left);
|
|
52
|
+
});
|
|
53
|
+
test('should return left point equal to `(window width - tooltip width)` if right of tooltip is bigger', () => {
|
|
54
|
+
const tooltipBounding = getSizeWithOne("width", 50);
|
|
55
|
+
const preCoordinate = getPosWithOne("left", 20);
|
|
56
|
+
const windowSize = getSizeWithOne("width", 90);
|
|
57
|
+
const blockBounding = getBoundingWithOne("left", 30);
|
|
58
|
+
const res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize, blockBounding);
|
|
59
|
+
expect(res.left).toBe(-8); // 50 + 20 + 30 > 90 => 90 - 30 - 50 - scrollPad(18)
|
|
60
|
+
});
|
|
61
|
+
test('should return left point equal to left of preCoordinate if right of tooltip is less than window width', () => {
|
|
62
|
+
const tooltipBounding = getSizeWithOne("width", 50);
|
|
63
|
+
const preCoordinate = getPosWithOne("left", 20);
|
|
64
|
+
const windowSize = getSizeWithOne("width", 200);
|
|
65
|
+
const blockBounding = getBoundingWithOne("left", 30);
|
|
66
|
+
const res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize, blockBounding);
|
|
67
|
+
expect(res.left).toBe(preCoordinate.left); // 50 + 20 + 30 < 200
|
|
68
|
+
});
|
|
69
|
+
test('should return top point equal to `-(top of parent block)` if top of tooltip is less', () => {
|
|
70
|
+
const tooltipBounding = getIgnoredSize();
|
|
71
|
+
const preCoordinate = getPosWithOne("top", -40);
|
|
72
|
+
const windowSize = getIgnoredSize(true);
|
|
73
|
+
const blockBounding = getBoundingWithOne("top", -20);
|
|
74
|
+
let res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize, blockBounding);
|
|
75
|
+
expect(res.top).toBe(-blockBounding.top);
|
|
76
|
+
blockBounding.top = -60;
|
|
77
|
+
res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize, blockBounding);
|
|
78
|
+
expect(res.top).toBe(-blockBounding.top); // 60 by blockBounding = 0 by window
|
|
79
|
+
blockBounding.top = -100;
|
|
80
|
+
preCoordinate.top = 20;
|
|
81
|
+
res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize, blockBounding);
|
|
82
|
+
expect(res.top).toBe(-blockBounding.top);
|
|
83
|
+
blockBounding.top = -10;
|
|
84
|
+
preCoordinate.top = 5;
|
|
85
|
+
res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize, blockBounding);
|
|
86
|
+
expect(res.top).toBe(-blockBounding.top);
|
|
87
|
+
});
|
|
88
|
+
test('should return top point equal top of preCoordinate if top of tooltip is bigger', () => {
|
|
89
|
+
const tooltipBounding = getIgnoredSize();
|
|
90
|
+
const preCoordinate = getPosWithOne("top", 20);
|
|
91
|
+
const windowSize = getIgnoredSize(true);
|
|
92
|
+
const blockBounding = getBoundingWithOne("top", 100);
|
|
93
|
+
let res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize, blockBounding);
|
|
94
|
+
expect(res.top).toBe(preCoordinate.top);
|
|
95
|
+
preCoordinate.top = -99;
|
|
96
|
+
res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize, blockBounding);
|
|
97
|
+
expect(res.top).toBe(preCoordinate.top);
|
|
98
|
+
});
|
|
99
|
+
test('should return top point equal to `(winHeight - tooltipHeight)` if bottom of tooltip is bigger than window height', () => {
|
|
100
|
+
const tooltipBounding = getSizeWithOne("height", 50);
|
|
101
|
+
const preCoordinate = getPosWithOne("top", 90);
|
|
102
|
+
const windowSize = getSizeWithOne("height", 200);
|
|
103
|
+
const blockBounding = {
|
|
104
|
+
left: ignoredValue,
|
|
105
|
+
bottom: 210,
|
|
106
|
+
height: 110,
|
|
107
|
+
top: 100,
|
|
108
|
+
width: ignoredValue
|
|
109
|
+
};
|
|
110
|
+
const res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize, blockBounding);
|
|
111
|
+
expect(res.top).toBe(50); // 110 - 50 - (210 - 200)
|
|
112
|
+
});
|
|
113
|
+
test('should return top point equal to top of preCoordinate if bottom of tooltip is less than height of window', () => {
|
|
114
|
+
const tooltipBounding = getSizeWithOne("height", 50);
|
|
115
|
+
const preCoordinate = getPosWithOne("top", 90);
|
|
116
|
+
const windowSize = getSizeWithOne("height", 300);
|
|
117
|
+
const blockBounding = {
|
|
118
|
+
left: ignoredValue,
|
|
119
|
+
bottom: 210,
|
|
120
|
+
height: 110,
|
|
121
|
+
top: 100,
|
|
122
|
+
width: ignoredValue
|
|
123
|
+
};
|
|
124
|
+
const res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize, blockBounding);
|
|
125
|
+
expect(res.top).toBe(preCoordinate.top); // 90 + 50 + 100 < 300
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
describe('getTooltipByWindow without parentBlock', () => {
|
|
129
|
+
test('should return left point equal to 0 if left of tooltip is less', () => {
|
|
130
|
+
const tooltipBounding = getIgnoredSize();
|
|
131
|
+
const preCoordinate = getPosWithOne("left", -50);
|
|
132
|
+
const windowSize = getIgnoredSize(true);
|
|
133
|
+
const res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize);
|
|
134
|
+
expect(res.left === 0).toBe(true); // negative zero jest not matching with simple zero
|
|
135
|
+
});
|
|
136
|
+
test('should return left point equal to left of preCoordinate if left of tooltip is bigger than 0', () => {
|
|
137
|
+
const tooltipBounding = getIgnoredSize();
|
|
138
|
+
const preCoordinate = getPosWithOne("left", 20);
|
|
139
|
+
const windowSize = getIgnoredSize(true);
|
|
140
|
+
const res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize);
|
|
141
|
+
expect(res.left).toBe(preCoordinate.left);
|
|
142
|
+
});
|
|
143
|
+
test('should return left point equal to `(window width - tooltip width)` if right of tooltip is bigger', () => {
|
|
144
|
+
const tooltipBounding = getSizeWithOne("width", 50);
|
|
145
|
+
const preCoordinate = getPosWithOne("left", 60);
|
|
146
|
+
const windowSize = getSizeWithOne("width", 100);
|
|
147
|
+
const res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize);
|
|
148
|
+
expect(res.left).toBe(32); // 60 + 50 > 100 => 100 - 50 - scrollPad(18)
|
|
149
|
+
});
|
|
150
|
+
test('should return left point equal to left of preCoordinate if right of tooltip is less than window width', () => {
|
|
151
|
+
const tooltipBounding = getSizeWithOne("width", 50);
|
|
152
|
+
const preCoordinate = getPosWithOne("left", 20);
|
|
153
|
+
const windowSize = getSizeWithOne("width", 200);
|
|
154
|
+
const res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize);
|
|
155
|
+
expect(res.left).toBe(preCoordinate.left); // 50 + 20 < 200
|
|
156
|
+
});
|
|
157
|
+
test('should return top point equal to 0 if top of tooltip is less than 0', () => {
|
|
158
|
+
const tooltipBounding = getIgnoredSize();
|
|
159
|
+
const preCoordinate = getPosWithOne("top", -40);
|
|
160
|
+
const windowSize = getIgnoredSize(true);
|
|
161
|
+
const res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize);
|
|
162
|
+
expect(res.top === 0).toBe(true);
|
|
163
|
+
});
|
|
164
|
+
test('should return top point equal top of preCoordinate if top of tooltip is bigger than 0', () => {
|
|
165
|
+
const tooltipBounding = getIgnoredSize();
|
|
166
|
+
const preCoordinate = getPosWithOne("top", 20);
|
|
167
|
+
const windowSize = getIgnoredSize(true);
|
|
168
|
+
const res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize);
|
|
169
|
+
expect(res.top).toBe(preCoordinate.top);
|
|
170
|
+
});
|
|
171
|
+
test('should return top point equal to `(winHeight - tooltipHeight)` if bottom of tooltip is bigger than window height', () => {
|
|
172
|
+
const tooltipBounding = getSizeWithOne("height", 50);
|
|
173
|
+
const preCoordinate = getPosWithOne("top", 90);
|
|
174
|
+
const windowSize = getSizeWithOne("height", 100);
|
|
175
|
+
const res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize);
|
|
176
|
+
expect(res.top).toBe(50); // 90 + 50 > 100 => 100 - 50
|
|
177
|
+
});
|
|
178
|
+
test('should return top point equal to top of preCoordinate if bottom of tooltip is less than height of window', () => {
|
|
179
|
+
const tooltipBounding = getSizeWithOne("height", 50);
|
|
180
|
+
const preCoordinate = getPosWithOne("top", 90);
|
|
181
|
+
const windowSize = getSizeWithOne("height", 300);
|
|
182
|
+
const res = service.getTooltipByWindow(tooltipBounding, preCoordinate, windowSize);
|
|
183
|
+
expect(res.top).toBe(preCoordinate.top); // 90 + 50 < 300
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface TooltipPreCoordinate {
|
|
2
|
+
top: number;
|
|
3
|
+
left: number;
|
|
4
|
+
}
|
|
5
|
+
export interface Sizable {
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
}
|
|
9
|
+
export interface ElBounding extends Sizable {
|
|
10
|
+
left: number;
|
|
11
|
+
top: number;
|
|
12
|
+
bottom: number;
|
|
13
|
+
}
|
|
14
|
+
export declare class NewTooltipServiceClass {
|
|
15
|
+
getTooltipByWindow(tooltipBounding: Sizable, preCoordinate: TooltipPreCoordinate, windowSize: Sizable, parentBounding?: ElBounding): TooltipPreCoordinate;
|
|
16
|
+
}
|
|
17
|
+
export declare const TooltipService: NewTooltipServiceClass;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export class NewTooltipServiceClass {
|
|
2
|
+
getTooltipByWindow(tooltipBounding, preCoordinate, windowSize, parentBounding) {
|
|
3
|
+
const scrollPad = 18;
|
|
4
|
+
const coordinate = {
|
|
5
|
+
top: preCoordinate.top,
|
|
6
|
+
left: preCoordinate.left
|
|
7
|
+
};
|
|
8
|
+
const blockBounding = parentBounding !== null && parentBounding !== void 0 ? parentBounding : {
|
|
9
|
+
top: 0,
|
|
10
|
+
left: 0,
|
|
11
|
+
height: windowSize.height,
|
|
12
|
+
width: windowSize.width,
|
|
13
|
+
bottom: windowSize.height
|
|
14
|
+
};
|
|
15
|
+
if (preCoordinate.left < 0 && Math.abs(preCoordinate.left) > blockBounding.left)
|
|
16
|
+
coordinate.left = -blockBounding.left;
|
|
17
|
+
if (blockBounding.left + preCoordinate.left + tooltipBounding.width > windowSize.width - scrollPad)
|
|
18
|
+
coordinate.left = windowSize.width - blockBounding.left - tooltipBounding.width - scrollPad;
|
|
19
|
+
if (preCoordinate.top + blockBounding.top < 0 && -preCoordinate.top > blockBounding.top)
|
|
20
|
+
coordinate.top = -blockBounding.top;
|
|
21
|
+
if (blockBounding.top + preCoordinate.top + tooltipBounding.height > windowSize.height)
|
|
22
|
+
coordinate.top = blockBounding.height - tooltipBounding.height - (blockBounding.bottom - windowSize.height);
|
|
23
|
+
return coordinate;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export const TooltipService = new NewTooltipServiceClass();
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Model } from "../../../model/model";
|
|
2
|
+
import { Block } from "../../block/block";
|
|
3
|
+
import { MdtChartsDataSource } from "../../../config/config";
|
|
4
|
+
import { Scales } from '../scale/scale';
|
|
5
|
+
import { TooltipSettings } from '../../../designer/designerConfig';
|
|
6
|
+
export declare class Tooltip {
|
|
7
|
+
static readonly tooltipBlockClass: string;
|
|
8
|
+
static readonly tooltipLineClass = "tooltip-line";
|
|
9
|
+
static readonly tooltipWrapperClass = "tooltip-wrapper";
|
|
10
|
+
static readonly tooltipContentClass = "tooltip-content";
|
|
11
|
+
static readonly tooltipArrowClass = "tooltip-arrow";
|
|
12
|
+
static render(block: Block, model: Model, data: MdtChartsDataSource, tooltipOptions: TooltipSettings, scales?: Scales): void;
|
|
13
|
+
static hide(block: Block): void;
|
|
14
|
+
private static renderTooltipFor2DCharts;
|
|
15
|
+
private static renderTooltipForIntervalCharts;
|
|
16
|
+
private static renderTooltipForPolar;
|
|
17
|
+
private static renderLineTooltip;
|
|
18
|
+
private static renderTooltipForDonut;
|
|
19
|
+
}
|