mdt-charts 1.10.3 → 1.12.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 +18 -5
- package/lib/designer/designerConfig.d.ts +8 -2
- package/lib/engine/features/aggregator/aggregator.d.ts +4 -3
- package/lib/engine/features/aggregator/aggregator.js +14 -11
- package/lib/engine/features/legend/legend.d.ts +10 -1
- package/lib/engine/features/legend/legend.js +10 -22
- package/lib/engine/features/legend/legendHelper.d.ts +4 -5
- package/lib/engine/features/legend/legendHelper.js +19 -23
- package/lib/engine/features/legend/legendHelperService.d.ts +12 -0
- package/lib/engine/features/legend/legendHelperService.js +30 -0
- package/lib/engine/features/recordOverflowAlert/recordOverflowAlertCore.d.ts +28 -0
- package/lib/engine/features/recordOverflowAlert/recordOverflowAlertCore.js +50 -0
- package/lib/engine/features/title/title.js +2 -0
- package/lib/engine/features/tolltip/tooltip.js +1 -1
- package/lib/engine/filterManager/filterEventManager.d.ts +3 -3
- package/lib/engine/filterManager/filterEventManager.js +4 -4
- package/lib/engine/intervalNotation/intervalManager.js +2 -5
- package/lib/engine/polarNotation/donut/DonutHelper.d.ts +2 -0
- package/lib/engine/polarNotation/donut/DonutHelper.js +20 -3
- package/lib/engine/polarNotation/donut/donut.js +1 -1
- package/lib/engine/polarNotation/extenders/polarRecordOverflowAlert.d.ts +15 -0
- package/lib/engine/polarNotation/extenders/polarRecordOverflowAlert.js +40 -0
- package/lib/engine/polarNotation/polarManager.js +16 -12
- package/lib/engine/twoDimensionalNotation/extenders/twoDimRecordOverflowAlert.d.ts +15 -0
- package/lib/engine/twoDimensionalNotation/extenders/twoDimRecordOverflowAlert.js +32 -0
- package/lib/engine/twoDimensionalNotation/twoDimensionalManager.js +13 -7
- package/lib/model/chartStyleModel/TwoDimensionalChartStyleModel.d.ts +19 -0
- package/lib/model/chartStyleModel/TwoDimensionalChartStyleModel.js +61 -0
- package/lib/model/chartStyleModel/chartStyleModel.d.ts +9 -0
- package/lib/model/chartStyleModel/chartStyleModel.js +27 -0
- package/lib/model/{dataManagerModel.d.ts → dataManagerModel/dataManagerModel.d.ts} +18 -6
- package/lib/model/{dataManagerModel.js → dataManagerModel/dataManagerModel.js} +52 -44
- package/lib/model/dataManagerModel/dataManagerModelService.d.ts +5 -0
- package/lib/model/dataManagerModel/dataManagerModelService.js +28 -0
- package/lib/model/featuresModel/axisModel.d.ts +10 -8
- package/lib/model/featuresModel/axisModel.js +28 -26
- package/lib/model/featuresModel/axisModelService.d.ts +4 -0
- package/lib/model/featuresModel/axisModelService.js +11 -0
- package/lib/model/featuresModel/legendModel/legendCanvasModel.d.ts +4 -2
- package/lib/model/featuresModel/legendModel/legendCanvasModel.js +42 -29
- package/lib/model/featuresModel/legendModel/legendModel.d.ts +4 -6
- package/lib/model/featuresModel/legendModel/legendModel.js +18 -21
- package/lib/model/featuresModel/legendModel/polarMarginCalculator.d.ts +11 -0
- package/lib/model/featuresModel/legendModel/polarMarginCalculator.js +42 -0
- package/lib/model/featuresModel/otherComponents.d.ts +9 -2
- package/lib/model/featuresModel/otherComponents.js +6 -4
- package/lib/model/featuresModel/scaleModel.d.ts +7 -6
- package/lib/model/featuresModel/scaleModel.js +9 -9
- package/lib/model/featuresModel/titleModel.d.ts +1 -1
- package/lib/model/featuresModel/titleModel.js +8 -6
- package/lib/model/marginModel.d.ts +7 -6
- package/lib/model/marginModel.js +44 -38
- package/lib/model/model.d.ts +25 -20
- package/lib/model/modelBuilder.js +27 -38
- package/lib/model/modelInstance/canvasModel/canvasModel.d.ts +24 -0
- package/lib/model/modelInstance/canvasModel/canvasModel.js +44 -0
- package/lib/model/modelInstance/canvasModel/legendCanvasModel.d.ts +7 -0
- package/lib/model/modelInstance/canvasModel/legendCanvasModel.js +13 -0
- package/lib/model/modelInstance/canvasModel/titleCanvas.d.ts +9 -0
- package/lib/model/modelInstance/canvasModel/titleCanvas.js +11 -0
- package/lib/model/modelInstance/dataModel.d.ts +11 -0
- package/lib/model/modelInstance/dataModel.js +23 -0
- package/lib/model/modelInstance/modelInstance.d.ts +10 -0
- package/lib/model/modelInstance/modelInstance.js +17 -0
- package/lib/model/notations/intervalModel.d.ts +2 -1
- package/lib/model/notations/intervalModel.js +17 -15
- package/lib/model/notations/polarModel.d.ts +11 -3
- package/lib/model/notations/polarModel.js +40 -8
- package/lib/model/notations/twoDimensionalModel.d.ts +7 -5
- package/lib/model/notations/twoDimensionalModel.js +19 -12
- package/lib/style/charts-main.css +27 -7
- package/lib/style/charts-main.less +27 -7
- package/package.json +3 -2
- package/tsconfig.production.json +23 -0
- package/lib/engine/features/recordOverflowAlert/recordOverflowAlert.d.ts +0 -14
- package/lib/engine/features/recordOverflowAlert/recordOverflowAlert.js +0 -97
- package/lib/model/chartStyleModel.d.ts +0 -16
- package/lib/model/chartStyleModel.js +0 -67
|
@@ -1,34 +1,37 @@
|
|
|
1
1
|
import { ModelHelper } from "../modelHelper";
|
|
2
2
|
import { AxisType, CLASSES } from "../modelBuilder";
|
|
3
|
-
import { DataManagerModel } from "../dataManagerModel";
|
|
3
|
+
import { DataManagerModel } from "../dataManagerModel/dataManagerModel";
|
|
4
4
|
import { TwoDimensionalModel } from "../notations/twoDimensionalModel";
|
|
5
|
+
import { AxisModelService } from "./axisModelService";
|
|
5
6
|
export class AxisModel {
|
|
6
|
-
static getKeyAxis(
|
|
7
|
+
static getKeyAxis(options, data, labelConfig, canvasModel, tooltipSettings) {
|
|
8
|
+
const { charts, orientation, data: dataOptions } = options;
|
|
9
|
+
const axisConfig = options.axis.key;
|
|
7
10
|
return {
|
|
8
11
|
type: 'key',
|
|
9
|
-
orient: AxisModel.getAxisOrient(AxisType.Key,
|
|
12
|
+
orient: AxisModel.getAxisOrient(AxisType.Key, orientation, axisConfig.position),
|
|
10
13
|
translate: {
|
|
11
|
-
translateX: AxisModel.getAxisTranslateX(AxisType.Key,
|
|
12
|
-
translateY: AxisModel.getAxisTranslateY(AxisType.Key,
|
|
14
|
+
translateX: AxisModel.getAxisTranslateX(AxisType.Key, orientation, axisConfig.position, canvasModel),
|
|
15
|
+
translateY: AxisModel.getAxisTranslateY(AxisType.Key, orientation, axisConfig.position, canvasModel)
|
|
13
16
|
},
|
|
14
17
|
cssClass: 'key-axis',
|
|
15
18
|
ticks: axisConfig.ticks,
|
|
16
19
|
labels: {
|
|
17
20
|
maxSize: AxisModel.getLabelSize(labelConfig.maxSize.main, data[dataOptions.dataSource].map(d => d[dataOptions.keyField.name])).width,
|
|
18
|
-
position: AxisModel.getKeyAxisLabelPosition(
|
|
19
|
-
visible: !TwoDimensionalModel.getChartsEmbeddedLabelsFlag(charts,
|
|
21
|
+
position: AxisModel.getKeyAxisLabelPosition(canvasModel, DataManagerModel.getDataValuesByKeyField(data, dataOptions.dataSource, dataOptions.keyField.name).length, axisConfig),
|
|
22
|
+
visible: !TwoDimensionalModel.getChartsEmbeddedLabelsFlag(charts, orientation),
|
|
20
23
|
defaultTooltip: tooltipSettings.position === 'fixed'
|
|
21
24
|
},
|
|
22
25
|
visibility: axisConfig.visibility
|
|
23
26
|
};
|
|
24
27
|
}
|
|
25
|
-
static getValueAxis(orient, axisConfig, labelConfig,
|
|
28
|
+
static getValueAxis(orient, axisConfig, labelConfig, canvasModel) {
|
|
26
29
|
return {
|
|
27
30
|
type: 'value',
|
|
28
31
|
orient: AxisModel.getAxisOrient(AxisType.Value, orient, axisConfig.position),
|
|
29
32
|
translate: {
|
|
30
|
-
translateX: AxisModel.getAxisTranslateX(AxisType.Value, orient, axisConfig.position,
|
|
31
|
-
translateY: AxisModel.getAxisTranslateY(AxisType.Value, orient, axisConfig.position,
|
|
33
|
+
translateX: AxisModel.getAxisTranslateX(AxisType.Value, orient, axisConfig.position, canvasModel),
|
|
34
|
+
translateY: AxisModel.getAxisTranslateY(AxisType.Value, orient, axisConfig.position, canvasModel)
|
|
32
35
|
},
|
|
33
36
|
cssClass: 'value-axis',
|
|
34
37
|
ticks: axisConfig.ticks,
|
|
@@ -41,12 +44,12 @@ export class AxisModel {
|
|
|
41
44
|
visibility: axisConfig.visibility
|
|
42
45
|
};
|
|
43
46
|
}
|
|
44
|
-
static getAxisLength(chartOrientation,
|
|
47
|
+
static getAxisLength(chartOrientation, canvasModel) {
|
|
45
48
|
if (chartOrientation === 'horizontal') {
|
|
46
|
-
return
|
|
49
|
+
return canvasModel.getChartBlockHeight();
|
|
47
50
|
}
|
|
48
51
|
else {
|
|
49
|
-
return
|
|
52
|
+
return canvasModel.getChartBlockWidth();
|
|
50
53
|
}
|
|
51
54
|
}
|
|
52
55
|
static getAxisOrient(axisType, chartOrientation, axisPosition) {
|
|
@@ -59,27 +62,25 @@ export class AxisModel {
|
|
|
59
62
|
return axisType === AxisType.Key ? 'left' : 'top';
|
|
60
63
|
return axisType === AxisType.Key ? 'right' : 'bottom';
|
|
61
64
|
}
|
|
62
|
-
static getAxisTranslateX(axisType, chartOrientation, axisPosition,
|
|
65
|
+
static getAxisTranslateX(axisType, chartOrientation, axisPosition, canvasModel) {
|
|
63
66
|
const orient = AxisModel.getAxisOrient(axisType, chartOrientation, axisPosition);
|
|
64
67
|
if (orient === 'top' || orient === 'left')
|
|
65
|
-
return
|
|
68
|
+
return canvasModel.getMarginSide("left");
|
|
66
69
|
else if (orient === 'bottom')
|
|
67
|
-
return
|
|
68
|
-
return
|
|
70
|
+
return canvasModel.getMarginSide("left");
|
|
71
|
+
return canvasModel.getBlockSize().width - canvasModel.getMarginSide("right");
|
|
69
72
|
}
|
|
70
|
-
static getAxisTranslateY(axisType, chartOrientation, axisPosition,
|
|
73
|
+
static getAxisTranslateY(axisType, chartOrientation, axisPosition, canvasModel) {
|
|
71
74
|
const orient = AxisModel.getAxisOrient(axisType, chartOrientation, axisPosition);
|
|
72
75
|
if (orient === 'top' || orient === 'left')
|
|
73
|
-
return
|
|
76
|
+
return canvasModel.getMarginSide("top");
|
|
74
77
|
else if (orient === 'bottom')
|
|
75
|
-
return
|
|
76
|
-
return
|
|
78
|
+
return canvasModel.getBlockSize().height - canvasModel.getMarginSide("bottom");
|
|
79
|
+
return canvasModel.getMarginSide("top");
|
|
77
80
|
}
|
|
78
|
-
static getKeyAxisLabelPosition(
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
return 'rotated';
|
|
82
|
-
return 'straight';
|
|
81
|
+
static getKeyAxisLabelPosition(canvasModel, scopedDataLength, axisConfig) {
|
|
82
|
+
var _a;
|
|
83
|
+
return this.service.getKeyAxisLabelPosition(canvasModel.getChartBlockWidth(), scopedDataLength, (_a = axisConfig === null || axisConfig === void 0 ? void 0 : axisConfig.labels) === null || _a === void 0 ? void 0 : _a.position);
|
|
83
84
|
}
|
|
84
85
|
static getLabelSize(labelMaxWidth, labelTexts) {
|
|
85
86
|
const labelSize = {
|
|
@@ -109,3 +110,4 @@ export class AxisModel {
|
|
|
109
110
|
return labelSize;
|
|
110
111
|
}
|
|
111
112
|
}
|
|
113
|
+
AxisModel.service = new AxisModelService();
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export class AxisModelService {
|
|
2
|
+
getKeyAxisLabelPosition(chartBlockWidth, scopedDataLength, positionFromConfig) {
|
|
3
|
+
if (positionFromConfig === "rotated" || positionFromConfig === "straight") {
|
|
4
|
+
return positionFromConfig;
|
|
5
|
+
}
|
|
6
|
+
const minBandSize = 50;
|
|
7
|
+
if (chartBlockWidth / scopedDataLength < minBandSize)
|
|
8
|
+
return 'rotated';
|
|
9
|
+
return 'straight';
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { DataLegendParams } from "../../dataManagerModel/dataManagerModel";
|
|
1
2
|
import { LegendPosition } from "../../model";
|
|
2
3
|
export declare type LegendItemsDirection = 'row' | 'column';
|
|
3
4
|
export declare class LegendCanvasModel {
|
|
4
|
-
static getLegendHeight(texts: string[],
|
|
5
|
+
static getLegendHeight(texts: string[], chartBlockWidth: number, itemsDirection: LegendItemsDirection, legendPosition: LegendPosition): number;
|
|
5
6
|
static getLegendItemWidth(text: string): number;
|
|
6
|
-
static findElementsAmountByLegendSize(texts: string[], position: LegendPosition, legendBlockWidth: number, legendBlockHeight: number):
|
|
7
|
+
static findElementsAmountByLegendSize(texts: string[], position: LegendPosition, legendBlockWidth: number, legendBlockHeight: number): DataLegendParams;
|
|
8
|
+
private static getLegendWrapperEl;
|
|
7
9
|
}
|
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
import { CLASSES } from "../../modelBuilder";
|
|
2
|
-
import { LegendModel } from "./legendModel";
|
|
3
2
|
export class LegendCanvasModel {
|
|
4
|
-
static getLegendHeight(texts,
|
|
5
|
-
const legendWrapper =
|
|
6
|
-
legendWrapper.style.opacity = '0';
|
|
7
|
-
legendWrapper.style.display = 'flex';
|
|
8
|
-
if (itemsPosition === 'column')
|
|
9
|
-
legendWrapper.style.flexDirection = 'column';
|
|
10
|
-
legendWrapper.style.position = 'absolute';
|
|
11
|
-
legendWrapper.style.width = blockWidth - marginLeft - marginRight + 'px';
|
|
3
|
+
static getLegendHeight(texts, chartBlockWidth, itemsDirection, legendPosition) {
|
|
4
|
+
const legendWrapper = this.getLegendWrapperEl(chartBlockWidth, itemsDirection);
|
|
12
5
|
texts.forEach(text => {
|
|
13
6
|
const itemWrapper = document.createElement('div');
|
|
14
7
|
const colorBlock = document.createElement('span');
|
|
15
8
|
const textBlock = document.createElement('span');
|
|
16
|
-
itemWrapper.classList.add(
|
|
17
|
-
if (
|
|
18
|
-
itemWrapper.
|
|
19
|
-
|
|
9
|
+
itemWrapper.classList.add("legend-item");
|
|
10
|
+
if (legendPosition === 'bottom') {
|
|
11
|
+
itemWrapper.classList.add('legend-item-inline');
|
|
12
|
+
textBlock.classList.add('legend-label-nowrap');
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
itemWrapper.classList.add('legend-item-row');
|
|
20
16
|
}
|
|
21
17
|
colorBlock.classList.add(CLASSES.legendColor);
|
|
22
18
|
textBlock.classList.add(CLASSES.legendLabel);
|
|
@@ -27,7 +23,7 @@ export class LegendCanvasModel {
|
|
|
27
23
|
document.body.append(legendWrapper);
|
|
28
24
|
const height = legendWrapper.offsetHeight;
|
|
29
25
|
legendWrapper.remove();
|
|
30
|
-
return height;
|
|
26
|
+
return height + 1;
|
|
31
27
|
}
|
|
32
28
|
static getLegendItemWidth(text) {
|
|
33
29
|
const itemWrapper = document.createElement('div');
|
|
@@ -48,39 +44,56 @@ export class LegendCanvasModel {
|
|
|
48
44
|
return sumWidth;
|
|
49
45
|
}
|
|
50
46
|
static findElementsAmountByLegendSize(texts, position, legendBlockWidth, legendBlockHeight) {
|
|
51
|
-
const legendWrapper =
|
|
52
|
-
legendWrapper.style.opacity = '0';
|
|
53
|
-
legendWrapper.style.display = 'flex';
|
|
54
|
-
legendWrapper.style.flexDirection = 'column';
|
|
55
|
-
legendWrapper.style.position = 'absolute';
|
|
56
|
-
legendWrapper.style.width = legendBlockWidth + 'px';
|
|
47
|
+
const legendWrapper = this.getLegendWrapperEl(legendBlockWidth, position === "right" ? "column" : "row");
|
|
57
48
|
document.body.append(legendWrapper);
|
|
58
49
|
let amount = 0;
|
|
59
50
|
for (let i = 0; i < texts.length; i++) {
|
|
60
51
|
const itemWrapper = document.createElement('div');
|
|
61
52
|
const colorBlock = document.createElement('span');
|
|
62
53
|
const textBlock = document.createElement('span');
|
|
63
|
-
itemWrapper.classList.add(
|
|
64
|
-
if (position === 'bottom')
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
54
|
+
itemWrapper.classList.add("legend-item");
|
|
55
|
+
if (position === 'bottom') {
|
|
56
|
+
itemWrapper.classList.add('legend-item-inline');
|
|
57
|
+
textBlock.classList.add('legend-label-nowrap');
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
itemWrapper.classList.add('legend-item-row');
|
|
61
|
+
}
|
|
68
62
|
colorBlock.classList.add(CLASSES.legendColor);
|
|
69
63
|
textBlock.classList.add(CLASSES.legendLabel);
|
|
70
64
|
textBlock.textContent = texts[i];
|
|
71
65
|
itemWrapper.append(colorBlock, textBlock);
|
|
72
66
|
legendWrapper.append(itemWrapper);
|
|
67
|
+
amount++;
|
|
73
68
|
if (legendWrapper.offsetHeight > legendBlockHeight) {
|
|
74
69
|
itemWrapper.remove();
|
|
75
70
|
if (legendBlockHeight - legendWrapper.offsetHeight >= 15 && position !== 'bottom')
|
|
76
|
-
amount =
|
|
71
|
+
amount = amount; //TODO: remove
|
|
77
72
|
else
|
|
78
|
-
amount
|
|
73
|
+
amount -= 1;
|
|
79
74
|
break;
|
|
80
75
|
}
|
|
81
|
-
amount++;
|
|
82
76
|
}
|
|
77
|
+
const size = {
|
|
78
|
+
width: legendWrapper.offsetWidth,
|
|
79
|
+
height: legendWrapper.offsetHeight
|
|
80
|
+
};
|
|
83
81
|
legendWrapper.remove();
|
|
84
|
-
return
|
|
82
|
+
return {
|
|
83
|
+
amount: amount < 0 ? 0 : amount,
|
|
84
|
+
size
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
static getLegendWrapperEl(legendBlockWidth, itemsDirection) {
|
|
88
|
+
const legendWrapper = document.createElement('div');
|
|
89
|
+
legendWrapper.style.opacity = '0';
|
|
90
|
+
legendWrapper.style.position = 'absolute';
|
|
91
|
+
legendWrapper.style.display = "flex";
|
|
92
|
+
if (itemsDirection === "column")
|
|
93
|
+
legendWrapper.classList.add("legend-block-column");
|
|
94
|
+
else
|
|
95
|
+
legendWrapper.classList.add("legend-block-row", "legend-wrapper-with-wrap");
|
|
96
|
+
legendWrapper.style.maxWidth = legendBlockWidth + 'px';
|
|
97
|
+
return legendWrapper;
|
|
85
98
|
}
|
|
86
99
|
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { ChartNotation, Size } from "../../../config/config";
|
|
2
|
-
import {
|
|
2
|
+
import { ILegendModel, LegendBlockModel, Orient } from "../../model";
|
|
3
|
+
import { CanvasModel } from "../../modelInstance/canvasModel/canvasModel";
|
|
3
4
|
import { LegendItemsDirection } from "./legendCanvasModel";
|
|
4
|
-
/** If donut block has width less than this const, legend change postion from "right" to "bottom" */
|
|
5
|
-
export declare const MIN_DONUT_BLOCK_SIZE = 260;
|
|
6
5
|
export declare class LegendModel {
|
|
7
6
|
static getLegendSize(chartNotation: ChartNotation, position: Orient, texts: string[], legendMaxWidth: number, blockSize: Size, legendBlockModel: LegendBlockModel): number;
|
|
8
|
-
static getBaseLegendBlockModel(notation: ChartNotation): LegendBlockModel;
|
|
9
|
-
static getLegendModel(chartNotation: ChartNotation, legendShow: boolean,
|
|
7
|
+
static getBaseLegendBlockModel(notation: ChartNotation, canvasModel: CanvasModel): LegendBlockModel;
|
|
8
|
+
static getLegendModel(chartNotation: ChartNotation, legendShow: boolean, canvasModel: CanvasModel): ILegendModel;
|
|
10
9
|
static getLegendItemClass(itemsPosition: LegendItemsDirection): string;
|
|
11
|
-
static getMarginClass(legendPosition: LegendPosition): string;
|
|
12
10
|
private static getLegendWidth;
|
|
13
11
|
}
|
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
import { ModelHelper } from "../../modelHelper";
|
|
2
|
-
import {
|
|
2
|
+
import { PolarModel } from "../../notations/polarModel";
|
|
3
3
|
import { LegendCanvasModel } from "./legendCanvasModel";
|
|
4
|
-
/** If donut block has width less than this const, legend change postion from "right" to "bottom" */
|
|
5
|
-
export const MIN_DONUT_BLOCK_SIZE = 260;
|
|
6
4
|
export class LegendModel {
|
|
7
5
|
static getLegendSize(chartNotation, position, texts, legendMaxWidth, blockSize, legendBlockModel) {
|
|
8
6
|
if (position === 'left' || position === 'right')
|
|
9
7
|
return this.getLegendWidth(texts, legendMaxWidth);
|
|
8
|
+
//TODO: rm duplicate
|
|
10
9
|
if (chartNotation === '2d' || chartNotation === 'interval') {
|
|
11
|
-
return LegendCanvasModel.getLegendHeight(texts, blockSize.width
|
|
10
|
+
return LegendCanvasModel.getLegendHeight(texts, blockSize.width - legendBlockModel.coordinate[position].margin.left - legendBlockModel.coordinate[position].margin.right, 'row', position);
|
|
12
11
|
}
|
|
13
12
|
else if (chartNotation === 'polar') {
|
|
14
|
-
const size = LegendCanvasModel.getLegendHeight(texts, blockSize.width
|
|
13
|
+
const size = LegendCanvasModel.getLegendHeight(texts, blockSize.width - legendBlockModel.coordinate[position].margin.left - legendBlockModel.coordinate[position].margin.right, 'row', position);
|
|
15
14
|
return size;
|
|
16
15
|
}
|
|
17
16
|
}
|
|
18
|
-
static getBaseLegendBlockModel(notation) {
|
|
17
|
+
static getBaseLegendBlockModel(notation, canvasModel) {
|
|
19
18
|
const mt = 20, mb = 20, ml = 20, mr = 20;
|
|
20
|
-
const titleModelTemplate = TitleModel.getTitleModel();
|
|
21
19
|
return {
|
|
22
20
|
coordinate: {
|
|
23
21
|
left: {
|
|
@@ -27,31 +25,33 @@ export class LegendModel {
|
|
|
27
25
|
},
|
|
28
26
|
bottom: {
|
|
29
27
|
size: 0,
|
|
30
|
-
margin: { top: 0, bottom: 20, left:
|
|
28
|
+
margin: { top: 0, bottom: 20, left: 0, right: 0 },
|
|
31
29
|
pad: 0
|
|
32
30
|
},
|
|
33
31
|
right: {
|
|
34
32
|
size: 0,
|
|
35
|
-
margin: { top:
|
|
33
|
+
margin: { top: canvasModel.titleCanvas.getAllNeededSpace(), bottom: mb, left: 10, right: 0 },
|
|
36
34
|
pad: 0
|
|
37
35
|
},
|
|
38
36
|
top: {
|
|
39
37
|
size: 0,
|
|
40
|
-
margin: { top:
|
|
41
|
-
pad:
|
|
38
|
+
margin: { top: 10, bottom: 10, left: 20, right: 20 },
|
|
39
|
+
pad: canvasModel.titleCanvas.getAllNeededSpace()
|
|
42
40
|
}
|
|
43
41
|
},
|
|
44
42
|
standartTooltip: notation === 'polar' ? false : true
|
|
45
43
|
};
|
|
46
44
|
}
|
|
47
|
-
static getLegendModel(chartNotation, legendShow,
|
|
45
|
+
static getLegendModel(chartNotation, legendShow, canvasModel) {
|
|
46
|
+
if (!legendShow)
|
|
47
|
+
return {
|
|
48
|
+
position: 'off'
|
|
49
|
+
};
|
|
48
50
|
let legendPosition = 'off';
|
|
49
|
-
if (
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
legendPosition = blockSize.width - margin.left - margin.right < MIN_DONUT_BLOCK_SIZE ? 'bottom' : 'right';
|
|
54
|
-
}
|
|
51
|
+
if (chartNotation === '2d' || chartNotation === 'interval')
|
|
52
|
+
legendPosition = 'top';
|
|
53
|
+
else if (chartNotation === 'polar') {
|
|
54
|
+
legendPosition = PolarModel.getLegendPositionByBlockSize(canvasModel);
|
|
55
55
|
}
|
|
56
56
|
return {
|
|
57
57
|
position: legendPosition
|
|
@@ -60,9 +60,6 @@ export class LegendModel {
|
|
|
60
60
|
static getLegendItemClass(itemsPosition) {
|
|
61
61
|
return itemsPosition === 'column' ? 'legend-item-row' : 'legend-item-inline';
|
|
62
62
|
}
|
|
63
|
-
static getMarginClass(legendPosition) {
|
|
64
|
-
return legendPosition === 'right' ? 'mt-15' : 'mt-10';
|
|
65
|
-
}
|
|
66
63
|
static getLegendWidth(texts, legendMaxWidth) {
|
|
67
64
|
let longestText = '';
|
|
68
65
|
let biggestScore = 0;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MdtChartsDataSource, MdtChartsPolarOptions } from "../../../config/config";
|
|
2
|
+
import { LegendBlockModel } from "../../model";
|
|
3
|
+
import { CanvasModel } from "../../modelInstance/canvasModel/canvasModel";
|
|
4
|
+
import { ModelInstance } from "../../modelInstance/modelInstance";
|
|
5
|
+
export declare class LegendPolarMarginCalculator {
|
|
6
|
+
recalcMargin(modelInstance: ModelInstance, options: MdtChartsPolarOptions, legendMaxWidth: number, legendBlockModel: LegendBlockModel, data: MdtChartsDataSource): void;
|
|
7
|
+
updateMargin(legendPosition: "right" | "bottom", canvasModel: CanvasModel, legendBlockModel: LegendBlockModel, size: number): void;
|
|
8
|
+
private updateMarginObj;
|
|
9
|
+
private getLegendSize;
|
|
10
|
+
private getLegendItemsContent;
|
|
11
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { DataManagerModel } from "../../dataManagerModel/dataManagerModel";
|
|
2
|
+
import { MarginModel } from "../../marginModel";
|
|
3
|
+
import { MIN_DONUT_BLOCK_SIZE } from "../../notations/polarModel";
|
|
4
|
+
import { LegendModel } from "./legendModel";
|
|
5
|
+
export class LegendPolarMarginCalculator {
|
|
6
|
+
recalcMargin(modelInstance, options, legendMaxWidth, legendBlockModel, data) {
|
|
7
|
+
const canvasModel = modelInstance.canvasModel;
|
|
8
|
+
let legendPosition = LegendModel.getLegendModel(options.type, options.legend.show, modelInstance.canvasModel).position;
|
|
9
|
+
modelInstance.canvasModel.legendCanvas.setPosition(legendPosition);
|
|
10
|
+
if (legendPosition === "off")
|
|
11
|
+
return;
|
|
12
|
+
let legendSize = this.getLegendSize(options, legendMaxWidth, legendBlockModel, data, canvasModel, legendPosition);
|
|
13
|
+
if (legendPosition === "right" && canvasModel.getChartBlockWidth() - legendSize < MIN_DONUT_BLOCK_SIZE) {
|
|
14
|
+
legendSize = this.getLegendSize(options, legendMaxWidth, legendBlockModel, data, canvasModel, "bottom");
|
|
15
|
+
legendPosition = "bottom";
|
|
16
|
+
modelInstance.canvasModel.legendCanvas.setPosition(legendPosition);
|
|
17
|
+
}
|
|
18
|
+
if (legendSize !== 0) {
|
|
19
|
+
canvasModel.increaseMarginSide(legendPosition, legendSize);
|
|
20
|
+
MarginModel.appendToGlobalMarginValuesLegendMargin(canvasModel, legendPosition, legendBlockModel);
|
|
21
|
+
}
|
|
22
|
+
legendBlockModel.coordinate[legendPosition].size = legendSize;
|
|
23
|
+
}
|
|
24
|
+
updateMargin(legendPosition, canvasModel, legendBlockModel, size) {
|
|
25
|
+
canvasModel.legendCanvas.setPosition(legendPosition);
|
|
26
|
+
this.updateMarginObj(legendBlockModel, legendPosition, size, canvasModel);
|
|
27
|
+
}
|
|
28
|
+
updateMarginObj(legendBlockModel, legendPosition, legendSize, canvasModel) {
|
|
29
|
+
if (legendSize !== 0) {
|
|
30
|
+
canvasModel.increaseMarginSide(legendPosition, legendSize);
|
|
31
|
+
MarginModel.appendToGlobalMarginValuesLegendMargin(canvasModel, legendPosition, legendBlockModel);
|
|
32
|
+
}
|
|
33
|
+
legendBlockModel.coordinate[legendPosition].size = legendSize;
|
|
34
|
+
}
|
|
35
|
+
getLegendSize(options, legendMaxWidth, legendBlockModel, data, canvasModel, legendPosition) {
|
|
36
|
+
const legendItemsContent = this.getLegendItemsContent(options, data);
|
|
37
|
+
return LegendModel.getLegendSize(options.type, legendPosition, legendItemsContent, legendMaxWidth, canvasModel.getBlockSize(), legendBlockModel);
|
|
38
|
+
}
|
|
39
|
+
getLegendItemsContent(options, data) {
|
|
40
|
+
return DataManagerModel.getDataValuesByKeyField(data, options.data.dataSource, options.data.keyField.name);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OtherCommonComponents } from "../model";
|
|
2
2
|
import { ElementsOptions } from "../../designer/designerConfig";
|
|
3
3
|
import { ChartNotation } from "../../config/config";
|
|
4
|
+
import { ModelInstance } from "../modelInstance/modelInstance";
|
|
5
|
+
interface OtherComponentsModelDependencies {
|
|
6
|
+
elementsOptions: ElementsOptions;
|
|
7
|
+
title: string;
|
|
8
|
+
notation: ChartNotation;
|
|
9
|
+
}
|
|
4
10
|
export declare class OtherComponentsModel {
|
|
5
|
-
static getOtherComponentsModel(
|
|
11
|
+
static getOtherComponentsModel(dependencies: OtherComponentsModelDependencies, modelInstance: ModelInstance): OtherCommonComponents;
|
|
6
12
|
}
|
|
13
|
+
export {};
|
|
@@ -2,11 +2,13 @@ import { LegendModel } from "./legendModel/legendModel";
|
|
|
2
2
|
import { TitleModel } from "./titleModel";
|
|
3
3
|
import { TooltipModel } from "./tooltipModel";
|
|
4
4
|
export class OtherComponentsModel {
|
|
5
|
-
static getOtherComponentsModel(
|
|
5
|
+
static getOtherComponentsModel(dependencies, modelInstance) {
|
|
6
|
+
const canvasModel = modelInstance.canvasModel;
|
|
7
|
+
canvasModel.titleCanvas.init(TitleModel.getTitleModel(dependencies.title));
|
|
6
8
|
return {
|
|
7
|
-
legendBlock: LegendModel.getBaseLegendBlockModel(notation),
|
|
8
|
-
titleBlock:
|
|
9
|
-
tooltipBlock: TooltipModel.getTooltipModel(elementsOptions.tooltip)
|
|
9
|
+
legendBlock: LegendModel.getBaseLegendBlockModel(dependencies.notation, canvasModel),
|
|
10
|
+
titleBlock: canvasModel.titleCanvas.getModel(),
|
|
11
|
+
tooltipBlock: TooltipModel.getTooltipModel(dependencies.elementsOptions.tooltip)
|
|
10
12
|
};
|
|
11
13
|
}
|
|
12
14
|
}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AxisPosition, NumberDomain, IntervalChart, TwoDimensionalChart,
|
|
1
|
+
import { ScaleKeyModel, ScaleKeyType, ScaleValueModel, ScaleValueType } from "../model";
|
|
2
|
+
import { AxisPosition, NumberDomain, IntervalChart, TwoDimensionalChart, MdtChartsTwoDimensionalOptions, ChartOrientation, MdtChartsDataSource } from "../../config/config";
|
|
3
|
+
import { CanvasModel } from "../modelInstance/canvasModel/canvasModel";
|
|
3
4
|
export declare enum ScaleType {
|
|
4
5
|
Key = 0,
|
|
5
6
|
Value = 1
|
|
6
7
|
}
|
|
7
8
|
export declare class ScaleModel {
|
|
8
|
-
static getScaleKey(allowableKeys: string[], orient: ChartOrientation,
|
|
9
|
-
static getScaleLinear(options:
|
|
10
|
-
static getRangePeek(scaleType: ScaleType, chartOrientation: string,
|
|
9
|
+
static getScaleKey(allowableKeys: string[], orient: ChartOrientation, canvasModel: CanvasModel, charts: TwoDimensionalChart[], barCharts: TwoDimensionalChart[]): ScaleKeyModel;
|
|
10
|
+
static getScaleLinear(options: MdtChartsTwoDimensionalOptions, data: MdtChartsDataSource, canvasModel: CanvasModel): ScaleValueModel;
|
|
11
|
+
static getRangePeek(scaleType: ScaleType, chartOrientation: string, canvasModel: CanvasModel): number;
|
|
11
12
|
static getDateValueDomain(data: MdtChartsDataSource, chart: IntervalChart, keyAxisPosition: AxisPosition, dataSource: string): [Date, Date];
|
|
12
|
-
static getLinearDomain(configDomain: NumberDomain, data: MdtChartsDataSource, configOptions:
|
|
13
|
+
static getLinearDomain(configDomain: NumberDomain, data: MdtChartsDataSource, configOptions: MdtChartsTwoDimensionalOptions): [number, number];
|
|
13
14
|
static getScaleKeyType(charts: TwoDimensionalChart[]): ScaleKeyType;
|
|
14
15
|
static getScaleValueType(charts: TwoDimensionalChart[] | IntervalChart[]): ScaleValueType;
|
|
15
16
|
static getElementsAmount(barCharts: TwoDimensionalChart[]): number;
|
|
@@ -5,35 +5,35 @@ export var ScaleType;
|
|
|
5
5
|
ScaleType[ScaleType["Value"] = 1] = "Value";
|
|
6
6
|
})(ScaleType || (ScaleType = {}));
|
|
7
7
|
export class ScaleModel {
|
|
8
|
-
static getScaleKey(allowableKeys, orient,
|
|
8
|
+
static getScaleKey(allowableKeys, orient, canvasModel, charts, barCharts) {
|
|
9
9
|
return {
|
|
10
10
|
domain: allowableKeys,
|
|
11
11
|
range: {
|
|
12
12
|
start: 0,
|
|
13
|
-
end: ScaleModel.getRangePeek(ScaleType.Key, orient,
|
|
13
|
+
end: ScaleModel.getRangePeek(ScaleType.Key, orient, canvasModel)
|
|
14
14
|
},
|
|
15
15
|
type: ScaleModel.getScaleKeyType(charts),
|
|
16
16
|
elementsAmount: this.getElementsAmount(barCharts)
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
|
-
static getScaleLinear(options, data,
|
|
19
|
+
static getScaleLinear(options, data, canvasModel) {
|
|
20
20
|
return {
|
|
21
21
|
domain: ScaleModel.getLinearDomain(options.axis.value.domain, data, options),
|
|
22
22
|
range: {
|
|
23
23
|
start: 0,
|
|
24
|
-
end: ScaleModel.getRangePeek(ScaleType.Value, options.orientation,
|
|
24
|
+
end: ScaleModel.getRangePeek(ScaleType.Value, options.orientation, canvasModel)
|
|
25
25
|
},
|
|
26
26
|
type: ScaleModel.getScaleValueType(options.charts)
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
-
static getRangePeek(scaleType, chartOrientation,
|
|
29
|
+
static getRangePeek(scaleType, chartOrientation, canvasModel) {
|
|
30
30
|
if (chartOrientation === 'vertical')
|
|
31
31
|
return scaleType === ScaleType.Key
|
|
32
|
-
?
|
|
33
|
-
:
|
|
32
|
+
? canvasModel.getChartBlockWidth()
|
|
33
|
+
: canvasModel.getChartBlockHeight();
|
|
34
34
|
return scaleType === ScaleType.Key
|
|
35
|
-
?
|
|
36
|
-
:
|
|
35
|
+
? canvasModel.getChartBlockHeight()
|
|
36
|
+
: canvasModel.getChartBlockWidth();
|
|
37
37
|
}
|
|
38
38
|
static getDateValueDomain(data, chart, keyAxisPosition, dataSource) {
|
|
39
39
|
const minMax = ModelHelper.getMinAndMaxOfIntervalData(data, dataSource, chart);
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
export class TitleModel {
|
|
2
|
-
static getTitleModel() {
|
|
2
|
+
static getTitleModel(titleText) {
|
|
3
|
+
const defaultPads = 20;
|
|
4
|
+
const pad = titleText ? defaultPads : 0;
|
|
3
5
|
return {
|
|
4
6
|
margin: {
|
|
5
|
-
bottom:
|
|
6
|
-
left:
|
|
7
|
-
right:
|
|
8
|
-
top:
|
|
7
|
+
bottom: 10,
|
|
8
|
+
left: pad,
|
|
9
|
+
right: pad,
|
|
10
|
+
top: pad
|
|
9
11
|
},
|
|
10
|
-
size:
|
|
12
|
+
size: pad,
|
|
11
13
|
pad: 0
|
|
12
14
|
};
|
|
13
15
|
}
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import { MdtChartsConfig, MdtChartsDataSource } from "../config/config";
|
|
2
2
|
import { DesignerConfig } from "../designer/designerConfig";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { DataScope, LegendBlockModel, Orient, OtherCommonComponents, PolarOptionsModel } from "./model";
|
|
4
|
+
import { ModelInstance } from "./modelInstance/modelInstance";
|
|
5
|
+
import { CanvasModel } from "./modelInstance/canvasModel/canvasModel";
|
|
5
6
|
export declare const AXIS_HORIZONTAL_LABEL_PADDING = 15;
|
|
6
7
|
export declare const AXIS_VERTICAL_LABEL_PADDING = 10;
|
|
7
8
|
export declare class MarginModel {
|
|
8
|
-
static
|
|
9
|
-
static recalcPolarMarginWithScopedData(
|
|
10
|
-
static recalcMarginByVerticalAxisLabel(
|
|
9
|
+
static initMargin(designerConfig: DesignerConfig, config: MdtChartsConfig, otherComponents: OtherCommonComponents, data: MdtChartsDataSource, modelInstance: ModelInstance): void;
|
|
10
|
+
static recalcPolarMarginWithScopedData(modelInstance: ModelInstance, designerConfig: DesignerConfig, config: MdtChartsConfig, legendBlockModel: LegendBlockModel, dataScope: DataScope, options: PolarOptionsModel): void;
|
|
11
|
+
static recalcMarginByVerticalAxisLabel(modelInstance: ModelInstance, config: MdtChartsConfig, designerConfig: DesignerConfig, dataScope: DataScope): void;
|
|
11
12
|
private static getHorizontalMarginByAxisLabels;
|
|
12
13
|
private static recalcVerticalMarginByAxisLabelHeight;
|
|
13
14
|
private static recalcHorizontalMarginByAxisLabelWidth;
|
|
14
15
|
private static recalcMarginWithLegend;
|
|
15
16
|
private static getLegendItemsContent;
|
|
16
|
-
|
|
17
|
+
static appendToGlobalMarginValuesLegendMargin(canvasModel: CanvasModel, position: Orient, legendBlockModel: LegendBlockModel): void;
|
|
17
18
|
private static clearMarginByLegendBlockPosition;
|
|
18
19
|
private static recalcMarginByTitle;
|
|
19
20
|
}
|