mdt-charts 1.12.4 → 1.12.8
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/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/area.js +3 -3
- package/lib/engine/twoDimensionalNotation/area/areaHelper.js +2 -2
- package/lib/engine/twoDimensionalNotation/bar/bar.js +6 -6
- package/lib/engine/twoDimensionalNotation/bar/barHelper.js +16 -16
- package/lib/engine/twoDimensionalNotation/bar/stackedData/dataStacker.d.ts +13 -0
- package/lib/engine/twoDimensionalNotation/bar/stackedData/dataStacker.js +32 -0
- package/lib/engine/twoDimensionalNotation/bar/stackedData/dataStacker.test.d.ts +1 -0
- package/lib/engine/twoDimensionalNotation/bar/stackedData/dataStacker.test.js +199 -0
- package/lib/engine/twoDimensionalNotation/bar/stackedData/dataStackerService.d.ts +5 -0
- package/lib/engine/twoDimensionalNotation/bar/stackedData/dataStackerService.js +19 -0
- package/lib/engine/twoDimensionalNotation/twoDimensionalManager.js +3 -2
- package/lib/model/featuresModel/axisModel.d.ts +2 -1
- package/lib/model/featuresModel/axisModel.js +23 -5
- 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 +118 -0
- package/lib/model/featuresModel/scaleModel.d.ts +3 -2
- package/lib/model/featuresModel/scaleModel.js +19 -4
- package/lib/model/marginModel.d.ts +1 -3
- package/lib/model/marginModel.js +7 -29
- 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/notations/intervalModel.js +1 -1
- package/lib/model/notations/twoDimensionalModel.js +7 -3
- package/lib/style/charts-main.css +3 -2
- package/lib/style/charts-main.less +3 -2
- package/package.json +1 -1
|
@@ -9,7 +9,7 @@ export interface LabelSize {
|
|
|
9
9
|
}
|
|
10
10
|
export declare class AxisModel {
|
|
11
11
|
private static service;
|
|
12
|
-
static getKeyAxis(options: MdtChartsTwoDimensionalOptions, data: MdtChartsDataSource, labelConfig: AxisLabelCanvas, canvasModel: CanvasModel, tooltipSettings: TooltipSettings): AxisModelOptions;
|
|
12
|
+
static getKeyAxis(options: MdtChartsTwoDimensionalOptions, data: MdtChartsDataSource, labelConfig: AxisLabelCanvas, canvasModel: CanvasModel, tooltipSettings: TooltipSettings, getZeroCoordinate?: () => number): AxisModelOptions;
|
|
13
13
|
static getValueAxis(orient: ChartOrientation, axisConfig: NumberAxisOptions, labelConfig: AxisLabelCanvas, canvasModel: CanvasModel): AxisModelOptions;
|
|
14
14
|
static getAxisLength(chartOrientation: ChartOrientation, canvasModel: CanvasModel): number;
|
|
15
15
|
static getAxisOrient(axisType: AxisType, chartOrientation: ChartOrientation, axisPosition: AxisPosition): Orient;
|
|
@@ -17,4 +17,5 @@ export declare class AxisModel {
|
|
|
17
17
|
static getAxisTranslateY(axisType: AxisType, chartOrientation: ChartOrientation, axisPosition: AxisPosition, canvasModel: CanvasModel): number;
|
|
18
18
|
static getKeyAxisLabelPosition(canvasModel: CanvasModel, scopedDataLength: number, axisConfig?: DiscreteAxisOptions): AxisLabelPosition;
|
|
19
19
|
static getLabelSize(labelMaxWidth: number, labelTexts: any[]): LabelSize;
|
|
20
|
+
private static getKeyAxisTranslateModel;
|
|
20
21
|
}
|
|
@@ -4,16 +4,14 @@ import { DataManagerModel } from "../dataManagerModel/dataManagerModel";
|
|
|
4
4
|
import { TwoDimensionalModel } from "../notations/twoDimensionalModel";
|
|
5
5
|
import { AxisModelService } from "./axisModelService";
|
|
6
6
|
export class AxisModel {
|
|
7
|
-
static getKeyAxis(options, data, labelConfig, canvasModel, tooltipSettings) {
|
|
7
|
+
static getKeyAxis(options, data, labelConfig, canvasModel, tooltipSettings, getZeroCoordinate) {
|
|
8
8
|
const { charts, orientation, data: dataOptions } = options;
|
|
9
9
|
const axisConfig = options.axis.key;
|
|
10
|
+
const translate = this.getKeyAxisTranslateModel(orientation, axisConfig.position, canvasModel, getZeroCoordinate);
|
|
10
11
|
return {
|
|
11
12
|
type: 'key',
|
|
12
13
|
orient: AxisModel.getAxisOrient(AxisType.Key, orientation, axisConfig.position),
|
|
13
|
-
translate
|
|
14
|
-
translateX: AxisModel.getAxisTranslateX(AxisType.Key, orientation, axisConfig.position, canvasModel),
|
|
15
|
-
translateY: AxisModel.getAxisTranslateY(AxisType.Key, orientation, axisConfig.position, canvasModel)
|
|
16
|
-
},
|
|
14
|
+
translate,
|
|
17
15
|
cssClass: 'key-axis',
|
|
18
16
|
ticks: axisConfig.ticks,
|
|
19
17
|
labels: {
|
|
@@ -109,5 +107,25 @@ export class AxisModel {
|
|
|
109
107
|
textBlock.remove();
|
|
110
108
|
return labelSize;
|
|
111
109
|
}
|
|
110
|
+
static getKeyAxisTranslateModel(chartOrientation, axisPosition, canvasModel, getZeroCoordinate) {
|
|
111
|
+
let translateY;
|
|
112
|
+
let translateX;
|
|
113
|
+
if (chartOrientation === "vertical") {
|
|
114
|
+
translateY = getZeroCoordinate
|
|
115
|
+
? getZeroCoordinate() + canvasModel.getMarginSide("top")
|
|
116
|
+
: AxisModel.getAxisTranslateY(AxisType.Key, chartOrientation, axisPosition, canvasModel);
|
|
117
|
+
translateX = AxisModel.getAxisTranslateX(AxisType.Key, chartOrientation, axisPosition, canvasModel);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
translateX = getZeroCoordinate
|
|
121
|
+
? getZeroCoordinate() + canvasModel.getMarginSide("left")
|
|
122
|
+
: AxisModel.getAxisTranslateX(AxisType.Key, chartOrientation, axisPosition, canvasModel);
|
|
123
|
+
translateY = AxisModel.getAxisTranslateY(AxisType.Key, chartOrientation, axisPosition, canvasModel);
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
126
|
+
translateX,
|
|
127
|
+
translateY
|
|
128
|
+
};
|
|
129
|
+
}
|
|
112
130
|
}
|
|
113
131
|
AxisModel.service = new AxisModelService();
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ScaleLinear, ScaleTime } from "d3-scale";
|
|
2
|
+
import { ChartOrientation, DiscreteAxisOptions } from "../../../config/config";
|
|
3
|
+
import { ScaleValueModel } from "../../model";
|
|
4
|
+
import { CanvasModel } from "../../modelInstance/canvasModel/canvasModel";
|
|
5
|
+
export declare const keyAxisLabelVerticalLog = "keyAxisLabel_vertical_margin_log";
|
|
6
|
+
export declare const keyAxisLabelHorizontalLog = "keyAxisLabel_horizontal_margin_log";
|
|
7
|
+
interface ScaleInfo {
|
|
8
|
+
scale: ScaleValueModel;
|
|
9
|
+
scaleFn: ScaleLinear<number, number, never> | ScaleTime<number, number, never>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Предназначен для получения нового scaleValue и уменьшения globalMargin, если ось ключей находится где-то внутри chartBlock, а не на его границе
|
|
13
|
+
*/
|
|
14
|
+
export declare class ScaleAxisRecalcer {
|
|
15
|
+
private generateScaleLinear;
|
|
16
|
+
constructor(generateScaleLinear: () => ScaleValueModel);
|
|
17
|
+
recalculateMargin(canvasModel: CanvasModel, chartOrientation: ChartOrientation, keyAxis: DiscreteAxisOptions): void;
|
|
18
|
+
getScaleValue(): ScaleInfo;
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Scale } from "../../../engine/features/scale/scale";
|
|
2
|
+
export const keyAxisLabelVerticalLog = "keyAxisLabel_vertical_margin_log";
|
|
3
|
+
export const keyAxisLabelHorizontalLog = "keyAxisLabel_horizontal_margin_log";
|
|
4
|
+
/**
|
|
5
|
+
* Предназначен для получения нового scaleValue и уменьшения globalMargin, если ось ключей находится где-то внутри chartBlock, а не на его границе
|
|
6
|
+
*/
|
|
7
|
+
export class ScaleAxisRecalcer {
|
|
8
|
+
constructor(generateScaleLinear) {
|
|
9
|
+
this.generateScaleLinear = generateScaleLinear;
|
|
10
|
+
}
|
|
11
|
+
recalculateMargin(canvasModel, chartOrientation, keyAxis) {
|
|
12
|
+
const scaleValue = this.generateScaleLinear();
|
|
13
|
+
//TODO: rm import from engine
|
|
14
|
+
const scaleValueFn = Scale.getScaleValue(scaleValue);
|
|
15
|
+
const coordinateOnChartBlock = (keyAxis.position === "start"
|
|
16
|
+
? scaleValueFn(0)
|
|
17
|
+
: (chartOrientation === "vertical"
|
|
18
|
+
? canvasModel.getChartBlockHeight()
|
|
19
|
+
: canvasModel.getChartBlockWidth()) - scaleValueFn(0));
|
|
20
|
+
const key = chartOrientation === "vertical" ? keyAxisLabelVerticalLog : keyAxisLabelHorizontalLog;
|
|
21
|
+
const logInfo = canvasModel.marginService.getDataByKey(key);
|
|
22
|
+
canvasModel.decreaseMarginSide(logInfo.side, logInfo.byValue - coordinateOnChartBlock < 0 ? logInfo.byValue : coordinateOnChartBlock);
|
|
23
|
+
}
|
|
24
|
+
getScaleValue() {
|
|
25
|
+
const scale = this.generateScaleLinear();
|
|
26
|
+
return {
|
|
27
|
+
scale,
|
|
28
|
+
scaleFn: Scale.getScaleValue(scale)
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ScaleKeyModel, ScaleKeyType, ScaleValueModel, ScaleValueType } from "../../model";
|
|
2
|
+
import { AxisPosition, NumberDomain, IntervalChart, MdtChartsTwoDimensionalChart, MdtChartsTwoDimensionalOptions, ChartOrientation, MdtChartsDataSource, MdtChartsDataRow } from "../../../config/config";
|
|
3
|
+
import { CanvasModel } from "../../modelInstance/canvasModel/canvasModel";
|
|
4
|
+
export declare enum ScaleType {
|
|
5
|
+
Key = 0,
|
|
6
|
+
Value = 1
|
|
7
|
+
}
|
|
8
|
+
export declare class ScaleModel {
|
|
9
|
+
static getScaleKey(allowableKeys: string[], orient: ChartOrientation, canvasModel: CanvasModel, charts: MdtChartsTwoDimensionalChart[], barCharts: MdtChartsTwoDimensionalChart[]): ScaleKeyModel;
|
|
10
|
+
static getScaleLinear(options: MdtChartsTwoDimensionalOptions, data: MdtChartsDataSource, canvasModel: CanvasModel): ScaleValueModel;
|
|
11
|
+
static getRangePeek(scaleType: ScaleType, chartOrientation: string, canvasModel: CanvasModel): number;
|
|
12
|
+
static getDateValueDomain(data: MdtChartsDataSource, chart: IntervalChart, keyAxisPosition: AxisPosition, dataSource: string): [Date, Date];
|
|
13
|
+
static getLinearDomain(configDomain: NumberDomain, data: MdtChartsDataSource, configOptions: MdtChartsTwoDimensionalOptions): [number, number];
|
|
14
|
+
static getScaleKeyType(charts: MdtChartsTwoDimensionalChart[]): ScaleKeyType;
|
|
15
|
+
static getScaleValueType(charts: MdtChartsTwoDimensionalChart[] | IntervalChart[]): ScaleValueType;
|
|
16
|
+
static getElementsAmount(barCharts: MdtChartsTwoDimensionalChart[]): number;
|
|
17
|
+
static getScaleMaxValue(charts: MdtChartsTwoDimensionalChart[], dataRows: MdtChartsDataRow[]): number;
|
|
18
|
+
static getScaleMinValue(charts: MdtChartsTwoDimensionalChart[], dataRows: MdtChartsDataRow[]): number;
|
|
19
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { ModelHelper } from "../../modelHelper";
|
|
2
|
+
export var ScaleType;
|
|
3
|
+
(function (ScaleType) {
|
|
4
|
+
ScaleType[ScaleType["Key"] = 0] = "Key";
|
|
5
|
+
ScaleType[ScaleType["Value"] = 1] = "Value";
|
|
6
|
+
})(ScaleType || (ScaleType = {}));
|
|
7
|
+
export class ScaleModel {
|
|
8
|
+
static getScaleKey(allowableKeys, orient, canvasModel, charts, barCharts) {
|
|
9
|
+
return {
|
|
10
|
+
domain: allowableKeys,
|
|
11
|
+
range: {
|
|
12
|
+
start: 0,
|
|
13
|
+
end: ScaleModel.getRangePeek(ScaleType.Key, orient, canvasModel)
|
|
14
|
+
},
|
|
15
|
+
type: ScaleModel.getScaleKeyType(charts),
|
|
16
|
+
elementsAmount: this.getElementsAmount(barCharts)
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
static getScaleLinear(options, data, canvasModel) {
|
|
20
|
+
return {
|
|
21
|
+
domain: ScaleModel.getLinearDomain(options.axis.value.domain, data, options),
|
|
22
|
+
range: {
|
|
23
|
+
start: 0,
|
|
24
|
+
end: ScaleModel.getRangePeek(ScaleType.Value, options.orientation, canvasModel)
|
|
25
|
+
},
|
|
26
|
+
type: ScaleModel.getScaleValueType(options.charts)
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
static getRangePeek(scaleType, chartOrientation, canvasModel) {
|
|
30
|
+
if (chartOrientation === 'vertical')
|
|
31
|
+
return scaleType === ScaleType.Key
|
|
32
|
+
? canvasModel.getChartBlockWidth()
|
|
33
|
+
: canvasModel.getChartBlockHeight();
|
|
34
|
+
return scaleType === ScaleType.Key
|
|
35
|
+
? canvasModel.getChartBlockHeight()
|
|
36
|
+
: canvasModel.getChartBlockWidth();
|
|
37
|
+
}
|
|
38
|
+
static getDateValueDomain(data, chart, keyAxisPosition, dataSource) {
|
|
39
|
+
const minMax = ModelHelper.getMinAndMaxOfIntervalData(data, dataSource, chart);
|
|
40
|
+
let domainPeekMin = minMax[0];
|
|
41
|
+
let domainPeekMax = minMax[1];
|
|
42
|
+
if (keyAxisPosition === 'start')
|
|
43
|
+
return [domainPeekMin, domainPeekMax];
|
|
44
|
+
return [domainPeekMax, domainPeekMin];
|
|
45
|
+
}
|
|
46
|
+
static getLinearDomain(configDomain, data, configOptions) {
|
|
47
|
+
let domainPeekMin;
|
|
48
|
+
let domainPeekMax;
|
|
49
|
+
if (configDomain.start === -1)
|
|
50
|
+
domainPeekMin = this.getScaleMinValue(configOptions.charts, data[configOptions.data.dataSource]);
|
|
51
|
+
else
|
|
52
|
+
domainPeekMin = configDomain.start;
|
|
53
|
+
if (configDomain.end === -1)
|
|
54
|
+
domainPeekMax = this.getScaleMaxValue(configOptions.charts, data[configOptions.data.dataSource]);
|
|
55
|
+
else
|
|
56
|
+
domainPeekMax = configDomain.end;
|
|
57
|
+
if (configOptions.axis.key.position === 'start')
|
|
58
|
+
return [domainPeekMin, domainPeekMax];
|
|
59
|
+
return [domainPeekMax, domainPeekMin];
|
|
60
|
+
}
|
|
61
|
+
static getScaleKeyType(charts) {
|
|
62
|
+
if (charts.findIndex((chart) => chart.type === 'bar') === -1)
|
|
63
|
+
return 'point';
|
|
64
|
+
return 'band';
|
|
65
|
+
}
|
|
66
|
+
static getScaleValueType(charts) {
|
|
67
|
+
if (charts.findIndex((chart) => chart.type === 'gantt') !== -1)
|
|
68
|
+
return 'datetime';
|
|
69
|
+
return 'linear';
|
|
70
|
+
}
|
|
71
|
+
static getElementsAmount(barCharts) {
|
|
72
|
+
if (barCharts.length === 0)
|
|
73
|
+
return 1;
|
|
74
|
+
let barsAmount = 0;
|
|
75
|
+
barCharts.forEach(chart => {
|
|
76
|
+
if (chart.isSegmented)
|
|
77
|
+
barsAmount += 1; // Если бар сегментированный, то все valueFields являются частями одного бара
|
|
78
|
+
else
|
|
79
|
+
barsAmount += chart.data.valueFields.length;
|
|
80
|
+
});
|
|
81
|
+
return barsAmount;
|
|
82
|
+
}
|
|
83
|
+
static getScaleMaxValue(charts, dataRows) {
|
|
84
|
+
let max = 0;
|
|
85
|
+
charts.forEach(chart => {
|
|
86
|
+
dataRows.forEach(dataRow => {
|
|
87
|
+
let sumInRow = 0;
|
|
88
|
+
chart.data.valueFields.forEach(field => {
|
|
89
|
+
if (chart.isSegmented && dataRow[field.name] > 0)
|
|
90
|
+
sumInRow += dataRow[field.name];
|
|
91
|
+
else if (dataRow[field.name] > sumInRow)
|
|
92
|
+
sumInRow = dataRow[field.name];
|
|
93
|
+
});
|
|
94
|
+
if (max < sumInRow)
|
|
95
|
+
max = sumInRow;
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
return max;
|
|
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 (chart.isSegmented && dataRow[field.name] < 0) {
|
|
107
|
+
sumInRow += dataRow[field.name];
|
|
108
|
+
}
|
|
109
|
+
else if (dataRow[field.name] < sumInRow)
|
|
110
|
+
sumInRow = dataRow[field.name];
|
|
111
|
+
});
|
|
112
|
+
if (min > sumInRow)
|
|
113
|
+
min = sumInRow;
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
return min;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -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
|
}
|
|
@@ -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
|
+
}
|
|
@@ -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,10 +1,14 @@
|
|
|
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
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,
|
|
@@ -12,10 +16,10 @@ export class TwoDimensionalModel {
|
|
|
12
16
|
orient: options.orientation,
|
|
13
17
|
scale: {
|
|
14
18
|
key: ScaleModel.getScaleKey(modelInstance.dataModel.getAllowableKeys(), options.orientation, canvasModel, options.charts, this.getChartsByType(options.charts, 'bar')),
|
|
15
|
-
value:
|
|
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,
|
|
@@ -58,10 +58,11 @@
|
|
|
58
58
|
.legend-item {
|
|
59
59
|
cursor: default;
|
|
60
60
|
transition: opacity 0.1s;
|
|
61
|
+
line-height: 1;
|
|
61
62
|
/* will-change: opacity; */
|
|
62
63
|
}
|
|
63
64
|
.legend-block-column .legend-item:not(:first-of-type) {
|
|
64
|
-
margin-top:
|
|
65
|
+
margin-top: 10px;
|
|
65
66
|
}
|
|
66
67
|
.legend-item-inline {
|
|
67
68
|
white-space: nowrap;
|
|
@@ -72,7 +73,7 @@
|
|
|
72
73
|
margin-left: 20px;
|
|
73
74
|
}
|
|
74
75
|
.legend-wrapper-with-wrap .legend-item-inline {
|
|
75
|
-
margin:
|
|
76
|
+
margin: 2px;
|
|
76
77
|
}
|
|
77
78
|
.legend-item-row {
|
|
78
79
|
display: flex;
|
|
@@ -58,10 +58,11 @@
|
|
|
58
58
|
.legend-item {
|
|
59
59
|
cursor: default;
|
|
60
60
|
transition: opacity 0.1s;
|
|
61
|
+
line-height: 1;
|
|
61
62
|
/* will-change: opacity; */
|
|
62
63
|
}
|
|
63
64
|
.legend-block-column .legend-item:not(:first-of-type) {
|
|
64
|
-
margin-top:
|
|
65
|
+
margin-top: 10px;
|
|
65
66
|
}
|
|
66
67
|
.legend-item-inline {
|
|
67
68
|
white-space: nowrap;
|
|
@@ -72,7 +73,7 @@
|
|
|
72
73
|
margin-left: 20px;
|
|
73
74
|
}
|
|
74
75
|
.legend-wrapper-with-wrap .legend-item-inline {
|
|
75
|
-
margin:
|
|
76
|
+
margin: 2px;
|
|
76
77
|
}
|
|
77
78
|
.legend-item-row {
|
|
78
79
|
display: flex;
|