mdt-charts 1.12.18 → 1.13.0
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 +6 -1
- package/lib/engine/cardsNotation/card/card.d.ts +1 -0
- package/lib/engine/cardsNotation/card/card.js +12 -5
- package/lib/engine/cardsNotation/card/cardChange.js +8 -4
- package/lib/engine/engine.js +1 -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 +6 -2
- package/lib/model/modelBuilder.js +4 -7
- package/lib/model/modelInstance/modelInstance.js +0 -1
- package/lib/model/notations/cards/cardsChangeService.d.ts +1 -3
- package/lib/model/notations/cards/cardsChangeService.js +1 -18
- package/lib/model/notations/cards/cardsModel.js +1 -0
- package/lib/model/notations/cards/cardsModelService.d.ts +6 -1
- package/lib/model/notations/cards/cardsModelService.js +31 -0
- package/lib/style/charts-main.css +14 -1
- package/lib/style/charts-main.less +14 -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;
|
|
@@ -70,12 +71,16 @@ export interface MdtChartsCardsOptions extends BasicOptions {
|
|
|
70
71
|
title: string;
|
|
71
72
|
description?: string;
|
|
72
73
|
icon?: MdtChartsIconElement;
|
|
74
|
+
color?: MdtChartsColorRangeItem[];
|
|
73
75
|
value: MdtChartsCardValue;
|
|
74
76
|
change?: MdtChartsCardsChange;
|
|
75
77
|
}
|
|
76
78
|
export interface Legend {
|
|
77
79
|
show: boolean;
|
|
78
80
|
}
|
|
81
|
+
export interface MdtChartsBasicDataOptions {
|
|
82
|
+
dataSource: string;
|
|
83
|
+
}
|
|
79
84
|
export interface DataOptions {
|
|
80
85
|
dataSource: string;
|
|
81
86
|
keyField: MdtChartsField;
|
|
@@ -18,6 +18,7 @@ export declare class CardChart {
|
|
|
18
18
|
updateData(options: CardsOptionsModel, data: MdtChartsDataSource): void;
|
|
19
19
|
private renderCardWrapper;
|
|
20
20
|
private renderContentBlock;
|
|
21
|
+
private setContentColor;
|
|
21
22
|
private setContentFontSize;
|
|
22
23
|
private renderHeaderBlock;
|
|
23
24
|
private appendTitle;
|
|
@@ -13,7 +13,7 @@ export class CardChart {
|
|
|
13
13
|
const parent = block.html.getBlock();
|
|
14
14
|
const dataRow = data[options.data.dataSource][0];
|
|
15
15
|
const wrapper = this.renderCardWrapper(parent);
|
|
16
|
-
this.renderContentBlock(wrapper);
|
|
16
|
+
this.renderContentBlock(wrapper, options.color);
|
|
17
17
|
this.setContentFontSize(this.cardContentElement, canvasOptions);
|
|
18
18
|
this.renderHeaderBlock(this.cardContentElement, {
|
|
19
19
|
title: options.title,
|
|
@@ -32,15 +32,20 @@ export class CardChart {
|
|
|
32
32
|
const dataRow = data[options.data.dataSource][0];
|
|
33
33
|
this.setValueContent(CardService.getValueContentFromDataSource(Object.assign(Object.assign({}, options.value), { dataSetName: options.data.dataSource }), data));
|
|
34
34
|
this.updateValueBlockStyle();
|
|
35
|
+
this.setContentColor(options.color);
|
|
35
36
|
(_a = this.changeBlock) === null || _a === void 0 ? void 0 : _a.update(options.change, dataRow);
|
|
36
37
|
}
|
|
37
38
|
renderCardWrapper(parent) {
|
|
38
39
|
return parent.append("div")
|
|
39
40
|
.classed(this.cardContentBlockCssClass, true);
|
|
40
41
|
}
|
|
41
|
-
renderContentBlock(wrapper) {
|
|
42
|
+
renderContentBlock(wrapper, color) {
|
|
42
43
|
this.cardContentElement = wrapper.append("div")
|
|
43
44
|
.classed(NamesHelper.getClassName("card-content"), true);
|
|
45
|
+
this.setContentColor(color);
|
|
46
|
+
}
|
|
47
|
+
setContentColor(color) {
|
|
48
|
+
this.cardContentElement.style("color", color);
|
|
44
49
|
}
|
|
45
50
|
setContentFontSize(contentBlock, canvasOptions) {
|
|
46
51
|
const fontSize = Math.floor(Math.min(canvasOptions.cardSize.height, canvasOptions.cardSize.width) / 10);
|
|
@@ -49,14 +54,15 @@ export class CardChart {
|
|
|
49
54
|
renderHeaderBlock(contentBlock, options) {
|
|
50
55
|
const header = contentBlock.append("div")
|
|
51
56
|
.classed(NamesHelper.getClassName("card-header"), true);
|
|
52
|
-
this.appendTitle(header, options.title);
|
|
53
57
|
if (options.icon)
|
|
54
58
|
this.appendIcon(header, options.icon);
|
|
59
|
+
this.appendTitle(header, options.title);
|
|
55
60
|
}
|
|
56
61
|
appendTitle(headerBlock, textContent) {
|
|
57
62
|
headerBlock.append("h3")
|
|
58
63
|
.classed(NamesHelper.getClassName("card-title"), true)
|
|
59
|
-
.text(textContent)
|
|
64
|
+
.text(textContent)
|
|
65
|
+
.attr("title", textContent);
|
|
60
66
|
}
|
|
61
67
|
appendIcon(headerBlock, icon) {
|
|
62
68
|
const iconEl = icon();
|
|
@@ -70,7 +76,8 @@ export class CardChart {
|
|
|
70
76
|
.classed(NamesHelper.getClassName("card-description-wrapper"), true);
|
|
71
77
|
wrapper.append("p")
|
|
72
78
|
.classed(NamesHelper.getClassName("card-description"), true)
|
|
73
|
-
.text(textContent)
|
|
79
|
+
.text(textContent)
|
|
80
|
+
.attr("title", textContent);
|
|
74
81
|
}
|
|
75
82
|
renderValueBlock(contentBlock, value) {
|
|
76
83
|
const wrapper = contentBlock.append("div")
|
|
@@ -36,11 +36,14 @@ export class CardChange {
|
|
|
36
36
|
this.renderIcon(this.renderContentItem(contentBlock), options.icon);
|
|
37
37
|
this.renderValue(this.renderContentItem(contentBlock), CardService.getValueContentFromRow(options.value, dataRow));
|
|
38
38
|
if (options.description)
|
|
39
|
-
this.renderDescription(this.renderContentItem(contentBlock), options.description);
|
|
39
|
+
this.renderDescription(this.renderContentItem(contentBlock, NamesHelper.getClassName("card-change-description-item")), options.description);
|
|
40
40
|
}
|
|
41
|
-
renderContentItem(contentBlock) {
|
|
42
|
-
|
|
41
|
+
renderContentItem(contentBlock, cssClass) {
|
|
42
|
+
const item = contentBlock.append("div")
|
|
43
43
|
.classed(NamesHelper.getClassName("card-change-content-item"), true);
|
|
44
|
+
if (cssClass)
|
|
45
|
+
item.classed(cssClass, true);
|
|
46
|
+
return item;
|
|
44
47
|
}
|
|
45
48
|
renderIcon(parentBlock, icon) {
|
|
46
49
|
this.iconBlock = parentBlock.append("div")
|
|
@@ -64,7 +67,8 @@ export class CardChange {
|
|
|
64
67
|
.classed(NamesHelper.getClassName("card-change-description-wrapper"), true)
|
|
65
68
|
.append("span")
|
|
66
69
|
.classed(NamesHelper.getClassName("card-change-description"), true)
|
|
67
|
-
.text(textContent)
|
|
70
|
+
.text(textContent)
|
|
71
|
+
.attr("title", textContent);
|
|
68
72
|
}
|
|
69
73
|
setValueContent(textContent) {
|
|
70
74
|
this.valueContentBlock.text(textContent);
|
package/lib/engine/engine.js
CHANGED
|
@@ -16,8 +16,8 @@ export class Engine {
|
|
|
16
16
|
this.block = new Block(model.blockCanvas.cssClass, parentElement, this.chartId, this.filterEventManager, model.transitions);
|
|
17
17
|
(_a = this.filterEventManager) === null || _a === void 0 ? void 0 : _a.setBlock(this.block);
|
|
18
18
|
this.block.renderWrapper(model.blockCanvas.size);
|
|
19
|
-
this.contentManager = new ContentManager(model);
|
|
20
19
|
if (model.options) {
|
|
20
|
+
this.contentManager = new ContentManager(model);
|
|
21
21
|
ValueFormatter.setFormatFunction(model.dataSettings.format.formatters);
|
|
22
22
|
this.renderCharts(model);
|
|
23
23
|
}
|
|
@@ -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,17 +66,21 @@ 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;
|
|
72
73
|
value: MdtChartsCardValue;
|
|
74
|
+
color: MdtChartsColorName;
|
|
73
75
|
change?: CardsChangeModel;
|
|
74
76
|
}
|
|
75
77
|
export interface ILegendModel {
|
|
76
78
|
position: LegendPosition;
|
|
77
79
|
}
|
|
78
|
-
export interface
|
|
80
|
+
export interface BasicOptionsModelData {
|
|
79
81
|
dataSource: string;
|
|
82
|
+
}
|
|
83
|
+
export interface OptionsModelData extends BasicOptionsModelData {
|
|
80
84
|
keyField: Field;
|
|
81
85
|
}
|
|
82
86
|
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
|
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MdtChartsCardsChange, MdtChartsDataRow } from "../../../config/config";
|
|
2
2
|
import { CardsChangeModel } from "../../model";
|
|
3
|
-
export declare const DEFAULT_CARD_CHANGE_COLOR: MdtChartsCardOptionByValue<MdtChartsColorName>;
|
|
4
|
-
export declare const DEFAULT_CARD_CHANGE_RANGE: MdtChartsColorRangeItem[];
|
|
5
3
|
export declare class CardsChangeService {
|
|
6
4
|
getChangeModel(dataRow: MdtChartsDataRow, changeOptions: MdtChartsCardsChange): CardsChangeModel;
|
|
7
5
|
private getColor;
|
|
@@ -1,22 +1,5 @@
|
|
|
1
1
|
import { ColorRangeManager } from "../../chartStyleModel/colorRange";
|
|
2
|
-
|
|
3
|
-
aboveZero: "#20b078",
|
|
4
|
-
equalZero: "#000",
|
|
5
|
-
belowZero: "#ff3131"
|
|
6
|
-
};
|
|
7
|
-
export const DEFAULT_CARD_CHANGE_RANGE = [
|
|
8
|
-
{
|
|
9
|
-
color: DEFAULT_CARD_CHANGE_COLOR.belowZero
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
color: DEFAULT_CARD_CHANGE_COLOR.equalZero,
|
|
13
|
-
value: 0
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
color: DEFAULT_CARD_CHANGE_COLOR.aboveZero,
|
|
17
|
-
value: 0
|
|
18
|
-
}
|
|
19
|
-
];
|
|
2
|
+
import { DEFAULT_CARD_CHANGE_RANGE } from "./cardsModelService";
|
|
20
3
|
export class CardsChangeService {
|
|
21
4
|
getChangeModel(dataRow, changeOptions) {
|
|
22
5
|
var _a;
|
|
@@ -11,6 +11,7 @@ export class CardsModel {
|
|
|
11
11
|
data: options.data,
|
|
12
12
|
tooltip: options.tooltip,
|
|
13
13
|
icon: options.icon,
|
|
14
|
+
color: this.service.getCardColor(options, modelInstance),
|
|
14
15
|
value: Object.assign({}, options.value),
|
|
15
16
|
change: this.service.getCardsChangeModel(options, modelInstance)
|
|
16
17
|
};
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import { MdtChartsCardsOptions } from "../../../config/config";
|
|
1
|
+
import { MdtChartsCardOptionByValue, MdtChartsCardsOptions, MdtChartsColorName, MdtChartsColorRangeItem } from "../../../config/config";
|
|
2
2
|
import { ModelInstance } from "../../modelInstance/modelInstance";
|
|
3
|
+
export declare const DEFAULT_CARD_COLOR: MdtChartsColorName;
|
|
4
|
+
export declare const DEFAULT_CARD_CHANGE_COLOR: MdtChartsCardOptionByValue<MdtChartsColorName>;
|
|
5
|
+
export declare const DEFAULT_CARD_CHANGE_RANGE: MdtChartsColorRangeItem[];
|
|
3
6
|
export declare class CardsModelService {
|
|
4
7
|
private changeService;
|
|
8
|
+
getCardColor(options: MdtChartsCardsOptions, modelInstance: ModelInstance): MdtChartsColorName;
|
|
5
9
|
getCardsChangeModel(options: MdtChartsCardsOptions, modelInstance: ModelInstance): import("../../model").CardsChangeModel;
|
|
6
10
|
}
|
|
11
|
+
export declare function getCardColor(value: number | string, colorRange: MdtChartsColorRangeItem[]): string;
|
|
@@ -1,10 +1,41 @@
|
|
|
1
|
+
import { ColorRangeManager } from "../../chartStyleModel/colorRange";
|
|
1
2
|
import { CardsChangeService } from "./cardsChangeService";
|
|
3
|
+
export const DEFAULT_CARD_COLOR = "#000";
|
|
4
|
+
export const DEFAULT_CARD_CHANGE_COLOR = {
|
|
5
|
+
aboveZero: "#20b078",
|
|
6
|
+
equalZero: DEFAULT_CARD_COLOR,
|
|
7
|
+
belowZero: "#ff3131"
|
|
8
|
+
};
|
|
9
|
+
export const DEFAULT_CARD_CHANGE_RANGE = [
|
|
10
|
+
{
|
|
11
|
+
color: DEFAULT_CARD_CHANGE_COLOR.belowZero
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
color: DEFAULT_CARD_CHANGE_COLOR.equalZero,
|
|
15
|
+
value: 0
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
color: DEFAULT_CARD_CHANGE_COLOR.aboveZero,
|
|
19
|
+
value: 0
|
|
20
|
+
}
|
|
21
|
+
];
|
|
2
22
|
export class CardsModelService {
|
|
3
23
|
constructor() {
|
|
4
24
|
this.changeService = new CardsChangeService();
|
|
5
25
|
}
|
|
26
|
+
getCardColor(options, modelInstance) {
|
|
27
|
+
const data = modelInstance.dataModel.repository.getFirstRow();
|
|
28
|
+
const value = data[options.value.field];
|
|
29
|
+
return getCardColor(value, options.color);
|
|
30
|
+
}
|
|
6
31
|
getCardsChangeModel(options, modelInstance) {
|
|
7
32
|
const data = modelInstance.dataModel.repository.getFirstRow();
|
|
8
33
|
return this.changeService.getChangeModel(data, options.change);
|
|
9
34
|
}
|
|
10
35
|
}
|
|
36
|
+
export function getCardColor(value, colorRange) {
|
|
37
|
+
if (typeof value === "string" || !(colorRange === null || colorRange === void 0 ? void 0 : colorRange.length))
|
|
38
|
+
return DEFAULT_CARD_COLOR;
|
|
39
|
+
const rangeManager = new ColorRangeManager(colorRange);
|
|
40
|
+
return rangeManager.getColorByValue(value);
|
|
41
|
+
}
|
|
@@ -290,11 +290,14 @@
|
|
|
290
290
|
|
|
291
291
|
.mdt-charts-card-header {
|
|
292
292
|
display: flex;
|
|
293
|
-
justify-content: space-between;
|
|
294
293
|
flex: 1;
|
|
295
294
|
font-size: 1.3em;
|
|
296
295
|
}
|
|
297
296
|
|
|
297
|
+
.mdt-charts-card-icon {
|
|
298
|
+
margin-right: 0.3em;
|
|
299
|
+
}
|
|
300
|
+
|
|
298
301
|
.mdt-charts-card-title {
|
|
299
302
|
margin: 0;
|
|
300
303
|
white-space: nowrap;
|
|
@@ -333,4 +336,14 @@
|
|
|
333
336
|
white-space: nowrap;
|
|
334
337
|
overflow: hidden;
|
|
335
338
|
text-overflow: ellipsis;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
.mdt-charts-card-change-description-item {
|
|
342
|
+
overflow: hidden;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
.mdt-charts-card-change-description {
|
|
346
|
+
display: block;
|
|
347
|
+
overflow: hidden;
|
|
348
|
+
text-overflow: ellipsis;
|
|
336
349
|
}
|
|
@@ -290,11 +290,14 @@
|
|
|
290
290
|
|
|
291
291
|
.mdt-charts-card-header {
|
|
292
292
|
display: flex;
|
|
293
|
-
justify-content: space-between;
|
|
294
293
|
flex: 1;
|
|
295
294
|
font-size: 1.3em;
|
|
296
295
|
}
|
|
297
296
|
|
|
297
|
+
.mdt-charts-card-icon {
|
|
298
|
+
margin-right: 0.3em;
|
|
299
|
+
}
|
|
300
|
+
|
|
298
301
|
.mdt-charts-card-title {
|
|
299
302
|
margin: 0;
|
|
300
303
|
white-space: nowrap;
|
|
@@ -333,4 +336,14 @@
|
|
|
333
336
|
white-space: nowrap;
|
|
334
337
|
overflow: hidden;
|
|
335
338
|
text-overflow: ellipsis;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
.mdt-charts-card-change-description-item {
|
|
342
|
+
overflow: hidden;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
.mdt-charts-card-change-description {
|
|
346
|
+
display: block;
|
|
347
|
+
overflow: hidden;
|
|
348
|
+
text-overflow: ellipsis;
|
|
336
349
|
}
|