mdt-charts 1.31.0 → 1.33.0
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 +18 -4
- package/lib/engine/features/valueLabels/valueLabels.js +30 -9
- package/lib/model/featuresModel/valueLabelsModel/valueLabelsModel.d.ts +4 -3
- package/lib/model/featuresModel/valueLabelsModel/valueLabelsModel.js +38 -6
- package/lib/model/margin/twoDim/twoDimMarginModel.js +2 -2
- package/lib/model/model.d.ts +10 -2
- package/lib/model/modelInstance/configReader.js +1 -1
- package/lib/model/notations/twoDimensionalModel.js +27 -21
- package/lib/style/charts-main.css +1 -1
- package/lib/style/charts-main.less +1 -1
- package/package.json +2 -3
package/lib/config/config.d.ts
CHANGED
|
@@ -294,15 +294,29 @@ export interface TwoDimensionalChartData {
|
|
|
294
294
|
valueFields: TwoDimValueField[];
|
|
295
295
|
valueGroup?: TwoDimensionalValueGroup;
|
|
296
296
|
}
|
|
297
|
-
export declare type
|
|
297
|
+
export declare type ValueLabelsPositionOptions = {
|
|
298
|
+
mode: "afterHead" | "beforeHead";
|
|
299
|
+
/** @default 10 */
|
|
300
|
+
offsetSize?: number;
|
|
301
|
+
} | {
|
|
302
|
+
mode?: "center";
|
|
303
|
+
};
|
|
304
|
+
export declare type ValueLabelsPositionMode = ValueLabelsPositionOptions["mode"];
|
|
305
|
+
export interface ValueLabelsContentSetterOptions {
|
|
306
|
+
dataRow: MdtChartsDataRow;
|
|
307
|
+
field: MdtChartsValueField;
|
|
308
|
+
}
|
|
309
|
+
export declare type ValueLabelsContentSetter = (options: ValueLabelsContentSetterOptions) => {
|
|
310
|
+
textContent: string | number;
|
|
311
|
+
};
|
|
298
312
|
export interface TwoDimensionalChartValueLabels {
|
|
299
313
|
on: boolean;
|
|
300
|
-
position?:
|
|
301
|
-
mode?: ValueLabelsPositionMode;
|
|
302
|
-
};
|
|
314
|
+
position?: ValueLabelsPositionOptions;
|
|
303
315
|
format?: ValueLabelsFormatter;
|
|
304
316
|
rotation?: ValueLabelsRotationOptions;
|
|
305
317
|
handleElement?: ValueLabelsHandleElement;
|
|
318
|
+
renderForFields?: MdtChartsFieldName[];
|
|
319
|
+
setContent?: ValueLabelsContentSetter;
|
|
306
320
|
}
|
|
307
321
|
export declare type ValueLabelsHandleElement = (elInfo: {
|
|
308
322
|
element: SVGTextElement;
|
|
@@ -24,14 +24,18 @@ export class ChartValueLabels {
|
|
|
24
24
|
render(scales, data) {
|
|
25
25
|
if (this.chart.isSegmented) {
|
|
26
26
|
const preparedData = getStackedData(data, this.chart);
|
|
27
|
-
preparedData
|
|
27
|
+
preparedData
|
|
28
|
+
.filter((segment) => { var _a; return this.options.forFields.includes((_a = segment[0]) === null || _a === void 0 ? void 0 : _a.fieldName); })
|
|
29
|
+
.forEach((segment, segmentIndex) => {
|
|
28
30
|
if (!segment[0])
|
|
29
31
|
return;
|
|
30
32
|
this.renderByGroupIndex(scales, segmentIndex, segment, segment[0].fieldName, "1", (d) => d.data);
|
|
31
33
|
});
|
|
32
34
|
}
|
|
33
35
|
else {
|
|
34
|
-
this.chart.data.valueFields
|
|
36
|
+
this.chart.data.valueFields
|
|
37
|
+
.filter((field) => this.options.forFields.includes(field.name))
|
|
38
|
+
.forEach((valueField, vfIndex) => {
|
|
35
39
|
this.renderByGroupIndex(scales, vfIndex, data, valueField.name, valueField.name, (d) => d);
|
|
36
40
|
});
|
|
37
41
|
}
|
|
@@ -41,14 +45,18 @@ export class ChartValueLabels {
|
|
|
41
45
|
this.options = updatedOptions;
|
|
42
46
|
if (this.chart.isSegmented) {
|
|
43
47
|
const preparedData = getStackedData(newData, this.chart);
|
|
44
|
-
preparedData
|
|
48
|
+
preparedData
|
|
49
|
+
.filter((segment) => { var _a; return this.options.forFields.includes((_a = segment[0]) === null || _a === void 0 ? void 0 : _a.fieldName); })
|
|
50
|
+
.forEach((segment, segmentIndex) => {
|
|
45
51
|
var _a;
|
|
46
52
|
const promise = this.updateByGroupIndex(scales, segmentIndex, segment, "1", (d) => d.data, (_a = segment[0]) === null || _a === void 0 ? void 0 : _a.fieldName);
|
|
47
53
|
updatePromises.push(promise);
|
|
48
54
|
});
|
|
49
55
|
}
|
|
50
56
|
else {
|
|
51
|
-
this.chart.data.valueFields
|
|
57
|
+
this.chart.data.valueFields
|
|
58
|
+
.filter((field) => this.options.forFields.includes(field.name))
|
|
59
|
+
.forEach((valueField, vfIndex) => {
|
|
52
60
|
const promise = this.updateByGroupIndex(scales, vfIndex, newData, valueField.name, (d) => d, valueField.name);
|
|
53
61
|
updatePromises.push(promise);
|
|
54
62
|
});
|
|
@@ -59,7 +67,7 @@ export class ChartValueLabels {
|
|
|
59
67
|
let valueLabels = this.getAllValueLabelsOfChart(groupIndex).data(data).enter().append("text");
|
|
60
68
|
valueLabels = this.renderPipeline.execute(valueLabels, { style: this.globalOptions.canvas.style });
|
|
61
69
|
const attrs = this.attrsProvider.getAttrs(this.globalOptions, this.options, scales, datumField, dataRowAccessor);
|
|
62
|
-
this.setAttrs(valueLabels, attrs, valueFieldName, this.options.
|
|
70
|
+
this.setAttrs(valueLabels, attrs, valueFieldName, this.options.setContent, dataRowAccessor);
|
|
63
71
|
this.setClasses(valueLabels, this.chart.cssClasses, groupIndex);
|
|
64
72
|
}
|
|
65
73
|
updateByGroupIndex(scales, groupIndex, data, datumField, dataRowAccessor, valueFieldName) {
|
|
@@ -74,21 +82,34 @@ export class ChartValueLabels {
|
|
|
74
82
|
let newValueLabels = valueLabels.enter().append("text");
|
|
75
83
|
newValueLabels = this.renderPipeline.execute(newValueLabels, { style: this.globalOptions.canvas.style });
|
|
76
84
|
const mergedValueLabels = newValueLabels.merge(valueLabels);
|
|
77
|
-
this.setAttrs(newValueLabels, attrs, valueFieldName, this.options.
|
|
85
|
+
this.setAttrs(newValueLabels, attrs, valueFieldName, this.options.setContent, dataRowAccessor);
|
|
78
86
|
this.setClasses(mergedValueLabels, this.chart.cssClasses, groupIndex);
|
|
79
|
-
this.setAttrs(valueLabels, attrs, valueFieldName, this.options.
|
|
87
|
+
this.setAttrs(valueLabels, attrs, valueFieldName, this.options.setContent, dataRowAccessor, true, resolve);
|
|
80
88
|
});
|
|
81
89
|
}
|
|
82
90
|
getAllValueLabelsOfChart(vfIndex) {
|
|
83
91
|
const block = this.globalOptions.elementAccessors.getBlock().svg.getChartBlock();
|
|
84
92
|
return block.selectAll(`.${ChartValueLabels.valueLabelClass}.${CLASSES.dataLabel}${Helper.getCssClassesLine(this.chart.cssClasses)}.chart-element-${vfIndex}`);
|
|
85
93
|
}
|
|
86
|
-
setAttrs(valueLabels, attrs, valueFieldName,
|
|
94
|
+
setAttrs(valueLabels, attrs, valueFieldName, setContent, dataRowAccessor, animate = false, onEndAnimation) {
|
|
87
95
|
const animationName = "labels-updating";
|
|
88
96
|
let selection = valueLabels
|
|
89
|
-
.text((d) => formatter(dataRowAccessor(d)[valueFieldName]))
|
|
90
97
|
.attr("dominant-baseline", attrs.dominantBaseline)
|
|
91
98
|
.attr("text-anchor", attrs.textAnchor);
|
|
99
|
+
selection.each(function (d) {
|
|
100
|
+
select(this).selectAll("tspan").remove();
|
|
101
|
+
const content = setContent({ dataRow: dataRowAccessor(d), fieldName: valueFieldName });
|
|
102
|
+
content.rows.forEach((row, rowIndex) => {
|
|
103
|
+
const tspan = document.createElementNS("http://www.w3.org/2000/svg", "tspan");
|
|
104
|
+
// Pass empty string to count this element for correct working of dy
|
|
105
|
+
// https://stackoverflow.com/questions/34078357/empty-tspan-not-rendered-dy-value-ignored
|
|
106
|
+
tspan.textContent = row.toString() || " ";
|
|
107
|
+
if (rowIndex !== 0)
|
|
108
|
+
tspan.setAttribute("dy", `1em`);
|
|
109
|
+
tspan.setAttribute("x", attrs.x(d).toString());
|
|
110
|
+
this.appendChild(tspan);
|
|
111
|
+
});
|
|
112
|
+
});
|
|
92
113
|
if (animate) {
|
|
93
114
|
selection = selection
|
|
94
115
|
.interrupt(animationName)
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import { BlockMargin, Orient, ValueLabelAnchor, ValueLabelDominantBaseline } from "../../model";
|
|
2
2
|
import { BoundingRect } from "../../../engine/features/valueLabelsCollision/valueLabelsCollision";
|
|
3
|
-
import { Size, ValueLabelsPositionMode, ValueLabelsRotationOptions } from "../../../config/config";
|
|
3
|
+
import { MdtChartsDataRow, Size, ValueLabelsPositionMode, ValueLabelsPositionOptions, ValueLabelsRotationOptions } from "../../../config/config";
|
|
4
4
|
interface ValueLabelAlignment {
|
|
5
5
|
dominantBaseline: ValueLabelDominantBaseline;
|
|
6
6
|
textAnchor: ValueLabelAnchor;
|
|
7
7
|
}
|
|
8
|
-
export declare const
|
|
8
|
+
export declare const VALUE_LABEL_OFFSET_ABS_SIZE_PX = 10;
|
|
9
9
|
export declare const BORDER_OFFSET_SIZE_PX = 2;
|
|
10
10
|
export declare class ValueLabelCoordinateCalculator {
|
|
11
11
|
private readonly keyAxisOrient;
|
|
12
12
|
private readonly margin;
|
|
13
13
|
private readonly offsetSizePx;
|
|
14
|
-
constructor(
|
|
14
|
+
constructor(positionOptions: ValueLabelsPositionOptions | undefined, keyAxisOrient: Orient, margin: BlockMargin);
|
|
15
15
|
getValueLabelY(scaledValue: number): number;
|
|
16
16
|
getValueLabelX(scaledValue: number): number;
|
|
17
17
|
}
|
|
18
18
|
export declare function calculateValueLabelAlignment(keyAxisOrient: Orient, positionMode?: ValueLabelsPositionMode, rotation?: ValueLabelsRotationOptions): ValueLabelAlignment;
|
|
19
|
+
export declare function handleScaledValue(dataRow: MdtChartsDataRow, datumField: string, isSegmented: boolean, positionMode?: ValueLabelsPositionMode): number;
|
|
19
20
|
export declare function hasCollisionLeftSide(labelClientRect: BoundingRect, margin: BlockMargin): boolean;
|
|
20
21
|
export declare function hasCollisionRightSide(labelClientRect: BoundingRect, blockSize: Size, margin: BlockMargin): boolean;
|
|
21
22
|
export declare function hasCollisionTopSide(labelClientRect: BoundingRect, margin: BlockMargin): boolean;
|
|
@@ -1,10 +1,19 @@
|
|
|
1
|
-
export const
|
|
1
|
+
export const VALUE_LABEL_OFFSET_ABS_SIZE_PX = 10;
|
|
2
2
|
export const BORDER_OFFSET_SIZE_PX = 2;
|
|
3
3
|
export class ValueLabelCoordinateCalculator {
|
|
4
|
-
constructor(
|
|
4
|
+
constructor(positionOptions, keyAxisOrient, margin) {
|
|
5
5
|
this.keyAxisOrient = keyAxisOrient;
|
|
6
6
|
this.margin = margin;
|
|
7
|
-
|
|
7
|
+
let offsetAbsSize = VALUE_LABEL_OFFSET_ABS_SIZE_PX;
|
|
8
|
+
if (((positionOptions === null || positionOptions === void 0 ? void 0 : positionOptions.mode) === "beforeHead" || (positionOptions === null || positionOptions === void 0 ? void 0 : positionOptions.mode) === "afterHead") &&
|
|
9
|
+
(positionOptions === null || positionOptions === void 0 ? void 0 : positionOptions.offsetSize) != null)
|
|
10
|
+
offsetAbsSize = positionOptions === null || positionOptions === void 0 ? void 0 : positionOptions.offsetSize;
|
|
11
|
+
if (!(positionOptions === null || positionOptions === void 0 ? void 0 : positionOptions.mode) || positionOptions.mode === "afterHead")
|
|
12
|
+
this.offsetSizePx = offsetAbsSize;
|
|
13
|
+
else if (positionOptions.mode === "beforeHead")
|
|
14
|
+
this.offsetSizePx = -offsetAbsSize;
|
|
15
|
+
else
|
|
16
|
+
this.offsetSizePx = 0;
|
|
8
17
|
}
|
|
9
18
|
getValueLabelY(scaledValue) {
|
|
10
19
|
switch (this.keyAxisOrient) {
|
|
@@ -28,7 +37,9 @@ export class ValueLabelCoordinateCalculator {
|
|
|
28
37
|
}
|
|
29
38
|
}
|
|
30
39
|
export function calculateValueLabelAlignment(keyAxisOrient, positionMode, rotation) {
|
|
31
|
-
if (
|
|
40
|
+
if (rotation === null || rotation === void 0 ? void 0 : rotation.angle)
|
|
41
|
+
return { dominantBaseline: "middle", textAnchor: "middle" };
|
|
42
|
+
if (!positionMode || positionMode === "afterHead") {
|
|
32
43
|
switch (keyAxisOrient) {
|
|
33
44
|
case "top":
|
|
34
45
|
return { dominantBaseline: "hanging", textAnchor: "middle" };
|
|
@@ -40,9 +51,30 @@ export function calculateValueLabelAlignment(keyAxisOrient, positionMode, rotati
|
|
|
40
51
|
return { dominantBaseline: "middle", textAnchor: "end" };
|
|
41
52
|
}
|
|
42
53
|
}
|
|
43
|
-
else {
|
|
44
|
-
|
|
54
|
+
else if (positionMode === "beforeHead") {
|
|
55
|
+
switch (keyAxisOrient) {
|
|
56
|
+
case "top":
|
|
57
|
+
return { dominantBaseline: "auto", textAnchor: "middle" };
|
|
58
|
+
case "bottom":
|
|
59
|
+
return { dominantBaseline: "hanging", textAnchor: "middle" };
|
|
60
|
+
case "left":
|
|
61
|
+
return { dominantBaseline: "middle", textAnchor: "end" };
|
|
62
|
+
case "right":
|
|
63
|
+
return { dominantBaseline: "middle", textAnchor: "start" };
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return { dominantBaseline: "middle", textAnchor: "middle" };
|
|
67
|
+
}
|
|
68
|
+
export function handleScaledValue(dataRow, datumField, isSegmented, positionMode) {
|
|
69
|
+
if (!positionMode || positionMode === "afterHead" || positionMode === "beforeHead")
|
|
70
|
+
return dataRow[datumField];
|
|
71
|
+
if (positionMode === "center") {
|
|
72
|
+
if (isSegmented)
|
|
73
|
+
return dataRow[datumField] - (dataRow[datumField] - dataRow["0"]) / 2;
|
|
74
|
+
else
|
|
75
|
+
return dataRow[datumField] / 2;
|
|
45
76
|
}
|
|
77
|
+
throw new Error("Invalid position mode");
|
|
46
78
|
}
|
|
47
79
|
export function hasCollisionLeftSide(labelClientRect, margin) {
|
|
48
80
|
return labelClientRect.x - labelClientRect.width / 2 <= margin.left;
|
|
@@ -3,7 +3,7 @@ import { TwoDimLegendModel } from "../../featuresModel/legendModel/twoDimLegendM
|
|
|
3
3
|
import { keyAxisLabelHorizontalLog, keyAxisLabelVerticalLog } from "../../featuresModel/scaleModel/scaleAxisRecalcer";
|
|
4
4
|
import { AxisType } from "../../modelBuilder";
|
|
5
5
|
import { TwoDimensionalModel } from "../../notations/twoDimensionalModel";
|
|
6
|
-
import {
|
|
6
|
+
import { VALUE_LABEL_OFFSET_ABS_SIZE_PX } from "../../featuresModel/valueLabelsModel/valueLabelsModel";
|
|
7
7
|
import { ScaleModel } from "../../featuresModel/scaleModel/scaleModel";
|
|
8
8
|
import { Scale } from "../../../engine/features/scale/scale";
|
|
9
9
|
export const AXIS_HORIZONTAL_LABEL_PADDING = 12;
|
|
@@ -110,7 +110,7 @@ export class TwoDimMarginModel {
|
|
|
110
110
|
top: "bottom",
|
|
111
111
|
bottom: "top"
|
|
112
112
|
};
|
|
113
|
-
canvasModel.increaseMarginSide(axisMarginMapping[keyAxisOrient], valueLabelFontSize +
|
|
113
|
+
canvasModel.increaseMarginSide(axisMarginMapping[keyAxisOrient], valueLabelFontSize + VALUE_LABEL_OFFSET_ABS_SIZE_PX);
|
|
114
114
|
}
|
|
115
115
|
getValueAxisLabels(scaleModel) {
|
|
116
116
|
const scale = Scale.getScaleValue(scaleModel);
|
package/lib/model/model.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChartOrientation, MdtChartsColorField, PolarChartType, Size, TwoDimensionalChartType, AxisLabelPosition, ShowTickFn, MdtChartsDataRow, TwoDimensionalValueGroup, ValueLabelsCollisionMode, ValueLabelsRotationOptions, ValueLabelsHandleElement } from "../config/config";
|
|
1
|
+
import { ChartOrientation, MdtChartsColorField, PolarChartType, Size, TwoDimensionalChartType, AxisLabelPosition, ShowTickFn, MdtChartsDataRow, TwoDimensionalValueGroup, ValueLabelsCollisionMode, ValueLabelsRotationOptions, ValueLabelsHandleElement, MdtChartsFieldName } from "../config/config";
|
|
2
2
|
import { DataType, DonutOptionsCanvas, Formatter, StaticLegendBlockCanvas, TooltipSettings, Transitions } from "../designer/designerConfig";
|
|
3
3
|
import { BoundingRect } from "../engine/features/valueLabelsCollision/valueLabelsCollision";
|
|
4
4
|
declare type AxisType = "key" | "value";
|
|
@@ -398,13 +398,21 @@ export interface TwoDimensionalChartDataModel {
|
|
|
398
398
|
export interface ValueField extends Field {
|
|
399
399
|
title: string;
|
|
400
400
|
}
|
|
401
|
+
export interface ValueLabelsInnerContentSetterOptions {
|
|
402
|
+
dataRow: MdtChartsDataRow;
|
|
403
|
+
fieldName: MdtChartsFieldName;
|
|
404
|
+
}
|
|
405
|
+
export declare type ValueLabelsInnerContentSetter = (options: ValueLabelsInnerContentSetterOptions) => {
|
|
406
|
+
rows: (string | number)[];
|
|
407
|
+
};
|
|
401
408
|
export interface TwoDimChartValueLabelsOptions {
|
|
402
409
|
show: boolean;
|
|
403
410
|
handleX: (scaledValue: number) => number;
|
|
404
411
|
handleY: (scaledValue: number) => number;
|
|
405
412
|
textAnchor: ValueLabelAnchor;
|
|
413
|
+
forFields: MdtChartsFieldName[];
|
|
406
414
|
dominantBaseline: ValueLabelDominantBaseline;
|
|
407
|
-
|
|
415
|
+
setContent: ValueLabelsInnerContentSetter;
|
|
408
416
|
handleScaledValue: (dataRow: MdtChartsDataRow, datumField: string) => number;
|
|
409
417
|
rotation?: ValueLabelsRotationOptions;
|
|
410
418
|
handleElement?: ValueLabelsHandleElement;
|
|
@@ -73,7 +73,7 @@ export class TwoDimConfigReader {
|
|
|
73
73
|
return this.options.charts.some((chart) => { var _a; return (_a = chart.valueLabels) === null || _a === void 0 ? void 0 : _a.on; });
|
|
74
74
|
}
|
|
75
75
|
areValueLabelsNeedIncreaseMargin() {
|
|
76
|
-
return
|
|
76
|
+
return this.options.charts.some((chart) => { var _a, _b, _c, _d; return !((_b = (_a = chart.valueLabels) === null || _a === void 0 ? void 0 : _a.position) === null || _b === void 0 ? void 0 : _b.mode) || ((_d = (_c = chart.valueLabels) === null || _c === void 0 ? void 0 : _c.position) === null || _d === void 0 ? void 0 : _d.mode) === "afterHead"; });
|
|
77
77
|
}
|
|
78
78
|
getValueLabelsStyleModel() {
|
|
79
79
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
@@ -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, getBarViewOptions, getLegendMarkerOptions, LINE_CHART_DEFAULT_WIDTH, parseDashStyles, parseShape } from "./twoDimensional/styles";
|
|
7
|
-
import { calculateValueLabelAlignment, ValueLabelCoordinateCalculator } from "../../model/featuresModel/valueLabelsModel/valueLabelsModel";
|
|
7
|
+
import { calculateValueLabelAlignment, handleScaledValue, 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";
|
|
@@ -95,10 +95,10 @@ export class TwoDimensionalModel {
|
|
|
95
95
|
const styleModel = new TwoDimensionalChartStyleModel(charts, designerConfig.chartStyle);
|
|
96
96
|
const chartsModel = [];
|
|
97
97
|
charts.forEach((chart, index) => {
|
|
98
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
|
|
98
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
|
|
99
99
|
const style = styleModel.getChartStyle(chart, index);
|
|
100
|
-
const valueLabelsCoordinateCalculator = new ValueLabelCoordinateCalculator((
|
|
101
|
-
const valueLabelsAlignment = calculateValueLabelAlignment(keyAxisOrient, (
|
|
100
|
+
const valueLabelsCoordinateCalculator = new ValueLabelCoordinateCalculator((_a = chart.valueLabels) === null || _a === void 0 ? void 0 : _a.position, keyAxisOrient, canvasModel.getMargin());
|
|
101
|
+
const valueLabelsAlignment = calculateValueLabelAlignment(keyAxisOrient, (_c = (_b = chart.valueLabels) === null || _b === void 0 ? void 0 : _b.position) === null || _c === void 0 ? void 0 : _c.mode, (_d = chart.valueLabels) === null || _d === void 0 ? void 0 : _d.rotation);
|
|
102
102
|
chartsModel.push({
|
|
103
103
|
type: chart.type,
|
|
104
104
|
isSegmented: chart.isSegmented,
|
|
@@ -111,44 +111,50 @@ export class TwoDimensionalModel {
|
|
|
111
111
|
styles: {
|
|
112
112
|
highlighted: {
|
|
113
113
|
size: {
|
|
114
|
-
radius: (
|
|
114
|
+
radius: (_g = (_f = (_e = designerConfig.canvas.markers) === null || _e === void 0 ? void 0 : _e.highlighted) === null || _f === void 0 ? void 0 : _f.radius) !== null && _g !== void 0 ? _g : 4,
|
|
115
115
|
borderSize: "3.5px"
|
|
116
116
|
}
|
|
117
117
|
},
|
|
118
118
|
normal: {
|
|
119
119
|
size: {
|
|
120
|
-
radius: (
|
|
121
|
-
borderSize: `${(
|
|
120
|
+
radius: (_k = (_j = (_h = designerConfig.canvas.markers) === null || _h === void 0 ? void 0 : _h.normal) === null || _j === void 0 ? void 0 : _j.radius) !== null && _k !== void 0 ? _k : 3,
|
|
121
|
+
borderSize: `${(_o = (_m = (_l = designerConfig.canvas.markers) === null || _l === void 0 ? void 0 : _l.normal) === null || _m === void 0 ? void 0 : _m.borderSize) !== null && _o !== void 0 ? _o : 2}px`
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
},
|
|
126
126
|
lineLikeViewOptions: {
|
|
127
|
-
dashedStyles: parseDashStyles((
|
|
128
|
-
strokeWidth: (
|
|
127
|
+
dashedStyles: parseDashStyles((_p = chart.lineStyles) === null || _p === void 0 ? void 0 : _p.dash),
|
|
128
|
+
strokeWidth: (_r = (_q = chart.lineStyles) === null || _q === void 0 ? void 0 : _q.width) !== null && _r !== void 0 ? _r : LINE_CHART_DEFAULT_WIDTH,
|
|
129
129
|
renderForKey: (dataRow, valueFieldName) => dataRow[valueFieldName] !== null && dataRow[valueFieldName] !== undefined
|
|
130
130
|
},
|
|
131
131
|
barViewOptions: getBarViewOptions(chart, keyAxisOrient, calculateBarIndexes(charts, chart, index)),
|
|
132
132
|
legend: getLegendMarkerOptions(chart),
|
|
133
133
|
index,
|
|
134
134
|
valueLabels: {
|
|
135
|
-
show: (
|
|
135
|
+
show: (_t = (_s = chart.valueLabels) === null || _s === void 0 ? void 0 : _s.on) !== null && _t !== void 0 ? _t : false,
|
|
136
136
|
handleX: (scaledValue) => valueLabelsCoordinateCalculator.getValueLabelX(scaledValue),
|
|
137
137
|
handleY: (scaledValue) => valueLabelsCoordinateCalculator.getValueLabelY(scaledValue),
|
|
138
138
|
handleScaledValue: (dataRow, datumField) => {
|
|
139
|
-
var _a, _b
|
|
140
|
-
|
|
141
|
-
return dataRow[datumField];
|
|
142
|
-
if (chart.isSegmented)
|
|
143
|
-
return dataRow[datumField] - (dataRow[datumField] - dataRow["0"]) / 2;
|
|
144
|
-
else
|
|
145
|
-
return dataRow[datumField] / 2;
|
|
139
|
+
var _a, _b;
|
|
140
|
+
return handleScaledValue(dataRow, datumField, chart.isSegmented, (_b = (_a = chart.valueLabels) === null || _a === void 0 ? void 0 : _a.position) === null || _b === void 0 ? void 0 : _b.mode);
|
|
146
141
|
},
|
|
147
142
|
textAnchor: valueLabelsAlignment.textAnchor,
|
|
148
143
|
dominantBaseline: valueLabelsAlignment.dominantBaseline,
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
144
|
+
rotation: (_u = chart.valueLabels) === null || _u === void 0 ? void 0 : _u.rotation,
|
|
145
|
+
handleElement: (_v = chart.valueLabels) === null || _v === void 0 ? void 0 : _v.handleElement,
|
|
146
|
+
forFields: (_x = (_w = chart.valueLabels) === null || _w === void 0 ? void 0 : _w.renderForFields) !== null && _x !== void 0 ? _x : chart.data.valueFields.map((field) => field.name),
|
|
147
|
+
setContent: ({ dataRow, fieldName }) => {
|
|
148
|
+
var _a;
|
|
149
|
+
if ((_a = chart.valueLabels) === null || _a === void 0 ? void 0 : _a.setContent) {
|
|
150
|
+
const content = chart.valueLabels.setContent({
|
|
151
|
+
dataRow,
|
|
152
|
+
field: chart.data.valueFields.find((field) => field.name === fieldName)
|
|
153
|
+
});
|
|
154
|
+
return { rows: content.textContent.toString().split("\n") };
|
|
155
|
+
}
|
|
156
|
+
return { rows: [configReader.getValueLabelFormatterForChart(index)(dataRow[fieldName])] };
|
|
157
|
+
}
|
|
152
158
|
},
|
|
153
159
|
areaViewOptions: getAreaViewOptions(chart, index, style, modelInstance.version.getVersionNumber()),
|
|
154
160
|
dotViewOptions: {
|
|
@@ -156,7 +162,7 @@ export class TwoDimensionalModel {
|
|
|
156
162
|
type: "line",
|
|
157
163
|
handleEndCoordinate: (v) => v + 2,
|
|
158
164
|
handleStartCoordinate: (v) => v - 2,
|
|
159
|
-
width: (
|
|
165
|
+
width: (_0 = (_z = (_y = chart.dotLikeStyles) === null || _y === void 0 ? void 0 : _y.shape) === null || _z === void 0 ? void 0 : _z.width) !== null && _0 !== void 0 ? _0 : LINE_CHART_DEFAULT_WIDTH
|
|
160
166
|
}
|
|
161
167
|
}
|
|
162
168
|
});
|
package/package.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mdt-charts",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.33.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/main.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"dev": "npx webpack --mode development",
|
|
7
|
+
"dev": "npx webpack --mode development --watch",
|
|
8
8
|
"build": "npx webpack --mode production",
|
|
9
|
-
"watch": "npx webpack --mode development --watch",
|
|
10
9
|
"test": "jest",
|
|
11
10
|
"build-lib": "shx rm -rf lib && npm run build-ts && npm run build-style",
|
|
12
11
|
"build-ts": "npx tsc -p tsconfig.production.json",
|