mdt-charts 1.12.19 → 1.12.20
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 +5 -1
- package/lib/model/dataManagerModel/dataManagerModel.js +11 -11
- package/lib/model/dataManagerModel/notations/cardsDataManagerModel.d.ts +1 -2
- package/lib/model/dataManagerModel/notations/cardsDataManagerModel.js +2 -4
- package/lib/model/model.d.ts +5 -2
- package/lib/model/modelBuilder.js +4 -7
- package/lib/model/modelInstance/modelInstance.js +0 -1
- package/package.json +1 -1
package/lib/config/config.d.ts
CHANGED
|
@@ -39,10 +39,11 @@ export interface NewSize {
|
|
|
39
39
|
height?: number;
|
|
40
40
|
}
|
|
41
41
|
interface BasicOptions {
|
|
42
|
-
data: DataOptions;
|
|
43
42
|
tooltip?: TooltipOptions;
|
|
43
|
+
data: MdtChartsBasicDataOptions;
|
|
44
44
|
}
|
|
45
45
|
interface GraphicNotationOptions extends BasicOptions {
|
|
46
|
+
data: DataOptions;
|
|
46
47
|
legend: Legend;
|
|
47
48
|
title?: string;
|
|
48
49
|
selectable: boolean;
|
|
@@ -76,6 +77,9 @@ export interface MdtChartsCardsOptions extends BasicOptions {
|
|
|
76
77
|
export interface Legend {
|
|
77
78
|
show: boolean;
|
|
78
79
|
}
|
|
80
|
+
export interface MdtChartsBasicDataOptions {
|
|
81
|
+
dataSource: string;
|
|
82
|
+
}
|
|
79
83
|
export interface DataOptions {
|
|
80
84
|
dataSource: string;
|
|
81
85
|
keyField: MdtChartsField;
|
|
@@ -7,12 +7,12 @@ import { LegendPolarMarginCalculator } from "../featuresModel/legendModel/polarM
|
|
|
7
7
|
import { CardsDataManagerModel } from "./notations/cardsDataManagerModel";
|
|
8
8
|
export class DataManagerModel {
|
|
9
9
|
static getPreparedData(data, allowableKeys, config) {
|
|
10
|
-
const scopedData = this.getScopedData(data, allowableKeys, config);
|
|
10
|
+
const scopedData = config.options.type !== "card" ? this.getScopedData(data, allowableKeys, config.options.data) : data;
|
|
11
11
|
this.setDataType(scopedData, config);
|
|
12
12
|
return scopedData;
|
|
13
13
|
}
|
|
14
14
|
static initDataScope(config, data, designerConfig, legendBlock, modelInstance) {
|
|
15
|
-
if (config.options.type === '2d'
|
|
15
|
+
if (config.options.type === '2d') {
|
|
16
16
|
this.initDataScopeFor2D(config.options, modelInstance, data, designerConfig);
|
|
17
17
|
}
|
|
18
18
|
else if (config.options.type === 'polar') {
|
|
@@ -20,7 +20,7 @@ export class DataManagerModel {
|
|
|
20
20
|
}
|
|
21
21
|
else if (config.options.type === "card") {
|
|
22
22
|
const manager = new CardsDataManagerModel();
|
|
23
|
-
manager.initDataScope(modelInstance
|
|
23
|
+
manager.initDataScope(modelInstance);
|
|
24
24
|
}
|
|
25
25
|
this.initScopedData(data, modelInstance, config);
|
|
26
26
|
}
|
|
@@ -33,13 +33,12 @@ export class DataManagerModel {
|
|
|
33
33
|
}
|
|
34
34
|
static initDataScopeFor2D(configOptions, modelInstance, data, designerConfig) {
|
|
35
35
|
// Для interval всегда один элемент, так как там может быть только один столбик
|
|
36
|
+
modelInstance.dataModel.initMaxRecordsAmount(configOptions.data.maxRecordsAmount);
|
|
36
37
|
let itemsLength = 1;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
itemsLength = 1; // Если баров нет, то для одной записи выделяется столько же места, сколько для одного столбика
|
|
42
|
-
}
|
|
38
|
+
itemsLength = (configOptions.charts)
|
|
39
|
+
.filter((chart) => chart.type === 'bar').length;
|
|
40
|
+
if (itemsLength === 0)
|
|
41
|
+
itemsLength = 1; // Если баров нет, то для одной записи выделяется столько же места, сколько для одного столбика
|
|
43
42
|
if (itemsLength !== 0) {
|
|
44
43
|
const axisLength = AxisModel.getAxisLength(configOptions.orientation, modelInstance.canvasModel);
|
|
45
44
|
const uniqueKeys = ModelHelper.getUniqueValues(data[configOptions.data.dataSource].map(d => d[configOptions.data.keyField.name]));
|
|
@@ -55,6 +54,7 @@ export class DataManagerModel {
|
|
|
55
54
|
}
|
|
56
55
|
}
|
|
57
56
|
static initDataScopeForPolar(configOptions, modelInstance, data, legendBlock, legendCanvas) {
|
|
57
|
+
modelInstance.dataModel.initMaxRecordsAmount(configOptions.data.maxRecordsAmount);
|
|
58
58
|
const canvasModel = modelInstance.canvasModel;
|
|
59
59
|
const keyFieldName = configOptions.data.keyField.name;
|
|
60
60
|
const keys = data[configOptions.data.dataSource].map(dataRow => dataRow[keyFieldName]);
|
|
@@ -116,9 +116,9 @@ export class DataManagerModel {
|
|
|
116
116
|
});
|
|
117
117
|
return barsAmount;
|
|
118
118
|
}
|
|
119
|
-
static getScopedData(data, allowableKeys,
|
|
119
|
+
static getScopedData(data, allowableKeys, dataOptions) {
|
|
120
120
|
const newData = {};
|
|
121
|
-
newData[
|
|
121
|
+
newData[dataOptions.dataSource] = this.getScopedChartData(data[dataOptions.dataSource], allowableKeys, dataOptions.keyField.name);
|
|
122
122
|
return newData;
|
|
123
123
|
}
|
|
124
124
|
static getScopedChartData(data, allowableKeys, keyFieldName) {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { MdtChartsCardsOptions, MdtChartsDataSource } from "../../../config/config";
|
|
2
1
|
import { ModelInstance } from "../../modelInstance/modelInstance";
|
|
3
2
|
export declare class CardsDataManagerModel {
|
|
4
|
-
initDataScope(modelInstance: ModelInstance
|
|
3
|
+
initDataScope(modelInstance: ModelInstance): void;
|
|
5
4
|
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { DataManagerModel } from "../dataManagerModel";
|
|
2
1
|
export class CardsDataManagerModel {
|
|
3
|
-
initDataScope(modelInstance
|
|
4
|
-
const firstKey = DataManagerModel.getDataValuesByKeyField(data, configOptions.data.dataSource, configOptions.data.keyField.name)[0];
|
|
2
|
+
initDataScope(modelInstance) {
|
|
5
3
|
modelInstance.dataModel.initScope({
|
|
6
|
-
allowableKeys: [
|
|
4
|
+
allowableKeys: [],
|
|
7
5
|
hidedRecordsAmount: 0
|
|
8
6
|
});
|
|
9
7
|
}
|
package/lib/model/model.d.ts
CHANGED
|
@@ -33,11 +33,11 @@ export interface BlockMargin {
|
|
|
33
33
|
right: number;
|
|
34
34
|
}
|
|
35
35
|
interface BasicOptionsModel {
|
|
36
|
-
data: OptionsModelData;
|
|
37
36
|
tooltip: TooltipOptions;
|
|
38
37
|
}
|
|
39
38
|
interface GraphicNotationOptionsModel extends BasicOptionsModel {
|
|
40
39
|
legend: ILegendModel;
|
|
40
|
+
data: OptionsModelData;
|
|
41
41
|
title: string;
|
|
42
42
|
selectable: boolean;
|
|
43
43
|
}
|
|
@@ -66,6 +66,7 @@ export interface IntervalOptionsModel extends GraphicNotationOptionsModel {
|
|
|
66
66
|
}
|
|
67
67
|
export interface CardsOptionsModel extends BasicOptionsModel {
|
|
68
68
|
type: "card";
|
|
69
|
+
data: BasicOptionsModelData;
|
|
69
70
|
title: string;
|
|
70
71
|
description?: string;
|
|
71
72
|
icon?: MdtChartsIconElement;
|
|
@@ -75,8 +76,10 @@ export interface CardsOptionsModel extends BasicOptionsModel {
|
|
|
75
76
|
export interface ILegendModel {
|
|
76
77
|
position: LegendPosition;
|
|
77
78
|
}
|
|
78
|
-
export interface
|
|
79
|
+
export interface BasicOptionsModelData {
|
|
79
80
|
dataSource: string;
|
|
81
|
+
}
|
|
82
|
+
export interface OptionsModelData extends BasicOptionsModelData {
|
|
80
83
|
keyField: Field;
|
|
81
84
|
}
|
|
82
85
|
export interface Field {
|
|
@@ -70,7 +70,7 @@ export function assembleModel(config, data, designerConfig) {
|
|
|
70
70
|
options: null,
|
|
71
71
|
dataSettings: null
|
|
72
72
|
};
|
|
73
|
-
resetFalsyValues(data
|
|
73
|
+
resetFalsyValues(data);
|
|
74
74
|
const otherComponents = OtherComponentsModel.getOtherComponentsModel({ elementsOptions: designerConfig.elementsOptions, title: config.options.title }, modelInstance);
|
|
75
75
|
const marginModel = new MarginModel();
|
|
76
76
|
marginModel.initMargin(designerConfig, config, otherComponents, data, modelInstance);
|
|
@@ -92,14 +92,11 @@ export function assembleModel(config, data, designerConfig) {
|
|
|
92
92
|
transitions
|
|
93
93
|
};
|
|
94
94
|
}
|
|
95
|
-
function resetFalsyValues(data
|
|
95
|
+
function resetFalsyValues(data) {
|
|
96
96
|
for (let setName in data) {
|
|
97
97
|
data[setName].forEach(dataRow => {
|
|
98
98
|
for (let fieldName in dataRow) {
|
|
99
|
-
if (
|
|
100
|
-
dataRow[fieldName] = '';
|
|
101
|
-
}
|
|
102
|
-
else if (dataRow[fieldName] !== 0 && !dataRow[fieldName]) {
|
|
99
|
+
if (dataRow[fieldName] == null) {
|
|
103
100
|
dataRow[fieldName] = 0;
|
|
104
101
|
}
|
|
105
102
|
}
|
|
@@ -107,7 +104,7 @@ function resetFalsyValues(data, keyFieldName) {
|
|
|
107
104
|
}
|
|
108
105
|
}
|
|
109
106
|
export function getPreparedData(model, data, config) {
|
|
110
|
-
resetFalsyValues(data
|
|
107
|
+
resetFalsyValues(data);
|
|
111
108
|
const isModelOrDataEmpty = !model || Object.keys(model).length === 0 || !data || Object.keys(data).length === 0;
|
|
112
109
|
if (isModelOrDataEmpty)
|
|
113
110
|
return null;
|
|
@@ -12,7 +12,6 @@ export class ModelInstance {
|
|
|
12
12
|
}
|
|
13
13
|
static initInitialParams(modelInstance, config, data) {
|
|
14
14
|
modelInstance.canvasModel.initBlockSize(config.canvas.size);
|
|
15
|
-
modelInstance.dataModel.initMaxRecordsAmount(config.options.data.maxRecordsAmount);
|
|
16
15
|
modelInstance.dataModel.repository.initSourceName(config.options.data.dataSource);
|
|
17
16
|
modelInstance.dataModel.repository.initRawFullSource(data);
|
|
18
17
|
}
|