mdt-charts 1.11.1 → 1.12.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/config/config.d.ts +25 -12
- package/lib/designer/designerConfig.d.ts +3 -5
- package/lib/engine/features/aggregator/aggregator.d.ts +8 -6
- package/lib/engine/features/aggregator/aggregator.js +45 -32
- 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/intervalNotation/intervalManager.js +0 -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 +11 -6
- 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 +9 -3
- package/lib/model/chartStyleModel/TwoDimensionalChartStyleModel.d.ts +4 -4
- package/lib/model/{dataManagerModel.d.ts → dataManagerModel/dataManagerModel.d.ts} +18 -7
- package/lib/model/{dataManagerModel.js → dataManagerModel/dataManagerModel.js} +51 -45
- package/lib/model/dataManagerModel/dataManagerModelService.d.ts +5 -0
- package/lib/model/dataManagerModel/dataManagerModelService.js +28 -0
- package/lib/model/featuresModel/axisModel.d.ts +5 -4
- package/lib/model/featuresModel/axisModel.js +14 -12
- 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 +1 -4
- package/lib/model/featuresModel/legendModel/legendModel.js +15 -16
- package/lib/model/featuresModel/legendModel/polarMarginCalculator.d.ts +11 -0
- package/lib/model/featuresModel/legendModel/polarMarginCalculator.js +42 -0
- package/lib/model/featuresModel/scaleModel.d.ts +6 -6
- package/lib/model/featuresModel/titleModel.js +4 -4
- package/lib/model/marginModel.d.ts +3 -2
- package/lib/model/marginModel.js +11 -7
- package/lib/model/model.d.ts +19 -8
- package/lib/model/modelBuilder.js +9 -9
- package/lib/model/modelInstance/canvasModel/canvasModel.d.ts +2 -0
- package/lib/model/modelInstance/canvasModel/canvasModel.js +2 -0
- package/lib/model/modelInstance/canvasModel/legendCanvasModel.d.ts +7 -0
- package/lib/model/modelInstance/canvasModel/legendCanvasModel.js +13 -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 +3 -0
- package/lib/model/modelInstance/modelInstance.js +7 -1
- package/lib/model/notations/intervalModel.d.ts +2 -2
- package/lib/model/notations/intervalModel.js +2 -3
- package/lib/model/notations/polar/donut/donutAggregatorService.d.ts +12 -0
- package/lib/model/notations/polar/donut/donutAggregatorService.js +25 -0
- package/lib/model/notations/polar/donut/donutModel.d.ts +10 -0
- package/lib/model/notations/polar/donut/donutModel.js +32 -0
- package/lib/model/notations/polar/donut/donutThicknessService.d.ts +9 -0
- package/lib/model/notations/polar/donut/donutThicknessService.js +30 -0
- package/lib/model/notations/polar/polarModel.d.ts +16 -0
- package/lib/model/notations/polar/polarModel.js +55 -0
- package/lib/model/notations/polarModel.d.ts +7 -1
- package/lib/model/notations/polarModel.js +24 -2
- package/lib/model/notations/twoDimensionalModel.d.ts +4 -4
- package/lib/model/notations/twoDimensionalModel.js +2 -3
- package/lib/style/charts-main.css +29 -9
- package/lib/style/charts-main.less +29 -9
- package/package.json +2 -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
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { ChartNotation, Size } from "../../../config/config";
|
|
2
|
-
import { ILegendModel, LegendBlockModel,
|
|
2
|
+
import { ILegendModel, LegendBlockModel, Orient } from "../../model";
|
|
3
3
|
import { CanvasModel } from "../../modelInstance/canvasModel/canvasModel";
|
|
4
4
|
import { LegendItemsDirection } from "./legendCanvasModel";
|
|
5
|
-
/** If donut block has width less than this const, legend change postion from "right" to "bottom" */
|
|
6
|
-
export declare const MIN_DONUT_BLOCK_SIZE = 260;
|
|
7
5
|
export declare class LegendModel {
|
|
8
6
|
static getLegendSize(chartNotation: ChartNotation, position: Orient, texts: string[], legendMaxWidth: number, blockSize: Size, legendBlockModel: LegendBlockModel): number;
|
|
9
7
|
static getBaseLegendBlockModel(notation: ChartNotation, canvasModel: CanvasModel): LegendBlockModel;
|
|
10
8
|
static getLegendModel(chartNotation: ChartNotation, legendShow: boolean, canvasModel: CanvasModel): ILegendModel;
|
|
11
9
|
static getLegendItemClass(itemsPosition: LegendItemsDirection): string;
|
|
12
|
-
static getMarginClass(legendPosition: LegendPosition): string;
|
|
13
10
|
private static getLegendWidth;
|
|
14
11
|
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { ModelHelper } from "../../modelHelper";
|
|
2
|
+
import { PolarModel } from "../../notations/polar/polarModel";
|
|
2
3
|
import { LegendCanvasModel } from "./legendCanvasModel";
|
|
3
|
-
/** If donut block has width less than this const, legend change postion from "right" to "bottom" */
|
|
4
|
-
export const MIN_DONUT_BLOCK_SIZE = 260;
|
|
5
4
|
export class LegendModel {
|
|
6
5
|
static getLegendSize(chartNotation, position, texts, legendMaxWidth, blockSize, legendBlockModel) {
|
|
7
6
|
if (position === 'left' || position === 'right')
|
|
8
7
|
return this.getLegendWidth(texts, legendMaxWidth);
|
|
8
|
+
//TODO: rm duplicate
|
|
9
9
|
if (chartNotation === '2d' || chartNotation === 'interval') {
|
|
10
|
-
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);
|
|
11
11
|
}
|
|
12
12
|
else if (chartNotation === 'polar') {
|
|
13
|
-
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);
|
|
14
14
|
return size;
|
|
15
15
|
}
|
|
16
16
|
}
|
|
@@ -25,17 +25,17 @@ export class LegendModel {
|
|
|
25
25
|
},
|
|
26
26
|
bottom: {
|
|
27
27
|
size: 0,
|
|
28
|
-
margin: { top: 0, bottom: 20, left:
|
|
28
|
+
margin: { top: 0, bottom: 20, left: 0, right: 0 },
|
|
29
29
|
pad: 0
|
|
30
30
|
},
|
|
31
31
|
right: {
|
|
32
32
|
size: 0,
|
|
33
|
-
margin: { top: canvasModel.titleCanvas.getAllNeededSpace(), bottom: mb, left:
|
|
33
|
+
margin: { top: canvasModel.titleCanvas.getAllNeededSpace(), bottom: mb, left: 10, right: 0 },
|
|
34
34
|
pad: 0
|
|
35
35
|
},
|
|
36
36
|
top: {
|
|
37
37
|
size: 0,
|
|
38
|
-
margin: { top:
|
|
38
|
+
margin: { top: 10, bottom: 10, left: 20, right: 20 },
|
|
39
39
|
pad: canvasModel.titleCanvas.getAllNeededSpace()
|
|
40
40
|
}
|
|
41
41
|
},
|
|
@@ -43,13 +43,15 @@ export class LegendModel {
|
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
45
|
static getLegendModel(chartNotation, legendShow, canvasModel) {
|
|
46
|
+
if (!legendShow)
|
|
47
|
+
return {
|
|
48
|
+
position: 'off'
|
|
49
|
+
};
|
|
46
50
|
let legendPosition = 'off';
|
|
47
|
-
if (
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
legendPosition = canvasModel.getChartBlockWidth() < MIN_DONUT_BLOCK_SIZE ? 'bottom' : 'right';
|
|
52
|
-
}
|
|
51
|
+
if (chartNotation === '2d' || chartNotation === 'interval')
|
|
52
|
+
legendPosition = 'top';
|
|
53
|
+
else if (chartNotation === 'polar') {
|
|
54
|
+
legendPosition = PolarModel.getLegendPositionByBlockSize(canvasModel);
|
|
53
55
|
}
|
|
54
56
|
return {
|
|
55
57
|
position: legendPosition
|
|
@@ -58,9 +60,6 @@ export class LegendModel {
|
|
|
58
60
|
static getLegendItemClass(itemsPosition) {
|
|
59
61
|
return itemsPosition === 'column' ? 'legend-item-row' : 'legend-item-inline';
|
|
60
62
|
}
|
|
61
|
-
static getMarginClass(legendPosition) {
|
|
62
|
-
return legendPosition === 'right' ? 'mt-15' : 'mt-10';
|
|
63
|
-
}
|
|
64
63
|
static getLegendWidth(texts, legendMaxWidth) {
|
|
65
64
|
let longestText = '';
|
|
66
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/polar/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,18 +1,18 @@
|
|
|
1
1
|
import { ScaleKeyModel, ScaleKeyType, ScaleValueModel, ScaleValueType } from "../model";
|
|
2
|
-
import { AxisPosition, NumberDomain, IntervalChart,
|
|
2
|
+
import { AxisPosition, NumberDomain, IntervalChart, MdtChartsTwoDimensionalChart, MdtChartsTwoDimensionalOptions, ChartOrientation, MdtChartsDataSource } from "../../config/config";
|
|
3
3
|
import { CanvasModel } from "../modelInstance/canvasModel/canvasModel";
|
|
4
4
|
export declare enum ScaleType {
|
|
5
5
|
Key = 0,
|
|
6
6
|
Value = 1
|
|
7
7
|
}
|
|
8
8
|
export declare class ScaleModel {
|
|
9
|
-
static getScaleKey(allowableKeys: string[], orient: ChartOrientation, canvasModel: CanvasModel, charts:
|
|
9
|
+
static getScaleKey(allowableKeys: string[], orient: ChartOrientation, canvasModel: CanvasModel, charts: MdtChartsTwoDimensionalChart[], barCharts: MdtChartsTwoDimensionalChart[]): ScaleKeyModel;
|
|
10
10
|
static getScaleLinear(options: MdtChartsTwoDimensionalOptions, data: MdtChartsDataSource, canvasModel: CanvasModel): ScaleValueModel;
|
|
11
11
|
static getRangePeek(scaleType: ScaleType, chartOrientation: string, canvasModel: CanvasModel): number;
|
|
12
12
|
static getDateValueDomain(data: MdtChartsDataSource, chart: IntervalChart, keyAxisPosition: AxisPosition, dataSource: string): [Date, Date];
|
|
13
13
|
static getLinearDomain(configDomain: NumberDomain, data: MdtChartsDataSource, configOptions: MdtChartsTwoDimensionalOptions): [number, number];
|
|
14
|
-
static getScaleKeyType(charts:
|
|
15
|
-
static getScaleValueType(charts:
|
|
16
|
-
static getElementsAmount(barCharts:
|
|
17
|
-
static getScaleMaxValue(charts:
|
|
14
|
+
static getScaleKeyType(charts: MdtChartsTwoDimensionalChart[]): ScaleKeyType;
|
|
15
|
+
static getScaleValueType(charts: MdtChartsTwoDimensionalChart[] | IntervalChart[]): ScaleValueType;
|
|
16
|
+
static getElementsAmount(barCharts: MdtChartsTwoDimensionalChart[]): number;
|
|
17
|
+
static getScaleMaxValue(charts: MdtChartsTwoDimensionalChart[], dataSource: string, data: MdtChartsDataSource): number;
|
|
18
18
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { MdtChartsConfig, MdtChartsDataSource } from "../config/config";
|
|
2
2
|
import { DesignerConfig } from "../designer/designerConfig";
|
|
3
|
-
import { DataScope, LegendBlockModel, OtherCommonComponents, PolarOptionsModel } from "./model";
|
|
3
|
+
import { DataScope, LegendBlockModel, Orient, OtherCommonComponents, PolarOptionsModel } from "./model";
|
|
4
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 {
|
|
@@ -13,7 +14,7 @@ export declare class MarginModel {
|
|
|
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
|
}
|
package/lib/model/marginModel.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { AxisModel } from "./featuresModel/axisModel";
|
|
2
|
-
import { DataManagerModel } from "./dataManagerModel";
|
|
3
|
-
import { LegendModel
|
|
2
|
+
import { DataManagerModel } from "./dataManagerModel/dataManagerModel";
|
|
3
|
+
import { LegendModel } from "./featuresModel/legendModel/legendModel";
|
|
4
4
|
import { AxisType } from "./modelBuilder";
|
|
5
5
|
import { TwoDimensionalModel } from "./notations/twoDimensionalModel";
|
|
6
|
+
import { PolarModel } from "./notations/polar/polarModel";
|
|
6
7
|
export const AXIS_HORIZONTAL_LABEL_PADDING = 15;
|
|
7
8
|
export const AXIS_VERTICAL_LABEL_PADDING = 10;
|
|
8
9
|
export class MarginModel {
|
|
@@ -25,10 +26,9 @@ export class MarginModel {
|
|
|
25
26
|
}
|
|
26
27
|
static recalcPolarMarginWithScopedData(modelInstance, designerConfig, config, legendBlockModel, dataScope, options) {
|
|
27
28
|
const canvasModel = modelInstance.canvasModel;
|
|
28
|
-
let position =
|
|
29
|
+
let position = canvasModel.legendCanvas.getPosition();
|
|
29
30
|
if (position !== 'off') {
|
|
30
|
-
|
|
31
|
-
position = 'bottom';
|
|
31
|
+
position = PolarModel.getLegendPositionByBlockSize(canvasModel); // reset position
|
|
32
32
|
this.clearMarginByLegendBlockPosition(canvasModel, legendBlockModel);
|
|
33
33
|
let allowableKeys = [...dataScope.allowableKeys];
|
|
34
34
|
if (dataScope.hidedRecordsAmount !== 0 && position === 'bottom')
|
|
@@ -42,7 +42,7 @@ export class MarginModel {
|
|
|
42
42
|
static recalcMarginByVerticalAxisLabel(modelInstance, config, designerConfig, dataScope) {
|
|
43
43
|
if ((config.options.type === '2d' || config.options.type === 'interval') && config.options.orientation === 'vertical') {
|
|
44
44
|
const axisLabelSize = AxisModel.getLabelSize(designerConfig.canvas.axisLabel.maxSize.main, dataScope.allowableKeys);
|
|
45
|
-
const axisConfig = AxisModel.getKeyAxisLabelPosition(modelInstance.canvasModel, dataScope.allowableKeys.length);
|
|
45
|
+
const axisConfig = AxisModel.getKeyAxisLabelPosition(modelInstance.canvasModel, dataScope.allowableKeys.length, config.options.axis.key);
|
|
46
46
|
const marginOrient = config.options.axis.key.position === 'end' ? 'bottom' : 'top';
|
|
47
47
|
if (axisConfig === 'rotated')
|
|
48
48
|
modelInstance.canvasModel.setMarginSide(marginOrient, modelInstance.canvasModel.getMarginSide(marginOrient) + (axisLabelSize.width - axisLabelSize.height));
|
|
@@ -80,8 +80,12 @@ export class MarginModel {
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
static recalcMarginWithLegend(modelInstance, config, legendMaxWidth, legendBlockModel, data) {
|
|
83
|
+
if (config.options.type === "polar") {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
83
86
|
const canvasModel = modelInstance.canvasModel;
|
|
84
87
|
const legendPosition = LegendModel.getLegendModel(config.options.type, config.options.legend.show, modelInstance.canvasModel).position;
|
|
88
|
+
modelInstance.canvasModel.legendCanvas.setPosition(legendPosition);
|
|
85
89
|
if (legendPosition !== 'off') {
|
|
86
90
|
const legendItemsContent = this.getLegendItemsContent(config.options, data);
|
|
87
91
|
const legendSize = LegendModel.getLegendSize(config.options.type, legendPosition, legendItemsContent, legendMaxWidth, canvasModel.getBlockSize(), legendBlockModel);
|
|
@@ -123,6 +127,6 @@ export class MarginModel {
|
|
|
123
127
|
});
|
|
124
128
|
}
|
|
125
129
|
static recalcMarginByTitle(canvasModel, titleBlockModel) {
|
|
126
|
-
canvasModel.increaseMarginSide("top", titleBlockModel.margin.top + titleBlockModel.size);
|
|
130
|
+
canvasModel.increaseMarginSide("top", titleBlockModel.margin.top + titleBlockModel.size + titleBlockModel.margin.bottom);
|
|
127
131
|
}
|
|
128
132
|
}
|
package/lib/model/model.d.ts
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
import { ChartOrientation, MdtChartsColorField, IntervalChartType, PolarChartType, Size, TooltipOptions, TwoDimensionalChartType } from "../config/config";
|
|
1
|
+
import { ChartOrientation, MdtChartsColorField, IntervalChartType, PolarChartType, Size, TooltipOptions, TwoDimensionalChartType, AxisLabelPosition } from "../config/config";
|
|
2
2
|
import { DataType, DonutOptionsCanvas, Formatter, TooltipSettings, Transitions } from "../designer/designerConfig";
|
|
3
3
|
declare type AxisType = "key" | "value";
|
|
4
4
|
export declare type Orient = "top" | "bottom" | "left" | "right";
|
|
5
5
|
export declare type ScaleKeyType = "band" | "point";
|
|
6
6
|
export declare type ScaleValueType = "linear" | "datetime";
|
|
7
|
-
export declare type AxisLabelPosition = "straight" | "rotated";
|
|
8
7
|
export declare type LegendPosition = "off" | "top" | "bottom" | "left" | "right";
|
|
9
8
|
export declare type EmbeddedLabelTypeModel = "none" | "key" | "value";
|
|
10
9
|
export declare type DataOptions = {
|
|
11
10
|
[option: string]: any;
|
|
12
11
|
};
|
|
13
|
-
export interface Model {
|
|
12
|
+
export interface Model<O = TwoDimensionalOptionsModel | PolarOptionsModel | IntervalOptionsModel> {
|
|
14
13
|
blockCanvas: BlockCanvas;
|
|
15
14
|
chartBlock: ChartBlockModel;
|
|
16
|
-
options:
|
|
15
|
+
options: O;
|
|
17
16
|
otherComponents: OtherCommonComponents;
|
|
18
17
|
dataSettings: DataSettings;
|
|
19
18
|
transitions?: Transitions;
|
|
@@ -137,12 +136,24 @@ export interface BarChartSettings {
|
|
|
137
136
|
maxBarWidth: number;
|
|
138
137
|
minBarWidth: number;
|
|
139
138
|
}
|
|
140
|
-
export interface DonutChartSettings extends Omit<DonutOptionsCanvas, "aggregatorPad"> {
|
|
141
|
-
aggregator:
|
|
139
|
+
export interface DonutChartSettings extends Omit<DonutOptionsCanvas, "aggregatorPad" | "thickness"> {
|
|
140
|
+
aggregator: DonutAggregatorModel;
|
|
141
|
+
thickness: DonutThicknessOptions;
|
|
142
142
|
}
|
|
143
|
-
export interface
|
|
143
|
+
export interface DonutAggregatorModel {
|
|
144
144
|
margin: number;
|
|
145
|
-
|
|
145
|
+
content: DonutAggregatorContent;
|
|
146
|
+
}
|
|
147
|
+
export interface DonutAggregatorContent {
|
|
148
|
+
value: string | number;
|
|
149
|
+
title: string;
|
|
150
|
+
}
|
|
151
|
+
export declare type DonutThicknessUnit = "px" | "%";
|
|
152
|
+
export interface DonutThicknessOptions {
|
|
153
|
+
min: number;
|
|
154
|
+
max: number;
|
|
155
|
+
value: number;
|
|
156
|
+
unit: DonutThicknessUnit;
|
|
146
157
|
}
|
|
147
158
|
interface ChartModel {
|
|
148
159
|
tooltip: TooltipModel;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MarginModel } from './marginModel';
|
|
2
2
|
import { TwoDimensionalModel } from './notations/twoDimensionalModel';
|
|
3
|
-
import { PolarModel } from './notations/polarModel';
|
|
4
|
-
import { DataManagerModel } from './dataManagerModel';
|
|
3
|
+
import { PolarModel } from './notations/polar/polarModel';
|
|
4
|
+
import { DataManagerModel } from './dataManagerModel/dataManagerModel';
|
|
5
5
|
import { IntervalModel } from './notations/intervalModel';
|
|
6
6
|
import { OtherComponentsModel } from './featuresModel/otherComponents';
|
|
7
7
|
import { ConfigValidator } from './configsValidator/configValidator';
|
|
@@ -69,17 +69,17 @@ export function assembleModel(config, data, designerConfig) {
|
|
|
69
69
|
resetFalsyValues(data, config.options.data.keyField.name);
|
|
70
70
|
const otherComponents = OtherComponentsModel.getOtherComponentsModel({ elementsOptions: designerConfig.elementsOptions, notation: config.options.type, title: config.options.title }, modelInstance);
|
|
71
71
|
MarginModel.initMargin(designerConfig, config, otherComponents, data, modelInstance);
|
|
72
|
-
|
|
73
|
-
const preparedData = DataManagerModel.getPreparedData(data,
|
|
72
|
+
DataManagerModel.initDataScope(config, data, designerConfig, otherComponents.legendBlock, modelInstance);
|
|
73
|
+
const preparedData = DataManagerModel.getPreparedData(data, modelInstance.dataModel.getAllowableKeys(), config);
|
|
74
74
|
if (config.options.type === '2d' && config.options.axis.key.visibility)
|
|
75
|
-
MarginModel.recalcMarginByVerticalAxisLabel(modelInstance, config, designerConfig,
|
|
75
|
+
MarginModel.recalcMarginByVerticalAxisLabel(modelInstance, config, designerConfig, modelInstance.dataModel.getScope());
|
|
76
76
|
const blockCanvas = getBlockCanvas(config, modelInstance);
|
|
77
77
|
const chartBlock = getChartBlockModel(modelInstance);
|
|
78
|
-
const options = getOptions(config, designerConfig, modelInstance,
|
|
79
|
-
const dataSettings = getDataSettings(
|
|
78
|
+
const options = getOptions(config, designerConfig, modelInstance, modelInstance.dataModel.getScope(), preparedData);
|
|
79
|
+
const dataSettings = getDataSettings(modelInstance.dataModel.getScope(), designerConfig);
|
|
80
80
|
const transitions = getTransitions(designerConfig);
|
|
81
|
-
if (options.type === 'polar')
|
|
82
|
-
|
|
81
|
+
// if (options.type === 'polar')
|
|
82
|
+
// MarginModel.recalcPolarMarginWithScopedData(modelInstance, designerConfig, config, otherComponents.legendBlock, modelInstance.dataModel.getScope(), options);
|
|
83
83
|
modelInstance.canvasModel.roundMargin();
|
|
84
84
|
return {
|
|
85
85
|
blockCanvas,
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { Size } from "../../../config/config";
|
|
2
2
|
import { BlockMargin } from "../../model";
|
|
3
|
+
import { LegendCanvasModelInstance } from "./legendCanvasModel";
|
|
3
4
|
import { TitleCanvasModel } from "./titleCanvas";
|
|
4
5
|
declare type MarginSide = keyof BlockMargin;
|
|
5
6
|
export declare class CanvasModel {
|
|
6
7
|
titleCanvas: TitleCanvasModel;
|
|
8
|
+
legendCanvas: LegendCanvasModelInstance;
|
|
7
9
|
private blockSize;
|
|
8
10
|
private margin;
|
|
9
11
|
constructor();
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { LegendCanvasModelInstance } from "./legendCanvasModel";
|
|
1
2
|
import { TitleCanvasModel } from "./titleCanvas";
|
|
2
3
|
export class CanvasModel {
|
|
3
4
|
constructor() {
|
|
4
5
|
this.titleCanvas = new TitleCanvasModel();
|
|
6
|
+
this.legendCanvas = new LegendCanvasModelInstance();
|
|
5
7
|
}
|
|
6
8
|
initMargin(margin) {
|
|
7
9
|
this.margin = margin;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DataScope } from "../model";
|
|
2
|
+
export declare const DEFAULT_MAX_RECORDS_AMOUNT = 50;
|
|
3
|
+
export declare class DataModelInstance {
|
|
4
|
+
private maxRecordsAmount;
|
|
5
|
+
private scope;
|
|
6
|
+
initMaxRecordsAmount(amount: number): void;
|
|
7
|
+
getMaxRecordsAmount(): number;
|
|
8
|
+
initScope(scope: DataScope): void;
|
|
9
|
+
getScope(): DataScope;
|
|
10
|
+
getAllowableKeys(): string[];
|
|
11
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export const DEFAULT_MAX_RECORDS_AMOUNT = 50;
|
|
2
|
+
export class DataModelInstance {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.maxRecordsAmount = DEFAULT_MAX_RECORDS_AMOUNT;
|
|
5
|
+
}
|
|
6
|
+
initMaxRecordsAmount(amount) {
|
|
7
|
+
if (typeof amount === "number" && amount > 0) {
|
|
8
|
+
this.maxRecordsAmount = amount;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
getMaxRecordsAmount() {
|
|
12
|
+
return this.maxRecordsAmount;
|
|
13
|
+
}
|
|
14
|
+
initScope(scope) {
|
|
15
|
+
this.scope = scope;
|
|
16
|
+
}
|
|
17
|
+
getScope() {
|
|
18
|
+
return this.scope;
|
|
19
|
+
}
|
|
20
|
+
getAllowableKeys() {
|
|
21
|
+
return this.getScope().allowableKeys;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { MdtChartsConfig } from "../../main";
|
|
2
2
|
import { CanvasModel } from "./canvasModel/canvasModel";
|
|
3
|
+
import { DataModelInstance } from "./dataModel";
|
|
3
4
|
export declare class ModelInstance {
|
|
4
5
|
static create(config: MdtChartsConfig): ModelInstance;
|
|
6
|
+
private static initInitialParams;
|
|
5
7
|
canvasModel: CanvasModel;
|
|
8
|
+
dataModel: DataModelInstance;
|
|
6
9
|
constructor();
|
|
7
10
|
}
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { CanvasModel } from "./canvasModel/canvasModel";
|
|
2
|
+
import { DataModelInstance } from "./dataModel";
|
|
2
3
|
export class ModelInstance {
|
|
3
4
|
constructor() {
|
|
4
5
|
this.canvasModel = new CanvasModel();
|
|
6
|
+
this.dataModel = new DataModelInstance();
|
|
5
7
|
}
|
|
6
8
|
static create(config) {
|
|
7
9
|
const modelInstance = new ModelInstance();
|
|
8
|
-
|
|
10
|
+
this.initInitialParams(modelInstance, config);
|
|
9
11
|
return modelInstance;
|
|
10
12
|
}
|
|
13
|
+
static initInitialParams(modelInstance, config) {
|
|
14
|
+
modelInstance.canvasModel.initBlockSize(config.canvas.size);
|
|
15
|
+
modelInstance.dataModel.initMaxRecordsAmount(config.options.data.maxRecordsAmount);
|
|
16
|
+
}
|
|
11
17
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { MdtChartsConfig, MdtChartsDataSource,
|
|
1
|
+
import { MdtChartsConfig, MdtChartsDataSource, MdtChartsIntervalOptions } from "../../config/config";
|
|
2
2
|
import { DesignerConfig } from "../../designer/designerConfig";
|
|
3
3
|
import { AdditionalElementsOptions, BlockMargin, DataScope, IntervalOptionsModel } from "../model";
|
|
4
4
|
import { ModelInstance } from "../modelInstance/modelInstance";
|
|
5
5
|
export declare class IntervalModel {
|
|
6
6
|
static getOptions(config: MdtChartsConfig, designerConfig: DesignerConfig, margin: BlockMargin, dataScope: DataScope, data: MdtChartsDataSource, modelInstance: ModelInstance): IntervalOptionsModel;
|
|
7
|
-
static getAdditionalElements(options:
|
|
7
|
+
static getAdditionalElements(options: MdtChartsIntervalOptions): AdditionalElementsOptions;
|
|
8
8
|
private static getChartsModel;
|
|
9
9
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { AxisModel } from "../featuresModel/axisModel";
|
|
2
2
|
import { ChartStyleModelService } from "../chartStyleModel/chartStyleModel";
|
|
3
|
-
import { DataManagerModel } from "../dataManagerModel";
|
|
4
|
-
import { LegendModel } from "../featuresModel/legendModel/legendModel";
|
|
3
|
+
import { DataManagerModel } from "../dataManagerModel/dataManagerModel";
|
|
5
4
|
import { AxisType } from "../modelBuilder";
|
|
6
5
|
import { ScaleModel, ScaleType } from "../featuresModel/scaleModel";
|
|
7
6
|
import { TwoDimensionalModel } from "./twoDimensionalModel";
|
|
@@ -10,7 +9,7 @@ export class IntervalModel {
|
|
|
10
9
|
const options = config.options;
|
|
11
10
|
const canvasModel = modelInstance.canvasModel;
|
|
12
11
|
return {
|
|
13
|
-
legend:
|
|
12
|
+
legend: canvasModel.legendCanvas.getModel(),
|
|
14
13
|
title: options.title,
|
|
15
14
|
selectable: !!options.selectable,
|
|
16
15
|
orient: options.orientation,
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { MdtChartsDataRow, MdtChartsDonutAggregator } from "../../../../config/config";
|
|
2
|
+
import { DonutAggregatorContent } from "../../../model";
|
|
3
|
+
export declare const AGGREGATOR_DEFAULT_TITLE = "\u0421\u0443\u043C\u043C\u0430";
|
|
4
|
+
export interface AggregatorServiceDataOptions {
|
|
5
|
+
rows: MdtChartsDataRow[];
|
|
6
|
+
valueFieldName: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class DonutAggregatorService {
|
|
9
|
+
getContent(aggregatorOptions: MdtChartsDonutAggregator, dataOptions: AggregatorServiceDataOptions): DonutAggregatorContent;
|
|
10
|
+
private doesValueExist;
|
|
11
|
+
private generateDefaultContent;
|
|
12
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export const AGGREGATOR_DEFAULT_TITLE = "Сумма";
|
|
2
|
+
export class DonutAggregatorService {
|
|
3
|
+
getContent(aggregatorOptions, dataOptions) {
|
|
4
|
+
if (!(aggregatorOptions === null || aggregatorOptions === void 0 ? void 0 : aggregatorOptions.content))
|
|
5
|
+
return this.generateDefaultContent(dataOptions);
|
|
6
|
+
const content = aggregatorOptions.content({ data: dataOptions.rows });
|
|
7
|
+
if (this.doesValueExist(content.value) && content.title)
|
|
8
|
+
return content;
|
|
9
|
+
if (!content.title && this.doesValueExist(content.value))
|
|
10
|
+
return {
|
|
11
|
+
value: content.value,
|
|
12
|
+
title: AGGREGATOR_DEFAULT_TITLE
|
|
13
|
+
};
|
|
14
|
+
return this.generateDefaultContent(dataOptions);
|
|
15
|
+
}
|
|
16
|
+
doesValueExist(content) {
|
|
17
|
+
return content != null;
|
|
18
|
+
}
|
|
19
|
+
generateDefaultContent(dataOptions) {
|
|
20
|
+
return {
|
|
21
|
+
title: AGGREGATOR_DEFAULT_TITLE,
|
|
22
|
+
value: dataOptions.rows.reduce((acc, row) => acc + row[dataOptions.valueFieldName], 0)
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { MdtChartsDataRow, PolarChart } from "../../../../config/config";
|
|
2
|
+
import { DonutOptionsCanvas } from "../../../../designer/designerConfig";
|
|
3
|
+
import { DonutChartSettings } from "../../../model";
|
|
4
|
+
export declare class DonutModel {
|
|
5
|
+
private thicknessService;
|
|
6
|
+
private aggregatorService;
|
|
7
|
+
getSettings(settingsFromConfig: DonutOptionsCanvas, chartOptions: PolarChart, dataRows: MdtChartsDataRow[]): DonutChartSettings;
|
|
8
|
+
private getThicknessOptions;
|
|
9
|
+
private getAggregatorOptions;
|
|
10
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { DonutAggregatorService } from "./donutAggregatorService";
|
|
2
|
+
import { DonutThicknessService } from "./donutThicknessService";
|
|
3
|
+
export class DonutModel {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.thicknessService = new DonutThicknessService();
|
|
6
|
+
this.aggregatorService = new DonutAggregatorService();
|
|
7
|
+
}
|
|
8
|
+
getSettings(settingsFromConfig, chartOptions, dataRows) {
|
|
9
|
+
return {
|
|
10
|
+
padAngle: settingsFromConfig.padAngle,
|
|
11
|
+
thickness: this.getThicknessOptions(settingsFromConfig.thickness),
|
|
12
|
+
aggregator: this.getAggregatorOptions(settingsFromConfig, chartOptions, dataRows)
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
getThicknessOptions(settingsFromConfig) {
|
|
16
|
+
return {
|
|
17
|
+
unit: this.thicknessService.getUnit(settingsFromConfig),
|
|
18
|
+
max: this.thicknessService.valueToNumber(settingsFromConfig.max),
|
|
19
|
+
min: this.thicknessService.valueToNumber(settingsFromConfig.min),
|
|
20
|
+
value: this.thicknessService.valueToNumber(settingsFromConfig.value),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
getAggregatorOptions(settingsFromConfig, chartOptions, dataRows) {
|
|
24
|
+
return {
|
|
25
|
+
margin: settingsFromConfig.aggregatorPad,
|
|
26
|
+
content: this.aggregatorService.getContent(chartOptions.aggregator, {
|
|
27
|
+
rows: dataRows,
|
|
28
|
+
valueFieldName: chartOptions.data.valueField.name
|
|
29
|
+
})
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { MdtChartsDonutThicknessOptions } from "../../../../designer/designerConfig";
|
|
2
|
+
import { DonutThicknessUnit } from "../../../model";
|
|
3
|
+
export declare class DonutThicknessService {
|
|
4
|
+
private defaultUnit;
|
|
5
|
+
getUnit(settingsFromConfig: MdtChartsDonutThicknessOptions): DonutThicknessUnit;
|
|
6
|
+
valueToNumber(value: string | number): number;
|
|
7
|
+
private getUnitByValue;
|
|
8
|
+
private getLastUnitFromString;
|
|
9
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export class DonutThicknessService {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.defaultUnit = "px";
|
|
4
|
+
}
|
|
5
|
+
getUnit(settingsFromConfig) {
|
|
6
|
+
if (settingsFromConfig.value)
|
|
7
|
+
return this.getUnitByValue(settingsFromConfig.value);
|
|
8
|
+
const minUnit = this.getUnitByValue(settingsFromConfig.min);
|
|
9
|
+
const maxUnit = this.getUnitByValue(settingsFromConfig.max);
|
|
10
|
+
return minUnit === maxUnit ? minUnit : this.defaultUnit;
|
|
11
|
+
}
|
|
12
|
+
valueToNumber(value) {
|
|
13
|
+
if (typeof value === "number")
|
|
14
|
+
return value;
|
|
15
|
+
return parseInt(value);
|
|
16
|
+
}
|
|
17
|
+
getUnitByValue(value) {
|
|
18
|
+
if (typeof value !== "string")
|
|
19
|
+
return this.defaultUnit;
|
|
20
|
+
return this.getLastUnitFromString(value);
|
|
21
|
+
}
|
|
22
|
+
getLastUnitFromString(value) {
|
|
23
|
+
let resultUnit = this.defaultUnit;
|
|
24
|
+
["%", "px"].forEach(unit => {
|
|
25
|
+
if (value.endsWith(unit))
|
|
26
|
+
resultUnit = unit;
|
|
27
|
+
});
|
|
28
|
+
return resultUnit;
|
|
29
|
+
}
|
|
30
|
+
}
|