mdt-charts 1.12.14 → 1.12.17
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 +42 -8
- package/lib/engine/block/block.d.ts +4 -13
- package/lib/engine/block/block.js +12 -61
- package/lib/engine/block/blockHtml.d.ts +14 -0
- package/lib/engine/block/blockHtml.js +18 -0
- package/lib/engine/block/blockSvg.d.ts +26 -0
- package/lib/engine/block/blockSvg.js +69 -0
- package/lib/engine/cardsNotation/card/card.d.ts +30 -0
- package/lib/engine/cardsNotation/card/card.js +97 -0
- package/lib/engine/cardsNotation/card/cardChange.d.ts +21 -0
- package/lib/engine/cardsNotation/card/cardChange.js +72 -0
- package/lib/engine/cardsNotation/card/cardElementsStyler.d.ts +6 -0
- package/lib/engine/cardsNotation/card/cardElementsStyler.js +11 -0
- package/lib/engine/cardsNotation/card/cardService.d.ts +11 -0
- package/lib/engine/cardsNotation/card/cardService.js +12 -0
- package/lib/engine/cardsNotation/cardsManager.d.ts +11 -0
- package/lib/engine/cardsNotation/cardsManager.js +14 -0
- package/lib/engine/contentManager/contentManager.d.ts +11 -0
- package/lib/engine/contentManager/contentManager.js +15 -0
- package/lib/engine/contentManager/contentManagerFactory.d.ts +14 -0
- package/lib/engine/contentManager/contentManagerFactory.js +22 -0
- package/lib/engine/engine.d.ts +4 -3
- package/lib/engine/engine.js +12 -8
- package/lib/engine/features/embeddedLabels/embeddedLabels.js +6 -6
- package/lib/engine/features/legend/legend.js +1 -1
- package/lib/engine/features/markDots/markDot.js +4 -4
- package/lib/engine/features/tolltip/newTooltip/newTooltip.js +1 -1
- package/lib/engine/features/tolltip/tooltip.d.ts +6 -6
- package/lib/engine/features/tolltip/tooltip.js +4 -7
- package/lib/engine/features/tolltip/tooltipComponentsManager.js +2 -2
- package/lib/engine/helpers/fontResizer/fontResizer.d.ts +16 -0
- package/lib/engine/helpers/fontResizer/fontResizer.js +21 -0
- package/lib/engine/helpers/fontResizer/fontResizerService.d.ts +6 -0
- package/lib/engine/helpers/fontResizer/fontResizerService.js +12 -0
- package/lib/engine/helpers/namesHelper.js +1 -1
- package/lib/engine/intervalNotation/gantt.js +2 -2
- package/lib/engine/intervalNotation/intervalManager.js +2 -4
- package/lib/engine/polarNotation/polarManager.d.ts +8 -7
- package/lib/engine/polarNotation/polarManager.js +5 -5
- package/lib/engine/twoDimensionalNotation/area/area.js +7 -7
- package/lib/engine/twoDimensionalNotation/bar/bar.js +11 -11
- package/lib/engine/twoDimensionalNotation/line/line.d.ts +1 -1
- package/lib/engine/twoDimensionalNotation/line/line.js +9 -9
- package/lib/engine/twoDimensionalNotation/twoDimensionalManager.d.ts +9 -8
- package/lib/engine/twoDimensionalNotation/twoDimensionalManager.js +9 -9
- package/lib/main.js +1 -1
- package/lib/model/chartStyleModel/chartStyleModel.d.ts +1 -1
- package/lib/model/chartStyleModel/chartStyleModel.js +2 -2
- package/lib/model/chartStyleModel/colorRange.d.ts +7 -0
- package/lib/model/chartStyleModel/colorRange.js +30 -0
- package/lib/model/dataManagerModel/dataManagerModel.js +7 -0
- package/lib/model/dataManagerModel/notations/cardsDataManagerModel.d.ts +5 -0
- package/lib/model/dataManagerModel/notations/cardsDataManagerModel.js +10 -0
- package/lib/model/featuresModel/legendModel/legendModel.d.ts +2 -1
- package/lib/model/featuresModel/legendModel/legendModel.js +7 -0
- package/lib/model/featuresModel/legendModel/polarMarginCalculator.js +2 -3
- package/lib/model/featuresModel/legendModel/twoDimLegendModel.d.ts +2 -1
- package/lib/model/featuresModel/legendModel/twoDimLegendModel.js +7 -6
- package/lib/model/featuresModel/scaleModel/scaleDomainService.d.ts +6 -0
- package/lib/model/featuresModel/scaleModel/scaleDomainService.js +53 -0
- package/lib/model/featuresModel/scaleModel/scaleModel.d.ts +5 -12
- package/lib/model/featuresModel/scaleModel/scaleModel.js +11 -94
- package/lib/model/featuresModel/scaleModel/scaleModelServices.d.ts +5 -0
- package/lib/model/featuresModel/scaleModel/scaleModelServices.js +22 -0
- package/lib/model/margin/marginModel.d.ts +5 -6
- package/lib/model/margin/marginModel.js +10 -16
- package/lib/model/margin/twoDim/twoDimMarginModel.js +1 -1
- package/lib/model/model.d.ts +25 -8
- package/lib/model/modelBuilder.js +7 -2
- package/lib/model/modelInstance/canvasModel/canvasModel.d.ts +4 -3
- package/lib/model/modelInstance/canvasModel/canvasModel.js +1 -1
- package/lib/model/modelInstance/canvasModel/canvasSizesModel/canvasMarginModel.d.ts +11 -0
- package/lib/model/modelInstance/canvasModel/canvasSizesModel/canvasMarginModel.js +1 -0
- package/lib/model/modelInstance/canvasModel/canvasSizesModel/canvasSizeModel.d.ts +4 -0
- package/lib/model/modelInstance/canvasModel/canvasSizesModel/canvasSizeModel.js +1 -0
- package/lib/model/modelInstance/canvasModel/canvasSizesModel/marginModelService.d.ts +11 -0
- package/lib/model/modelInstance/canvasModel/canvasSizesModel/marginModelService.js +26 -0
- package/lib/model/modelInstance/canvasModel/titleCanvas.js +1 -1
- package/lib/model/modelInstance/dataModel/dataRepository.d.ts +1 -0
- package/lib/model/modelInstance/dataModel/dataRepository.js +3 -0
- package/lib/model/notations/cards/cardsChangeService.d.ts +10 -0
- package/lib/model/notations/cards/cardsChangeService.js +50 -0
- package/lib/model/notations/cards/cardsModel.d.ts +8 -0
- package/lib/model/notations/cards/cardsModel.js +19 -0
- package/lib/model/notations/cards/cardsModelService.d.ts +6 -0
- package/lib/model/notations/cards/cardsModelService.js +10 -0
- package/lib/model/notations/intervalModel.js +3 -4
- package/lib/model/notations/twoDimensionalModel.js +3 -2
- package/lib/optionsServices/publicOptionsService.d.ts +1 -1
- package/lib/optionsServices/validators/sizeValidator.d.ts +1 -1
- package/lib/style/charts-main.css +84 -14
- package/lib/style/charts-main.less +84 -14
- package/package.json +1 -1
package/lib/config/config.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
declare type DataType = string;
|
|
2
|
+
export declare type MdtChartsIconElement = () => HTMLElement;
|
|
2
3
|
export declare type AxisPosition = 'start' | 'end';
|
|
3
4
|
export declare type ChartOrientation = 'vertical' | 'horizontal';
|
|
4
|
-
export declare type ChartNotation = '2d' | 'polar' | 'interval';
|
|
5
|
+
export declare type ChartNotation = '2d' | 'polar' | 'interval' | 'card';
|
|
5
6
|
export declare type ChartType = 'bar' | 'line' | 'area' | 'donut' | 'gantt';
|
|
6
7
|
export declare type TwoDimensionalChartType = 'line' | 'bar' | 'area';
|
|
7
8
|
export declare type PolarChartType = 'donut';
|
|
@@ -11,13 +12,19 @@ export declare type TooltipHtml = (dataRow: MdtChartsDataRow) => string;
|
|
|
11
12
|
export declare type MdtChartsDataRow = {
|
|
12
13
|
[field: string]: any;
|
|
13
14
|
};
|
|
15
|
+
export declare type MdtChartsColorName = string;
|
|
16
|
+
export interface MdtChartsColorRangeItem {
|
|
17
|
+
color: MdtChartsColorName;
|
|
18
|
+
value?: number;
|
|
19
|
+
}
|
|
14
20
|
export interface MdtChartsDataSource {
|
|
15
21
|
[source: string]: MdtChartsDataRow[];
|
|
16
22
|
}
|
|
17
23
|
export declare type AxisLabelPosition = "straight" | "rotated";
|
|
24
|
+
export declare type MdtChartsConfigOptions = MdtChartsPolarOptions | MdtChartsTwoDimensionalOptions | MdtChartsIntervalOptions | MdtChartsCardsOptions;
|
|
18
25
|
export interface MdtChartsConfig {
|
|
19
26
|
canvas: ChartBlockCanvas;
|
|
20
|
-
options:
|
|
27
|
+
options: MdtChartsConfigOptions;
|
|
21
28
|
}
|
|
22
29
|
export interface ChartBlockCanvas {
|
|
23
30
|
size: Size;
|
|
@@ -31,31 +38,41 @@ export interface NewSize {
|
|
|
31
38
|
width?: number;
|
|
32
39
|
height?: number;
|
|
33
40
|
}
|
|
34
|
-
interface
|
|
35
|
-
legend: Legend;
|
|
41
|
+
interface BasicOptions {
|
|
36
42
|
data: DataOptions;
|
|
43
|
+
tooltip?: TooltipOptions;
|
|
44
|
+
}
|
|
45
|
+
interface GraphicNotationOptions extends BasicOptions {
|
|
46
|
+
legend: Legend;
|
|
37
47
|
title?: string;
|
|
38
48
|
selectable: boolean;
|
|
39
|
-
tooltip?: TooltipOptions;
|
|
40
49
|
}
|
|
41
|
-
export interface MdtChartsTwoDimensionalOptions extends
|
|
50
|
+
export interface MdtChartsTwoDimensionalOptions extends GraphicNotationOptions {
|
|
42
51
|
type: '2d';
|
|
43
52
|
axis: TwoDimensionalAxis;
|
|
44
53
|
additionalElements: AdditionalElements;
|
|
45
54
|
charts: MdtChartsTwoDimensionalChart[];
|
|
46
55
|
orientation: ChartOrientation;
|
|
47
56
|
}
|
|
48
|
-
export interface MdtChartsPolarOptions extends
|
|
57
|
+
export interface MdtChartsPolarOptions extends GraphicNotationOptions {
|
|
49
58
|
type: 'polar';
|
|
50
59
|
chart: PolarChart;
|
|
51
60
|
}
|
|
52
|
-
export interface MdtChartsIntervalOptions extends
|
|
61
|
+
export interface MdtChartsIntervalOptions extends GraphicNotationOptions {
|
|
53
62
|
type: 'interval';
|
|
54
63
|
axis: IntervalAxis;
|
|
55
64
|
chart: IntervalChart;
|
|
56
65
|
additionalElements: AdditionalElements;
|
|
57
66
|
orientation: ChartOrientation;
|
|
58
67
|
}
|
|
68
|
+
export interface MdtChartsCardsOptions extends BasicOptions {
|
|
69
|
+
type: 'card';
|
|
70
|
+
title: string;
|
|
71
|
+
description?: string;
|
|
72
|
+
icon?: MdtChartsIconElement;
|
|
73
|
+
value: MdtChartsCardValue;
|
|
74
|
+
change?: MdtChartsCardsChange;
|
|
75
|
+
}
|
|
59
76
|
export interface Legend {
|
|
60
77
|
show: boolean;
|
|
61
78
|
}
|
|
@@ -118,6 +135,23 @@ export interface IntervalAxis {
|
|
|
118
135
|
}
|
|
119
136
|
interface DateAxisOptions extends AxisOptions {
|
|
120
137
|
}
|
|
138
|
+
export interface MdtChartsCardValue {
|
|
139
|
+
field: string;
|
|
140
|
+
dataType?: DataType;
|
|
141
|
+
}
|
|
142
|
+
export interface MdtChartsCardsChange {
|
|
143
|
+
value: MdtChartsCardValue;
|
|
144
|
+
color?: MdtChartsColorRangeItem[];
|
|
145
|
+
description?: string;
|
|
146
|
+
icon?: MdtChartsCardsChangeIcon;
|
|
147
|
+
}
|
|
148
|
+
export interface MdtChartsCardOptionByValue<T> {
|
|
149
|
+
belowZero?: T;
|
|
150
|
+
equalZero?: T;
|
|
151
|
+
aboveZero?: T;
|
|
152
|
+
}
|
|
153
|
+
export interface MdtChartsCardsChangeIcon extends MdtChartsCardOptionByValue<MdtChartsIconElement> {
|
|
154
|
+
}
|
|
121
155
|
interface ChartSettings {
|
|
122
156
|
tooltip: Tooltip;
|
|
123
157
|
}
|
|
@@ -1,35 +1,26 @@
|
|
|
1
1
|
import { Selection, BaseType } from "d3-selection";
|
|
2
2
|
import { Transitions } from "../../designer/designerConfig";
|
|
3
|
-
import { BlockMargin } from "../../model/model";
|
|
4
3
|
import { Scales } from "../features/scale/scale";
|
|
5
4
|
import { FilterEventManager } from "../filterManager/filterEventManager";
|
|
6
5
|
import { TransitionManager } from "../transitionManager";
|
|
7
6
|
import { Size } from "../../config/config";
|
|
7
|
+
import { BlockSvg } from "./blockSvg";
|
|
8
|
+
import { BlockHtml } from "./blockHtml";
|
|
8
9
|
export declare class Block {
|
|
9
10
|
parentElement: HTMLElement;
|
|
10
|
-
id: number;
|
|
11
11
|
transitionManager: TransitionManager;
|
|
12
12
|
scales: Scales;
|
|
13
13
|
filterEventManager: FilterEventManager;
|
|
14
|
-
|
|
14
|
+
svg: BlockSvg;
|
|
15
|
+
html: BlockHtml;
|
|
15
16
|
private wrapperCssClasses;
|
|
16
17
|
private parentElementSelection;
|
|
17
18
|
private wrapper;
|
|
18
|
-
private readonly chartBlockClass;
|
|
19
|
-
private readonly chartGroupClass;
|
|
20
19
|
constructor(cssClass: string, parentElement: HTMLElement, blockId: number, filterEventManager: FilterEventManager, transitions?: Transitions);
|
|
21
|
-
renderSvg(blockSize: Size): void;
|
|
22
20
|
renderWrapper(blockSize: Size): void;
|
|
23
21
|
destroy(): void;
|
|
24
22
|
getSvg(): Selection<SVGElement, unknown, HTMLElement, any>;
|
|
25
23
|
getWrapper(): Selection<BaseType, unknown, HTMLElement, any>;
|
|
26
|
-
renderChartsBlock(): void;
|
|
27
|
-
getChartBlock(): Selection<SVGGElement, unknown, HTMLElement, any>;
|
|
28
|
-
getChartGroup(chartIndex: number): Selection<SVGGElement, any, BaseType, any>;
|
|
29
|
-
renderChartClipPath(margin: BlockMargin, blockSize: Size): void;
|
|
30
|
-
updateChartClipPath(margin: BlockMargin, blockSize: Size): void;
|
|
31
|
-
getClipPathId(): string;
|
|
32
|
-
renderDefs(): Selection<SVGDefsElement, unknown, HTMLElement, unknown>;
|
|
33
24
|
removeMouseEvents(): void;
|
|
34
25
|
clearWrapper(): void;
|
|
35
26
|
}
|
|
@@ -1,30 +1,25 @@
|
|
|
1
1
|
import { select } from "d3-selection";
|
|
2
2
|
import { TipBox } from "../features/tipBox/tipBox";
|
|
3
3
|
import { Helper } from "../helpers/helper";
|
|
4
|
-
import { NamesHelper } from "../helpers/namesHelper";
|
|
5
4
|
import { Donut } from "../polarNotation/donut/donut";
|
|
6
5
|
import { TransitionManager } from "../transitionManager";
|
|
7
6
|
import { BlockHelper } from "./blockHelper";
|
|
7
|
+
import { BlockSvg } from "./blockSvg";
|
|
8
|
+
import { BlockHtml } from "./blockHtml";
|
|
8
9
|
export class Block {
|
|
9
10
|
constructor(cssClass, parentElement, blockId, filterEventManager, transitions = null) {
|
|
10
|
-
this.
|
|
11
|
-
|
|
11
|
+
this.svg = new BlockSvg({
|
|
12
|
+
svgCssClasses: cssClass,
|
|
13
|
+
parentBlockId: blockId
|
|
14
|
+
});
|
|
15
|
+
this.html = new BlockHtml({ blockCssClass: cssClass });
|
|
12
16
|
this.wrapperCssClasses = Helper.getCssClassesArray(cssClass);
|
|
13
|
-
this.svgCssClasses = Helper.getCssClassesArray(cssClass);
|
|
14
17
|
this.wrapperCssClasses = BlockHelper.getFormattedCssClassesForWrapper(this.wrapperCssClasses);
|
|
15
18
|
this.parentElement = parentElement;
|
|
16
19
|
this.parentElementSelection = select(parentElement);
|
|
17
|
-
this.id = blockId;
|
|
18
20
|
this.transitionManager = new TransitionManager(this, transitions);
|
|
19
21
|
this.filterEventManager = filterEventManager;
|
|
20
22
|
}
|
|
21
|
-
renderSvg(blockSize) {
|
|
22
|
-
this.getWrapper()
|
|
23
|
-
.append('svg')
|
|
24
|
-
.attr('width', blockSize.width)
|
|
25
|
-
.attr('height', blockSize.height)
|
|
26
|
-
.attr('class', this.svgCssClasses.join(' ') + ' ' + NamesHelper.getClassName('svg-chart'));
|
|
27
|
-
}
|
|
28
23
|
renderWrapper(blockSize) {
|
|
29
24
|
this.wrapper = this.parentElementSelection
|
|
30
25
|
.append('div')
|
|
@@ -32,6 +27,8 @@ export class Block {
|
|
|
32
27
|
.style('width', blockSize.width + 'px')
|
|
33
28
|
.style('height', blockSize.height + 'px')
|
|
34
29
|
.style('position', 'relative');
|
|
30
|
+
this.svg.initParent(this.wrapper);
|
|
31
|
+
this.html.initParent(this.wrapper);
|
|
35
32
|
}
|
|
36
33
|
destroy() {
|
|
37
34
|
this.transitionManager.interruptTransitions();
|
|
@@ -39,60 +36,14 @@ export class Block {
|
|
|
39
36
|
this.getWrapper().remove();
|
|
40
37
|
}
|
|
41
38
|
getSvg() {
|
|
42
|
-
|
|
39
|
+
//TODO: move this method in blockSvg
|
|
40
|
+
return this.svg.getBlock();
|
|
43
41
|
}
|
|
44
42
|
getWrapper() {
|
|
45
43
|
return this.wrapper;
|
|
46
44
|
}
|
|
47
|
-
renderChartsBlock() {
|
|
48
|
-
this.getSvg()
|
|
49
|
-
.append('g')
|
|
50
|
-
.attr('class', this.chartBlockClass);
|
|
51
|
-
}
|
|
52
|
-
getChartBlock() {
|
|
53
|
-
return this.getSvg().select(`.${this.chartBlockClass}`);
|
|
54
|
-
}
|
|
55
|
-
getChartGroup(chartIndex) {
|
|
56
|
-
let group = this.getChartBlock().select(`.${this.chartGroupClass}-${chartIndex}`);
|
|
57
|
-
if (group.empty()) {
|
|
58
|
-
group = this.getChartBlock()
|
|
59
|
-
.append('g')
|
|
60
|
-
.attr('class', `${this.chartGroupClass}-${chartIndex}`);
|
|
61
|
-
}
|
|
62
|
-
return group;
|
|
63
|
-
}
|
|
64
|
-
renderChartClipPath(margin, blockSize) {
|
|
65
|
-
const attributes = BlockHelper.getClipPathAttributes(blockSize, margin);
|
|
66
|
-
this.renderDefs()
|
|
67
|
-
.append('clipPath')
|
|
68
|
-
.attr('id', this.getClipPathId())
|
|
69
|
-
.append('rect')
|
|
70
|
-
.attr('x', attributes.x)
|
|
71
|
-
.attr('y', attributes.y)
|
|
72
|
-
.attr('width', attributes.width)
|
|
73
|
-
.attr('height', attributes.height);
|
|
74
|
-
}
|
|
75
|
-
updateChartClipPath(margin, blockSize) {
|
|
76
|
-
const attributes = BlockHelper.getClipPathAttributes(blockSize, margin);
|
|
77
|
-
this.renderDefs()
|
|
78
|
-
.select('clipPath')
|
|
79
|
-
.select('rect')
|
|
80
|
-
.attr('x', attributes.x)
|
|
81
|
-
.attr('y', attributes.y)
|
|
82
|
-
.attr('width', attributes.width)
|
|
83
|
-
.attr('height', attributes.height);
|
|
84
|
-
}
|
|
85
|
-
getClipPathId() {
|
|
86
|
-
return NamesHelper.getId('clip-path', this.id);
|
|
87
|
-
}
|
|
88
|
-
renderDefs() {
|
|
89
|
-
let defs = this.getSvg()
|
|
90
|
-
.select('defs');
|
|
91
|
-
if (defs.empty())
|
|
92
|
-
defs = this.getSvg().append('defs');
|
|
93
|
-
return defs;
|
|
94
|
-
}
|
|
95
45
|
removeMouseEvents() {
|
|
46
|
+
//TODO: move this method in blockSvg
|
|
96
47
|
const tipBoxes = this.getSvg().selectAll(`.${TipBox.tipBoxClass}`);
|
|
97
48
|
tipBoxes.on('mousemove', null);
|
|
98
49
|
tipBoxes.on('mouseover', null);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Selection } from "d3-selection";
|
|
2
|
+
interface BlockHtmlOptions {
|
|
3
|
+
blockCssClass: string;
|
|
4
|
+
}
|
|
5
|
+
export declare class BlockHtml {
|
|
6
|
+
private parent;
|
|
7
|
+
private block;
|
|
8
|
+
private blockCssClass;
|
|
9
|
+
constructor(options: BlockHtmlOptions);
|
|
10
|
+
initParent(parent: Selection<HTMLDivElement, unknown, HTMLElement, any>): void;
|
|
11
|
+
render(): void;
|
|
12
|
+
getBlock(): Selection<HTMLDivElement, unknown, HTMLElement, any>;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { NamesHelper } from "../helpers/namesHelper";
|
|
2
|
+
export class BlockHtml {
|
|
3
|
+
constructor(options) {
|
|
4
|
+
this.blockCssClass = options.blockCssClass;
|
|
5
|
+
}
|
|
6
|
+
initParent(parent) {
|
|
7
|
+
this.parent = parent;
|
|
8
|
+
}
|
|
9
|
+
render() {
|
|
10
|
+
this.block = this.parent
|
|
11
|
+
.append("div")
|
|
12
|
+
.attr("class", NamesHelper.getClassName("html-chart"))
|
|
13
|
+
.classed(this.blockCssClass, true);
|
|
14
|
+
}
|
|
15
|
+
getBlock() {
|
|
16
|
+
return this.block;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Selection, BaseType } from "d3-selection";
|
|
2
|
+
import { Size } from "../../config/config";
|
|
3
|
+
import { BlockMargin } from "../../model/model";
|
|
4
|
+
interface BlockSvgOptions {
|
|
5
|
+
parentBlockId: number;
|
|
6
|
+
svgCssClasses: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class BlockSvg {
|
|
9
|
+
private parentBlockId;
|
|
10
|
+
private parent;
|
|
11
|
+
private svgCssClasses;
|
|
12
|
+
private readonly chartBlockClass;
|
|
13
|
+
private readonly chartGroupClass;
|
|
14
|
+
constructor(options: BlockSvgOptions);
|
|
15
|
+
initParent(parent: Selection<BaseType, unknown, HTMLElement, any>): void;
|
|
16
|
+
render(blockSize: Size): void;
|
|
17
|
+
getBlock(): Selection<SVGElement, unknown, HTMLElement, any>;
|
|
18
|
+
renderChartsBlock(): void;
|
|
19
|
+
getChartBlock(): Selection<SVGGElement, unknown, HTMLElement, any>;
|
|
20
|
+
getChartGroup(chartIndex: number): Selection<SVGGElement, any, BaseType, any>;
|
|
21
|
+
getClipPathId(): string;
|
|
22
|
+
renderChartClipPath(margin: BlockMargin, blockSize: Size): void;
|
|
23
|
+
updateChartClipPath(margin: BlockMargin, blockSize: Size): void;
|
|
24
|
+
private renderDefs;
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { NamesHelper } from "../helpers/namesHelper";
|
|
2
|
+
import { BlockHelper } from "./blockHelper";
|
|
3
|
+
export class BlockSvg {
|
|
4
|
+
constructor(options) {
|
|
5
|
+
this.chartBlockClass = 'chart-block';
|
|
6
|
+
this.chartGroupClass = 'chart-group';
|
|
7
|
+
this.svgCssClasses = options.svgCssClasses;
|
|
8
|
+
this.parentBlockId = options.parentBlockId;
|
|
9
|
+
}
|
|
10
|
+
initParent(parent) {
|
|
11
|
+
this.parent = parent;
|
|
12
|
+
}
|
|
13
|
+
render(blockSize) {
|
|
14
|
+
this.parent
|
|
15
|
+
.append('svg')
|
|
16
|
+
.attr('width', blockSize.width)
|
|
17
|
+
.attr('height', blockSize.height)
|
|
18
|
+
.attr('class', this.svgCssClasses + ' ' + NamesHelper.getClassName('svg-chart'));
|
|
19
|
+
}
|
|
20
|
+
getBlock() {
|
|
21
|
+
return this.parent.select(`svg.${NamesHelper.getClassName('svg-chart')}`);
|
|
22
|
+
}
|
|
23
|
+
renderChartsBlock() {
|
|
24
|
+
this.getBlock()
|
|
25
|
+
.append('g')
|
|
26
|
+
.attr('class', this.chartBlockClass);
|
|
27
|
+
}
|
|
28
|
+
getChartBlock() {
|
|
29
|
+
return this.getBlock().select(`.${this.chartBlockClass}`);
|
|
30
|
+
}
|
|
31
|
+
getChartGroup(chartIndex) {
|
|
32
|
+
let group = this.getChartBlock().select(`.${this.chartGroupClass}-${chartIndex}`);
|
|
33
|
+
if (group.empty()) {
|
|
34
|
+
group = this.getChartBlock().append('g')
|
|
35
|
+
.attr('class', `${this.chartGroupClass}-${chartIndex}`);
|
|
36
|
+
}
|
|
37
|
+
return group;
|
|
38
|
+
}
|
|
39
|
+
getClipPathId() {
|
|
40
|
+
return NamesHelper.getId('clip-path', this.parentBlockId);
|
|
41
|
+
}
|
|
42
|
+
renderChartClipPath(margin, blockSize) {
|
|
43
|
+
const attributes = BlockHelper.getClipPathAttributes(blockSize, margin);
|
|
44
|
+
this.renderDefs()
|
|
45
|
+
.append('clipPath')
|
|
46
|
+
.attr('id', this.getClipPathId())
|
|
47
|
+
.append('rect')
|
|
48
|
+
.attr('x', attributes.x)
|
|
49
|
+
.attr('y', attributes.y)
|
|
50
|
+
.attr('width', attributes.width)
|
|
51
|
+
.attr('height', attributes.height);
|
|
52
|
+
}
|
|
53
|
+
updateChartClipPath(margin, blockSize) {
|
|
54
|
+
const attributes = BlockHelper.getClipPathAttributes(blockSize, margin);
|
|
55
|
+
this.renderDefs()
|
|
56
|
+
.select('clipPath')
|
|
57
|
+
.select('rect')
|
|
58
|
+
.attr('x', attributes.x)
|
|
59
|
+
.attr('y', attributes.y)
|
|
60
|
+
.attr('width', attributes.width)
|
|
61
|
+
.attr('height', attributes.height);
|
|
62
|
+
}
|
|
63
|
+
renderDefs() {
|
|
64
|
+
let defs = this.getBlock().select('defs');
|
|
65
|
+
if (defs.empty())
|
|
66
|
+
defs = this.getBlock().append('defs');
|
|
67
|
+
return defs;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { BaseType, Selection } from "d3-selection";
|
|
2
|
+
import { MdtChartsDataSource, Size } from "../../../config/config";
|
|
3
|
+
import { CardsOptionsModel } from "../../../model/model";
|
|
4
|
+
import { Block } from "../../block/block";
|
|
5
|
+
export declare type CardChildElement<T extends Element = HTMLElement> = Selection<T, unknown, BaseType, unknown>;
|
|
6
|
+
interface CanvasOptions {
|
|
7
|
+
cardSize: Size;
|
|
8
|
+
}
|
|
9
|
+
export declare type CardValueContent = string | number;
|
|
10
|
+
export declare class CardChart {
|
|
11
|
+
private readonly cardValueCssClass;
|
|
12
|
+
private readonly cardContentBlockCssClass;
|
|
13
|
+
private valueContentElement;
|
|
14
|
+
private cardContentElement;
|
|
15
|
+
private changeBlock;
|
|
16
|
+
private styler;
|
|
17
|
+
render(block: Block, options: CardsOptionsModel, data: MdtChartsDataSource, canvasOptions: CanvasOptions): void;
|
|
18
|
+
updateData(options: CardsOptionsModel, data: MdtChartsDataSource): void;
|
|
19
|
+
private renderCardWrapper;
|
|
20
|
+
private renderContentBlock;
|
|
21
|
+
private setContentFontSize;
|
|
22
|
+
private renderHeaderBlock;
|
|
23
|
+
private appendTitle;
|
|
24
|
+
private appendIcon;
|
|
25
|
+
private renderDescriptionBlock;
|
|
26
|
+
private renderValueBlock;
|
|
27
|
+
private updateValueBlockStyle;
|
|
28
|
+
private setValueContent;
|
|
29
|
+
}
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { FontResizer } from "../../helpers/fontResizer/fontResizer";
|
|
2
|
+
import { NamesHelper } from "../../helpers/namesHelper";
|
|
3
|
+
import { CardChange } from "./cardChange";
|
|
4
|
+
import { CardElementsStyler } from "./cardElementsStyler";
|
|
5
|
+
import { CardService } from "./cardService";
|
|
6
|
+
export class CardChart {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.cardValueCssClass = NamesHelper.getClassName("card-value");
|
|
9
|
+
this.cardContentBlockCssClass = NamesHelper.getClassName("card-content");
|
|
10
|
+
this.styler = new CardElementsStyler();
|
|
11
|
+
}
|
|
12
|
+
render(block, options, data, canvasOptions) {
|
|
13
|
+
const parent = block.html.getBlock();
|
|
14
|
+
const dataRow = data[options.data.dataSource][0];
|
|
15
|
+
const wrapper = this.renderCardWrapper(parent);
|
|
16
|
+
this.renderContentBlock(wrapper);
|
|
17
|
+
this.setContentFontSize(this.cardContentElement, canvasOptions);
|
|
18
|
+
this.renderHeaderBlock(this.cardContentElement, {
|
|
19
|
+
title: options.title,
|
|
20
|
+
icon: options.icon
|
|
21
|
+
});
|
|
22
|
+
if (options.description)
|
|
23
|
+
this.renderDescriptionBlock(this.cardContentElement, options.description);
|
|
24
|
+
this.renderValueBlock(this.cardContentElement, CardService.getValueContentFromDataSource(Object.assign(Object.assign({}, options.value), { dataSetName: options.data.dataSource }), data));
|
|
25
|
+
if (options.change) {
|
|
26
|
+
this.changeBlock = new CardChange();
|
|
27
|
+
this.changeBlock.render(this.cardContentElement, options.change, dataRow);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
updateData(options, data) {
|
|
31
|
+
var _a;
|
|
32
|
+
const dataRow = data[options.data.dataSource][0];
|
|
33
|
+
this.setValueContent(CardService.getValueContentFromDataSource(Object.assign(Object.assign({}, options.value), { dataSetName: options.data.dataSource }), data));
|
|
34
|
+
this.updateValueBlockStyle();
|
|
35
|
+
(_a = this.changeBlock) === null || _a === void 0 ? void 0 : _a.update(options.change, dataRow);
|
|
36
|
+
}
|
|
37
|
+
renderCardWrapper(parent) {
|
|
38
|
+
return parent.append("div")
|
|
39
|
+
.classed(this.cardContentBlockCssClass, true);
|
|
40
|
+
}
|
|
41
|
+
renderContentBlock(wrapper) {
|
|
42
|
+
this.cardContentElement = wrapper.append("div")
|
|
43
|
+
.classed(NamesHelper.getClassName("card-content"), true);
|
|
44
|
+
}
|
|
45
|
+
setContentFontSize(contentBlock, canvasOptions) {
|
|
46
|
+
const fontSize = Math.floor(Math.min(canvasOptions.cardSize.height, canvasOptions.cardSize.width) / 10);
|
|
47
|
+
contentBlock.style("font-size", `${fontSize}px`);
|
|
48
|
+
}
|
|
49
|
+
renderHeaderBlock(contentBlock, options) {
|
|
50
|
+
const header = contentBlock.append("div")
|
|
51
|
+
.classed(NamesHelper.getClassName("card-header"), true);
|
|
52
|
+
this.appendTitle(header, options.title);
|
|
53
|
+
if (options.icon)
|
|
54
|
+
this.appendIcon(header, options.icon);
|
|
55
|
+
}
|
|
56
|
+
appendTitle(headerBlock, textContent) {
|
|
57
|
+
headerBlock.append("h3")
|
|
58
|
+
.classed(NamesHelper.getClassName("card-title"), true)
|
|
59
|
+
.text(textContent);
|
|
60
|
+
}
|
|
61
|
+
appendIcon(headerBlock, icon) {
|
|
62
|
+
const iconEl = icon();
|
|
63
|
+
headerBlock.append("div")
|
|
64
|
+
.classed(NamesHelper.getClassName("card-icon"), true)
|
|
65
|
+
.node()
|
|
66
|
+
.appendChild(iconEl);
|
|
67
|
+
}
|
|
68
|
+
renderDescriptionBlock(contentBlock, textContent) {
|
|
69
|
+
const wrapper = contentBlock.append("div")
|
|
70
|
+
.classed(NamesHelper.getClassName("card-description-wrapper"), true);
|
|
71
|
+
wrapper.append("p")
|
|
72
|
+
.classed(NamesHelper.getClassName("card-description"), true)
|
|
73
|
+
.text(textContent);
|
|
74
|
+
}
|
|
75
|
+
renderValueBlock(contentBlock, value) {
|
|
76
|
+
const wrapper = contentBlock.append("div")
|
|
77
|
+
.classed(NamesHelper.getClassName("card-value-wrapper"), true);
|
|
78
|
+
this.valueContentElement = wrapper.append("div")
|
|
79
|
+
.classed(NamesHelper.getClassName("card-value-block"), true)
|
|
80
|
+
.append("span")
|
|
81
|
+
.classed(this.cardValueCssClass, true);
|
|
82
|
+
this.setValueContent(value);
|
|
83
|
+
this.updateValueBlockStyle();
|
|
84
|
+
}
|
|
85
|
+
updateValueBlockStyle() {
|
|
86
|
+
this.styler.setValueBlockFontSize(this.valueContentElement);
|
|
87
|
+
FontResizer.setSize(this.valueContentElement.node(), {
|
|
88
|
+
elWrapper: this.cardContentElement.node(),
|
|
89
|
+
unit: "em",
|
|
90
|
+
smallestFontSize: 0.5,
|
|
91
|
+
step: 0.1
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
setValueContent(value) {
|
|
95
|
+
this.valueContentElement.text(value);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { MdtChartsDataRow } from "../../../config/config";
|
|
2
|
+
import { CardsChangeModel } from "../../../model/model";
|
|
3
|
+
import { CardChildElement } from "./card";
|
|
4
|
+
export declare class CardChange {
|
|
5
|
+
private wrapper;
|
|
6
|
+
private iconBlock;
|
|
7
|
+
private valueContentBlock;
|
|
8
|
+
private contentBlock;
|
|
9
|
+
render(contentBlock: CardChildElement, options: CardsChangeModel, dataRow: MdtChartsDataRow): void;
|
|
10
|
+
update(options: CardsChangeModel, dataRow: MdtChartsDataRow): void;
|
|
11
|
+
private renderWrapper;
|
|
12
|
+
private setColor;
|
|
13
|
+
private renderContentBlock;
|
|
14
|
+
private renderContentItems;
|
|
15
|
+
private renderContentItem;
|
|
16
|
+
private renderIcon;
|
|
17
|
+
private renderIconEl;
|
|
18
|
+
private renderValue;
|
|
19
|
+
private renderDescription;
|
|
20
|
+
private setValueContent;
|
|
21
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { NamesHelper } from "../../helpers/namesHelper";
|
|
2
|
+
import { CardService } from "./cardService";
|
|
3
|
+
export class CardChange {
|
|
4
|
+
render(contentBlock, options, dataRow) {
|
|
5
|
+
this.wrapper = this.renderWrapper(contentBlock);
|
|
6
|
+
this.setColor(this.wrapper, options);
|
|
7
|
+
this.renderContentBlock(this.wrapper);
|
|
8
|
+
this.renderContentItems(this.contentBlock, options, dataRow);
|
|
9
|
+
}
|
|
10
|
+
update(options, dataRow) {
|
|
11
|
+
this.setColor(this.wrapper, options);
|
|
12
|
+
this.setValueContent(CardService.getValueContentFromRow(options.value, dataRow));
|
|
13
|
+
if (options.icon) {
|
|
14
|
+
if (this.iconBlock) {
|
|
15
|
+
this.iconBlock.html("");
|
|
16
|
+
this.renderIconEl(options.icon);
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
this.renderIcon(this.contentBlock, options.icon);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
renderWrapper(contentBlock) {
|
|
24
|
+
return contentBlock.append("div")
|
|
25
|
+
.classed(NamesHelper.getClassName("card-change-wrapper"), true);
|
|
26
|
+
}
|
|
27
|
+
setColor(wrapper, options) {
|
|
28
|
+
wrapper.style("color", options.color);
|
|
29
|
+
}
|
|
30
|
+
renderContentBlock(wrapper) {
|
|
31
|
+
this.contentBlock = wrapper.append("div")
|
|
32
|
+
.classed(NamesHelper.getClassName("card-change-content"), true);
|
|
33
|
+
}
|
|
34
|
+
renderContentItems(contentBlock, options, dataRow) {
|
|
35
|
+
if (options.icon)
|
|
36
|
+
this.renderIcon(this.renderContentItem(contentBlock), options.icon);
|
|
37
|
+
this.renderValue(this.renderContentItem(contentBlock), CardService.getValueContentFromRow(options.value, dataRow));
|
|
38
|
+
if (options.description)
|
|
39
|
+
this.renderDescription(this.renderContentItem(contentBlock), options.description);
|
|
40
|
+
}
|
|
41
|
+
renderContentItem(contentBlock) {
|
|
42
|
+
return contentBlock.append("div")
|
|
43
|
+
.classed(NamesHelper.getClassName("card-change-content-item"), true);
|
|
44
|
+
}
|
|
45
|
+
renderIcon(parentBlock, icon) {
|
|
46
|
+
this.iconBlock = parentBlock.append("div")
|
|
47
|
+
.classed(NamesHelper.getClassName("card-change-icon"), true);
|
|
48
|
+
this.renderIconEl(icon);
|
|
49
|
+
}
|
|
50
|
+
renderIconEl(icon) {
|
|
51
|
+
const iconEl = icon();
|
|
52
|
+
this.iconBlock
|
|
53
|
+
.node()
|
|
54
|
+
.appendChild(iconEl);
|
|
55
|
+
}
|
|
56
|
+
renderValue(parentBlock, value) {
|
|
57
|
+
this.valueContentBlock = parentBlock.append("div")
|
|
58
|
+
.classed(NamesHelper.getClassName("card-change-value"), true)
|
|
59
|
+
.append("span");
|
|
60
|
+
this.setValueContent(value);
|
|
61
|
+
}
|
|
62
|
+
renderDescription(parentBlock, textContent) {
|
|
63
|
+
return parentBlock.append("div")
|
|
64
|
+
.classed(NamesHelper.getClassName("card-change-description-wrapper"), true)
|
|
65
|
+
.append("span")
|
|
66
|
+
.classed(NamesHelper.getClassName("card-change-description"), true)
|
|
67
|
+
.text(textContent);
|
|
68
|
+
}
|
|
69
|
+
setValueContent(textContent) {
|
|
70
|
+
this.valueContentBlock.text(textContent);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export class CardElementsStyler {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.cardValueFontSize = "2em";
|
|
4
|
+
}
|
|
5
|
+
setValueBlockFontSize(valueBlock) {
|
|
6
|
+
this.setFontSize(valueBlock, this.cardValueFontSize);
|
|
7
|
+
}
|
|
8
|
+
setFontSize(cardElement, value) {
|
|
9
|
+
cardElement.style("font-size", value);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MdtChartsCardValue, MdtChartsDataRow, MdtChartsDataSource } from "../../../config/config";
|
|
2
|
+
import { CardValueContent } from "./card";
|
|
3
|
+
interface ValueContentGetterOptions extends MdtChartsCardValue {
|
|
4
|
+
dataSetName: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class CardServiceClass {
|
|
7
|
+
getValueContentFromDataSource(valueOptions: ValueContentGetterOptions, data: MdtChartsDataSource): CardValueContent;
|
|
8
|
+
getValueContentFromRow(valueOptions: MdtChartsCardValue, dataRow: MdtChartsDataRow): string;
|
|
9
|
+
}
|
|
10
|
+
export declare const CardService: CardServiceClass;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ValueFormatter } from "../../valueFormatter";
|
|
2
|
+
export class CardServiceClass {
|
|
3
|
+
getValueContentFromDataSource(valueOptions, data) {
|
|
4
|
+
const dataRow = data[valueOptions.dataSetName][0];
|
|
5
|
+
return this.getValueContentFromRow(valueOptions, dataRow);
|
|
6
|
+
}
|
|
7
|
+
getValueContentFromRow(valueOptions, dataRow) {
|
|
8
|
+
const value = dataRow[valueOptions.field];
|
|
9
|
+
return ValueFormatter.formatField(valueOptions.dataType, value);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export const CardService = new CardServiceClass();
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MdtChartsDataSource } from "../../config/config";
|
|
2
|
+
import { CardsOptionsModel, Model } from "../../model/model";
|
|
3
|
+
import { Block } from "../block/block";
|
|
4
|
+
import { ChartContentManager } from "../contentManager/contentManagerFactory";
|
|
5
|
+
import { Engine } from "../engine";
|
|
6
|
+
export declare class CardsManager implements ChartContentManager {
|
|
7
|
+
private chart;
|
|
8
|
+
render(engine: Engine, model: Model<CardsOptionsModel>): void;
|
|
9
|
+
updateData(block: Block, model: Model<CardsOptionsModel>, newData: MdtChartsDataSource): void;
|
|
10
|
+
updateColors(block: Block, model: Model<CardsOptionsModel>): void;
|
|
11
|
+
}
|