mdt-charts 1.12.3 → 1.12.7
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/engine/features/aggregator/aggregator.d.ts +1 -1
- package/lib/engine/features/aggregator/aggregator.js +16 -15
- package/lib/engine/features/axis/axis.d.ts +3 -1
- package/lib/engine/features/axis/axis.js +8 -0
- package/lib/engine/features/gridLine/gidLineHelper.d.ts +2 -0
- package/lib/engine/features/gridLine/gidLineHelper.js +22 -0
- package/lib/engine/features/gridLine/gridLine.d.ts +5 -3
- package/lib/engine/features/gridLine/gridLine.js +16 -17
- package/lib/engine/features/scale/scale.d.ts +2 -0
- package/lib/engine/features/scale/scale.js +6 -3
- package/lib/engine/intervalNotation/intervalManager.js +1 -1
- package/lib/engine/twoDimensionalNotation/area/areaHelper.js +2 -2
- package/lib/engine/twoDimensionalNotation/bar/bar.js +3 -3
- package/lib/engine/twoDimensionalNotation/bar/barHelper.js +8 -8
- package/lib/engine/twoDimensionalNotation/twoDimensionalManager.js +3 -2
- package/lib/model/featuresModel/axisModel.d.ts +2 -1
- package/lib/model/featuresModel/axisModel.js +19 -5
- package/lib/model/featuresModel/legendModel/legendModel.js +2 -2
- package/lib/model/featuresModel/scaleModel/scaleAxisRecalcer.d.ts +20 -0
- package/lib/model/featuresModel/scaleModel/scaleAxisRecalcer.js +31 -0
- package/lib/model/featuresModel/scaleModel/scaleModel.d.ts +19 -0
- package/lib/model/featuresModel/scaleModel/scaleModel.js +115 -0
- package/lib/model/featuresModel/scaleModel.d.ts +3 -2
- package/lib/model/featuresModel/scaleModel.js +19 -4
- package/lib/model/featuresModel/titleModel.js +1 -1
- package/lib/model/marginModel.d.ts +1 -3
- package/lib/model/marginModel.js +7 -29
- package/lib/model/modelBuilder.js +7 -8
- package/lib/model/modelInstance/canvasModel/canvasModel.d.ts +5 -4
- package/lib/model/modelInstance/canvasModel/canvasModel.js +6 -2
- package/lib/model/modelInstance/canvasModel/marginModelService.d.ts +11 -0
- package/lib/model/modelInstance/canvasModel/marginModelService.js +26 -0
- package/lib/model/modelInstance/dataModel/dataModel.d.ts +14 -0
- package/lib/model/modelInstance/dataModel/dataModel.js +26 -0
- package/lib/model/modelInstance/dataModel/dataRepository.d.ts +12 -0
- package/lib/model/modelInstance/dataModel/dataRepository.js +20 -0
- package/lib/model/modelInstance/modelInstance.d.ts +3 -3
- package/lib/model/modelInstance/modelInstance.js +6 -4
- package/lib/model/notations/intervalModel.js +1 -1
- package/lib/model/notations/polar/donut/donutAggregatorService.js +2 -2
- package/lib/model/notations/polar/donut/donutModel.d.ts +1 -1
- package/lib/model/notations/polar/donut/donutModel.js +4 -4
- package/lib/model/notations/polar/polarModel.d.ts +2 -3
- package/lib/model/notations/polar/polarModel.js +3 -5
- package/lib/model/notations/twoDimensionalModel.d.ts +2 -2
- package/lib/model/notations/twoDimensionalModel.js +9 -5
- package/lib/style/charts-main.css +1 -0
- package/lib/style/charts-main.less +1 -0
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ScaleKeyModel, ScaleKeyType, ScaleValueModel, ScaleValueType } from "../model";
|
|
2
|
-
import { AxisPosition, NumberDomain, IntervalChart, MdtChartsTwoDimensionalChart, MdtChartsTwoDimensionalOptions, ChartOrientation, MdtChartsDataSource } from "../../config/config";
|
|
2
|
+
import { AxisPosition, NumberDomain, IntervalChart, MdtChartsTwoDimensionalChart, MdtChartsTwoDimensionalOptions, ChartOrientation, MdtChartsDataSource, MdtChartsDataRow } from "../../config/config";
|
|
3
3
|
import { CanvasModel } from "../modelInstance/canvasModel/canvasModel";
|
|
4
4
|
export declare enum ScaleType {
|
|
5
5
|
Key = 0,
|
|
@@ -14,5 +14,6 @@ export declare class ScaleModel {
|
|
|
14
14
|
static getScaleKeyType(charts: MdtChartsTwoDimensionalChart[]): ScaleKeyType;
|
|
15
15
|
static getScaleValueType(charts: MdtChartsTwoDimensionalChart[] | IntervalChart[]): ScaleValueType;
|
|
16
16
|
static getElementsAmount(barCharts: MdtChartsTwoDimensionalChart[]): number;
|
|
17
|
-
static getScaleMaxValue(charts: MdtChartsTwoDimensionalChart[],
|
|
17
|
+
static getScaleMaxValue(charts: MdtChartsTwoDimensionalChart[], dataRows: MdtChartsDataRow[]): number;
|
|
18
|
+
static getScaleMinValue(charts: MdtChartsTwoDimensionalChart[], dataRows: MdtChartsDataRow[]): number;
|
|
18
19
|
}
|
|
@@ -47,11 +47,11 @@ export class ScaleModel {
|
|
|
47
47
|
let domainPeekMin;
|
|
48
48
|
let domainPeekMax;
|
|
49
49
|
if (configDomain.start === -1)
|
|
50
|
-
domainPeekMin =
|
|
50
|
+
domainPeekMin = this.getScaleMinValue(configOptions.charts, data[configOptions.data.dataSource]);
|
|
51
51
|
else
|
|
52
52
|
domainPeekMin = configDomain.start;
|
|
53
53
|
if (configDomain.end === -1)
|
|
54
|
-
domainPeekMax = this.getScaleMaxValue(configOptions.charts, configOptions.data.dataSource
|
|
54
|
+
domainPeekMax = this.getScaleMaxValue(configOptions.charts, data[configOptions.data.dataSource]);
|
|
55
55
|
else
|
|
56
56
|
domainPeekMax = configDomain.end;
|
|
57
57
|
if (configOptions.axis.key.position === 'start')
|
|
@@ -80,10 +80,10 @@ export class ScaleModel {
|
|
|
80
80
|
});
|
|
81
81
|
return barsAmount;
|
|
82
82
|
}
|
|
83
|
-
static getScaleMaxValue(charts,
|
|
83
|
+
static getScaleMaxValue(charts, dataRows) {
|
|
84
84
|
let max = 0;
|
|
85
85
|
charts.forEach(chart => {
|
|
86
|
-
|
|
86
|
+
dataRows.forEach(dataRow => {
|
|
87
87
|
let sumInRow = 0;
|
|
88
88
|
chart.data.valueFields.forEach(field => {
|
|
89
89
|
if (chart.isSegmented)
|
|
@@ -97,4 +97,19 @@ export class ScaleModel {
|
|
|
97
97
|
});
|
|
98
98
|
return max;
|
|
99
99
|
}
|
|
100
|
+
static getScaleMinValue(charts, dataRows) {
|
|
101
|
+
let min = 0;
|
|
102
|
+
charts.forEach(chart => {
|
|
103
|
+
dataRows.forEach(dataRow => {
|
|
104
|
+
let sumInRow = 0;
|
|
105
|
+
chart.data.valueFields.forEach(field => {
|
|
106
|
+
if (dataRow[field.name] < sumInRow)
|
|
107
|
+
sumInRow = dataRow[field.name];
|
|
108
|
+
});
|
|
109
|
+
if (min > sumInRow)
|
|
110
|
+
min = sumInRow;
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
return min;
|
|
114
|
+
}
|
|
100
115
|
}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { MdtChartsConfig, MdtChartsDataSource } from "../config/config";
|
|
2
2
|
import { DesignerConfig } from "../designer/designerConfig";
|
|
3
|
-
import { DataScope, LegendBlockModel, Orient, OtherCommonComponents
|
|
3
|
+
import { DataScope, LegendBlockModel, Orient, OtherCommonComponents } from "./model";
|
|
4
4
|
import { ModelInstance } from "./modelInstance/modelInstance";
|
|
5
5
|
import { CanvasModel } from "./modelInstance/canvasModel/canvasModel";
|
|
6
6
|
export declare const AXIS_HORIZONTAL_LABEL_PADDING = 15;
|
|
7
7
|
export declare const AXIS_VERTICAL_LABEL_PADDING = 10;
|
|
8
8
|
export declare class MarginModel {
|
|
9
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
10
|
static recalcMarginByVerticalAxisLabel(modelInstance: ModelInstance, config: MdtChartsConfig, designerConfig: DesignerConfig, dataScope: DataScope): void;
|
|
12
11
|
private static getHorizontalMarginByAxisLabels;
|
|
13
12
|
private static recalcVerticalMarginByAxisLabelHeight;
|
|
@@ -15,6 +14,5 @@ export declare class MarginModel {
|
|
|
15
14
|
private static recalcMarginWithLegend;
|
|
16
15
|
private static getLegendItemsContent;
|
|
17
16
|
static appendToGlobalMarginValuesLegendMargin(canvasModel: CanvasModel, position: Orient, legendBlockModel: LegendBlockModel): void;
|
|
18
|
-
private static clearMarginByLegendBlockPosition;
|
|
19
17
|
private static recalcMarginByTitle;
|
|
20
18
|
}
|
package/lib/model/marginModel.js
CHANGED
|
@@ -3,7 +3,7 @@ import { DataManagerModel } from "./dataManagerModel/dataManagerModel";
|
|
|
3
3
|
import { LegendModel } from "./featuresModel/legendModel/legendModel";
|
|
4
4
|
import { AxisType } from "./modelBuilder";
|
|
5
5
|
import { TwoDimensionalModel } from "./notations/twoDimensionalModel";
|
|
6
|
-
import {
|
|
6
|
+
import { keyAxisLabelHorizontalLog, keyAxisLabelVerticalLog } from "./featuresModel/scaleModel/scaleAxisRecalcer";
|
|
7
7
|
export const AXIS_HORIZONTAL_LABEL_PADDING = 15;
|
|
8
8
|
export const AXIS_VERTICAL_LABEL_PADDING = 10;
|
|
9
9
|
export class MarginModel {
|
|
@@ -24,28 +24,15 @@ export class MarginModel {
|
|
|
24
24
|
this.recalcHorizontalMarginByAxisLabelWidth(labelSize, canvasModel, config.options.orientation, config.options.axis, showingFlag);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
static recalcPolarMarginWithScopedData(modelInstance, designerConfig, config, legendBlockModel, dataScope, options) {
|
|
28
|
-
const canvasModel = modelInstance.canvasModel;
|
|
29
|
-
let position = canvasModel.legendCanvas.getPosition();
|
|
30
|
-
if (position !== 'off') {
|
|
31
|
-
position = PolarModel.getLegendPositionByBlockSize(canvasModel); // reset position
|
|
32
|
-
this.clearMarginByLegendBlockPosition(canvasModel, legendBlockModel);
|
|
33
|
-
let allowableKeys = [...dataScope.allowableKeys];
|
|
34
|
-
if (dataScope.hidedRecordsAmount !== 0 && position === 'bottom')
|
|
35
|
-
allowableKeys.push('1'); // Если есть спрятанные записи, то в массив добавляется объект, чтобы выделить место в легенде для индикатора переполнения
|
|
36
|
-
const legendSize = LegendModel.getLegendSize(config.options.type, position, allowableKeys, designerConfig.canvas.legendBlock.maxWidth, config.canvas.size, legendBlockModel);
|
|
37
|
-
canvasModel.increaseMarginSide(position, legendSize + legendBlockModel.coordinate[position].margin[position]);
|
|
38
|
-
legendBlockModel.coordinate[position].size = legendSize;
|
|
39
|
-
options.legend.position = position;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
27
|
static recalcMarginByVerticalAxisLabel(modelInstance, config, designerConfig, dataScope) {
|
|
43
28
|
if ((config.options.type === '2d' || config.options.type === 'interval') && config.options.orientation === 'vertical') {
|
|
44
29
|
const axisLabelSize = AxisModel.getLabelSize(designerConfig.canvas.axisLabel.maxSize.main, dataScope.allowableKeys);
|
|
45
30
|
const axisConfig = AxisModel.getKeyAxisLabelPosition(modelInstance.canvasModel, dataScope.allowableKeys.length, config.options.axis.key);
|
|
46
31
|
const marginOrient = config.options.axis.key.position === 'end' ? 'bottom' : 'top';
|
|
47
|
-
if (axisConfig === 'rotated')
|
|
48
|
-
modelInstance.canvasModel.
|
|
32
|
+
if (axisConfig === 'rotated') {
|
|
33
|
+
modelInstance.canvasModel.decreaseMarginSide(marginOrient, axisLabelSize.height);
|
|
34
|
+
modelInstance.canvasModel.increaseMarginSide(marginOrient, axisLabelSize.width, keyAxisLabelVerticalLog);
|
|
35
|
+
}
|
|
49
36
|
}
|
|
50
37
|
}
|
|
51
38
|
static getHorizontalMarginByAxisLabels(labelsMaxWidth, axis, data, options) {
|
|
@@ -64,7 +51,7 @@ export class MarginModel {
|
|
|
64
51
|
const valueAxisOrient = AxisModel.getAxisOrient(AxisType.Value, orientation, axis.value.position);
|
|
65
52
|
if ((keyAxisOrient === 'bottom' || keyAxisOrient === 'top')) {
|
|
66
53
|
if (axis.key.visibility)
|
|
67
|
-
canvasModel.increaseMarginSide(keyAxisOrient, labelSize.height + AXIS_HORIZONTAL_LABEL_PADDING);
|
|
54
|
+
canvasModel.increaseMarginSide(keyAxisOrient, labelSize.height + AXIS_HORIZONTAL_LABEL_PADDING, keyAxisLabelVerticalLog);
|
|
68
55
|
}
|
|
69
56
|
else if (axis.value.visibility)
|
|
70
57
|
canvasModel.increaseMarginSide(valueAxisOrient, labelSize.height + AXIS_HORIZONTAL_LABEL_PADDING);
|
|
@@ -73,7 +60,7 @@ export class MarginModel {
|
|
|
73
60
|
const keyAxisOrient = AxisModel.getAxisOrient(AxisType.Key, orientation, axis.key.position);
|
|
74
61
|
const valueAxisOrient = AxisModel.getAxisOrient(AxisType.Value, orientation, axis.value.position);
|
|
75
62
|
if ((keyAxisOrient === 'left' || keyAxisOrient === 'right') && isShow && axis.key.visibility) {
|
|
76
|
-
canvasModel.increaseMarginSide(keyAxisOrient, labelSize.width + AXIS_VERTICAL_LABEL_PADDING);
|
|
63
|
+
canvasModel.increaseMarginSide(keyAxisOrient, labelSize.width + AXIS_VERTICAL_LABEL_PADDING, keyAxisLabelHorizontalLog);
|
|
77
64
|
}
|
|
78
65
|
else if ((valueAxisOrient === 'left' || valueAxisOrient === 'right') && axis.value.visibility) {
|
|
79
66
|
canvasModel.increaseMarginSide(valueAxisOrient, labelSize.width + AXIS_VERTICAL_LABEL_PADDING);
|
|
@@ -117,15 +104,6 @@ export class MarginModel {
|
|
|
117
104
|
else
|
|
118
105
|
canvasModel.increaseMarginSide(position, legendCoordinate[position].margin.top + legendCoordinate[position].margin.bottom);
|
|
119
106
|
}
|
|
120
|
-
static clearMarginByLegendBlockPosition(canvasModel, legendBlockModel) {
|
|
121
|
-
const legendCoordinate = legendBlockModel.coordinate;
|
|
122
|
-
['left', 'right', 'top', 'bottom'].forEach((position) => {
|
|
123
|
-
const decreaseByValue = legendCoordinate[position].size === 0
|
|
124
|
-
? 0
|
|
125
|
-
: legendCoordinate[position].size + legendCoordinate[position].margin[position];
|
|
126
|
-
canvasModel.descreaseMarginSide(position, decreaseByValue);
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
107
|
static recalcMarginByTitle(canvasModel, titleBlockModel) {
|
|
130
108
|
canvasModel.increaseMarginSide("top", titleBlockModel.margin.top + titleBlockModel.size + titleBlockModel.margin.bottom);
|
|
131
109
|
}
|
|
@@ -30,16 +30,16 @@ function getChartBlockModel(modelInstance) {
|
|
|
30
30
|
margin: modelInstance.canvasModel.getMargin()
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
|
-
function getOptions(config, designerConfig, modelInstance,
|
|
33
|
+
function getOptions(config, designerConfig, modelInstance, data) {
|
|
34
34
|
//TODO: migrate to polymorphism
|
|
35
35
|
if (config.options.type === '2d') {
|
|
36
|
-
return TwoDimensionalModel.getOptions(config.options, designerConfig,
|
|
36
|
+
return TwoDimensionalModel.getOptions(config.options, designerConfig, data, modelInstance);
|
|
37
37
|
}
|
|
38
38
|
else if (config.options.type === 'polar') {
|
|
39
|
-
return PolarModel.getOptions(config.options,
|
|
39
|
+
return PolarModel.getOptions(config.options, designerConfig, modelInstance);
|
|
40
40
|
}
|
|
41
41
|
else if (config.options.type === 'interval') {
|
|
42
|
-
return IntervalModel.getOptions(config, designerConfig, modelInstance.canvasModel.getMargin(),
|
|
42
|
+
return IntervalModel.getOptions(config, designerConfig, modelInstance.canvasModel.getMargin(), modelInstance.dataModel.getScope(), data, modelInstance);
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
function getDataSettings(dataScope, designerConfig) {
|
|
@@ -57,7 +57,7 @@ function getTransitions(designerConfig) {
|
|
|
57
57
|
return designerConfig.transitions;
|
|
58
58
|
}
|
|
59
59
|
export function assembleModel(config, data, designerConfig) {
|
|
60
|
-
const modelInstance = ModelInstance.create(config);
|
|
60
|
+
const modelInstance = ModelInstance.create(config, data);
|
|
61
61
|
if (!data || Object.keys(data).length === 0)
|
|
62
62
|
return {
|
|
63
63
|
blockCanvas: getBlockCanvas(config, modelInstance),
|
|
@@ -71,15 +71,14 @@ export function assembleModel(config, data, designerConfig) {
|
|
|
71
71
|
MarginModel.initMargin(designerConfig, config, otherComponents, data, modelInstance);
|
|
72
72
|
DataManagerModel.initDataScope(config, data, designerConfig, otherComponents.legendBlock, modelInstance);
|
|
73
73
|
const preparedData = DataManagerModel.getPreparedData(data, modelInstance.dataModel.getAllowableKeys(), config);
|
|
74
|
+
modelInstance.dataModel.repository.initScopedFullSource(preparedData);
|
|
74
75
|
if (config.options.type === '2d' && config.options.axis.key.visibility)
|
|
75
76
|
MarginModel.recalcMarginByVerticalAxisLabel(modelInstance, config, designerConfig, modelInstance.dataModel.getScope());
|
|
76
77
|
const blockCanvas = getBlockCanvas(config, modelInstance);
|
|
77
78
|
const chartBlock = getChartBlockModel(modelInstance);
|
|
78
|
-
const options = getOptions(config, designerConfig, modelInstance,
|
|
79
|
+
const options = getOptions(config, designerConfig, modelInstance, preparedData);
|
|
79
80
|
const dataSettings = getDataSettings(modelInstance.dataModel.getScope(), designerConfig);
|
|
80
81
|
const transitions = getTransitions(designerConfig);
|
|
81
|
-
// if (options.type === 'polar')
|
|
82
|
-
// MarginModel.recalcPolarMarginWithScopedData(modelInstance, designerConfig, config, otherComponents.legendBlock, modelInstance.dataModel.getScope(), options);
|
|
83
82
|
modelInstance.canvasModel.roundMargin();
|
|
84
83
|
return {
|
|
85
84
|
blockCanvas,
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { Size } from "../../../config/config";
|
|
2
2
|
import { BlockMargin } from "../../model";
|
|
3
3
|
import { LegendCanvasModelInstance } from "./legendCanvasModel";
|
|
4
|
+
import { MarginModelService } from "./marginModelService";
|
|
4
5
|
import { TitleCanvasModel } from "./titleCanvas";
|
|
5
|
-
declare type MarginSide = keyof BlockMargin;
|
|
6
|
+
export declare type MarginSide = keyof BlockMargin;
|
|
6
7
|
export declare class CanvasModel {
|
|
7
8
|
titleCanvas: TitleCanvasModel;
|
|
8
9
|
legendCanvas: LegendCanvasModelInstance;
|
|
10
|
+
marginService: MarginModelService;
|
|
9
11
|
private blockSize;
|
|
10
12
|
private margin;
|
|
11
13
|
constructor();
|
|
@@ -13,12 +15,11 @@ export declare class CanvasModel {
|
|
|
13
15
|
getMargin(): BlockMargin;
|
|
14
16
|
getMarginSide(side: MarginSide): number;
|
|
15
17
|
setMarginSide(side: MarginSide, size: number): void;
|
|
16
|
-
increaseMarginSide(side: MarginSide, byValue: number): void;
|
|
17
|
-
|
|
18
|
+
increaseMarginSide(side: MarginSide, byValue: number, key?: string): void;
|
|
19
|
+
decreaseMarginSide(side: MarginSide, byValue: number): void;
|
|
18
20
|
roundMargin(): void;
|
|
19
21
|
initBlockSize(blockSize: Size): void;
|
|
20
22
|
getBlockSize(): Size;
|
|
21
23
|
getChartBlockWidth(): number;
|
|
22
24
|
getChartBlockHeight(): number;
|
|
23
25
|
}
|
|
24
|
-
export {};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { LegendCanvasModelInstance } from "./legendCanvasModel";
|
|
2
|
+
import { MarginModelService } from "./marginModelService";
|
|
2
3
|
import { TitleCanvasModel } from "./titleCanvas";
|
|
3
4
|
export class CanvasModel {
|
|
4
5
|
constructor() {
|
|
5
6
|
this.titleCanvas = new TitleCanvasModel();
|
|
6
7
|
this.legendCanvas = new LegendCanvasModelInstance();
|
|
8
|
+
this.marginService = new MarginModelService();
|
|
7
9
|
}
|
|
8
10
|
initMargin(margin) {
|
|
9
11
|
this.margin = margin;
|
|
@@ -17,10 +19,12 @@ export class CanvasModel {
|
|
|
17
19
|
setMarginSide(side, size) {
|
|
18
20
|
this.margin[side] = size;
|
|
19
21
|
}
|
|
20
|
-
increaseMarginSide(side, byValue) {
|
|
22
|
+
increaseMarginSide(side, byValue, key) {
|
|
21
23
|
this.margin[side] += byValue;
|
|
24
|
+
if (key)
|
|
25
|
+
this.marginService.appendLog(key, side, byValue);
|
|
22
26
|
}
|
|
23
|
-
|
|
27
|
+
decreaseMarginSide(side, byValue) {
|
|
24
28
|
this.margin[side] -= byValue;
|
|
25
29
|
}
|
|
26
30
|
roundMargin() {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MarginSide } from "./canvasModel";
|
|
2
|
+
export interface MarginLogData {
|
|
3
|
+
side: MarginSide;
|
|
4
|
+
byValue: number;
|
|
5
|
+
}
|
|
6
|
+
export declare class MarginModelService {
|
|
7
|
+
private log;
|
|
8
|
+
appendLog(key: string, side: MarginSide, byValue: number): void;
|
|
9
|
+
getDataByKey(key: string): MarginLogData;
|
|
10
|
+
private findLogByKey;
|
|
11
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export class MarginModelService {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.log = [];
|
|
4
|
+
}
|
|
5
|
+
appendLog(key, side, byValue) {
|
|
6
|
+
const log = this.findLogByKey(key);
|
|
7
|
+
if (log) {
|
|
8
|
+
log.data = { side, byValue };
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
this.log.push({
|
|
12
|
+
key,
|
|
13
|
+
data: {
|
|
14
|
+
side,
|
|
15
|
+
byValue
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
getDataByKey(key) {
|
|
20
|
+
var _a;
|
|
21
|
+
return (_a = this.findLogByKey(key)) === null || _a === void 0 ? void 0 : _a.data;
|
|
22
|
+
}
|
|
23
|
+
findLogByKey(key) {
|
|
24
|
+
return this.log.find(l => l.key === key);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DataScope } from "../../model";
|
|
2
|
+
import { DataRepositoryModel } from "./dataRepository";
|
|
3
|
+
export declare const DEFAULT_MAX_RECORDS_AMOUNT = 50;
|
|
4
|
+
export declare class DataModelInstance {
|
|
5
|
+
repository: DataRepositoryModel;
|
|
6
|
+
constructor();
|
|
7
|
+
private maxRecordsAmount;
|
|
8
|
+
private scope;
|
|
9
|
+
initMaxRecordsAmount(amount: number): void;
|
|
10
|
+
getMaxRecordsAmount(): number;
|
|
11
|
+
initScope(scope: DataScope): void;
|
|
12
|
+
getScope(): DataScope;
|
|
13
|
+
getAllowableKeys(): string[];
|
|
14
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { DataRepositoryModel } from "./dataRepository";
|
|
2
|
+
export const DEFAULT_MAX_RECORDS_AMOUNT = 50;
|
|
3
|
+
export class DataModelInstance {
|
|
4
|
+
constructor() {
|
|
5
|
+
//TODO: create dataScopeModel.
|
|
6
|
+
this.maxRecordsAmount = DEFAULT_MAX_RECORDS_AMOUNT;
|
|
7
|
+
this.repository = new DataRepositoryModel();
|
|
8
|
+
}
|
|
9
|
+
initMaxRecordsAmount(amount) {
|
|
10
|
+
if (typeof amount === "number" && amount > 0) {
|
|
11
|
+
this.maxRecordsAmount = amount;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
getMaxRecordsAmount() {
|
|
15
|
+
return this.maxRecordsAmount;
|
|
16
|
+
}
|
|
17
|
+
initScope(scope) {
|
|
18
|
+
this.scope = scope;
|
|
19
|
+
}
|
|
20
|
+
getScope() {
|
|
21
|
+
return this.scope;
|
|
22
|
+
}
|
|
23
|
+
getAllowableKeys() {
|
|
24
|
+
return this.getScope().allowableKeys;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { MdtChartsDataSource } from "../../../config/config";
|
|
2
|
+
export declare class DataRepositoryModel {
|
|
3
|
+
private rawFullSource;
|
|
4
|
+
private scopedFullSource;
|
|
5
|
+
private sourceName;
|
|
6
|
+
initSourceName(sourceName: string): void;
|
|
7
|
+
initRawFullSource(rawSource: MdtChartsDataSource): void;
|
|
8
|
+
getRawRows(): import("../../../config/config").MdtChartsDataRow[];
|
|
9
|
+
initScopedFullSource(scopedSource: MdtChartsDataSource): void;
|
|
10
|
+
getScopedFullSource(): MdtChartsDataSource;
|
|
11
|
+
getScopedRows(): import("../../../config/config").MdtChartsDataRow[];
|
|
12
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export class DataRepositoryModel {
|
|
2
|
+
initSourceName(sourceName) {
|
|
3
|
+
this.sourceName = sourceName;
|
|
4
|
+
}
|
|
5
|
+
initRawFullSource(rawSource) {
|
|
6
|
+
this.rawFullSource = rawSource;
|
|
7
|
+
}
|
|
8
|
+
getRawRows() {
|
|
9
|
+
return this.rawFullSource[this.sourceName];
|
|
10
|
+
}
|
|
11
|
+
initScopedFullSource(scopedSource) {
|
|
12
|
+
this.scopedFullSource = scopedSource;
|
|
13
|
+
}
|
|
14
|
+
getScopedFullSource() {
|
|
15
|
+
return this.scopedFullSource;
|
|
16
|
+
}
|
|
17
|
+
getScopedRows() {
|
|
18
|
+
return this.scopedFullSource[this.sourceName];
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { MdtChartsConfig } from "../../
|
|
1
|
+
import { MdtChartsConfig, MdtChartsDataSource } from "../../config/config";
|
|
2
2
|
import { CanvasModel } from "./canvasModel/canvasModel";
|
|
3
|
-
import { DataModelInstance } from "./dataModel";
|
|
3
|
+
import { DataModelInstance } from "./dataModel/dataModel";
|
|
4
4
|
export declare class ModelInstance {
|
|
5
|
-
static create(config: MdtChartsConfig): ModelInstance;
|
|
5
|
+
static create(config: MdtChartsConfig, data: MdtChartsDataSource): ModelInstance;
|
|
6
6
|
private static initInitialParams;
|
|
7
7
|
canvasModel: CanvasModel;
|
|
8
8
|
dataModel: DataModelInstance;
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import { CanvasModel } from "./canvasModel/canvasModel";
|
|
2
|
-
import { DataModelInstance } from "./dataModel";
|
|
2
|
+
import { DataModelInstance } from "./dataModel/dataModel";
|
|
3
3
|
export class ModelInstance {
|
|
4
4
|
constructor() {
|
|
5
5
|
this.canvasModel = new CanvasModel();
|
|
6
6
|
this.dataModel = new DataModelInstance();
|
|
7
7
|
}
|
|
8
|
-
static create(config) {
|
|
8
|
+
static create(config, data) {
|
|
9
9
|
const modelInstance = new ModelInstance();
|
|
10
|
-
this.initInitialParams(modelInstance, config);
|
|
10
|
+
this.initInitialParams(modelInstance, config, data);
|
|
11
11
|
return modelInstance;
|
|
12
12
|
}
|
|
13
|
-
static initInitialParams(modelInstance, config) {
|
|
13
|
+
static initInitialParams(modelInstance, config, data) {
|
|
14
14
|
modelInstance.canvasModel.initBlockSize(config.canvas.size);
|
|
15
15
|
modelInstance.dataModel.initMaxRecordsAmount(config.options.data.maxRecordsAmount);
|
|
16
|
+
modelInstance.dataModel.repository.initSourceName(config.options.data.dataSource);
|
|
17
|
+
modelInstance.dataModel.repository.initRawFullSource(data);
|
|
16
18
|
}
|
|
17
19
|
}
|
|
@@ -2,7 +2,7 @@ import { AxisModel } from "../featuresModel/axisModel";
|
|
|
2
2
|
import { ChartStyleModelService } from "../chartStyleModel/chartStyleModel";
|
|
3
3
|
import { DataManagerModel } from "../dataManagerModel/dataManagerModel";
|
|
4
4
|
import { AxisType } from "../modelBuilder";
|
|
5
|
-
import { ScaleModel, ScaleType } from "../featuresModel/scaleModel";
|
|
5
|
+
import { ScaleModel, ScaleType } from "../featuresModel/scaleModel/scaleModel";
|
|
6
6
|
import { TwoDimensionalModel } from "./twoDimensionalModel";
|
|
7
7
|
export class IntervalModel {
|
|
8
8
|
static getOptions(config, designerConfig, margin, dataScope, data, modelInstance) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export const AGGREGATOR_DEFAULT_TITLE = "Сумма";
|
|
2
2
|
export class DonutAggregatorService {
|
|
3
3
|
getContent(aggregatorOptions, dataOptions) {
|
|
4
|
-
if (!(aggregatorOptions === null || aggregatorOptions === void 0 ? void 0 : aggregatorOptions.content))
|
|
4
|
+
if (!(aggregatorOptions === null || aggregatorOptions === void 0 ? void 0 : aggregatorOptions.content) || !dataOptions.rows)
|
|
5
5
|
return this.generateDefaultContent(dataOptions);
|
|
6
6
|
const content = aggregatorOptions.content({ data: dataOptions.rows });
|
|
7
7
|
if (this.doesValueExist(content.value) && content.title)
|
|
@@ -19,7 +19,7 @@ export class DonutAggregatorService {
|
|
|
19
19
|
generateDefaultContent(dataOptions) {
|
|
20
20
|
return {
|
|
21
21
|
title: AGGREGATOR_DEFAULT_TITLE,
|
|
22
|
-
value: dataOptions.rows.reduce((acc, row) => acc + row[dataOptions.valueFieldName], 0)
|
|
22
|
+
value: dataOptions.rows ? dataOptions.rows.reduce((acc, row) => acc + row[dataOptions.valueFieldName], 0) : 0
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
}
|
|
@@ -4,7 +4,7 @@ import { DonutChartSettings } from "../../../model";
|
|
|
4
4
|
export declare class DonutModel {
|
|
5
5
|
private thicknessService;
|
|
6
6
|
private aggregatorService;
|
|
7
|
-
getSettings(settingsFromConfig: DonutOptionsCanvas, chartOptions: PolarChart,
|
|
7
|
+
getSettings(settingsFromConfig: DonutOptionsCanvas, chartOptions: PolarChart, rawDataRows: MdtChartsDataRow[]): DonutChartSettings;
|
|
8
8
|
private getThicknessOptions;
|
|
9
9
|
private getAggregatorOptions;
|
|
10
10
|
}
|
|
@@ -5,11 +5,11 @@ export class DonutModel {
|
|
|
5
5
|
this.thicknessService = new DonutThicknessService();
|
|
6
6
|
this.aggregatorService = new DonutAggregatorService();
|
|
7
7
|
}
|
|
8
|
-
getSettings(settingsFromConfig, chartOptions,
|
|
8
|
+
getSettings(settingsFromConfig, chartOptions, rawDataRows) {
|
|
9
9
|
return {
|
|
10
10
|
padAngle: settingsFromConfig.padAngle,
|
|
11
11
|
thickness: this.getThicknessOptions(settingsFromConfig.thickness),
|
|
12
|
-
aggregator: this.getAggregatorOptions(settingsFromConfig, chartOptions,
|
|
12
|
+
aggregator: this.getAggregatorOptions(settingsFromConfig, chartOptions, rawDataRows)
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
15
|
getThicknessOptions(settingsFromConfig) {
|
|
@@ -20,11 +20,11 @@ export class DonutModel {
|
|
|
20
20
|
value: this.thicknessService.valueToNumber(settingsFromConfig.value),
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
getAggregatorOptions(settingsFromConfig, chartOptions,
|
|
23
|
+
getAggregatorOptions(settingsFromConfig, chartOptions, rawDataRows) {
|
|
24
24
|
return {
|
|
25
25
|
margin: settingsFromConfig.aggregatorPad,
|
|
26
26
|
content: this.aggregatorService.getContent(chartOptions.aggregator, {
|
|
27
|
-
rows:
|
|
27
|
+
rows: rawDataRows,
|
|
28
28
|
valueFieldName: chartOptions.data.valueField.name
|
|
29
29
|
})
|
|
30
30
|
};
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MdtChartsPolarOptions } from "../../../config/config";
|
|
2
2
|
import { DesignerConfig } from "../../../designer/designerConfig";
|
|
3
3
|
import { PolarOptionsModel, LegendCoordinate } from "../../model";
|
|
4
4
|
import { CanvasModel } from "../../modelInstance/canvasModel/canvasModel";
|
|
5
5
|
import { ModelInstance } from "../../modelInstance/modelInstance";
|
|
6
|
-
/** If donut block has width less than this const, legend change postion from "right" to "bottom" */
|
|
7
6
|
export declare const MIN_DONUT_BLOCK_SIZE = 120;
|
|
8
7
|
export declare class PolarModel {
|
|
9
8
|
private static donutModel;
|
|
10
|
-
static getOptions(options: MdtChartsPolarOptions,
|
|
9
|
+
static getOptions(options: MdtChartsPolarOptions, designerConfig: DesignerConfig, modelInstance: ModelInstance): PolarOptionsModel;
|
|
11
10
|
static getLegendPositionByBlockSize(canvasModel: CanvasModel): "bottom" | "right";
|
|
12
11
|
static doesChartBlockHasEnoughWidthForContainsLegend(chartBlockWidth: number, legendWidth: number, legendCoordinate: LegendCoordinate): boolean;
|
|
13
12
|
static doesChartBlockHasEnoughHeightForContainsLegend(chartBlockHeight: number, legendCoordinate: LegendCoordinate): boolean;
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import { ChartStyleModelService } from "../../chartStyleModel/chartStyleModel";
|
|
2
2
|
import { DonutModel } from "./donut/donutModel";
|
|
3
|
-
/** If donut block has width less than this const, legend change postion from "right" to "bottom" */
|
|
4
3
|
export const MIN_DONUT_BLOCK_SIZE = 120;
|
|
5
4
|
export class PolarModel {
|
|
6
|
-
static getOptions(options,
|
|
7
|
-
const dataRows = data[options.data.dataSource];
|
|
5
|
+
static getOptions(options, designerConfig, modelInstance) {
|
|
8
6
|
return {
|
|
9
7
|
type: options.type,
|
|
10
8
|
selectable: !!options.selectable,
|
|
11
9
|
title: options.title,
|
|
12
10
|
data: Object.assign({}, options.data),
|
|
13
|
-
charts: this.getChartsModel(options.chart,
|
|
11
|
+
charts: this.getChartsModel(options.chart, modelInstance.dataModel.repository.getScopedRows().length, designerConfig.chartStyle),
|
|
14
12
|
legend: modelInstance.canvasModel.legendCanvas.getModel(),
|
|
15
13
|
tooltip: options.tooltip,
|
|
16
|
-
chartCanvas: this.getDonutSettings(designerConfig.canvas.chartOptions.donut, options.chart,
|
|
14
|
+
chartCanvas: this.getDonutSettings(designerConfig.canvas.chartOptions.donut, options.chart, modelInstance.dataModel.repository.getRawRows())
|
|
17
15
|
};
|
|
18
16
|
}
|
|
19
17
|
//TODO: type for returned value
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ChartOrientation, MdtChartsDataSource, MdtChartsTwoDimensionalChart, MdtChartsTwoDimensionalOptions } from "../../config/config";
|
|
2
2
|
import { BarOptionsCanvas, DesignerConfig } from "../../designer/designerConfig";
|
|
3
|
-
import {
|
|
3
|
+
import { TwoDimensionalOptionsModel, TwoDimChartElementsSettings } from "../model";
|
|
4
4
|
import { ModelInstance } from "../modelInstance/modelInstance";
|
|
5
5
|
export declare class TwoDimensionalModel {
|
|
6
|
-
static getOptions(options: MdtChartsTwoDimensionalOptions, designerConfig: DesignerConfig,
|
|
6
|
+
static getOptions(options: MdtChartsTwoDimensionalOptions, designerConfig: DesignerConfig, data: MdtChartsDataSource, modelInstance: ModelInstance): TwoDimensionalOptionsModel;
|
|
7
7
|
static getChartsEmbeddedLabelsFlag(charts: MdtChartsTwoDimensionalChart[], chartOrientation: ChartOrientation): boolean;
|
|
8
8
|
/**
|
|
9
9
|
* Сортирует список чартов в порядке: area - bar - line.
|
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
import { ChartStyleModelService } from "../chartStyleModel/chartStyleModel";
|
|
2
2
|
import { TwoDimensionalChartStyleModel } from "../chartStyleModel/TwoDimensionalChartStyleModel";
|
|
3
3
|
import { AxisModel } from "../featuresModel/axisModel";
|
|
4
|
-
import {
|
|
4
|
+
import { ScaleAxisRecalcer } from "../featuresModel/scaleModel/scaleAxisRecalcer";
|
|
5
|
+
import { ScaleModel } from "../featuresModel/scaleModel/scaleModel";
|
|
5
6
|
export class TwoDimensionalModel {
|
|
6
|
-
static getOptions(options, designerConfig,
|
|
7
|
+
static getOptions(options, designerConfig, data, modelInstance) {
|
|
7
8
|
const canvasModel = modelInstance.canvasModel;
|
|
9
|
+
const scaleMarginRecalcer = new ScaleAxisRecalcer(() => ScaleModel.getScaleLinear(options, data, canvasModel));
|
|
10
|
+
scaleMarginRecalcer.recalculateMargin(canvasModel, options.orientation, options.axis.key);
|
|
11
|
+
const scaleValueInfo = scaleMarginRecalcer.getScaleValue();
|
|
8
12
|
return {
|
|
9
13
|
legend: canvasModel.legendCanvas.getModel(),
|
|
10
14
|
title: options.title,
|
|
11
15
|
selectable: !!options.selectable,
|
|
12
16
|
orient: options.orientation,
|
|
13
17
|
scale: {
|
|
14
|
-
key: ScaleModel.getScaleKey(
|
|
15
|
-
value:
|
|
18
|
+
key: ScaleModel.getScaleKey(modelInstance.dataModel.getAllowableKeys(), options.orientation, canvasModel, options.charts, this.getChartsByType(options.charts, 'bar')),
|
|
19
|
+
value: scaleValueInfo.scale
|
|
16
20
|
},
|
|
17
21
|
axis: {
|
|
18
|
-
key: AxisModel.getKeyAxis(options, data, designerConfig.canvas.axisLabel, canvasModel, designerConfig.elementsOptions.tooltip),
|
|
22
|
+
key: AxisModel.getKeyAxis(options, data, designerConfig.canvas.axisLabel, canvasModel, designerConfig.elementsOptions.tooltip, () => scaleValueInfo.scaleFn(0)),
|
|
19
23
|
value: AxisModel.getValueAxis(options.orientation, options.axis.value, designerConfig.canvas.axisLabel, canvasModel)
|
|
20
24
|
},
|
|
21
25
|
type: options.type,
|