mdt-charts 1.12.1 → 1.12.5
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 +19 -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/scale/scale.d.ts +2 -0
- package/lib/engine/features/scale/scale.js +6 -3
- package/lib/engine/polarNotation/donut/donut.js +1 -1
- package/lib/engine/polarNotation/polarManager.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/model/chartStyleModel/TwoDimensionalChartStyleModel.d.ts +4 -4
- package/lib/model/dataManagerModel/dataManagerModel.js +1 -1
- package/lib/model/featuresModel/axisModel.d.ts +2 -1
- package/lib/model/featuresModel/axisModel.js +20 -5
- package/lib/model/featuresModel/legendModel/legendModel.js +3 -3
- package/lib/model/featuresModel/legendModel/polarMarginCalculator.js +1 -1
- package/lib/model/featuresModel/scaleModel.d.ts +7 -6
- package/lib/model/featuresModel/scaleModel.js +19 -4
- package/lib/model/featuresModel/titleModel.js +4 -4
- package/lib/model/marginModel.d.ts +1 -3
- package/lib/model/marginModel.js +0 -25
- package/lib/model/model.d.ts +18 -6
- 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/twoDimensionalModel.d.ts +6 -6
- package/lib/model/notations/twoDimensionalModel.js +11 -5
- package/lib/style/charts-main.css +6 -4
- package/lib/style/charts-main.less +6 -4
- package/package.json +1 -1
package/lib/model/marginModel.js
CHANGED
|
@@ -3,7 +3,6 @@ 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";
|
|
7
6
|
export const AXIS_HORIZONTAL_LABEL_PADDING = 15;
|
|
8
7
|
export const AXIS_VERTICAL_LABEL_PADDING = 10;
|
|
9
8
|
export class MarginModel {
|
|
@@ -24,21 +23,6 @@ export class MarginModel {
|
|
|
24
23
|
this.recalcHorizontalMarginByAxisLabelWidth(labelSize, canvasModel, config.options.orientation, config.options.axis, showingFlag);
|
|
25
24
|
}
|
|
26
25
|
}
|
|
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
26
|
static recalcMarginByVerticalAxisLabel(modelInstance, config, designerConfig, dataScope) {
|
|
43
27
|
if ((config.options.type === '2d' || config.options.type === 'interval') && config.options.orientation === 'vertical') {
|
|
44
28
|
const axisLabelSize = AxisModel.getLabelSize(designerConfig.canvas.axisLabel.maxSize.main, dataScope.allowableKeys);
|
|
@@ -117,15 +101,6 @@ export class MarginModel {
|
|
|
117
101
|
else
|
|
118
102
|
canvasModel.increaseMarginSide(position, legendCoordinate[position].margin.top + legendCoordinate[position].margin.bottom);
|
|
119
103
|
}
|
|
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
104
|
static recalcMarginByTitle(canvasModel, titleBlockModel) {
|
|
130
105
|
canvasModel.increaseMarginSide("top", titleBlockModel.margin.top + titleBlockModel.size + titleBlockModel.margin.bottom);
|
|
131
106
|
}
|
package/lib/model/model.d.ts
CHANGED
|
@@ -9,10 +9,10 @@ export declare type EmbeddedLabelTypeModel = "none" | "key" | "value";
|
|
|
9
9
|
export declare type DataOptions = {
|
|
10
10
|
[option: string]: any;
|
|
11
11
|
};
|
|
12
|
-
export interface Model {
|
|
12
|
+
export interface Model<O = TwoDimensionalOptionsModel | PolarOptionsModel | IntervalOptionsModel> {
|
|
13
13
|
blockCanvas: BlockCanvas;
|
|
14
14
|
chartBlock: ChartBlockModel;
|
|
15
|
-
options:
|
|
15
|
+
options: O;
|
|
16
16
|
otherComponents: OtherCommonComponents;
|
|
17
17
|
dataSettings: DataSettings;
|
|
18
18
|
transitions?: Transitions;
|
|
@@ -136,12 +136,24 @@ export interface BarChartSettings {
|
|
|
136
136
|
maxBarWidth: number;
|
|
137
137
|
minBarWidth: number;
|
|
138
138
|
}
|
|
139
|
-
export interface DonutChartSettings extends Omit<DonutOptionsCanvas, "aggregatorPad"> {
|
|
140
|
-
aggregator:
|
|
139
|
+
export interface DonutChartSettings extends Omit<DonutOptionsCanvas, "aggregatorPad" | "thickness"> {
|
|
140
|
+
aggregator: DonutAggregatorModel;
|
|
141
|
+
thickness: DonutThicknessOptions;
|
|
141
142
|
}
|
|
142
|
-
export interface
|
|
143
|
+
export interface DonutAggregatorModel {
|
|
143
144
|
margin: number;
|
|
144
|
-
|
|
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;
|
|
145
157
|
}
|
|
146
158
|
interface ChartModel {
|
|
147
159
|
tooltip: TooltipModel;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MarginModel } from './marginModel';
|
|
2
2
|
import { TwoDimensionalModel } from './notations/twoDimensionalModel';
|
|
3
|
-
import { PolarModel } from './notations/polarModel';
|
|
3
|
+
import { PolarModel } from './notations/polar/polarModel';
|
|
4
4
|
import { DataManagerModel } from './dataManagerModel/dataManagerModel';
|
|
5
5
|
import { IntervalModel } from './notations/intervalModel';
|
|
6
6
|
import { OtherComponentsModel } from './featuresModel/otherComponents';
|
|
@@ -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,
|
|
@@ -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
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { MdtChartsConfig, MdtChartsDataSource,
|
|
1
|
+
import { MdtChartsConfig, MdtChartsDataSource, MdtChartsIntervalOptions } from "../../config/config";
|
|
2
2
|
import { DesignerConfig } from "../../designer/designerConfig";
|
|
3
3
|
import { AdditionalElementsOptions, BlockMargin, DataScope, IntervalOptionsModel } from "../model";
|
|
4
4
|
import { ModelInstance } from "../modelInstance/modelInstance";
|
|
5
5
|
export declare class IntervalModel {
|
|
6
6
|
static getOptions(config: MdtChartsConfig, designerConfig: DesignerConfig, margin: BlockMargin, dataScope: DataScope, data: MdtChartsDataSource, modelInstance: ModelInstance): IntervalOptionsModel;
|
|
7
|
-
static getAdditionalElements(options:
|
|
7
|
+
static getAdditionalElements(options: MdtChartsIntervalOptions): AdditionalElementsOptions;
|
|
8
8
|
private static getChartsModel;
|
|
9
9
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { MdtChartsDataRow, MdtChartsDonutAggregator } from "../../../../config/config";
|
|
2
|
+
import { DonutAggregatorContent } from "../../../model";
|
|
3
|
+
export declare const AGGREGATOR_DEFAULT_TITLE = "\u0421\u0443\u043C\u043C\u0430";
|
|
4
|
+
export interface AggregatorServiceDataOptions {
|
|
5
|
+
rows: MdtChartsDataRow[];
|
|
6
|
+
valueFieldName: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class DonutAggregatorService {
|
|
9
|
+
getContent(aggregatorOptions: MdtChartsDonutAggregator, dataOptions: AggregatorServiceDataOptions): DonutAggregatorContent;
|
|
10
|
+
private doesValueExist;
|
|
11
|
+
private generateDefaultContent;
|
|
12
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export const AGGREGATOR_DEFAULT_TITLE = "Сумма";
|
|
2
|
+
export class DonutAggregatorService {
|
|
3
|
+
getContent(aggregatorOptions, dataOptions) {
|
|
4
|
+
if (!(aggregatorOptions === null || aggregatorOptions === void 0 ? void 0 : aggregatorOptions.content) || !dataOptions.rows)
|
|
5
|
+
return this.generateDefaultContent(dataOptions);
|
|
6
|
+
const content = aggregatorOptions.content({ data: dataOptions.rows });
|
|
7
|
+
if (this.doesValueExist(content.value) && content.title)
|
|
8
|
+
return content;
|
|
9
|
+
if (!content.title && this.doesValueExist(content.value))
|
|
10
|
+
return {
|
|
11
|
+
value: content.value,
|
|
12
|
+
title: AGGREGATOR_DEFAULT_TITLE
|
|
13
|
+
};
|
|
14
|
+
return this.generateDefaultContent(dataOptions);
|
|
15
|
+
}
|
|
16
|
+
doesValueExist(content) {
|
|
17
|
+
return content != null;
|
|
18
|
+
}
|
|
19
|
+
generateDefaultContent(dataOptions) {
|
|
20
|
+
return {
|
|
21
|
+
title: AGGREGATOR_DEFAULT_TITLE,
|
|
22
|
+
value: dataOptions.rows ? dataOptions.rows.reduce((acc, row) => acc + row[dataOptions.valueFieldName], 0) : 0
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { MdtChartsDataRow, PolarChart } from "../../../../config/config";
|
|
2
|
+
import { DonutOptionsCanvas } from "../../../../designer/designerConfig";
|
|
3
|
+
import { DonutChartSettings } from "../../../model";
|
|
4
|
+
export declare class DonutModel {
|
|
5
|
+
private thicknessService;
|
|
6
|
+
private aggregatorService;
|
|
7
|
+
getSettings(settingsFromConfig: DonutOptionsCanvas, chartOptions: PolarChart, rawDataRows: MdtChartsDataRow[]): DonutChartSettings;
|
|
8
|
+
private getThicknessOptions;
|
|
9
|
+
private getAggregatorOptions;
|
|
10
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { DonutAggregatorService } from "./donutAggregatorService";
|
|
2
|
+
import { DonutThicknessService } from "./donutThicknessService";
|
|
3
|
+
export class DonutModel {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.thicknessService = new DonutThicknessService();
|
|
6
|
+
this.aggregatorService = new DonutAggregatorService();
|
|
7
|
+
}
|
|
8
|
+
getSettings(settingsFromConfig, chartOptions, rawDataRows) {
|
|
9
|
+
return {
|
|
10
|
+
padAngle: settingsFromConfig.padAngle,
|
|
11
|
+
thickness: this.getThicknessOptions(settingsFromConfig.thickness),
|
|
12
|
+
aggregator: this.getAggregatorOptions(settingsFromConfig, chartOptions, rawDataRows)
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
getThicknessOptions(settingsFromConfig) {
|
|
16
|
+
return {
|
|
17
|
+
unit: this.thicknessService.getUnit(settingsFromConfig),
|
|
18
|
+
max: this.thicknessService.valueToNumber(settingsFromConfig.max),
|
|
19
|
+
min: this.thicknessService.valueToNumber(settingsFromConfig.min),
|
|
20
|
+
value: this.thicknessService.valueToNumber(settingsFromConfig.value),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
getAggregatorOptions(settingsFromConfig, chartOptions, rawDataRows) {
|
|
24
|
+
return {
|
|
25
|
+
margin: settingsFromConfig.aggregatorPad,
|
|
26
|
+
content: this.aggregatorService.getContent(chartOptions.aggregator, {
|
|
27
|
+
rows: rawDataRows,
|
|
28
|
+
valueFieldName: chartOptions.data.valueField.name
|
|
29
|
+
})
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { MdtChartsDonutThicknessOptions } from "../../../../designer/designerConfig";
|
|
2
|
+
import { DonutThicknessUnit } from "../../../model";
|
|
3
|
+
export declare class DonutThicknessService {
|
|
4
|
+
private defaultUnit;
|
|
5
|
+
getUnit(settingsFromConfig: MdtChartsDonutThicknessOptions): DonutThicknessUnit;
|
|
6
|
+
valueToNumber(value: string | number): number;
|
|
7
|
+
private getUnitByValue;
|
|
8
|
+
private getLastUnitFromString;
|
|
9
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export class DonutThicknessService {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.defaultUnit = "px";
|
|
4
|
+
}
|
|
5
|
+
getUnit(settingsFromConfig) {
|
|
6
|
+
if (settingsFromConfig.value)
|
|
7
|
+
return this.getUnitByValue(settingsFromConfig.value);
|
|
8
|
+
const minUnit = this.getUnitByValue(settingsFromConfig.min);
|
|
9
|
+
const maxUnit = this.getUnitByValue(settingsFromConfig.max);
|
|
10
|
+
return minUnit === maxUnit ? minUnit : this.defaultUnit;
|
|
11
|
+
}
|
|
12
|
+
valueToNumber(value) {
|
|
13
|
+
if (typeof value === "number")
|
|
14
|
+
return value;
|
|
15
|
+
return parseInt(value);
|
|
16
|
+
}
|
|
17
|
+
getUnitByValue(value) {
|
|
18
|
+
if (typeof value !== "string")
|
|
19
|
+
return this.defaultUnit;
|
|
20
|
+
return this.getLastUnitFromString(value);
|
|
21
|
+
}
|
|
22
|
+
getLastUnitFromString(value) {
|
|
23
|
+
let resultUnit = this.defaultUnit;
|
|
24
|
+
["%", "px"].forEach(unit => {
|
|
25
|
+
if (value.endsWith(unit))
|
|
26
|
+
resultUnit = unit;
|
|
27
|
+
});
|
|
28
|
+
return resultUnit;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { MdtChartsPolarOptions } from "../../../config/config";
|
|
2
|
+
import { DesignerConfig } from "../../../designer/designerConfig";
|
|
3
|
+
import { PolarOptionsModel, LegendCoordinate } from "../../model";
|
|
4
|
+
import { CanvasModel } from "../../modelInstance/canvasModel/canvasModel";
|
|
5
|
+
import { ModelInstance } from "../../modelInstance/modelInstance";
|
|
6
|
+
export declare const MIN_DONUT_BLOCK_SIZE = 120;
|
|
7
|
+
export declare class PolarModel {
|
|
8
|
+
private static donutModel;
|
|
9
|
+
static getOptions(options: MdtChartsPolarOptions, designerConfig: DesignerConfig, modelInstance: ModelInstance): PolarOptionsModel;
|
|
10
|
+
static getLegendPositionByBlockSize(canvasModel: CanvasModel): "bottom" | "right";
|
|
11
|
+
static doesChartBlockHasEnoughWidthForContainsLegend(chartBlockWidth: number, legendWidth: number, legendCoordinate: LegendCoordinate): boolean;
|
|
12
|
+
static doesChartBlockHasEnoughHeightForContainsLegend(chartBlockHeight: number, legendCoordinate: LegendCoordinate): boolean;
|
|
13
|
+
private static getDonutSettings;
|
|
14
|
+
private static getChartsModel;
|
|
15
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { ChartStyleModelService } from "../../chartStyleModel/chartStyleModel";
|
|
2
|
+
import { DonutModel } from "./donut/donutModel";
|
|
3
|
+
export const MIN_DONUT_BLOCK_SIZE = 120;
|
|
4
|
+
export class PolarModel {
|
|
5
|
+
static getOptions(options, designerConfig, modelInstance) {
|
|
6
|
+
return {
|
|
7
|
+
type: options.type,
|
|
8
|
+
selectable: !!options.selectable,
|
|
9
|
+
title: options.title,
|
|
10
|
+
data: Object.assign({}, options.data),
|
|
11
|
+
charts: this.getChartsModel(options.chart, modelInstance.dataModel.repository.getScopedRows().length, designerConfig.chartStyle),
|
|
12
|
+
legend: modelInstance.canvasModel.legendCanvas.getModel(),
|
|
13
|
+
tooltip: options.tooltip,
|
|
14
|
+
chartCanvas: this.getDonutSettings(designerConfig.canvas.chartOptions.donut, options.chart, modelInstance.dataModel.repository.getRawRows())
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
//TODO: type for returned value
|
|
18
|
+
static getLegendPositionByBlockSize(canvasModel) {
|
|
19
|
+
const widthCoefficientWhenLegendShouldInBottom = 1.5;
|
|
20
|
+
const avgLegendWidth = 100;
|
|
21
|
+
const blockWidth = canvasModel.getBlockSize().width;
|
|
22
|
+
const blockHeight = canvasModel.getBlockSize().height;
|
|
23
|
+
return canvasModel.getChartBlockWidth() < MIN_DONUT_BLOCK_SIZE + avgLegendWidth
|
|
24
|
+
&& blockWidth * widthCoefficientWhenLegendShouldInBottom < blockHeight
|
|
25
|
+
? 'bottom'
|
|
26
|
+
: 'right';
|
|
27
|
+
}
|
|
28
|
+
static doesChartBlockHasEnoughWidthForContainsLegend(chartBlockWidth, legendWidth, legendCoordinate) {
|
|
29
|
+
const rightLegendMargin = legendCoordinate.right.margin;
|
|
30
|
+
return chartBlockWidth - legendWidth - rightLegendMargin.left - rightLegendMargin.right >= MIN_DONUT_BLOCK_SIZE;
|
|
31
|
+
}
|
|
32
|
+
static doesChartBlockHasEnoughHeightForContainsLegend(chartBlockHeight, legendCoordinate) {
|
|
33
|
+
const minHeightForLegend = 30;
|
|
34
|
+
const bottomLegendMargin = legendCoordinate.bottom.margin;
|
|
35
|
+
const heightForLegend = chartBlockHeight - bottomLegendMargin.bottom - bottomLegendMargin.top - MIN_DONUT_BLOCK_SIZE;
|
|
36
|
+
return heightForLegend >= minHeightForLegend;
|
|
37
|
+
}
|
|
38
|
+
static getDonutSettings(settings, chartOptions, dataRows) {
|
|
39
|
+
return this.donutModel.getSettings(settings, chartOptions, dataRows);
|
|
40
|
+
}
|
|
41
|
+
static getChartsModel(chart, dataLength, chartStyleConfig) {
|
|
42
|
+
const chartsModel = [];
|
|
43
|
+
chartsModel.push({
|
|
44
|
+
type: chart.type,
|
|
45
|
+
data: Object.assign({}, chart.data),
|
|
46
|
+
tooltip: chart.tooltip,
|
|
47
|
+
cssClasses: ChartStyleModelService.getCssClasses(0),
|
|
48
|
+
style: ChartStyleModelService.getChartStyle(dataLength, chartStyleConfig)
|
|
49
|
+
});
|
|
50
|
+
return chartsModel;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
PolarModel.donutModel = new DonutModel();
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { ChartOrientation, MdtChartsDataSource,
|
|
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,
|
|
7
|
-
static getChartsEmbeddedLabelsFlag(charts:
|
|
6
|
+
static getOptions(options: MdtChartsTwoDimensionalOptions, designerConfig: DesignerConfig, data: MdtChartsDataSource, modelInstance: ModelInstance): TwoDimensionalOptionsModel;
|
|
7
|
+
static getChartsEmbeddedLabelsFlag(charts: MdtChartsTwoDimensionalChart[], chartOrientation: ChartOrientation): boolean;
|
|
8
8
|
/**
|
|
9
9
|
* Сортирует список чартов в порядке: area - bar - line.
|
|
10
10
|
* Используется для того, чтобы при рендере графики с наибольшей площадью (area) не перекрывали графики с меньшей площадью (bar, line).
|
|
11
11
|
* @param charts Чарты из конфига
|
|
12
12
|
*/
|
|
13
|
-
static sortCharts(charts:
|
|
13
|
+
static sortCharts(charts: MdtChartsTwoDimensionalChart[]): void;
|
|
14
14
|
static getChartsSettings(barSettings: BarOptionsCanvas): TwoDimChartElementsSettings;
|
|
15
15
|
private static getChartsModel;
|
|
16
16
|
private static findChartsWithEmbeddedKeyLabels;
|
|
17
17
|
private static getEmbeddedLabelType;
|
|
18
18
|
private static getAdditionalElements;
|
|
19
19
|
private static getChartsByType;
|
|
20
|
-
static getChartsValueFieldsAmount(charts:
|
|
20
|
+
static getChartsValueFieldsAmount(charts: MdtChartsTwoDimensionalChart[]): number[];
|
|
21
21
|
}
|
|
@@ -1,21 +1,27 @@
|
|
|
1
|
+
import { Scale } from "../../engine/features/scale/scale";
|
|
1
2
|
import { ChartStyleModelService } from "../chartStyleModel/chartStyleModel";
|
|
2
3
|
import { TwoDimensionalChartStyleModel } from "../chartStyleModel/TwoDimensionalChartStyleModel";
|
|
3
4
|
import { AxisModel } from "../featuresModel/axisModel";
|
|
4
5
|
import { ScaleModel } from "../featuresModel/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 scaleKey = ScaleModel.getScaleKey(modelInstance.dataModel.getAllowableKeys(), options.orientation, canvasModel, options.charts, this.getChartsByType(options.charts, 'bar'));
|
|
10
|
+
const scaleValue = ScaleModel.getScaleLinear(options, data, canvasModel);
|
|
11
|
+
const chartSettings = this.getChartsSettings(designerConfig.canvas.chartOptions.bar);
|
|
12
|
+
//TODO: rm import from engine
|
|
13
|
+
const scaleValueFn = Scale.getScaleValue(scaleValue);
|
|
8
14
|
return {
|
|
9
15
|
legend: canvasModel.legendCanvas.getModel(),
|
|
10
16
|
title: options.title,
|
|
11
17
|
selectable: !!options.selectable,
|
|
12
18
|
orient: options.orientation,
|
|
13
19
|
scale: {
|
|
14
|
-
key:
|
|
15
|
-
value:
|
|
20
|
+
key: scaleKey,
|
|
21
|
+
value: scaleValue
|
|
16
22
|
},
|
|
17
23
|
axis: {
|
|
18
|
-
key: AxisModel.getKeyAxis(options, data, designerConfig.canvas.axisLabel, canvasModel, designerConfig.elementsOptions.tooltip),
|
|
24
|
+
key: AxisModel.getKeyAxis(options, data, designerConfig.canvas.axisLabel, canvasModel, designerConfig.elementsOptions.tooltip, () => scaleValueFn(0)),
|
|
19
25
|
value: AxisModel.getValueAxis(options.orientation, options.axis.value, designerConfig.canvas.axisLabel, canvasModel)
|
|
20
26
|
},
|
|
21
27
|
type: options.type,
|
|
@@ -23,7 +29,7 @@ export class TwoDimensionalModel {
|
|
|
23
29
|
charts: this.getChartsModel(options.charts, options.orientation, designerConfig.chartStyle),
|
|
24
30
|
additionalElements: this.getAdditionalElements(options),
|
|
25
31
|
tooltip: options.tooltip,
|
|
26
|
-
chartSettings
|
|
32
|
+
chartSettings
|
|
27
33
|
};
|
|
28
34
|
}
|
|
29
35
|
static getChartsEmbeddedLabelsFlag(charts, chartOrientation) {
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
@import url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap');
|
|
2
|
-
|
|
3
1
|
.wrapper {
|
|
4
2
|
margin: 0 auto;
|
|
5
3
|
position: relative;
|
|
@@ -60,6 +58,7 @@
|
|
|
60
58
|
.legend-item {
|
|
61
59
|
cursor: default;
|
|
62
60
|
transition: opacity 0.1s;
|
|
61
|
+
line-height: 1;
|
|
63
62
|
/* will-change: opacity; */
|
|
64
63
|
}
|
|
65
64
|
.legend-block-column .legend-item:not(:first-of-type) {
|
|
@@ -202,12 +201,15 @@
|
|
|
202
201
|
line-height: 1;
|
|
203
202
|
}
|
|
204
203
|
.aggregator-value {
|
|
205
|
-
margin-top:
|
|
204
|
+
margin-top: 0.5em;
|
|
206
205
|
pointer-events: auto;
|
|
207
206
|
}
|
|
208
207
|
.aggregator-name {
|
|
209
|
-
margin-top:
|
|
208
|
+
margin-top: 0.5em;
|
|
210
209
|
pointer-events: auto;
|
|
210
|
+
max-width: 90%;
|
|
211
|
+
overflow: hidden;
|
|
212
|
+
text-overflow: ellipsis;
|
|
211
213
|
}
|
|
212
214
|
|
|
213
215
|
/* Grid */
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
@import url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap');
|
|
2
|
-
|
|
3
1
|
.wrapper {
|
|
4
2
|
margin: 0 auto;
|
|
5
3
|
position: relative;
|
|
@@ -60,6 +58,7 @@
|
|
|
60
58
|
.legend-item {
|
|
61
59
|
cursor: default;
|
|
62
60
|
transition: opacity 0.1s;
|
|
61
|
+
line-height: 1;
|
|
63
62
|
/* will-change: opacity; */
|
|
64
63
|
}
|
|
65
64
|
.legend-block-column .legend-item:not(:first-of-type) {
|
|
@@ -202,12 +201,15 @@
|
|
|
202
201
|
line-height: 1;
|
|
203
202
|
}
|
|
204
203
|
.aggregator-value {
|
|
205
|
-
margin-top:
|
|
204
|
+
margin-top: 0.5em;
|
|
206
205
|
pointer-events: auto;
|
|
207
206
|
}
|
|
208
207
|
.aggregator-name {
|
|
209
|
-
margin-top:
|
|
208
|
+
margin-top: 0.5em;
|
|
210
209
|
pointer-events: auto;
|
|
210
|
+
max-width: 90%;
|
|
211
|
+
overflow: hidden;
|
|
212
|
+
text-overflow: ellipsis;
|
|
211
213
|
}
|
|
212
214
|
|
|
213
215
|
/* Grid */
|