mdt-charts 1.30.2 → 1.32.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 +30 -5
- package/lib/engine/features/legend/legendHelper.d.ts +3 -3
- package/lib/engine/features/legend/legendMarkerCreator.d.ts +6 -6
- package/lib/engine/features/legend/legendMarkerCreator.js +2 -2
- package/lib/engine/features/tolltip/tooltip.d.ts +1 -2
- package/lib/engine/features/tolltip/tooltip.js +14 -17
- package/lib/engine/features/tolltip/tooltipDomHelper.d.ts +2 -14
- package/lib/engine/features/tolltip/tooltipDomHelper.js +30 -107
- package/lib/engine/features/valueLabels/valueLabels.js +17 -9
- package/lib/engine/polarNotation/polarManager.js +2 -2
- package/lib/engine/twoDimensionalNotation/twoDimensionalManager.js +2 -2
- package/lib/model/dataManagerModel/dataManagerModel.js +1 -1
- package/lib/model/featuresModel/{axisModel.d.ts → axis/axisModel.d.ts} +5 -5
- package/lib/model/featuresModel/{axisModel.js → axis/axisModel.js} +4 -4
- package/lib/model/featuresModel/{axisModelService.d.ts → axis/axisModelService.d.ts} +1 -1
- package/lib/model/featuresModel/otherComponents.js +2 -2
- package/lib/model/featuresModel/tooltipModel/contentByNotations/polarInitialRowsProvider.d.ts +14 -0
- package/lib/model/featuresModel/tooltipModel/contentByNotations/polarInitialRowsProvider.js +16 -0
- package/lib/model/featuresModel/tooltipModel/contentByNotations/tooltipContentInitialRowsProvider.d.ts +13 -0
- package/lib/model/featuresModel/tooltipModel/contentByNotations/tooltipContentInitialRowsProvider.js +1 -0
- package/lib/model/featuresModel/tooltipModel/contentByNotations/twoDimInitialRowsProvider.d.ts +10 -0
- package/lib/model/featuresModel/tooltipModel/contentByNotations/twoDimInitialRowsProvider.js +17 -0
- package/lib/model/featuresModel/tooltipModel/tooltipCanvasModel.d.ts +4 -0
- package/lib/model/featuresModel/{tooltipModel.js → tooltipModel/tooltipCanvasModel.js} +2 -2
- package/lib/model/featuresModel/tooltipModel/tooltipContentModel.d.ts +18 -0
- package/lib/model/featuresModel/tooltipModel/tooltipContentModel.js +87 -0
- 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 +3 -3
- package/lib/model/model.d.ts +45 -13
- package/lib/model/modelInstance/configReader.js +1 -1
- package/lib/model/notations/polar/modelConstants/polarLegendMarker.d.ts +2 -0
- package/lib/model/notations/polar/modelConstants/polarLegendMarker.js +3 -0
- package/lib/model/notations/polar/polarModel.js +25 -20
- package/lib/model/notations/twoDimensional/styles.d.ts +2 -2
- package/lib/model/notations/twoDimensionalModel.js +40 -24
- package/lib/style/charts-main.css +2 -2
- package/lib/style/charts-main.less +2 -2
- package/package.json +2 -3
- package/lib/model/featuresModel/tooltipModel.d.ts +0 -4
- /package/lib/model/featuresModel/{axisModelService.js → axis/axisModelService.js} +0 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { MdtChartsDataRow } from "../../../../config/config";
|
|
2
|
+
import { TooltipMarkerModel, ValueField } from "../../../model";
|
|
3
|
+
export interface TooltipContentInitialRow {
|
|
4
|
+
marker: TooltipMarkerModel;
|
|
5
|
+
valueField: ValueField;
|
|
6
|
+
}
|
|
7
|
+
export interface TooltipContentInitialRowsProviderContext {
|
|
8
|
+
keyFieldValue: string;
|
|
9
|
+
currentDataRow: MdtChartsDataRow;
|
|
10
|
+
}
|
|
11
|
+
export interface TooltipContentInitialRowsProvider {
|
|
12
|
+
getInitialRows(context: TooltipContentInitialRowsProviderContext): TooltipContentInitialRow[];
|
|
13
|
+
}
|
package/lib/model/featuresModel/tooltipModel/contentByNotations/tooltipContentInitialRowsProvider.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/model/featuresModel/tooltipModel/contentByNotations/twoDimInitialRowsProvider.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TwoDimensionalChartModel } from "../../../model";
|
|
2
|
+
import { TooltipContentInitialRow, TooltipContentInitialRowsProvider } from "./tooltipContentInitialRowsProvider";
|
|
3
|
+
export interface TwoDimInitialRowsProviderOptions {
|
|
4
|
+
chartsInfo: Pick<TwoDimensionalChartModel, "data" | "style" | "legend">[];
|
|
5
|
+
}
|
|
6
|
+
export declare class TwoDimInitialRowsProvider implements TooltipContentInitialRowsProvider {
|
|
7
|
+
private readonly options;
|
|
8
|
+
constructor(options: TwoDimInitialRowsProviderOptions);
|
|
9
|
+
getInitialRows(): TooltipContentInitialRow[];
|
|
10
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export class TwoDimInitialRowsProvider {
|
|
2
|
+
constructor(options) {
|
|
3
|
+
this.options = options;
|
|
4
|
+
}
|
|
5
|
+
getInitialRows() {
|
|
6
|
+
const initialRows = [];
|
|
7
|
+
this.options.chartsInfo.forEach((chart) => {
|
|
8
|
+
chart.data.valueFields.forEach((valueField, valueFieldIndex) => {
|
|
9
|
+
initialRows.push({
|
|
10
|
+
marker: Object.assign({ color: chart.style.elementColors[valueFieldIndex % chart.style.elementColors.length] }, chart.legend),
|
|
11
|
+
valueField
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
return initialRows;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { MdtChartsDataRow, TooltipOptions } from "../../../config/config";
|
|
2
|
+
import { Formatter } from "../../../main";
|
|
3
|
+
import { TooltipContent } from "../../model";
|
|
4
|
+
import { TooltipContentInitialRowsProvider } from "./contentByNotations/tooltipContentInitialRowsProvider";
|
|
5
|
+
export interface TooltipContentGeneratorOptions {
|
|
6
|
+
datasource: MdtChartsDataRow[];
|
|
7
|
+
initialRowsProvider: TooltipContentInitialRowsProvider;
|
|
8
|
+
publicOptions?: TooltipOptions;
|
|
9
|
+
keyFieldName: string;
|
|
10
|
+
valueGlobalFormatter: Formatter;
|
|
11
|
+
}
|
|
12
|
+
export declare class TwoDimTooltipContentGenerator {
|
|
13
|
+
private readonly options;
|
|
14
|
+
private readonly headWrapperCssClassName;
|
|
15
|
+
constructor(options: TooltipContentGeneratorOptions);
|
|
16
|
+
generateContent(keyFieldValue: string): TooltipContent;
|
|
17
|
+
private createRows;
|
|
18
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
export class TwoDimTooltipContentGenerator {
|
|
2
|
+
constructor(options) {
|
|
3
|
+
this.options = options;
|
|
4
|
+
this.headWrapperCssClassName = "tooltip-head";
|
|
5
|
+
}
|
|
6
|
+
generateContent(keyFieldValue) {
|
|
7
|
+
var _a;
|
|
8
|
+
const currentDataRow = this.options.datasource.find((r) => r[this.options.keyFieldName] === keyFieldValue);
|
|
9
|
+
if ((_a = this.options.publicOptions) === null || _a === void 0 ? void 0 : _a.html)
|
|
10
|
+
return {
|
|
11
|
+
type: "html",
|
|
12
|
+
htmlContent: this.options.publicOptions.html(currentDataRow)
|
|
13
|
+
};
|
|
14
|
+
return this.createRows(keyFieldValue, currentDataRow);
|
|
15
|
+
}
|
|
16
|
+
createRows(keyFieldValue, currentDataRow) {
|
|
17
|
+
var _a, _b, _c, _d, _e;
|
|
18
|
+
let contentRows = [];
|
|
19
|
+
let initialRows = this.options.initialRowsProvider
|
|
20
|
+
.getInitialRows({ keyFieldValue, currentDataRow })
|
|
21
|
+
.map((initialRow) => {
|
|
22
|
+
return {
|
|
23
|
+
marker: initialRow.marker,
|
|
24
|
+
textContent: {
|
|
25
|
+
caption: initialRow.valueField.title,
|
|
26
|
+
value: currentDataRow[initialRow.valueField.name]
|
|
27
|
+
},
|
|
28
|
+
valueField: initialRow.valueField
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
initialRows = ((_b = (_a = this.options.publicOptions) === null || _a === void 0 ? void 0 : _a.rows) === null || _b === void 0 ? void 0 : _b.filterPredicate)
|
|
32
|
+
? initialRows.filter((row) => this.options.publicOptions.rows.filterPredicate(row))
|
|
33
|
+
: initialRows;
|
|
34
|
+
if ((_d = (_c = this.options.publicOptions) === null || _c === void 0 ? void 0 : _c.rows) === null || _d === void 0 ? void 0 : _d.sortCompareFn)
|
|
35
|
+
initialRows.sort(this.options.publicOptions.rows.sortCompareFn);
|
|
36
|
+
initialRows.forEach((initialRow) => {
|
|
37
|
+
var _a;
|
|
38
|
+
const formattedValueByDefault = this.options.valueGlobalFormatter(initialRow.textContent.value, {
|
|
39
|
+
type: initialRow.valueField.format
|
|
40
|
+
});
|
|
41
|
+
const formattedValue = ((_a = this.options.publicOptions) === null || _a === void 0 ? void 0 : _a.formatValue)
|
|
42
|
+
? this.options.publicOptions.formatValue({
|
|
43
|
+
rawValue: currentDataRow[initialRow.valueField.name],
|
|
44
|
+
autoFormattedValue: formattedValueByDefault
|
|
45
|
+
})
|
|
46
|
+
: formattedValueByDefault;
|
|
47
|
+
contentRows.push({
|
|
48
|
+
marker: initialRow.marker,
|
|
49
|
+
textContent: {
|
|
50
|
+
caption: initialRow.textContent.caption,
|
|
51
|
+
value: formattedValue
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
if ((_e = this.options.publicOptions) === null || _e === void 0 ? void 0 : _e.aggregator) {
|
|
56
|
+
const contentResult = this.options.publicOptions.aggregator.content({ row: currentDataRow });
|
|
57
|
+
const aggregatorContent = Array.isArray(contentResult) ? contentResult : [contentResult];
|
|
58
|
+
const tooltipAggregatorItem = aggregatorContent.map((content) => {
|
|
59
|
+
const caption = content.type === "plainText" ? content.textContent : content.caption;
|
|
60
|
+
const value = content.type === "plainText" ? undefined : content.value;
|
|
61
|
+
return {
|
|
62
|
+
textContent: {
|
|
63
|
+
caption,
|
|
64
|
+
value
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
if (this.options.publicOptions.aggregator.position === "underValues")
|
|
69
|
+
contentRows = contentRows.concat(tooltipAggregatorItem);
|
|
70
|
+
else
|
|
71
|
+
contentRows = tooltipAggregatorItem.concat(contentRows);
|
|
72
|
+
}
|
|
73
|
+
const headerRow = {
|
|
74
|
+
textContent: {
|
|
75
|
+
caption: keyFieldValue
|
|
76
|
+
},
|
|
77
|
+
wrapper: {
|
|
78
|
+
cssClassName: this.headWrapperCssClassName
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
contentRows.unshift(headerRow);
|
|
82
|
+
return {
|
|
83
|
+
type: "rows",
|
|
84
|
+
rows: contentRows
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -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;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { AxisModel, LABEL_ELEMENT_HEIGHT_PX } from "../../featuresModel/axisModel";
|
|
1
|
+
import { AxisModel, LABEL_ELEMENT_HEIGHT_PX } from "../../featuresModel/axis/axisModel";
|
|
2
2
|
import { TwoDimLegendModel } from "../../featuresModel/legendModel/twoDimLegendModel";
|
|
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,
|
|
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";
|
|
@@ -36,8 +36,32 @@ export interface BlockMargin {
|
|
|
36
36
|
left: number;
|
|
37
37
|
right: number;
|
|
38
38
|
}
|
|
39
|
+
export interface TooltipBasicModel {
|
|
40
|
+
getContent: (keyFieldValue: string) => TooltipContent;
|
|
41
|
+
}
|
|
42
|
+
export declare type TooltipMarkerModel = ChartLegendMarkerModel & {
|
|
43
|
+
color: string;
|
|
44
|
+
};
|
|
45
|
+
export declare type TooltipContent = {
|
|
46
|
+
type: "html";
|
|
47
|
+
htmlContent: string;
|
|
48
|
+
} | TooltipContentWithRows;
|
|
49
|
+
export interface TooltipContentWithRows {
|
|
50
|
+
type: "rows";
|
|
51
|
+
rows: TooltipContentRow[];
|
|
52
|
+
}
|
|
53
|
+
export interface TooltipContentRow {
|
|
54
|
+
marker?: TooltipMarkerModel;
|
|
55
|
+
textContent: {
|
|
56
|
+
caption: string;
|
|
57
|
+
value?: string | number;
|
|
58
|
+
};
|
|
59
|
+
wrapper?: {
|
|
60
|
+
cssClassName?: string;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
39
63
|
interface BasicOptionsModel {
|
|
40
|
-
tooltip:
|
|
64
|
+
tooltip: TooltipBasicModel;
|
|
41
65
|
}
|
|
42
66
|
interface GraphicNotationOptionsModel extends BasicOptionsModel {
|
|
43
67
|
legend: ILegendModel;
|
|
@@ -281,23 +305,23 @@ export interface DonutThicknessOptions {
|
|
|
281
305
|
unit: DonutThicknessUnit;
|
|
282
306
|
}
|
|
283
307
|
interface ChartModel {
|
|
284
|
-
tooltip: TooltipModel;
|
|
285
308
|
cssClasses: string[];
|
|
286
309
|
style: ChartStyle;
|
|
287
310
|
}
|
|
288
|
-
interface TooltipModel {
|
|
289
|
-
show: boolean;
|
|
290
|
-
}
|
|
291
311
|
export interface ChartStyle {
|
|
292
312
|
elementColors: string[];
|
|
293
313
|
opacity: number;
|
|
294
314
|
}
|
|
295
|
-
export
|
|
296
|
-
markerShape:
|
|
315
|
+
export declare type ChartLegendMarkerModel = {
|
|
316
|
+
markerShape: "circle";
|
|
317
|
+
} | {
|
|
318
|
+
markerShape: "bar";
|
|
297
319
|
barViewOptions: TwoDimensionalChartLegendBarModel;
|
|
320
|
+
} | {
|
|
321
|
+
markerShape: "line";
|
|
298
322
|
lineViewOptions: TwoDimensionalChartLegendLineModel;
|
|
299
|
-
}
|
|
300
|
-
export declare type LegendMarkerShape = "
|
|
323
|
+
};
|
|
324
|
+
export declare type LegendMarkerShape = ChartLegendMarkerModel["markerShape"];
|
|
301
325
|
export interface TwoDimensionalChartLegendBarModel {
|
|
302
326
|
hatch: BarLikeChartHatchOptions;
|
|
303
327
|
borderRadius: BarBorderRadius;
|
|
@@ -359,13 +383,13 @@ export interface TwoDimensionalChartModel extends ChartModel, TwoDimensionalLine
|
|
|
359
383
|
index: number;
|
|
360
384
|
embeddedLabels: EmbeddedLabelTypeModel;
|
|
361
385
|
isSegmented: boolean;
|
|
362
|
-
legend:
|
|
386
|
+
legend: ChartLegendMarkerModel;
|
|
363
387
|
valueLabels: TwoDimChartValueLabelsOptions;
|
|
364
388
|
}
|
|
365
389
|
export interface PolarChartModel extends ChartModel {
|
|
366
390
|
type: PolarChartType;
|
|
367
391
|
data: PolarChartDataModel;
|
|
368
|
-
legend:
|
|
392
|
+
legend: ChartLegendMarkerModel;
|
|
369
393
|
}
|
|
370
394
|
export interface TwoDimensionalChartDataModel {
|
|
371
395
|
valueFields: ValueField[];
|
|
@@ -374,13 +398,21 @@ export interface TwoDimensionalChartDataModel {
|
|
|
374
398
|
export interface ValueField extends Field {
|
|
375
399
|
title: string;
|
|
376
400
|
}
|
|
401
|
+
export interface ValueLabelsInnerContentSetterOptions {
|
|
402
|
+
dataRow: MdtChartsDataRow;
|
|
403
|
+
fieldName: MdtChartsFieldName;
|
|
404
|
+
}
|
|
405
|
+
export declare type ValueLabelsInnerContentSetter = (options: ValueLabelsInnerContentSetterOptions) => {
|
|
406
|
+
textContent: string | number;
|
|
407
|
+
};
|
|
377
408
|
export interface TwoDimChartValueLabelsOptions {
|
|
378
409
|
show: boolean;
|
|
379
410
|
handleX: (scaledValue: number) => number;
|
|
380
411
|
handleY: (scaledValue: number) => number;
|
|
381
412
|
textAnchor: ValueLabelAnchor;
|
|
413
|
+
forFields: MdtChartsFieldName[];
|
|
382
414
|
dominantBaseline: ValueLabelDominantBaseline;
|
|
383
|
-
|
|
415
|
+
setContent: ValueLabelsInnerContentSetter;
|
|
384
416
|
handleScaledValue: (dataRow: MdtChartsDataRow, datumField: string) => number;
|
|
385
417
|
rotation?: ValueLabelsRotationOptions;
|
|
386
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;
|
|
@@ -2,10 +2,14 @@ import { ChartStyleModelService } from "../../chartStyleModel/chartStyleModel";
|
|
|
2
2
|
import { DonutModel } from "./donut/donutModel";
|
|
3
3
|
import { TitleConfigReader } from "../../modelInstance/titleConfigReader";
|
|
4
4
|
import { createRecordOverflowModel } from "../../featuresModel/recordOverflowModel/recordOverflowModel";
|
|
5
|
+
import { POLAR_LEGEND_MARKER } from "./modelConstants/polarLegendMarker";
|
|
6
|
+
import { TwoDimTooltipContentGenerator } from "../../featuresModel/tooltipModel/tooltipContentModel";
|
|
7
|
+
import { PolarInitialRowsProvider } from "../../featuresModel/tooltipModel/contentByNotations/polarInitialRowsProvider";
|
|
5
8
|
export const MIN_DONUT_BLOCK_SIZE = 120;
|
|
6
9
|
export class PolarModel {
|
|
7
10
|
static getOptions(options, designerConfig, modelInstance) {
|
|
8
11
|
const titleConfig = TitleConfigReader.create(options.title, modelInstance);
|
|
12
|
+
const chart = this.getChartsModel(options.chart, modelInstance.dataModel.repository.getScopedRows().length, designerConfig.chartStyle);
|
|
9
13
|
return {
|
|
10
14
|
type: options.type,
|
|
11
15
|
selectable: !!options.selectable,
|
|
@@ -14,9 +18,25 @@ export class PolarModel {
|
|
|
14
18
|
fontSize: titleConfig.getFontSize()
|
|
15
19
|
},
|
|
16
20
|
data: Object.assign({}, options.data),
|
|
17
|
-
charts:
|
|
21
|
+
charts: [chart],
|
|
18
22
|
legend: modelInstance.canvasModel.legendCanvas.getModel(),
|
|
19
|
-
tooltip:
|
|
23
|
+
tooltip: {
|
|
24
|
+
getContent: (keyFieldValue) => {
|
|
25
|
+
const generator = new TwoDimTooltipContentGenerator({
|
|
26
|
+
datasource: modelInstance.dataModel.repository.getRawRows(),
|
|
27
|
+
keyFieldName: options.data.keyField.name,
|
|
28
|
+
publicOptions: options.tooltip,
|
|
29
|
+
initialRowsProvider: new PolarInitialRowsProvider({
|
|
30
|
+
datasource: modelInstance.dataModel.repository.getRawRows(),
|
|
31
|
+
valueField: options.chart.data.valueField,
|
|
32
|
+
keyFieldName: options.data.keyField.name,
|
|
33
|
+
chartColors: chart.style.elementColors
|
|
34
|
+
}),
|
|
35
|
+
valueGlobalFormatter: designerConfig.dataFormat.formatters
|
|
36
|
+
});
|
|
37
|
+
return generator.generateContent(keyFieldValue);
|
|
38
|
+
}
|
|
39
|
+
},
|
|
20
40
|
chartCanvas: this.getDonutSettings(designerConfig.canvas.chartOptions.donut, options.chart, modelInstance.dataModel.repository.getRawRows()),
|
|
21
41
|
defs: { gradients: [] },
|
|
22
42
|
recordOverflowAlert: createRecordOverflowModel(modelInstance.dataModel.getScope().hidedRecordsAmount, {
|
|
@@ -52,28 +72,13 @@ export class PolarModel {
|
|
|
52
72
|
return this.donutModel.getSettings(settings, chartOptions, dataRows);
|
|
53
73
|
}
|
|
54
74
|
static getChartsModel(chart, dataLength, chartStyleConfig) {
|
|
55
|
-
|
|
56
|
-
chartsModel.push({
|
|
75
|
+
return {
|
|
57
76
|
type: chart.type,
|
|
58
77
|
data: Object.assign({}, chart.data),
|
|
59
|
-
tooltip: { show: true },
|
|
60
78
|
cssClasses: ChartStyleModelService.getCssClasses(0),
|
|
61
79
|
style: ChartStyleModelService.getChartStyle(dataLength, chartStyleConfig),
|
|
62
|
-
legend:
|
|
63
|
-
|
|
64
|
-
barViewOptions: {
|
|
65
|
-
hatch: { on: false },
|
|
66
|
-
borderRadius: { topLeft: 0, topRight: 0, bottomLeft: 0, bottomRight: 0 },
|
|
67
|
-
width: 0
|
|
68
|
-
},
|
|
69
|
-
lineViewOptions: {
|
|
70
|
-
dashedStyles: { on: false, dashSize: 0, gapSize: 0 },
|
|
71
|
-
strokeWidth: 0,
|
|
72
|
-
length: 0
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
return chartsModel;
|
|
80
|
+
legend: POLAR_LEGEND_MARKER
|
|
81
|
+
};
|
|
77
82
|
}
|
|
78
83
|
}
|
|
79
84
|
PolarModel.donutModel = new DonutModel();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AreaChartViewOptions, BarBorderRadius,
|
|
1
|
+
import { AreaChartViewOptions, BarBorderRadius, ChartLegendMarkerModel, ChartStyle, GradientId, LineLikeChartDashOptions, LineLikeChartShapeOptions, Orient, TwoDimensionalBarLikeChartViewModel, TwoDimensionalChartLegendLineModel } from "../../model";
|
|
2
2
|
import { ChartOrientation, MdtChartsLineLikeChartDashedStyles, MdtChartsTwoDimensionalChart, TwoDimensionalChartType } from "../../../config/config";
|
|
3
3
|
import { MdtChartsLineLikeChartShape } from "../../../designer/designerConfig";
|
|
4
4
|
export declare const LINE_CHART_DEFAULT_WIDTH = 2;
|
|
@@ -7,7 +7,7 @@ export declare function parseDashStyles(configOptions?: MdtChartsLineLikeChartDa
|
|
|
7
7
|
export declare function getBarViewOptions(chart: MdtChartsTwoDimensionalChart, keyAxisOrient: Orient, barIndexes: number[]): TwoDimensionalBarLikeChartViewModel;
|
|
8
8
|
export declare function calculateBarIndexes(allCharts: Pick<MdtChartsTwoDimensionalChart, "isSegmented" | "data" | "type">[], currentChart: Pick<MdtChartsTwoDimensionalChart, "isSegmented" | "data" | "type">, currentChartIndex: number): number[];
|
|
9
9
|
export declare function getSegmentedRadiusValues(segmentsLength: number, segmentIndex: number, keyAxisOrient: Orient, defaultRadius: number): BarBorderRadius;
|
|
10
|
-
export declare function getLegendMarkerOptions(chart: MdtChartsTwoDimensionalChart):
|
|
10
|
+
export declare function getLegendMarkerOptions(chart: MdtChartsTwoDimensionalChart): ChartLegendMarkerModel;
|
|
11
11
|
export declare function getLineViewOptions(chart: MdtChartsTwoDimensionalChart): TwoDimensionalChartLegendLineModel;
|
|
12
12
|
export declare function getWidthOfLegendMarkerByType(chartType: TwoDimensionalChartType): number;
|
|
13
13
|
export declare function getAreaViewOptions(chart: MdtChartsTwoDimensionalChart, chartIndex: number, style: ChartStyle, chartBlockId: number): AreaChartViewOptions;
|