mdt-charts 1.12.0 → 1.12.4
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 +24 -12
- package/lib/designer/designerConfig.d.ts +3 -5
- package/lib/engine/features/aggregator/aggregator.d.ts +9 -7
- package/lib/engine/features/aggregator/aggregator.js +51 -37
- 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/polarNotation/donut/donut.js +1 -1
- package/lib/engine/polarNotation/extenders/polarRecordOverflowAlert.d.ts +0 -1
- package/lib/engine/polarNotation/extenders/polarRecordOverflowAlert.js +9 -17
- package/lib/engine/polarNotation/polarManager.js +1 -1
- package/lib/model/chartStyleModel/TwoDimensionalChartStyleModel.d.ts +4 -4
- package/lib/model/dataManagerModel/dataManagerModel.d.ts +8 -0
- package/lib/model/dataManagerModel/dataManagerModel.js +26 -13
- package/lib/model/featuresModel/axisModel.d.ts +5 -4
- package/lib/model/featuresModel/axisModel.js +13 -11
- package/lib/model/featuresModel/axisModelService.d.ts +4 -0
- package/lib/model/featuresModel/axisModelService.js +11 -0
- package/lib/model/featuresModel/legendModel/legendCanvasModel.d.ts +4 -2
- package/lib/model/featuresModel/legendModel/legendCanvasModel.js +42 -29
- package/lib/model/featuresModel/legendModel/legendModel.d.ts +1 -2
- package/lib/model/featuresModel/legendModel/legendModel.js +15 -15
- package/lib/model/featuresModel/legendModel/polarMarginCalculator.d.ts +11 -0
- package/lib/model/featuresModel/legendModel/polarMarginCalculator.js +42 -0
- package/lib/model/featuresModel/scaleModel.d.ts +6 -6
- package/lib/model/featuresModel/titleModel.js +4 -4
- package/lib/model/marginModel.d.ts +3 -2
- package/lib/model/marginModel.js +6 -3
- package/lib/model/model.d.ts +19 -8
- package/lib/model/modelBuilder.js +8 -9
- 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.d.ts +2 -2
- package/lib/model/notations/polar/donut/donutAggregatorService.d.ts +12 -0
- package/lib/model/notations/polar/donut/donutAggregatorService.js +25 -0
- package/lib/model/notations/polar/donut/donutModel.d.ts +10 -0
- package/lib/model/notations/polar/donut/donutModel.js +32 -0
- package/lib/model/notations/polar/donut/donutThicknessService.d.ts +9 -0
- package/lib/model/notations/polar/donut/donutThicknessService.js +30 -0
- package/lib/model/notations/polar/polarModel.d.ts +15 -0
- package/lib/model/notations/polar/polarModel.js +53 -0
- package/lib/model/notations/polarModel.d.ts +3 -1
- package/lib/model/notations/polarModel.js +12 -1
- package/lib/model/notations/twoDimensionalModel.d.ts +6 -6
- package/lib/model/notations/twoDimensionalModel.js +3 -3
- package/lib/style/charts-main.css +29 -9
- package/lib/style/charts-main.less +29 -9
- package/package.json +2 -2
- package/tsconfig.production.json +23 -0
- package/lib/engine/features/recordOverflowAlert/recordOverflowAlert.d.ts +0 -14
- package/lib/engine/features/recordOverflowAlert/recordOverflowAlert.js +0 -97
- package/lib/model/dataManagerModel.d.ts +0 -23
- package/lib/model/dataManagerModel.js +0 -139
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { AxisModel } from "../featuresModel/axisModel";
|
|
2
2
|
import { LegendCanvasModel } from "../featuresModel/legendModel/legendCanvasModel";
|
|
3
|
+
import { LegendPolarMarginCalculator } from "../featuresModel/legendModel/polarMarginCalculator";
|
|
3
4
|
import { ModelHelper } from "../modelHelper";
|
|
4
|
-
import { MIN_DONUT_BLOCK_SIZE, PolarModel } from "../notations/polarModel";
|
|
5
|
+
import { MIN_DONUT_BLOCK_SIZE, PolarModel } from "../notations/polar/polarModel";
|
|
5
6
|
import { DataManagerModelService } from "./dataManagerModelService";
|
|
6
7
|
export class DataManagerModel {
|
|
7
8
|
static getPreparedData(data, allowableKeys, config) {
|
|
@@ -44,28 +45,40 @@ export class DataManagerModel {
|
|
|
44
45
|
}
|
|
45
46
|
}
|
|
46
47
|
static initDataScopeForPolar(configOptions, modelInstance, data, legendBlock, legendCanvas) {
|
|
47
|
-
const
|
|
48
|
-
const dataset = data[configOptions.data.dataSource];
|
|
48
|
+
const canvasModel = modelInstance.canvasModel;
|
|
49
49
|
const keyFieldName = configOptions.data.keyField.name;
|
|
50
|
-
const keys =
|
|
50
|
+
const keys = data[configOptions.data.dataSource].map(dataRow => dataRow[keyFieldName]);
|
|
51
51
|
if (!configOptions.legend.show) {
|
|
52
52
|
modelInstance.dataModel.initScope(this.getMaximumPossibleScope(keys, modelInstance.dataModel));
|
|
53
53
|
return;
|
|
54
54
|
}
|
|
55
|
-
|
|
56
|
-
let maxItemsNumber;
|
|
57
|
-
if (position ===
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
55
|
+
let position = PolarModel.getLegendPositionByBlockSize(modelInstance.canvasModel);
|
|
56
|
+
let { amount: maxItemsNumber, size } = this.getLegendDataParams(position, keys, legendCanvas, canvasModel, legendBlock);
|
|
57
|
+
if (position === "right" && !PolarModel.doesChartBlockHasEnoughWidthForContainsLegend(canvasModel.getChartBlockWidth(), size.width, legendBlock.coordinate)) {
|
|
58
|
+
const doesFreeSpaceExist = PolarModel.doesChartBlockHasEnoughHeightForContainsLegend(canvasModel.getChartBlockHeight(), legendBlock.coordinate);
|
|
59
|
+
if (doesFreeSpaceExist) {
|
|
60
|
+
const newParams = this.getLegendDataParams("bottom", keys, legendCanvas, canvasModel, legendBlock);
|
|
61
|
+
position = "bottom";
|
|
62
|
+
maxItemsNumber = newParams.amount;
|
|
63
|
+
size = newParams.size;
|
|
64
|
+
}
|
|
64
65
|
}
|
|
66
|
+
//TODO: global refactor of method
|
|
65
67
|
const allowableKeys = keys.slice(0, maxItemsNumber);
|
|
66
68
|
const hidedRecordsAmount = keys.length - maxItemsNumber;
|
|
69
|
+
const marginCalculator = new LegendPolarMarginCalculator();
|
|
70
|
+
marginCalculator.updateMargin(position, canvasModel, legendBlock, position === "bottom" ? size.height : size.width);
|
|
67
71
|
modelInstance.dataModel.initScope(this.limitAllowableKeys(allowableKeys, hidedRecordsAmount, modelInstance.dataModel));
|
|
68
72
|
}
|
|
73
|
+
//TODO: position type
|
|
74
|
+
static getLegendDataParams(position, keys, legendCanvas, canvasModel, legendBlock) {
|
|
75
|
+
if (position === 'right') {
|
|
76
|
+
return LegendCanvasModel.findElementsAmountByLegendSize(keys, position, legendCanvas.maxWidth, canvasModel.getChartBlockHeight() - legendBlock.coordinate.bottom.margin.bottom);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
return LegendCanvasModel.findElementsAmountByLegendSize(keys, position, canvasModel.getChartBlockWidth() - legendBlock.coordinate.bottom.margin.left - legendBlock.coordinate.bottom.margin.right, canvasModel.getChartBlockHeight() - legendBlock.coordinate.bottom.margin.bottom - legendBlock.coordinate.bottom.margin.top - MIN_DONUT_BLOCK_SIZE);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
69
82
|
static getMaximumPossibleScope(keys, dataModel) {
|
|
70
83
|
return this.service.getMaximumPossibleAmount(keys, dataModel.getMaxRecordsAmount());
|
|
71
84
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AxisPosition, ChartOrientation,
|
|
2
|
-
import {
|
|
1
|
+
import { AxisPosition, ChartOrientation, MdtChartsDataSource, NumberAxisOptions, AxisLabelPosition, MdtChartsTwoDimensionalOptions, DiscreteAxisOptions } from "../../config/config";
|
|
2
|
+
import { AxisModelOptions, Orient } from "../model";
|
|
3
3
|
import { AxisType } from "../modelBuilder";
|
|
4
4
|
import { AxisLabelCanvas, TooltipSettings } from "../../designer/designerConfig";
|
|
5
5
|
import { CanvasModel } from "../modelInstance/canvasModel/canvasModel";
|
|
@@ -8,12 +8,13 @@ export interface LabelSize {
|
|
|
8
8
|
height: number;
|
|
9
9
|
}
|
|
10
10
|
export declare class AxisModel {
|
|
11
|
-
static
|
|
11
|
+
private static service;
|
|
12
|
+
static getKeyAxis(options: MdtChartsTwoDimensionalOptions, data: MdtChartsDataSource, labelConfig: AxisLabelCanvas, canvasModel: CanvasModel, tooltipSettings: TooltipSettings): AxisModelOptions;
|
|
12
13
|
static getValueAxis(orient: ChartOrientation, axisConfig: NumberAxisOptions, labelConfig: AxisLabelCanvas, canvasModel: CanvasModel): AxisModelOptions;
|
|
13
14
|
static getAxisLength(chartOrientation: ChartOrientation, canvasModel: CanvasModel): number;
|
|
14
15
|
static getAxisOrient(axisType: AxisType, chartOrientation: ChartOrientation, axisPosition: AxisPosition): Orient;
|
|
15
16
|
static getAxisTranslateX(axisType: AxisType, chartOrientation: ChartOrientation, axisPosition: AxisPosition, canvasModel: CanvasModel): number;
|
|
16
17
|
static getAxisTranslateY(axisType: AxisType, chartOrientation: ChartOrientation, axisPosition: AxisPosition, canvasModel: CanvasModel): number;
|
|
17
|
-
static getKeyAxisLabelPosition(canvasModel: CanvasModel, scopedDataLength: number): AxisLabelPosition;
|
|
18
|
+
static getKeyAxisLabelPosition(canvasModel: CanvasModel, scopedDataLength: number, axisConfig?: DiscreteAxisOptions): AxisLabelPosition;
|
|
18
19
|
static getLabelSize(labelMaxWidth: number, labelTexts: any[]): LabelSize;
|
|
19
20
|
}
|
|
@@ -2,21 +2,24 @@ import { ModelHelper } from "../modelHelper";
|
|
|
2
2
|
import { AxisType, CLASSES } from "../modelBuilder";
|
|
3
3
|
import { DataManagerModel } from "../dataManagerModel/dataManagerModel";
|
|
4
4
|
import { TwoDimensionalModel } from "../notations/twoDimensionalModel";
|
|
5
|
+
import { AxisModelService } from "./axisModelService";
|
|
5
6
|
export class AxisModel {
|
|
6
|
-
static getKeyAxis(
|
|
7
|
+
static getKeyAxis(options, data, labelConfig, canvasModel, tooltipSettings) {
|
|
8
|
+
const { charts, orientation, data: dataOptions } = options;
|
|
9
|
+
const axisConfig = options.axis.key;
|
|
7
10
|
return {
|
|
8
11
|
type: 'key',
|
|
9
|
-
orient: AxisModel.getAxisOrient(AxisType.Key,
|
|
12
|
+
orient: AxisModel.getAxisOrient(AxisType.Key, orientation, axisConfig.position),
|
|
10
13
|
translate: {
|
|
11
|
-
translateX: AxisModel.getAxisTranslateX(AxisType.Key,
|
|
12
|
-
translateY: AxisModel.getAxisTranslateY(AxisType.Key,
|
|
14
|
+
translateX: AxisModel.getAxisTranslateX(AxisType.Key, orientation, axisConfig.position, canvasModel),
|
|
15
|
+
translateY: AxisModel.getAxisTranslateY(AxisType.Key, orientation, axisConfig.position, canvasModel)
|
|
13
16
|
},
|
|
14
17
|
cssClass: 'key-axis',
|
|
15
18
|
ticks: axisConfig.ticks,
|
|
16
19
|
labels: {
|
|
17
20
|
maxSize: AxisModel.getLabelSize(labelConfig.maxSize.main, data[dataOptions.dataSource].map(d => d[dataOptions.keyField.name])).width,
|
|
18
|
-
position: AxisModel.getKeyAxisLabelPosition(canvasModel, DataManagerModel.getDataValuesByKeyField(data, dataOptions.dataSource, dataOptions.keyField.name).length),
|
|
19
|
-
visible: !TwoDimensionalModel.getChartsEmbeddedLabelsFlag(charts,
|
|
21
|
+
position: AxisModel.getKeyAxisLabelPosition(canvasModel, DataManagerModel.getDataValuesByKeyField(data, dataOptions.dataSource, dataOptions.keyField.name).length, axisConfig),
|
|
22
|
+
visible: !TwoDimensionalModel.getChartsEmbeddedLabelsFlag(charts, orientation),
|
|
20
23
|
defaultTooltip: tooltipSettings.position === 'fixed'
|
|
21
24
|
},
|
|
22
25
|
visibility: axisConfig.visibility
|
|
@@ -75,11 +78,9 @@ export class AxisModel {
|
|
|
75
78
|
return canvasModel.getBlockSize().height - canvasModel.getMarginSide("bottom");
|
|
76
79
|
return canvasModel.getMarginSide("top");
|
|
77
80
|
}
|
|
78
|
-
static getKeyAxisLabelPosition(canvasModel, scopedDataLength) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
return 'rotated';
|
|
82
|
-
return 'straight';
|
|
81
|
+
static getKeyAxisLabelPosition(canvasModel, scopedDataLength, axisConfig) {
|
|
82
|
+
var _a;
|
|
83
|
+
return this.service.getKeyAxisLabelPosition(canvasModel.getChartBlockWidth(), scopedDataLength, (_a = axisConfig === null || axisConfig === void 0 ? void 0 : axisConfig.labels) === null || _a === void 0 ? void 0 : _a.position);
|
|
83
84
|
}
|
|
84
85
|
static getLabelSize(labelMaxWidth, labelTexts) {
|
|
85
86
|
const labelSize = {
|
|
@@ -109,3 +110,4 @@ export class AxisModel {
|
|
|
109
110
|
return labelSize;
|
|
110
111
|
}
|
|
111
112
|
}
|
|
113
|
+
AxisModel.service = new AxisModelService();
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export class AxisModelService {
|
|
2
|
+
getKeyAxisLabelPosition(chartBlockWidth, scopedDataLength, positionFromConfig) {
|
|
3
|
+
if (positionFromConfig === "rotated" || positionFromConfig === "straight") {
|
|
4
|
+
return positionFromConfig;
|
|
5
|
+
}
|
|
6
|
+
const minBandSize = 50;
|
|
7
|
+
if (chartBlockWidth / scopedDataLength < minBandSize)
|
|
8
|
+
return 'rotated';
|
|
9
|
+
return 'straight';
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { DataLegendParams } from "../../dataManagerModel/dataManagerModel";
|
|
1
2
|
import { LegendPosition } from "../../model";
|
|
2
3
|
export declare type LegendItemsDirection = 'row' | 'column';
|
|
3
4
|
export declare class LegendCanvasModel {
|
|
4
|
-
static getLegendHeight(texts: string[],
|
|
5
|
+
static getLegendHeight(texts: string[], chartBlockWidth: number, itemsDirection: LegendItemsDirection, legendPosition: LegendPosition): number;
|
|
5
6
|
static getLegendItemWidth(text: string): number;
|
|
6
|
-
static findElementsAmountByLegendSize(texts: string[], position: LegendPosition, legendBlockWidth: number, legendBlockHeight: number):
|
|
7
|
+
static findElementsAmountByLegendSize(texts: string[], position: LegendPosition, legendBlockWidth: number, legendBlockHeight: number): DataLegendParams;
|
|
8
|
+
private static getLegendWrapperEl;
|
|
7
9
|
}
|
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
import { CLASSES } from "../../modelBuilder";
|
|
2
|
-
import { LegendModel } from "./legendModel";
|
|
3
2
|
export class LegendCanvasModel {
|
|
4
|
-
static getLegendHeight(texts,
|
|
5
|
-
const legendWrapper =
|
|
6
|
-
legendWrapper.style.opacity = '0';
|
|
7
|
-
legendWrapper.style.display = 'flex';
|
|
8
|
-
if (itemsPosition === 'column')
|
|
9
|
-
legendWrapper.style.flexDirection = 'column';
|
|
10
|
-
legendWrapper.style.position = 'absolute';
|
|
11
|
-
legendWrapper.style.width = blockWidth - marginLeft - marginRight + 'px';
|
|
3
|
+
static getLegendHeight(texts, chartBlockWidth, itemsDirection, legendPosition) {
|
|
4
|
+
const legendWrapper = this.getLegendWrapperEl(chartBlockWidth, itemsDirection);
|
|
12
5
|
texts.forEach(text => {
|
|
13
6
|
const itemWrapper = document.createElement('div');
|
|
14
7
|
const colorBlock = document.createElement('span');
|
|
15
8
|
const textBlock = document.createElement('span');
|
|
16
|
-
itemWrapper.classList.add(
|
|
17
|
-
if (
|
|
18
|
-
itemWrapper.
|
|
19
|
-
|
|
9
|
+
itemWrapper.classList.add("legend-item");
|
|
10
|
+
if (legendPosition === 'bottom') {
|
|
11
|
+
itemWrapper.classList.add('legend-item-inline');
|
|
12
|
+
textBlock.classList.add('legend-label-nowrap');
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
itemWrapper.classList.add('legend-item-row');
|
|
20
16
|
}
|
|
21
17
|
colorBlock.classList.add(CLASSES.legendColor);
|
|
22
18
|
textBlock.classList.add(CLASSES.legendLabel);
|
|
@@ -27,7 +23,7 @@ export class LegendCanvasModel {
|
|
|
27
23
|
document.body.append(legendWrapper);
|
|
28
24
|
const height = legendWrapper.offsetHeight;
|
|
29
25
|
legendWrapper.remove();
|
|
30
|
-
return height;
|
|
26
|
+
return height + 1;
|
|
31
27
|
}
|
|
32
28
|
static getLegendItemWidth(text) {
|
|
33
29
|
const itemWrapper = document.createElement('div');
|
|
@@ -48,39 +44,56 @@ export class LegendCanvasModel {
|
|
|
48
44
|
return sumWidth;
|
|
49
45
|
}
|
|
50
46
|
static findElementsAmountByLegendSize(texts, position, legendBlockWidth, legendBlockHeight) {
|
|
51
|
-
const legendWrapper =
|
|
52
|
-
legendWrapper.style.opacity = '0';
|
|
53
|
-
legendWrapper.style.display = 'flex';
|
|
54
|
-
legendWrapper.style.flexDirection = 'column';
|
|
55
|
-
legendWrapper.style.position = 'absolute';
|
|
56
|
-
legendWrapper.style.width = legendBlockWidth + 'px';
|
|
47
|
+
const legendWrapper = this.getLegendWrapperEl(legendBlockWidth, position === "right" ? "column" : "row");
|
|
57
48
|
document.body.append(legendWrapper);
|
|
58
49
|
let amount = 0;
|
|
59
50
|
for (let i = 0; i < texts.length; i++) {
|
|
60
51
|
const itemWrapper = document.createElement('div');
|
|
61
52
|
const colorBlock = document.createElement('span');
|
|
62
53
|
const textBlock = document.createElement('span');
|
|
63
|
-
itemWrapper.classList.add(
|
|
64
|
-
if (position === 'bottom')
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
54
|
+
itemWrapper.classList.add("legend-item");
|
|
55
|
+
if (position === 'bottom') {
|
|
56
|
+
itemWrapper.classList.add('legend-item-inline');
|
|
57
|
+
textBlock.classList.add('legend-label-nowrap');
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
itemWrapper.classList.add('legend-item-row');
|
|
61
|
+
}
|
|
68
62
|
colorBlock.classList.add(CLASSES.legendColor);
|
|
69
63
|
textBlock.classList.add(CLASSES.legendLabel);
|
|
70
64
|
textBlock.textContent = texts[i];
|
|
71
65
|
itemWrapper.append(colorBlock, textBlock);
|
|
72
66
|
legendWrapper.append(itemWrapper);
|
|
67
|
+
amount++;
|
|
73
68
|
if (legendWrapper.offsetHeight > legendBlockHeight) {
|
|
74
69
|
itemWrapper.remove();
|
|
75
70
|
if (legendBlockHeight - legendWrapper.offsetHeight >= 15 && position !== 'bottom')
|
|
76
|
-
amount =
|
|
71
|
+
amount = amount; //TODO: remove
|
|
77
72
|
else
|
|
78
|
-
amount
|
|
73
|
+
amount -= 1;
|
|
79
74
|
break;
|
|
80
75
|
}
|
|
81
|
-
amount++;
|
|
82
76
|
}
|
|
77
|
+
const size = {
|
|
78
|
+
width: legendWrapper.offsetWidth,
|
|
79
|
+
height: legendWrapper.offsetHeight
|
|
80
|
+
};
|
|
83
81
|
legendWrapper.remove();
|
|
84
|
-
return
|
|
82
|
+
return {
|
|
83
|
+
amount: amount < 0 ? 0 : amount,
|
|
84
|
+
size
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
static getLegendWrapperEl(legendBlockWidth, itemsDirection) {
|
|
88
|
+
const legendWrapper = document.createElement('div');
|
|
89
|
+
legendWrapper.style.opacity = '0';
|
|
90
|
+
legendWrapper.style.position = 'absolute';
|
|
91
|
+
legendWrapper.style.display = "flex";
|
|
92
|
+
if (itemsDirection === "column")
|
|
93
|
+
legendWrapper.classList.add("legend-block-column");
|
|
94
|
+
else
|
|
95
|
+
legendWrapper.classList.add("legend-block-row", "legend-wrapper-with-wrap");
|
|
96
|
+
legendWrapper.style.maxWidth = legendBlockWidth + 'px';
|
|
97
|
+
return legendWrapper;
|
|
85
98
|
}
|
|
86
99
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ChartNotation, Size } from "../../../config/config";
|
|
2
|
-
import { ILegendModel, LegendBlockModel,
|
|
2
|
+
import { ILegendModel, LegendBlockModel, Orient } from "../../model";
|
|
3
3
|
import { CanvasModel } from "../../modelInstance/canvasModel/canvasModel";
|
|
4
4
|
import { LegendItemsDirection } from "./legendCanvasModel";
|
|
5
5
|
export declare class LegendModel {
|
|
@@ -7,6 +7,5 @@ export declare class LegendModel {
|
|
|
7
7
|
static getBaseLegendBlockModel(notation: ChartNotation, canvasModel: CanvasModel): LegendBlockModel;
|
|
8
8
|
static getLegendModel(chartNotation: ChartNotation, legendShow: boolean, canvasModel: CanvasModel): ILegendModel;
|
|
9
9
|
static getLegendItemClass(itemsPosition: LegendItemsDirection): string;
|
|
10
|
-
static getMarginClass(legendPosition: LegendPosition): string;
|
|
11
10
|
private static getLegendWidth;
|
|
12
11
|
}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { ModelHelper } from "../../modelHelper";
|
|
2
|
-
import { PolarModel } from "../../notations/polarModel";
|
|
2
|
+
import { PolarModel } from "../../notations/polar/polarModel";
|
|
3
3
|
import { LegendCanvasModel } from "./legendCanvasModel";
|
|
4
4
|
export class LegendModel {
|
|
5
5
|
static getLegendSize(chartNotation, position, texts, legendMaxWidth, blockSize, legendBlockModel) {
|
|
6
6
|
if (position === 'left' || position === 'right')
|
|
7
7
|
return this.getLegendWidth(texts, legendMaxWidth);
|
|
8
|
+
//TODO: rm duplicate
|
|
8
9
|
if (chartNotation === '2d' || chartNotation === 'interval') {
|
|
9
|
-
return LegendCanvasModel.getLegendHeight(texts, blockSize.width
|
|
10
|
+
return LegendCanvasModel.getLegendHeight(texts, blockSize.width - legendBlockModel.coordinate[position].margin.left - legendBlockModel.coordinate[position].margin.right, 'row', position);
|
|
10
11
|
}
|
|
11
12
|
else if (chartNotation === 'polar') {
|
|
12
|
-
const size = LegendCanvasModel.getLegendHeight(texts, blockSize.width
|
|
13
|
+
const size = LegendCanvasModel.getLegendHeight(texts, blockSize.width - legendBlockModel.coordinate[position].margin.left - legendBlockModel.coordinate[position].margin.right, 'row', position);
|
|
13
14
|
return size;
|
|
14
15
|
}
|
|
15
16
|
}
|
|
@@ -24,17 +25,17 @@ export class LegendModel {
|
|
|
24
25
|
},
|
|
25
26
|
bottom: {
|
|
26
27
|
size: 0,
|
|
27
|
-
margin: { top: 0, bottom: 20, left:
|
|
28
|
+
margin: { top: 0, bottom: 20, left: 0, right: 0 },
|
|
28
29
|
pad: 0
|
|
29
30
|
},
|
|
30
31
|
right: {
|
|
31
32
|
size: 0,
|
|
32
|
-
margin: { top: canvasModel.titleCanvas.getAllNeededSpace(), bottom: mb, left:
|
|
33
|
+
margin: { top: canvasModel.titleCanvas.getAllNeededSpace(), bottom: mb, left: 5, right: 0 },
|
|
33
34
|
pad: 0
|
|
34
35
|
},
|
|
35
36
|
top: {
|
|
36
37
|
size: 0,
|
|
37
|
-
margin: { top:
|
|
38
|
+
margin: { top: 5, bottom: 10, left: 0, right: 0 },
|
|
38
39
|
pad: canvasModel.titleCanvas.getAllNeededSpace()
|
|
39
40
|
}
|
|
40
41
|
},
|
|
@@ -42,13 +43,15 @@ export class LegendModel {
|
|
|
42
43
|
};
|
|
43
44
|
}
|
|
44
45
|
static getLegendModel(chartNotation, legendShow, canvasModel) {
|
|
46
|
+
if (!legendShow)
|
|
47
|
+
return {
|
|
48
|
+
position: 'off'
|
|
49
|
+
};
|
|
45
50
|
let legendPosition = 'off';
|
|
46
|
-
if (
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
legendPosition = PolarModel.getLegendPositionByBlockSize(canvasModel);
|
|
51
|
-
}
|
|
51
|
+
if (chartNotation === '2d' || chartNotation === 'interval')
|
|
52
|
+
legendPosition = 'top';
|
|
53
|
+
else if (chartNotation === 'polar') {
|
|
54
|
+
legendPosition = PolarModel.getLegendPositionByBlockSize(canvasModel);
|
|
52
55
|
}
|
|
53
56
|
return {
|
|
54
57
|
position: legendPosition
|
|
@@ -57,9 +60,6 @@ export class LegendModel {
|
|
|
57
60
|
static getLegendItemClass(itemsPosition) {
|
|
58
61
|
return itemsPosition === 'column' ? 'legend-item-row' : 'legend-item-inline';
|
|
59
62
|
}
|
|
60
|
-
static getMarginClass(legendPosition) {
|
|
61
|
-
return legendPosition === 'right' ? 'mt-15' : 'mt-10';
|
|
62
|
-
}
|
|
63
63
|
static getLegendWidth(texts, legendMaxWidth) {
|
|
64
64
|
let longestText = '';
|
|
65
65
|
let biggestScore = 0;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MdtChartsDataSource, MdtChartsPolarOptions } from "../../../config/config";
|
|
2
|
+
import { LegendBlockModel } from "../../model";
|
|
3
|
+
import { CanvasModel } from "../../modelInstance/canvasModel/canvasModel";
|
|
4
|
+
import { ModelInstance } from "../../modelInstance/modelInstance";
|
|
5
|
+
export declare class LegendPolarMarginCalculator {
|
|
6
|
+
recalcMargin(modelInstance: ModelInstance, options: MdtChartsPolarOptions, legendMaxWidth: number, legendBlockModel: LegendBlockModel, data: MdtChartsDataSource): void;
|
|
7
|
+
updateMargin(legendPosition: "right" | "bottom", canvasModel: CanvasModel, legendBlockModel: LegendBlockModel, size: number): void;
|
|
8
|
+
private updateMarginObj;
|
|
9
|
+
private getLegendSize;
|
|
10
|
+
private getLegendItemsContent;
|
|
11
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { DataManagerModel } from "../../dataManagerModel/dataManagerModel";
|
|
2
|
+
import { MarginModel } from "../../marginModel";
|
|
3
|
+
import { MIN_DONUT_BLOCK_SIZE } from "../../notations/polar/polarModel";
|
|
4
|
+
import { LegendModel } from "./legendModel";
|
|
5
|
+
export class LegendPolarMarginCalculator {
|
|
6
|
+
recalcMargin(modelInstance, options, legendMaxWidth, legendBlockModel, data) {
|
|
7
|
+
const canvasModel = modelInstance.canvasModel;
|
|
8
|
+
let legendPosition = LegendModel.getLegendModel(options.type, options.legend.show, modelInstance.canvasModel).position;
|
|
9
|
+
modelInstance.canvasModel.legendCanvas.setPosition(legendPosition);
|
|
10
|
+
if (legendPosition === "off")
|
|
11
|
+
return;
|
|
12
|
+
let legendSize = this.getLegendSize(options, legendMaxWidth, legendBlockModel, data, canvasModel, legendPosition);
|
|
13
|
+
if (legendPosition === "right" && canvasModel.getChartBlockWidth() - legendSize < MIN_DONUT_BLOCK_SIZE) {
|
|
14
|
+
legendSize = this.getLegendSize(options, legendMaxWidth, legendBlockModel, data, canvasModel, "bottom");
|
|
15
|
+
legendPosition = "bottom";
|
|
16
|
+
modelInstance.canvasModel.legendCanvas.setPosition(legendPosition);
|
|
17
|
+
}
|
|
18
|
+
if (legendSize !== 0) {
|
|
19
|
+
canvasModel.increaseMarginSide(legendPosition, legendSize);
|
|
20
|
+
MarginModel.appendToGlobalMarginValuesLegendMargin(canvasModel, legendPosition, legendBlockModel);
|
|
21
|
+
}
|
|
22
|
+
legendBlockModel.coordinate[legendPosition].size = legendSize;
|
|
23
|
+
}
|
|
24
|
+
updateMargin(legendPosition, canvasModel, legendBlockModel, size) {
|
|
25
|
+
canvasModel.legendCanvas.setPosition(legendPosition);
|
|
26
|
+
this.updateMarginObj(legendBlockModel, legendPosition, size, canvasModel);
|
|
27
|
+
}
|
|
28
|
+
updateMarginObj(legendBlockModel, legendPosition, legendSize, canvasModel) {
|
|
29
|
+
if (legendSize !== 0) {
|
|
30
|
+
canvasModel.increaseMarginSide(legendPosition, legendSize);
|
|
31
|
+
MarginModel.appendToGlobalMarginValuesLegendMargin(canvasModel, legendPosition, legendBlockModel);
|
|
32
|
+
}
|
|
33
|
+
legendBlockModel.coordinate[legendPosition].size = legendSize;
|
|
34
|
+
}
|
|
35
|
+
getLegendSize(options, legendMaxWidth, legendBlockModel, data, canvasModel, legendPosition) {
|
|
36
|
+
const legendItemsContent = this.getLegendItemsContent(options, data);
|
|
37
|
+
return LegendModel.getLegendSize(options.type, legendPosition, legendItemsContent, legendMaxWidth, canvasModel.getBlockSize(), legendBlockModel);
|
|
38
|
+
}
|
|
39
|
+
getLegendItemsContent(options, data) {
|
|
40
|
+
return DataManagerModel.getDataValuesByKeyField(data, options.data.dataSource, options.data.keyField.name);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { ScaleKeyModel, ScaleKeyType, ScaleValueModel, ScaleValueType } from "../model";
|
|
2
|
-
import { AxisPosition, NumberDomain, IntervalChart,
|
|
2
|
+
import { AxisPosition, NumberDomain, IntervalChart, MdtChartsTwoDimensionalChart, MdtChartsTwoDimensionalOptions, ChartOrientation, MdtChartsDataSource } from "../../config/config";
|
|
3
3
|
import { CanvasModel } from "../modelInstance/canvasModel/canvasModel";
|
|
4
4
|
export declare enum ScaleType {
|
|
5
5
|
Key = 0,
|
|
6
6
|
Value = 1
|
|
7
7
|
}
|
|
8
8
|
export declare class ScaleModel {
|
|
9
|
-
static getScaleKey(allowableKeys: string[], orient: ChartOrientation, canvasModel: CanvasModel, charts:
|
|
9
|
+
static getScaleKey(allowableKeys: string[], orient: ChartOrientation, canvasModel: CanvasModel, charts: MdtChartsTwoDimensionalChart[], barCharts: MdtChartsTwoDimensionalChart[]): ScaleKeyModel;
|
|
10
10
|
static getScaleLinear(options: MdtChartsTwoDimensionalOptions, data: MdtChartsDataSource, canvasModel: CanvasModel): ScaleValueModel;
|
|
11
11
|
static getRangePeek(scaleType: ScaleType, chartOrientation: string, canvasModel: CanvasModel): number;
|
|
12
12
|
static getDateValueDomain(data: MdtChartsDataSource, chart: IntervalChart, keyAxisPosition: AxisPosition, dataSource: string): [Date, Date];
|
|
13
13
|
static getLinearDomain(configDomain: NumberDomain, data: MdtChartsDataSource, configOptions: MdtChartsTwoDimensionalOptions): [number, number];
|
|
14
|
-
static getScaleKeyType(charts:
|
|
15
|
-
static getScaleValueType(charts:
|
|
16
|
-
static getElementsAmount(barCharts:
|
|
17
|
-
static getScaleMaxValue(charts:
|
|
14
|
+
static getScaleKeyType(charts: MdtChartsTwoDimensionalChart[]): ScaleKeyType;
|
|
15
|
+
static getScaleValueType(charts: MdtChartsTwoDimensionalChart[] | IntervalChart[]): ScaleValueType;
|
|
16
|
+
static getElementsAmount(barCharts: MdtChartsTwoDimensionalChart[]): number;
|
|
17
|
+
static getScaleMaxValue(charts: MdtChartsTwoDimensionalChart[], dataSource: string, data: MdtChartsDataSource): number;
|
|
18
18
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { MdtChartsConfig, MdtChartsDataSource } from "../config/config";
|
|
2
2
|
import { DesignerConfig } from "../designer/designerConfig";
|
|
3
|
-
import { DataScope, LegendBlockModel, OtherCommonComponents, PolarOptionsModel } from "./model";
|
|
3
|
+
import { DataScope, LegendBlockModel, Orient, OtherCommonComponents, PolarOptionsModel } from "./model";
|
|
4
4
|
import { ModelInstance } from "./modelInstance/modelInstance";
|
|
5
|
+
import { CanvasModel } from "./modelInstance/canvasModel/canvasModel";
|
|
5
6
|
export declare const AXIS_HORIZONTAL_LABEL_PADDING = 15;
|
|
6
7
|
export declare const AXIS_VERTICAL_LABEL_PADDING = 10;
|
|
7
8
|
export declare class MarginModel {
|
|
@@ -13,7 +14,7 @@ export declare class MarginModel {
|
|
|
13
14
|
private static recalcHorizontalMarginByAxisLabelWidth;
|
|
14
15
|
private static recalcMarginWithLegend;
|
|
15
16
|
private static getLegendItemsContent;
|
|
16
|
-
|
|
17
|
+
static appendToGlobalMarginValuesLegendMargin(canvasModel: CanvasModel, position: Orient, legendBlockModel: LegendBlockModel): void;
|
|
17
18
|
private static clearMarginByLegendBlockPosition;
|
|
18
19
|
private static recalcMarginByTitle;
|
|
19
20
|
}
|
package/lib/model/marginModel.js
CHANGED
|
@@ -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 { PolarModel } from "./notations/polarModel";
|
|
6
|
+
import { PolarModel } from "./notations/polar/polarModel";
|
|
7
7
|
export const AXIS_HORIZONTAL_LABEL_PADDING = 15;
|
|
8
8
|
export const AXIS_VERTICAL_LABEL_PADDING = 10;
|
|
9
9
|
export class MarginModel {
|
|
@@ -42,7 +42,7 @@ export class MarginModel {
|
|
|
42
42
|
static recalcMarginByVerticalAxisLabel(modelInstance, config, designerConfig, dataScope) {
|
|
43
43
|
if ((config.options.type === '2d' || config.options.type === 'interval') && config.options.orientation === 'vertical') {
|
|
44
44
|
const axisLabelSize = AxisModel.getLabelSize(designerConfig.canvas.axisLabel.maxSize.main, dataScope.allowableKeys);
|
|
45
|
-
const axisConfig = AxisModel.getKeyAxisLabelPosition(modelInstance.canvasModel, dataScope.allowableKeys.length);
|
|
45
|
+
const axisConfig = AxisModel.getKeyAxisLabelPosition(modelInstance.canvasModel, dataScope.allowableKeys.length, config.options.axis.key);
|
|
46
46
|
const marginOrient = config.options.axis.key.position === 'end' ? 'bottom' : 'top';
|
|
47
47
|
if (axisConfig === 'rotated')
|
|
48
48
|
modelInstance.canvasModel.setMarginSide(marginOrient, modelInstance.canvasModel.getMarginSide(marginOrient) + (axisLabelSize.width - axisLabelSize.height));
|
|
@@ -80,6 +80,9 @@ export class MarginModel {
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
static recalcMarginWithLegend(modelInstance, config, legendMaxWidth, legendBlockModel, data) {
|
|
83
|
+
if (config.options.type === "polar") {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
83
86
|
const canvasModel = modelInstance.canvasModel;
|
|
84
87
|
const legendPosition = LegendModel.getLegendModel(config.options.type, config.options.legend.show, modelInstance.canvasModel).position;
|
|
85
88
|
modelInstance.canvasModel.legendCanvas.setPosition(legendPosition);
|
|
@@ -124,6 +127,6 @@ export class MarginModel {
|
|
|
124
127
|
});
|
|
125
128
|
}
|
|
126
129
|
static recalcMarginByTitle(canvasModel, titleBlockModel) {
|
|
127
|
-
canvasModel.increaseMarginSide("top", titleBlockModel.margin.top + titleBlockModel.size);
|
|
130
|
+
canvasModel.increaseMarginSide("top", titleBlockModel.margin.top + titleBlockModel.size + titleBlockModel.margin.bottom);
|
|
128
131
|
}
|
|
129
132
|
}
|
package/lib/model/model.d.ts
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
import { ChartOrientation, MdtChartsColorField, IntervalChartType, PolarChartType, Size, TooltipOptions, TwoDimensionalChartType } from "../config/config";
|
|
1
|
+
import { ChartOrientation, MdtChartsColorField, IntervalChartType, PolarChartType, Size, TooltipOptions, TwoDimensionalChartType, AxisLabelPosition } from "../config/config";
|
|
2
2
|
import { DataType, DonutOptionsCanvas, Formatter, TooltipSettings, Transitions } from "../designer/designerConfig";
|
|
3
3
|
declare type AxisType = "key" | "value";
|
|
4
4
|
export declare type Orient = "top" | "bottom" | "left" | "right";
|
|
5
5
|
export declare type ScaleKeyType = "band" | "point";
|
|
6
6
|
export declare type ScaleValueType = "linear" | "datetime";
|
|
7
|
-
export declare type AxisLabelPosition = "straight" | "rotated";
|
|
8
7
|
export declare type LegendPosition = "off" | "top" | "bottom" | "left" | "right";
|
|
9
8
|
export declare type EmbeddedLabelTypeModel = "none" | "key" | "value";
|
|
10
9
|
export declare type DataOptions = {
|
|
11
10
|
[option: string]: any;
|
|
12
11
|
};
|
|
13
|
-
export interface Model {
|
|
12
|
+
export interface Model<O = TwoDimensionalOptionsModel | PolarOptionsModel | IntervalOptionsModel> {
|
|
14
13
|
blockCanvas: BlockCanvas;
|
|
15
14
|
chartBlock: ChartBlockModel;
|
|
16
|
-
options:
|
|
15
|
+
options: O;
|
|
17
16
|
otherComponents: OtherCommonComponents;
|
|
18
17
|
dataSettings: DataSettings;
|
|
19
18
|
transitions?: Transitions;
|
|
@@ -137,12 +136,24 @@ export interface BarChartSettings {
|
|
|
137
136
|
maxBarWidth: number;
|
|
138
137
|
minBarWidth: number;
|
|
139
138
|
}
|
|
140
|
-
export interface DonutChartSettings extends Omit<DonutOptionsCanvas, "aggregatorPad"> {
|
|
141
|
-
aggregator:
|
|
139
|
+
export interface DonutChartSettings extends Omit<DonutOptionsCanvas, "aggregatorPad" | "thickness"> {
|
|
140
|
+
aggregator: DonutAggregatorModel;
|
|
141
|
+
thickness: DonutThicknessOptions;
|
|
142
142
|
}
|
|
143
|
-
export interface
|
|
143
|
+
export interface DonutAggregatorModel {
|
|
144
144
|
margin: number;
|
|
145
|
-
|
|
145
|
+
content: DonutAggregatorContent;
|
|
146
|
+
}
|
|
147
|
+
export interface DonutAggregatorContent {
|
|
148
|
+
value: string | number;
|
|
149
|
+
title: string;
|
|
150
|
+
}
|
|
151
|
+
export declare type DonutThicknessUnit = "px" | "%";
|
|
152
|
+
export interface DonutThicknessOptions {
|
|
153
|
+
min: number;
|
|
154
|
+
max: number;
|
|
155
|
+
value: number;
|
|
156
|
+
unit: DonutThicknessUnit;
|
|
146
157
|
}
|
|
147
158
|
interface ChartModel {
|
|
148
159
|
tooltip: TooltipModel;
|