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
package/lib/model/marginModel.js
CHANGED
|
@@ -1,50 +1,51 @@
|
|
|
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/polarModel";
|
|
6
7
|
export const AXIS_HORIZONTAL_LABEL_PADDING = 15;
|
|
7
8
|
export const AXIS_VERTICAL_LABEL_PADDING = 10;
|
|
8
9
|
export class MarginModel {
|
|
9
|
-
static
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
this.
|
|
10
|
+
static initMargin(designerConfig, config, otherComponents, data, modelInstance) {
|
|
11
|
+
const canvasModel = modelInstance.canvasModel;
|
|
12
|
+
canvasModel.initMargin(Object.assign({}, designerConfig.canvas.chartBlockMargin));
|
|
13
|
+
this.recalcMarginWithLegend(modelInstance, config, designerConfig.canvas.legendBlock.maxWidth, otherComponents.legendBlock, data);
|
|
14
|
+
this.recalcMarginByTitle(canvasModel, otherComponents.titleBlock);
|
|
13
15
|
if (config.options.type === '2d' || config.options.type === 'interval') {
|
|
14
16
|
const labelSize = this.getHorizontalMarginByAxisLabels(designerConfig.canvas.axisLabel.maxSize.main, config.options.axis, data, config.options);
|
|
15
|
-
this.recalcVerticalMarginByAxisLabelHeight(labelSize,
|
|
17
|
+
this.recalcVerticalMarginByAxisLabelHeight(labelSize, canvasModel, config.options.orientation, config.options.axis);
|
|
16
18
|
// Если встроенный лейбл показывает ключи, то лейблы оси ключей не показываются
|
|
17
19
|
// При этом все графики должны иметь: embeddedLabels = 'key'
|
|
18
20
|
// И все графики должны быть типа bar.
|
|
19
21
|
const showingFlag = config.options.type === '2d'
|
|
20
22
|
? !TwoDimensionalModel.getChartsEmbeddedLabelsFlag(config.options.charts, config.options.orientation)
|
|
21
23
|
: true;
|
|
22
|
-
this.recalcHorizontalMarginByAxisLabelWidth(labelSize,
|
|
24
|
+
this.recalcHorizontalMarginByAxisLabelWidth(labelSize, canvasModel, config.options.orientation, config.options.axis, showingFlag);
|
|
23
25
|
}
|
|
24
|
-
return margin;
|
|
25
26
|
}
|
|
26
|
-
static recalcPolarMarginWithScopedData(
|
|
27
|
-
|
|
27
|
+
static recalcPolarMarginWithScopedData(modelInstance, designerConfig, config, legendBlockModel, dataScope, options) {
|
|
28
|
+
const canvasModel = modelInstance.canvasModel;
|
|
29
|
+
let position = canvasModel.legendCanvas.getPosition();
|
|
28
30
|
if (position !== 'off') {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
this.clearMarginByLegendBlockPosition(margin, legendBlockModel);
|
|
31
|
+
position = PolarModel.getLegendPositionByBlockSize(canvasModel); // reset position
|
|
32
|
+
this.clearMarginByLegendBlockPosition(canvasModel, legendBlockModel);
|
|
32
33
|
let allowableKeys = [...dataScope.allowableKeys];
|
|
33
34
|
if (dataScope.hidedRecordsAmount !== 0 && position === 'bottom')
|
|
34
35
|
allowableKeys.push('1'); // Если есть спрятанные записи, то в массив добавляется объект, чтобы выделить место в легенде для индикатора переполнения
|
|
35
36
|
const legendSize = LegendModel.getLegendSize(config.options.type, position, allowableKeys, designerConfig.canvas.legendBlock.maxWidth, config.canvas.size, legendBlockModel);
|
|
36
|
-
|
|
37
|
+
canvasModel.increaseMarginSide(position, legendSize + legendBlockModel.coordinate[position].margin[position]);
|
|
37
38
|
legendBlockModel.coordinate[position].size = legendSize;
|
|
38
39
|
options.legend.position = position;
|
|
39
40
|
}
|
|
40
41
|
}
|
|
41
|
-
static recalcMarginByVerticalAxisLabel(
|
|
42
|
+
static recalcMarginByVerticalAxisLabel(modelInstance, config, designerConfig, dataScope) {
|
|
42
43
|
if ((config.options.type === '2d' || config.options.type === 'interval') && config.options.orientation === 'vertical') {
|
|
43
44
|
const axisLabelSize = AxisModel.getLabelSize(designerConfig.canvas.axisLabel.maxSize.main, dataScope.allowableKeys);
|
|
44
|
-
const axisConfig = AxisModel.getKeyAxisLabelPosition(
|
|
45
|
+
const axisConfig = AxisModel.getKeyAxisLabelPosition(modelInstance.canvasModel, dataScope.allowableKeys.length, config.options.axis.key);
|
|
45
46
|
const marginOrient = config.options.axis.key.position === 'end' ? 'bottom' : 'top';
|
|
46
47
|
if (axisConfig === 'rotated')
|
|
47
|
-
|
|
48
|
+
modelInstance.canvasModel.setMarginSide(marginOrient, modelInstance.canvasModel.getMarginSide(marginOrient) + (axisLabelSize.width - axisLabelSize.height));
|
|
48
49
|
}
|
|
49
50
|
}
|
|
50
51
|
static getHorizontalMarginByAxisLabels(labelsMaxWidth, axis, data, options) {
|
|
@@ -58,35 +59,39 @@ export class MarginModel {
|
|
|
58
59
|
}
|
|
59
60
|
return AxisModel.getLabelSize(labelsMaxWidth, labelsTexts);
|
|
60
61
|
}
|
|
61
|
-
static recalcVerticalMarginByAxisLabelHeight(labelSize,
|
|
62
|
+
static recalcVerticalMarginByAxisLabelHeight(labelSize, canvasModel, orientation, axis) {
|
|
62
63
|
const keyAxisOrient = AxisModel.getAxisOrient(AxisType.Key, orientation, axis.key.position);
|
|
63
64
|
const valueAxisOrient = AxisModel.getAxisOrient(AxisType.Value, orientation, axis.value.position);
|
|
64
65
|
if ((keyAxisOrient === 'bottom' || keyAxisOrient === 'top')) {
|
|
65
66
|
if (axis.key.visibility)
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
else if (axis.value.visibility) {
|
|
69
|
-
margin[valueAxisOrient] += labelSize.height + AXIS_HORIZONTAL_LABEL_PADDING;
|
|
67
|
+
canvasModel.increaseMarginSide(keyAxisOrient, labelSize.height + AXIS_HORIZONTAL_LABEL_PADDING);
|
|
70
68
|
}
|
|
69
|
+
else if (axis.value.visibility)
|
|
70
|
+
canvasModel.increaseMarginSide(valueAxisOrient, labelSize.height + AXIS_HORIZONTAL_LABEL_PADDING);
|
|
71
71
|
}
|
|
72
|
-
static recalcHorizontalMarginByAxisLabelWidth(labelSize,
|
|
72
|
+
static recalcHorizontalMarginByAxisLabelWidth(labelSize, canvasModel, orientation, axis, isShow) {
|
|
73
73
|
const keyAxisOrient = AxisModel.getAxisOrient(AxisType.Key, orientation, axis.key.position);
|
|
74
74
|
const valueAxisOrient = AxisModel.getAxisOrient(AxisType.Value, orientation, axis.value.position);
|
|
75
75
|
if ((keyAxisOrient === 'left' || keyAxisOrient === 'right') && isShow && axis.key.visibility) {
|
|
76
|
-
|
|
76
|
+
canvasModel.increaseMarginSide(keyAxisOrient, labelSize.width + AXIS_VERTICAL_LABEL_PADDING);
|
|
77
77
|
}
|
|
78
78
|
else if ((valueAxisOrient === 'left' || valueAxisOrient === 'right') && axis.value.visibility) {
|
|
79
|
-
|
|
79
|
+
canvasModel.increaseMarginSide(valueAxisOrient, labelSize.width + AXIS_VERTICAL_LABEL_PADDING);
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
-
static recalcMarginWithLegend(
|
|
83
|
-
|
|
82
|
+
static recalcMarginWithLegend(modelInstance, config, legendMaxWidth, legendBlockModel, data) {
|
|
83
|
+
if (config.options.type === "polar") {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const canvasModel = modelInstance.canvasModel;
|
|
87
|
+
const legendPosition = LegendModel.getLegendModel(config.options.type, config.options.legend.show, modelInstance.canvasModel).position;
|
|
88
|
+
modelInstance.canvasModel.legendCanvas.setPosition(legendPosition);
|
|
84
89
|
if (legendPosition !== 'off') {
|
|
85
90
|
const legendItemsContent = this.getLegendItemsContent(config.options, data);
|
|
86
|
-
const legendSize = LegendModel.getLegendSize(config.options.type, legendPosition, legendItemsContent, legendMaxWidth,
|
|
87
|
-
|
|
91
|
+
const legendSize = LegendModel.getLegendSize(config.options.type, legendPosition, legendItemsContent, legendMaxWidth, canvasModel.getBlockSize(), legendBlockModel);
|
|
92
|
+
canvasModel.increaseMarginSide(legendPosition, legendSize);
|
|
88
93
|
if (legendSize !== 0)
|
|
89
|
-
this.appendToGlobalMarginValuesLegendMargin(
|
|
94
|
+
this.appendToGlobalMarginValuesLegendMargin(canvasModel, legendPosition, legendBlockModel);
|
|
90
95
|
legendBlockModel.coordinate[legendPosition].size = legendSize;
|
|
91
96
|
}
|
|
92
97
|
}
|
|
@@ -105,22 +110,23 @@ export class MarginModel {
|
|
|
105
110
|
return [options.chart.data.valueField1.name];
|
|
106
111
|
}
|
|
107
112
|
}
|
|
108
|
-
static appendToGlobalMarginValuesLegendMargin(
|
|
113
|
+
static appendToGlobalMarginValuesLegendMargin(canvasModel, position, legendBlockModel) {
|
|
109
114
|
const legendCoordinate = legendBlockModel.coordinate;
|
|
110
115
|
if (position === 'left' || position === 'right')
|
|
111
|
-
|
|
116
|
+
canvasModel.increaseMarginSide(position, legendCoordinate[position].margin.left + legendCoordinate[position].margin.right);
|
|
112
117
|
else
|
|
113
|
-
|
|
118
|
+
canvasModel.increaseMarginSide(position, legendCoordinate[position].margin.top + legendCoordinate[position].margin.bottom);
|
|
114
119
|
}
|
|
115
|
-
static clearMarginByLegendBlockPosition(
|
|
120
|
+
static clearMarginByLegendBlockPosition(canvasModel, legendBlockModel) {
|
|
116
121
|
const legendCoordinate = legendBlockModel.coordinate;
|
|
117
122
|
['left', 'right', 'top', 'bottom'].forEach((position) => {
|
|
118
|
-
|
|
123
|
+
const decreaseByValue = legendCoordinate[position].size === 0
|
|
119
124
|
? 0
|
|
120
125
|
: legendCoordinate[position].size + legendCoordinate[position].margin[position];
|
|
126
|
+
canvasModel.descreaseMarginSide(position, decreaseByValue);
|
|
121
127
|
});
|
|
122
128
|
}
|
|
123
|
-
static recalcMarginByTitle(
|
|
124
|
-
|
|
129
|
+
static recalcMarginByTitle(canvasModel, titleBlockModel) {
|
|
130
|
+
canvasModel.increaseMarginSide("top", titleBlockModel.margin.top + titleBlockModel.size + titleBlockModel.margin.bottom);
|
|
125
131
|
}
|
|
126
132
|
}
|
package/lib/model/model.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
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 = {
|
|
@@ -12,18 +11,17 @@ export declare type DataOptions = {
|
|
|
12
11
|
};
|
|
13
12
|
export interface Model {
|
|
14
13
|
blockCanvas: BlockCanvas;
|
|
15
|
-
chartBlock:
|
|
14
|
+
chartBlock: ChartBlockModel;
|
|
16
15
|
options: TwoDimensionalOptionsModel | PolarOptionsModel | IntervalOptionsModel;
|
|
17
|
-
otherComponents:
|
|
16
|
+
otherComponents: OtherCommonComponents;
|
|
18
17
|
dataSettings: DataSettings;
|
|
19
|
-
chartSettings: ChartElementsSettings;
|
|
20
18
|
transitions?: Transitions;
|
|
21
19
|
}
|
|
22
20
|
export interface BlockCanvas {
|
|
23
21
|
size: Size;
|
|
24
22
|
cssClass: string;
|
|
25
23
|
}
|
|
26
|
-
export interface
|
|
24
|
+
export interface ChartBlockModel {
|
|
27
25
|
margin: BlockMargin;
|
|
28
26
|
}
|
|
29
27
|
export interface BlockMargin {
|
|
@@ -46,10 +44,12 @@ export interface TwoDimensionalOptionsModel extends OptionsModel {
|
|
|
46
44
|
charts: TwoDimensionalChartModel[];
|
|
47
45
|
additionalElements: AdditionalElementsOptions;
|
|
48
46
|
orient: ChartOrientation;
|
|
47
|
+
chartSettings: TwoDimChartElementsSettings;
|
|
49
48
|
}
|
|
50
49
|
export interface PolarOptionsModel extends OptionsModel {
|
|
51
50
|
type: "polar";
|
|
52
51
|
charts: PolarChartModel[];
|
|
52
|
+
chartCanvas: DonutChartSettings;
|
|
53
53
|
}
|
|
54
54
|
export interface IntervalOptionsModel extends OptionsModel {
|
|
55
55
|
type: "interval";
|
|
@@ -58,6 +58,7 @@ export interface IntervalOptionsModel extends OptionsModel {
|
|
|
58
58
|
charts: IntervalChartModel[];
|
|
59
59
|
additionalElements: AdditionalElementsOptions;
|
|
60
60
|
orient: ChartOrientation;
|
|
61
|
+
chartSettings: TwoDimChartElementsSettings;
|
|
61
62
|
}
|
|
62
63
|
export interface ILegendModel {
|
|
63
64
|
position: LegendPosition;
|
|
@@ -125,6 +126,23 @@ export interface GridLineFlag {
|
|
|
125
126
|
key: boolean;
|
|
126
127
|
value: boolean;
|
|
127
128
|
}
|
|
129
|
+
export interface TwoDimChartElementsSettings {
|
|
130
|
+
bar: BarChartSettings;
|
|
131
|
+
}
|
|
132
|
+
export interface BarChartSettings {
|
|
133
|
+
groupMaxDistance: number;
|
|
134
|
+
groupMinDistance: number;
|
|
135
|
+
barDistance: number;
|
|
136
|
+
maxBarWidth: number;
|
|
137
|
+
minBarWidth: number;
|
|
138
|
+
}
|
|
139
|
+
export interface DonutChartSettings extends Omit<DonutOptionsCanvas, "aggregatorPad"> {
|
|
140
|
+
aggregator: DonutChartAggreagorModel;
|
|
141
|
+
}
|
|
142
|
+
export interface DonutChartAggreagorModel {
|
|
143
|
+
margin: number;
|
|
144
|
+
text: string;
|
|
145
|
+
}
|
|
128
146
|
interface ChartModel {
|
|
129
147
|
tooltip: TooltipModel;
|
|
130
148
|
cssClasses: string[];
|
|
@@ -181,20 +199,7 @@ export interface DataScope {
|
|
|
181
199
|
export interface DataFormat {
|
|
182
200
|
formatters: Formatter;
|
|
183
201
|
}
|
|
184
|
-
export interface
|
|
185
|
-
bar: BarChartSettings;
|
|
186
|
-
donut: DonutChartSettings;
|
|
187
|
-
}
|
|
188
|
-
export interface BarChartSettings {
|
|
189
|
-
groupMaxDistance: number;
|
|
190
|
-
groupMinDistance: number;
|
|
191
|
-
barDistance: number;
|
|
192
|
-
maxBarWidth: number;
|
|
193
|
-
minBarWidth: number;
|
|
194
|
-
}
|
|
195
|
-
export interface DonutChartSettings extends DonutOptionsCanvas {
|
|
196
|
-
}
|
|
197
|
-
export interface OtherComponents {
|
|
202
|
+
export interface OtherCommonComponents {
|
|
198
203
|
legendBlock: LegendBlockModel;
|
|
199
204
|
titleBlock: TitleBlockModel;
|
|
200
205
|
tooltipBlock: TooltipSettings;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { MarginModel } from './marginModel';
|
|
2
2
|
import { TwoDimensionalModel } from './notations/twoDimensionalModel';
|
|
3
3
|
import { PolarModel } from './notations/polarModel';
|
|
4
|
-
import { DataManagerModel } from './dataManagerModel';
|
|
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';
|
|
8
|
+
import { ModelInstance } from './modelInstance/modelInstance';
|
|
8
9
|
export var AxisType;
|
|
9
10
|
(function (AxisType) {
|
|
10
11
|
AxisType[AxisType["Key"] = 0] = "Key";
|
|
@@ -16,27 +17,29 @@ export const CLASSES = {
|
|
|
16
17
|
legendColor: 'legend-circle',
|
|
17
18
|
legendItem: 'legend-item',
|
|
18
19
|
};
|
|
19
|
-
function getBlockCanvas(config) {
|
|
20
|
-
const
|
|
20
|
+
function getBlockCanvas(config, modelInstance) {
|
|
21
|
+
const emptyBlockParams = { width: 0, height: 0 };
|
|
22
|
+
const size = ConfigValidator.validateCanvasSize(modelInstance.canvasModel.getBlockSize()) ? Object.assign({}, modelInstance.canvasModel.getBlockSize()) : emptyBlockParams;
|
|
21
23
|
return {
|
|
22
24
|
size,
|
|
23
25
|
cssClass: config.canvas.class
|
|
24
26
|
};
|
|
25
27
|
}
|
|
26
|
-
function
|
|
28
|
+
function getChartBlockModel(modelInstance) {
|
|
27
29
|
return {
|
|
28
|
-
margin
|
|
30
|
+
margin: modelInstance.canvasModel.getMargin()
|
|
29
31
|
};
|
|
30
32
|
}
|
|
31
|
-
function getOptions(config, designerConfig,
|
|
33
|
+
function getOptions(config, designerConfig, modelInstance, dataScope, data) {
|
|
34
|
+
//TODO: migrate to polymorphism
|
|
32
35
|
if (config.options.type === '2d') {
|
|
33
|
-
return TwoDimensionalModel.getOptions(config, designerConfig,
|
|
36
|
+
return TwoDimensionalModel.getOptions(config.options, designerConfig, dataScope, data, modelInstance);
|
|
34
37
|
}
|
|
35
38
|
else if (config.options.type === 'polar') {
|
|
36
|
-
return PolarModel.getOptions(config, data,
|
|
39
|
+
return PolarModel.getOptions(config.options, data, designerConfig, modelInstance);
|
|
37
40
|
}
|
|
38
41
|
else if (config.options.type === 'interval') {
|
|
39
|
-
return IntervalModel.getOptions(config, designerConfig,
|
|
42
|
+
return IntervalModel.getOptions(config, designerConfig, modelInstance.canvasModel.getMargin(), dataScope, data, modelInstance);
|
|
40
43
|
}
|
|
41
44
|
}
|
|
42
45
|
function getDataSettings(dataScope, designerConfig) {
|
|
@@ -45,12 +48,6 @@ function getDataSettings(dataScope, designerConfig) {
|
|
|
45
48
|
format: getDataFormat(designerConfig)
|
|
46
49
|
};
|
|
47
50
|
}
|
|
48
|
-
function getChartSettings(barSettings, donutSettings) {
|
|
49
|
-
return {
|
|
50
|
-
bar: Object.assign({}, barSettings),
|
|
51
|
-
donut: Object.assign({}, donutSettings)
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
51
|
function getDataFormat(designerConfig) {
|
|
55
52
|
return {
|
|
56
53
|
formatters: designerConfig.dataFormat.formatters
|
|
@@ -59,45 +56,37 @@ function getDataFormat(designerConfig) {
|
|
|
59
56
|
function getTransitions(designerConfig) {
|
|
60
57
|
return designerConfig.transitions;
|
|
61
58
|
}
|
|
62
|
-
function roundMargin(margin) {
|
|
63
|
-
margin.top = Math.ceil(margin.top);
|
|
64
|
-
margin.bottom = Math.ceil(margin.bottom);
|
|
65
|
-
margin.left = Math.ceil(margin.left);
|
|
66
|
-
margin.right = Math.ceil(margin.right);
|
|
67
|
-
}
|
|
68
59
|
export function assembleModel(config, data, designerConfig) {
|
|
60
|
+
const modelInstance = ModelInstance.create(config);
|
|
69
61
|
if (!data || Object.keys(data).length === 0)
|
|
70
62
|
return {
|
|
71
|
-
blockCanvas: getBlockCanvas(config),
|
|
63
|
+
blockCanvas: getBlockCanvas(config, modelInstance),
|
|
72
64
|
chartBlock: null,
|
|
73
65
|
otherComponents: null,
|
|
74
66
|
options: null,
|
|
75
|
-
dataSettings: null
|
|
76
|
-
chartSettings: null
|
|
67
|
+
dataSettings: null
|
|
77
68
|
};
|
|
78
69
|
resetFalsyValues(data, config.options.data.keyField.name);
|
|
79
|
-
const otherComponents = OtherComponentsModel.getOtherComponentsModel(designerConfig.elementsOptions, config.options.type);
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const preparedData = DataManagerModel.getPreparedData(data,
|
|
70
|
+
const otherComponents = OtherComponentsModel.getOtherComponentsModel({ elementsOptions: designerConfig.elementsOptions, notation: config.options.type, title: config.options.title }, modelInstance);
|
|
71
|
+
MarginModel.initMargin(designerConfig, config, otherComponents, data, modelInstance);
|
|
72
|
+
DataManagerModel.initDataScope(config, data, designerConfig, otherComponents.legendBlock, modelInstance);
|
|
73
|
+
const preparedData = DataManagerModel.getPreparedData(data, modelInstance.dataModel.getAllowableKeys(), config);
|
|
83
74
|
if (config.options.type === '2d' && config.options.axis.key.visibility)
|
|
84
|
-
MarginModel.recalcMarginByVerticalAxisLabel(
|
|
85
|
-
const blockCanvas = getBlockCanvas(config);
|
|
86
|
-
const chartBlock =
|
|
87
|
-
const options = getOptions(config, designerConfig,
|
|
88
|
-
const dataSettings = getDataSettings(
|
|
89
|
-
const chartSettings = getChartSettings(designerConfig.canvas.chartOptions.bar, designerConfig.canvas.chartOptions.donut);
|
|
75
|
+
MarginModel.recalcMarginByVerticalAxisLabel(modelInstance, config, designerConfig, modelInstance.dataModel.getScope());
|
|
76
|
+
const blockCanvas = getBlockCanvas(config, modelInstance);
|
|
77
|
+
const chartBlock = getChartBlockModel(modelInstance);
|
|
78
|
+
const options = getOptions(config, designerConfig, modelInstance, modelInstance.dataModel.getScope(), preparedData);
|
|
79
|
+
const dataSettings = getDataSettings(modelInstance.dataModel.getScope(), designerConfig);
|
|
90
80
|
const transitions = getTransitions(designerConfig);
|
|
91
|
-
if (options.type === 'polar')
|
|
92
|
-
|
|
93
|
-
roundMargin(
|
|
81
|
+
// if (options.type === 'polar')
|
|
82
|
+
// MarginModel.recalcPolarMarginWithScopedData(modelInstance, designerConfig, config, otherComponents.legendBlock, modelInstance.dataModel.getScope(), options);
|
|
83
|
+
modelInstance.canvasModel.roundMargin();
|
|
94
84
|
return {
|
|
95
85
|
blockCanvas,
|
|
96
86
|
chartBlock,
|
|
97
87
|
otherComponents,
|
|
98
88
|
options,
|
|
99
89
|
dataSettings,
|
|
100
|
-
chartSettings,
|
|
101
90
|
transitions
|
|
102
91
|
};
|
|
103
92
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Size } from "../../../config/config";
|
|
2
|
+
import { BlockMargin } from "../../model";
|
|
3
|
+
import { LegendCanvasModelInstance } from "./legendCanvasModel";
|
|
4
|
+
import { TitleCanvasModel } from "./titleCanvas";
|
|
5
|
+
declare type MarginSide = keyof BlockMargin;
|
|
6
|
+
export declare class CanvasModel {
|
|
7
|
+
titleCanvas: TitleCanvasModel;
|
|
8
|
+
legendCanvas: LegendCanvasModelInstance;
|
|
9
|
+
private blockSize;
|
|
10
|
+
private margin;
|
|
11
|
+
constructor();
|
|
12
|
+
initMargin(margin: BlockMargin): void;
|
|
13
|
+
getMargin(): BlockMargin;
|
|
14
|
+
getMarginSide(side: MarginSide): number;
|
|
15
|
+
setMarginSide(side: MarginSide, size: number): void;
|
|
16
|
+
increaseMarginSide(side: MarginSide, byValue: number): void;
|
|
17
|
+
descreaseMarginSide(side: MarginSide, byValue: number): void;
|
|
18
|
+
roundMargin(): void;
|
|
19
|
+
initBlockSize(blockSize: Size): void;
|
|
20
|
+
getBlockSize(): Size;
|
|
21
|
+
getChartBlockWidth(): number;
|
|
22
|
+
getChartBlockHeight(): number;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { LegendCanvasModelInstance } from "./legendCanvasModel";
|
|
2
|
+
import { TitleCanvasModel } from "./titleCanvas";
|
|
3
|
+
export class CanvasModel {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.titleCanvas = new TitleCanvasModel();
|
|
6
|
+
this.legendCanvas = new LegendCanvasModelInstance();
|
|
7
|
+
}
|
|
8
|
+
initMargin(margin) {
|
|
9
|
+
this.margin = margin;
|
|
10
|
+
}
|
|
11
|
+
getMargin() {
|
|
12
|
+
return this.margin;
|
|
13
|
+
}
|
|
14
|
+
getMarginSide(side) {
|
|
15
|
+
return this.margin[side];
|
|
16
|
+
}
|
|
17
|
+
setMarginSide(side, size) {
|
|
18
|
+
this.margin[side] = size;
|
|
19
|
+
}
|
|
20
|
+
increaseMarginSide(side, byValue) {
|
|
21
|
+
this.margin[side] += byValue;
|
|
22
|
+
}
|
|
23
|
+
descreaseMarginSide(side, byValue) {
|
|
24
|
+
this.margin[side] -= byValue;
|
|
25
|
+
}
|
|
26
|
+
roundMargin() {
|
|
27
|
+
this.margin.top = Math.ceil(this.margin.top);
|
|
28
|
+
this.margin.bottom = Math.ceil(this.margin.bottom);
|
|
29
|
+
this.margin.left = Math.ceil(this.margin.left);
|
|
30
|
+
this.margin.right = Math.ceil(this.margin.right);
|
|
31
|
+
}
|
|
32
|
+
initBlockSize(blockSize) {
|
|
33
|
+
this.blockSize = blockSize;
|
|
34
|
+
}
|
|
35
|
+
getBlockSize() {
|
|
36
|
+
return this.blockSize;
|
|
37
|
+
}
|
|
38
|
+
getChartBlockWidth() {
|
|
39
|
+
return this.blockSize.width - this.margin.left - this.margin.right;
|
|
40
|
+
}
|
|
41
|
+
getChartBlockHeight() {
|
|
42
|
+
return this.blockSize.height - this.margin.top - this.margin.bottom;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TitleBlockModel } from "../../model";
|
|
2
|
+
declare type TitleBlockCanvas = TitleBlockModel;
|
|
3
|
+
export declare class TitleCanvasModel {
|
|
4
|
+
private model;
|
|
5
|
+
init(model: TitleBlockCanvas): void;
|
|
6
|
+
getModel(): TitleBlockModel;
|
|
7
|
+
getAllNeededSpace(): number;
|
|
8
|
+
}
|
|
9
|
+
export {};
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { MdtChartsConfig } from "../../main";
|
|
2
|
+
import { CanvasModel } from "./canvasModel/canvasModel";
|
|
3
|
+
import { DataModelInstance } from "./dataModel";
|
|
4
|
+
export declare class ModelInstance {
|
|
5
|
+
static create(config: MdtChartsConfig): ModelInstance;
|
|
6
|
+
private static initInitialParams;
|
|
7
|
+
canvasModel: CanvasModel;
|
|
8
|
+
dataModel: DataModelInstance;
|
|
9
|
+
constructor();
|
|
10
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CanvasModel } from "./canvasModel/canvasModel";
|
|
2
|
+
import { DataModelInstance } from "./dataModel";
|
|
3
|
+
export class ModelInstance {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.canvasModel = new CanvasModel();
|
|
6
|
+
this.dataModel = new DataModelInstance();
|
|
7
|
+
}
|
|
8
|
+
static create(config) {
|
|
9
|
+
const modelInstance = new ModelInstance();
|
|
10
|
+
this.initInitialParams(modelInstance, config);
|
|
11
|
+
return modelInstance;
|
|
12
|
+
}
|
|
13
|
+
static initInitialParams(modelInstance, config) {
|
|
14
|
+
modelInstance.canvasModel.initBlockSize(config.canvas.size);
|
|
15
|
+
modelInstance.dataModel.initMaxRecordsAmount(config.options.data.maxRecordsAmount);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { MdtChartsConfig, MdtChartsDataSource, IntervalOptions } from "../../config/config";
|
|
2
2
|
import { DesignerConfig } from "../../designer/designerConfig";
|
|
3
3
|
import { AdditionalElementsOptions, BlockMargin, DataScope, IntervalOptionsModel } from "../model";
|
|
4
|
+
import { ModelInstance } from "../modelInstance/modelInstance";
|
|
4
5
|
export declare class IntervalModel {
|
|
5
|
-
static getOptions(config: MdtChartsConfig, designerConfig: DesignerConfig, margin: BlockMargin, dataScope: DataScope, data: MdtChartsDataSource): IntervalOptionsModel;
|
|
6
|
+
static getOptions(config: MdtChartsConfig, designerConfig: DesignerConfig, margin: BlockMargin, dataScope: DataScope, data: MdtChartsDataSource, modelInstance: ModelInstance): IntervalOptionsModel;
|
|
6
7
|
static getAdditionalElements(options: IntervalOptions): AdditionalElementsOptions;
|
|
7
8
|
private static getChartsModel;
|
|
8
9
|
}
|