mdt-charts 1.12.20 → 1.13.2
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 +1 -0
- 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 +14 -10
- package/lib/model/model.d.ts +2 -0
- package/lib/model/notations/cards/cardsChangeService.d.ts +2 -3
- package/lib/model/notations/cards/cardsChangeService.js +10 -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 +20 -1
- package/lib/style/charts-main.less +20 -1
- package/package.json +1 -1
package/lib/config/config.d.ts
CHANGED
|
@@ -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")
|
|
@@ -9,7 +9,7 @@ export class CardChange {
|
|
|
9
9
|
}
|
|
10
10
|
update(options, dataRow) {
|
|
11
11
|
this.setColor(this.wrapper, options);
|
|
12
|
-
this.setValueContent(CardService.getValueContentFromRow(options.value, dataRow));
|
|
12
|
+
this.setValueContent(CardService.getValueContentFromRow(options.value, dataRow), options.valuePrefix);
|
|
13
13
|
if (options.icon) {
|
|
14
14
|
if (this.iconBlock) {
|
|
15
15
|
this.iconBlock.html("");
|
|
@@ -34,13 +34,16 @@ export class CardChange {
|
|
|
34
34
|
renderContentItems(contentBlock, options, dataRow) {
|
|
35
35
|
if (options.icon)
|
|
36
36
|
this.renderIcon(this.renderContentItem(contentBlock), options.icon);
|
|
37
|
-
this.renderValue(this.renderContentItem(contentBlock), CardService.getValueContentFromRow(options.value, dataRow));
|
|
37
|
+
this.renderValue(this.renderContentItem(contentBlock), CardService.getValueContentFromRow(options.value, dataRow), options.valuePrefix);
|
|
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")
|
|
@@ -53,20 +56,21 @@ export class CardChange {
|
|
|
53
56
|
.node()
|
|
54
57
|
.appendChild(iconEl);
|
|
55
58
|
}
|
|
56
|
-
renderValue(parentBlock, value) {
|
|
59
|
+
renderValue(parentBlock, value, prefix) {
|
|
57
60
|
this.valueContentBlock = parentBlock.append("div")
|
|
58
61
|
.classed(NamesHelper.getClassName("card-change-value"), true)
|
|
59
62
|
.append("span");
|
|
60
|
-
this.setValueContent(value);
|
|
63
|
+
this.setValueContent(value, prefix);
|
|
61
64
|
}
|
|
62
65
|
renderDescription(parentBlock, textContent) {
|
|
63
66
|
return parentBlock.append("div")
|
|
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
|
-
setValueContent(textContent) {
|
|
70
|
-
this.valueContentBlock.text(textContent);
|
|
73
|
+
setValueContent(textContent, prefix) {
|
|
74
|
+
this.valueContentBlock.text(prefix + textContent);
|
|
71
75
|
}
|
|
72
76
|
}
|
package/lib/model/model.d.ts
CHANGED
|
@@ -71,6 +71,7 @@ export interface CardsOptionsModel extends BasicOptionsModel {
|
|
|
71
71
|
description?: string;
|
|
72
72
|
icon?: MdtChartsIconElement;
|
|
73
73
|
value: MdtChartsCardValue;
|
|
74
|
+
color: MdtChartsColorName;
|
|
74
75
|
change?: CardsChangeModel;
|
|
75
76
|
}
|
|
76
77
|
export interface ILegendModel {
|
|
@@ -172,6 +173,7 @@ export interface DonutThicknessOptions {
|
|
|
172
173
|
}
|
|
173
174
|
export interface CardsChangeModel {
|
|
174
175
|
value: MdtChartsCardValue;
|
|
176
|
+
valuePrefix: string;
|
|
175
177
|
description?: string;
|
|
176
178
|
color: MdtChartsColorName;
|
|
177
179
|
icon?: MdtChartsIconElement;
|
|
@@ -1,9 +1,8 @@
|
|
|
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;
|
|
5
|
+
private getValuePrefix;
|
|
7
6
|
private getColor;
|
|
8
7
|
private getIcon;
|
|
9
8
|
private getOptionsByValue;
|
|
@@ -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;
|
|
@@ -26,10 +9,19 @@ export class CardsChangeService {
|
|
|
26
9
|
return {
|
|
27
10
|
description: changeOptions.description,
|
|
28
11
|
value: Object.assign({}, changeOptions.value),
|
|
12
|
+
valuePrefix: this.getValuePrefix(value),
|
|
29
13
|
color: this.getColor(value, changeOptions.color),
|
|
30
14
|
icon: this.getIcon(value, changeOptions.icon)
|
|
31
15
|
};
|
|
32
16
|
}
|
|
17
|
+
getValuePrefix(value) {
|
|
18
|
+
const prefixes = {
|
|
19
|
+
aboveZero: "+",
|
|
20
|
+
belowZero: "",
|
|
21
|
+
equalZero: ""
|
|
22
|
+
};
|
|
23
|
+
return this.getOptionsByValue(value, prefixes);
|
|
24
|
+
}
|
|
33
25
|
getColor(changeValue, colorOptions) {
|
|
34
26
|
const range = (colorOptions === null || colorOptions === void 0 ? void 0 : colorOptions.length) ? colorOptions : DEFAULT_CARD_CHANGE_RANGE;
|
|
35
27
|
const rangeManager = new ColorRangeManager(range);
|
|
@@ -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,20 @@
|
|
|
290
290
|
|
|
291
291
|
.mdt-charts-card-header {
|
|
292
292
|
display: flex;
|
|
293
|
-
justify-content: space-between;
|
|
294
293
|
flex: 1;
|
|
294
|
+
align-items: baseline;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
.mdt-charts-card-title,
|
|
298
|
+
.mdt-charts-card-icon
|
|
299
|
+
{
|
|
295
300
|
font-size: 1.3em;
|
|
296
301
|
}
|
|
297
302
|
|
|
303
|
+
.mdt-charts-card-icon {
|
|
304
|
+
margin-right: 0.3em;
|
|
305
|
+
}
|
|
306
|
+
|
|
298
307
|
.mdt-charts-card-title {
|
|
299
308
|
margin: 0;
|
|
300
309
|
white-space: nowrap;
|
|
@@ -333,4 +342,14 @@
|
|
|
333
342
|
white-space: nowrap;
|
|
334
343
|
overflow: hidden;
|
|
335
344
|
text-overflow: ellipsis;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
.mdt-charts-card-change-description-item {
|
|
348
|
+
overflow: hidden;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
.mdt-charts-card-change-description {
|
|
352
|
+
display: block;
|
|
353
|
+
overflow: hidden;
|
|
354
|
+
text-overflow: ellipsis;
|
|
336
355
|
}
|
|
@@ -290,11 +290,20 @@
|
|
|
290
290
|
|
|
291
291
|
.mdt-charts-card-header {
|
|
292
292
|
display: flex;
|
|
293
|
-
justify-content: space-between;
|
|
294
293
|
flex: 1;
|
|
294
|
+
align-items: baseline;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
.mdt-charts-card-title,
|
|
298
|
+
.mdt-charts-card-icon
|
|
299
|
+
{
|
|
295
300
|
font-size: 1.3em;
|
|
296
301
|
}
|
|
297
302
|
|
|
303
|
+
.mdt-charts-card-icon {
|
|
304
|
+
margin-right: 0.3em;
|
|
305
|
+
}
|
|
306
|
+
|
|
298
307
|
.mdt-charts-card-title {
|
|
299
308
|
margin: 0;
|
|
300
309
|
white-space: nowrap;
|
|
@@ -333,4 +342,14 @@
|
|
|
333
342
|
white-space: nowrap;
|
|
334
343
|
overflow: hidden;
|
|
335
344
|
text-overflow: ellipsis;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
.mdt-charts-card-change-description-item {
|
|
348
|
+
overflow: hidden;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
.mdt-charts-card-change-description {
|
|
352
|
+
display: block;
|
|
353
|
+
overflow: hidden;
|
|
354
|
+
text-overflow: ellipsis;
|
|
336
355
|
}
|