mdt-charts 1.37.3 → 1.38.1
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 +5 -3
- package/lib/engine/features/tolltip/tooltip.js +1 -3
- package/lib/engine/features/valueLabels/valueLabelsHelper.js +2 -2
- package/lib/model/featuresModel/valueLabelsModel/valueLabelsModel.d.ts +1 -1
- package/lib/model/featuresModel/valueLabelsModel/valueLabelsModel.js +14 -7
- package/lib/model/model.d.ts +1 -1
- package/lib/model/notations/twoDimensionalModel.js +3 -3
- package/package.json +1 -1
package/lib/config/config.d.ts
CHANGED
|
@@ -334,11 +334,13 @@ export interface TwoDimensionalChartData {
|
|
|
334
334
|
valueFields: TwoDimValueField[];
|
|
335
335
|
valueGroup?: TwoDimensionalValueGroup;
|
|
336
336
|
}
|
|
337
|
-
export
|
|
338
|
-
mode: "afterHead" | "beforeHead";
|
|
337
|
+
export interface ValueLabelsWithOffsetOptions {
|
|
339
338
|
/** @default 10 */
|
|
340
339
|
offsetSize?: number;
|
|
341
|
-
}
|
|
340
|
+
}
|
|
341
|
+
export declare type ValueLabelsPositionOptions = ({
|
|
342
|
+
mode?: "afterHead" | "beforeHead" | "afterStart";
|
|
343
|
+
} & ValueLabelsWithOffsetOptions) | {
|
|
342
344
|
mode?: "center";
|
|
343
345
|
};
|
|
344
346
|
export declare type ValueLabelsPositionMode = ValueLabelsPositionOptions["mode"];
|
|
@@ -115,9 +115,7 @@ export class Tooltip {
|
|
|
115
115
|
tooltipArrow = TooltipComponentsManager.renderTooltipArrow(tooltipBlock.getEl());
|
|
116
116
|
if (tooltipSettings.position === "followCursor") {
|
|
117
117
|
elements.on("mousemove", function (e) {
|
|
118
|
-
const pointerCoordinate =
|
|
119
|
-
? e.detail.pointer
|
|
120
|
-
: pointer(e, block.getSvg().node());
|
|
118
|
+
const pointerCoordinate = e instanceof CustomEvent ? e.detail.pointer : pointer(e, block.getSvg().node());
|
|
121
119
|
const tooltipCoordinate = TooltipHelper.getTooltipCursorCoordinate(pointerCoordinate, block.getSvg().node().getBoundingClientRect(), tooltipBlock.getEl().node().getBoundingClientRect());
|
|
122
120
|
tooltipBlock.setCoordinate(tooltipCoordinate);
|
|
123
121
|
});
|
|
@@ -8,12 +8,12 @@ export class ValueLabelsAttrsProvider {
|
|
|
8
8
|
};
|
|
9
9
|
const orient = globalOptions.canvas.keyAxisOrient;
|
|
10
10
|
if (orient === "left" || orient === "right") {
|
|
11
|
-
attrs.x = (d) => valueLabels.handleX(scales.value(valueLabels.
|
|
11
|
+
attrs.x = (d) => valueLabels.handleX(scales.value(valueLabels.handleValueBeforeScale(d, datumField)), fieldIndexInChart);
|
|
12
12
|
attrs.y = (d) => valueLabels.handleY(scales.key(dataRowAccessor(d)[globalOptions.data.keyFieldName]), fieldIndexInChart);
|
|
13
13
|
}
|
|
14
14
|
else if (orient === "bottom" || orient === "top") {
|
|
15
15
|
attrs.x = (d) => valueLabels.handleX(scales.key(dataRowAccessor(d)[globalOptions.data.keyFieldName]), fieldIndexInChart);
|
|
16
|
-
attrs.y = (d) => valueLabels.handleY(scales.value(valueLabels.
|
|
16
|
+
attrs.y = (d) => valueLabels.handleY(scales.value(valueLabels.handleValueBeforeScale(d, datumField)), fieldIndexInChart);
|
|
17
17
|
}
|
|
18
18
|
return attrs;
|
|
19
19
|
}
|
|
@@ -19,7 +19,7 @@ export declare class ValueLabelCoordinateCalculator {
|
|
|
19
19
|
private getOverrideFieldIndex;
|
|
20
20
|
}
|
|
21
21
|
export declare function calculateValueLabelAlignment(keyAxisOrient: Orient, positionMode?: ValueLabelsPositionMode, rotation?: ValueLabelsRotationOptions): ValueLabelAlignment;
|
|
22
|
-
export declare function
|
|
22
|
+
export declare function handleValueBeforeScale(dataRow: MdtChartsDataRow, datumField: string, isSegmented: boolean, positionMode?: ValueLabelsPositionMode): number;
|
|
23
23
|
export declare function hasCollisionLeftSide(labelClientRect: BoundingRect, margin: BlockMargin): boolean;
|
|
24
24
|
export declare function hasCollisionRightSide(labelClientRect: BoundingRect, blockSize: Size, margin: BlockMargin): boolean;
|
|
25
25
|
export declare function hasCollisionTopSide(labelClientRect: BoundingRect, margin: BlockMargin): boolean;
|
|
@@ -7,10 +7,13 @@ export class ValueLabelCoordinateCalculator {
|
|
|
7
7
|
this.isSegmented = isSegmented;
|
|
8
8
|
this.shiftCoordinateByKeyScale = shiftCoordinateByKeyScale;
|
|
9
9
|
let offsetAbsSize = VALUE_LABEL_OFFSET_ABS_SIZE_PX;
|
|
10
|
-
if (((positionOptions === null || positionOptions === void 0 ? void 0 : positionOptions.mode)
|
|
10
|
+
if ((!(positionOptions === null || positionOptions === void 0 ? void 0 : positionOptions.mode) ||
|
|
11
|
+
(positionOptions === null || positionOptions === void 0 ? void 0 : positionOptions.mode) === "beforeHead" ||
|
|
12
|
+
(positionOptions === null || positionOptions === void 0 ? void 0 : positionOptions.mode) === "afterHead" ||
|
|
13
|
+
(positionOptions === null || positionOptions === void 0 ? void 0 : positionOptions.mode) === "afterStart") &&
|
|
11
14
|
(positionOptions === null || positionOptions === void 0 ? void 0 : positionOptions.offsetSize) != null)
|
|
12
|
-
offsetAbsSize = positionOptions
|
|
13
|
-
if (!(positionOptions === null || positionOptions === void 0 ? void 0 : positionOptions.mode) || positionOptions.mode === "afterHead")
|
|
15
|
+
offsetAbsSize = positionOptions.offsetSize;
|
|
16
|
+
if (!(positionOptions === null || positionOptions === void 0 ? void 0 : positionOptions.mode) || positionOptions.mode === "afterHead" || positionOptions.mode === "afterStart")
|
|
14
17
|
this.offsetSizePx = offsetAbsSize;
|
|
15
18
|
else if (positionOptions.mode === "beforeHead")
|
|
16
19
|
this.offsetSizePx = -offsetAbsSize;
|
|
@@ -44,7 +47,7 @@ export class ValueLabelCoordinateCalculator {
|
|
|
44
47
|
export function calculateValueLabelAlignment(keyAxisOrient, positionMode, rotation) {
|
|
45
48
|
if (rotation === null || rotation === void 0 ? void 0 : rotation.angle)
|
|
46
49
|
return { dominantBaseline: "middle", textAnchor: "middle" };
|
|
47
|
-
if (!positionMode || positionMode === "afterHead") {
|
|
50
|
+
if (!positionMode || positionMode === "afterHead" || positionMode === "afterStart") {
|
|
48
51
|
switch (keyAxisOrient) {
|
|
49
52
|
case "top":
|
|
50
53
|
return { dominantBaseline: "hanging", textAnchor: "middle" };
|
|
@@ -70,14 +73,18 @@ export function calculateValueLabelAlignment(keyAxisOrient, positionMode, rotati
|
|
|
70
73
|
}
|
|
71
74
|
return { dominantBaseline: "middle", textAnchor: "middle" };
|
|
72
75
|
}
|
|
73
|
-
export function
|
|
76
|
+
export function handleValueBeforeScale(dataRow, datumField, isSegmented, positionMode) {
|
|
74
77
|
if (!positionMode || positionMode === "afterHead" || positionMode === "beforeHead")
|
|
75
78
|
return dataRow[datumField];
|
|
76
79
|
if (positionMode === "center") {
|
|
77
80
|
if (isSegmented)
|
|
78
81
|
return dataRow[datumField] - (dataRow[datumField] - dataRow["0"]) / 2;
|
|
79
|
-
|
|
80
|
-
|
|
82
|
+
return dataRow[datumField] / 2;
|
|
83
|
+
}
|
|
84
|
+
if (positionMode === "afterStart") {
|
|
85
|
+
if (isSegmented)
|
|
86
|
+
return dataRow["0"];
|
|
87
|
+
return 0;
|
|
81
88
|
}
|
|
82
89
|
throw new Error("Invalid position mode");
|
|
83
90
|
}
|
package/lib/model/model.d.ts
CHANGED
|
@@ -474,7 +474,7 @@ export interface TwoDimChartValueLabelsOptions {
|
|
|
474
474
|
forFields: MdtChartsFieldName[];
|
|
475
475
|
dominantBaseline: DominantBaseline;
|
|
476
476
|
setContent: ValueLabelsInnerContentSetter;
|
|
477
|
-
|
|
477
|
+
handleValueBeforeScale: (dataRow: MdtChartsDataRow, datumField: string) => number;
|
|
478
478
|
rotation?: ValueLabelsRotationOptions;
|
|
479
479
|
handleElement?: ValueLabelsHandleElement;
|
|
480
480
|
}
|
|
@@ -4,7 +4,7 @@ import { AxisModel } from "../featuresModel/axis/axisModel";
|
|
|
4
4
|
import { ScaleAxisRecalcer } from "../featuresModel/scaleModel/scaleAxisRecalcer";
|
|
5
5
|
import { ScaleModel } from "../featuresModel/scaleModel/scaleModel";
|
|
6
6
|
import { calculateBarIndexes, getAreaViewOptions, getBarsAmount, getBarViewOptions, getLegendMarkerOptions, LINE_CHART_DEFAULT_WIDTH, parseDashStyles, parseShape } from "./twoDimensional/styles";
|
|
7
|
-
import { calculateValueLabelAlignment,
|
|
7
|
+
import { calculateValueLabelAlignment, handleValueBeforeScale, ValueLabelCoordinateCalculator } from "../../model/featuresModel/valueLabelsModel/valueLabelsModel";
|
|
8
8
|
import { TwoDimensionalModelHelper } from "../helpers/twoDimensionalModelHelper";
|
|
9
9
|
import { TitleConfigReader } from "../modelInstance/titleConfigReader";
|
|
10
10
|
import { createRecordOverflowModel } from "../featuresModel/recordOverflowModel/recordOverflowModel";
|
|
@@ -236,9 +236,9 @@ export class TwoDimensionalModel {
|
|
|
236
236
|
},
|
|
237
237
|
handleX: (scaledValue, fieldIndex) => valueLabelsCoordinateCalculator.getValueLabelX(scaledValue, fieldIndex),
|
|
238
238
|
handleY: (scaledValue, fieldIndex) => valueLabelsCoordinateCalculator.getValueLabelY(scaledValue, fieldIndex),
|
|
239
|
-
|
|
239
|
+
handleValueBeforeScale: (dataRow, datumField) => {
|
|
240
240
|
var _a, _b;
|
|
241
|
-
return
|
|
241
|
+
return handleValueBeforeScale(dataRow, datumField, chart.isSegmented, (_b = (_a = chart.valueLabels) === null || _a === void 0 ? void 0 : _a.position) === null || _b === void 0 ? void 0 : _b.mode);
|
|
242
242
|
},
|
|
243
243
|
textAnchor: valueLabelsAlignment.textAnchor,
|
|
244
244
|
dominantBaseline: valueLabelsAlignment.dominantBaseline,
|