mdt-charts 1.11.0 → 1.12.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 +9 -3
- package/lib/engine/features/legend/legend.d.ts +10 -1
- package/lib/engine/features/legend/legend.js +10 -22
- package/lib/engine/features/legend/legendHelper.d.ts +4 -5
- package/lib/engine/features/legend/legendHelper.js +19 -23
- package/lib/engine/features/legend/legendHelperService.d.ts +12 -0
- package/lib/engine/features/legend/legendHelperService.js +30 -0
- package/lib/engine/features/recordOverflowAlert/recordOverflowAlertCore.d.ts +28 -0
- package/lib/engine/features/recordOverflowAlert/recordOverflowAlertCore.js +50 -0
- package/lib/engine/intervalNotation/intervalManager.js +0 -3
- package/lib/engine/polarNotation/extenders/polarRecordOverflowAlert.d.ts +15 -0
- package/lib/engine/polarNotation/extenders/polarRecordOverflowAlert.js +40 -0
- package/lib/engine/polarNotation/polarManager.js +10 -5
- package/lib/engine/twoDimensionalNotation/extenders/twoDimRecordOverflowAlert.d.ts +15 -0
- package/lib/engine/twoDimensionalNotation/extenders/twoDimRecordOverflowAlert.js +32 -0
- package/lib/engine/twoDimensionalNotation/twoDimensionalManager.js +9 -3
- package/lib/model/{dataManagerModel.d.ts → dataManagerModel/dataManagerModel.d.ts} +18 -7
- package/lib/model/{dataManagerModel.js → dataManagerModel/dataManagerModel.js} +51 -45
- package/lib/model/dataManagerModel/dataManagerModelService.d.ts +5 -0
- package/lib/model/dataManagerModel/dataManagerModelService.js +28 -0
- package/lib/model/featuresModel/axisModel.d.ts +5 -4
- package/lib/model/featuresModel/axisModel.js +14 -12
- package/lib/model/featuresModel/axisModelService.d.ts +4 -0
- package/lib/model/featuresModel/axisModelService.js +11 -0
- package/lib/model/featuresModel/legendModel/legendCanvasModel.d.ts +4 -2
- package/lib/model/featuresModel/legendModel/legendCanvasModel.js +42 -29
- package/lib/model/featuresModel/legendModel/legendModel.d.ts +1 -4
- package/lib/model/featuresModel/legendModel/legendModel.js +15 -16
- package/lib/model/featuresModel/legendModel/polarMarginCalculator.d.ts +11 -0
- package/lib/model/featuresModel/legendModel/polarMarginCalculator.js +42 -0
- package/lib/model/featuresModel/scaleModel.d.ts +3 -3
- package/lib/model/featuresModel/titleModel.js +1 -1
- package/lib/model/marginModel.d.ts +3 -2
- package/lib/model/marginModel.js +11 -7
- package/lib/model/model.d.ts +1 -2
- package/lib/model/modelBuilder.js +8 -8
- package/lib/model/modelInstance/canvasModel/canvasModel.d.ts +2 -0
- package/lib/model/modelInstance/canvasModel/canvasModel.js +2 -0
- package/lib/model/modelInstance/canvasModel/legendCanvasModel.d.ts +7 -0
- package/lib/model/modelInstance/canvasModel/legendCanvasModel.js +13 -0
- package/lib/model/modelInstance/dataModel.d.ts +11 -0
- package/lib/model/modelInstance/dataModel.js +23 -0
- package/lib/model/modelInstance/modelInstance.d.ts +3 -0
- package/lib/model/modelInstance/modelInstance.js +7 -1
- package/lib/model/notations/intervalModel.js +2 -3
- package/lib/model/notations/polarModel.d.ts +9 -3
- package/lib/model/notations/polarModel.js +24 -2
- package/lib/model/notations/twoDimensionalModel.d.ts +2 -2
- package/lib/model/notations/twoDimensionalModel.js +2 -3
- package/lib/style/charts-main.css +24 -7
- package/lib/style/charts-main.less +24 -7
- package/package.json +2 -2
- package/tsconfig.production.json +23 -0
- package/lib/engine/features/recordOverflowAlert/recordOverflowAlert.d.ts +0 -14
- package/lib/engine/features/recordOverflowAlert/recordOverflowAlert.js +0 -97
package/lib/config/config.d.ts
CHANGED
|
@@ -14,9 +14,10 @@ export declare type MdtChartsDataRow = {
|
|
|
14
14
|
export interface MdtChartsDataSource {
|
|
15
15
|
[source: string]: MdtChartsDataRow[];
|
|
16
16
|
}
|
|
17
|
+
export declare type AxisLabelPosition = "straight" | "rotated";
|
|
17
18
|
export interface MdtChartsConfig {
|
|
18
19
|
canvas: ChartBlockCanvas;
|
|
19
|
-
options:
|
|
20
|
+
options: MdtChartsPolarOptions | MdtChartsTwoDimensionalOptions | IntervalOptions;
|
|
20
21
|
}
|
|
21
22
|
export interface ChartBlockCanvas {
|
|
22
23
|
size: Size;
|
|
@@ -37,14 +38,14 @@ interface Options {
|
|
|
37
38
|
selectable: boolean;
|
|
38
39
|
tooltip?: TooltipOptions;
|
|
39
40
|
}
|
|
40
|
-
export interface
|
|
41
|
+
export interface MdtChartsTwoDimensionalOptions extends Options {
|
|
41
42
|
type: '2d';
|
|
42
43
|
axis: TwoDimensionalAxis;
|
|
43
44
|
additionalElements: AdditionalElements;
|
|
44
45
|
charts: TwoDimensionalChart[];
|
|
45
46
|
orientation: ChartOrientation;
|
|
46
47
|
}
|
|
47
|
-
export interface
|
|
48
|
+
export interface MdtChartsPolarOptions extends Options {
|
|
48
49
|
type: 'polar';
|
|
49
50
|
chart: PolarChart;
|
|
50
51
|
}
|
|
@@ -61,6 +62,7 @@ export interface Legend {
|
|
|
61
62
|
export interface DataOptions {
|
|
62
63
|
dataSource: string;
|
|
63
64
|
keyField: MdtChartsField;
|
|
65
|
+
maxRecordsAmount?: number;
|
|
64
66
|
}
|
|
65
67
|
export interface MdtChartsField {
|
|
66
68
|
name: string;
|
|
@@ -105,6 +107,10 @@ export interface NumberDomain {
|
|
|
105
107
|
end: number;
|
|
106
108
|
}
|
|
107
109
|
export interface DiscreteAxisOptions extends AxisOptions {
|
|
110
|
+
labels?: MdtChartsDiscreteAxisLabel;
|
|
111
|
+
}
|
|
112
|
+
export interface MdtChartsDiscreteAxisLabel {
|
|
113
|
+
position?: AxisLabelPosition;
|
|
108
114
|
}
|
|
109
115
|
export interface IntervalAxis {
|
|
110
116
|
key: DiscreteAxisOptions;
|
|
@@ -3,12 +3,21 @@ import { MdtChartsDataSource } from "../../../config/config";
|
|
|
3
3
|
import { IntervalOptionsModel, Model, PolarOptionsModel, TwoDimensionalOptionsModel } from "../../../model/model";
|
|
4
4
|
import { Block } from "../../block/block";
|
|
5
5
|
import { SelectionCondition } from "../../helpers/domHelper";
|
|
6
|
+
export interface LegendContentRenderingOptions {
|
|
7
|
+
wrapperClasses: string[];
|
|
8
|
+
shouldCropLabels: boolean;
|
|
9
|
+
itemsOptions: {
|
|
10
|
+
wrapperClasses: string[];
|
|
11
|
+
markerClass: string;
|
|
12
|
+
labelClass: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
6
15
|
export declare class Legend {
|
|
7
16
|
static readonly objectClass = "legend-object";
|
|
8
17
|
static readonly labelClass = "legend-label";
|
|
9
18
|
static readonly itemClass = "legend-item";
|
|
10
19
|
static readonly markerClass = "legend-circle";
|
|
11
|
-
|
|
20
|
+
static readonly legendBlockClass = "legend-block";
|
|
12
21
|
static render(block: Block, data: MdtChartsDataSource, options: TwoDimensionalOptionsModel | PolarOptionsModel | IntervalOptionsModel, model: Model): void;
|
|
13
22
|
static update(block: Block, data: MdtChartsDataSource, model: Model): void;
|
|
14
23
|
static updateColors(block: Block, options: TwoDimensionalOptionsModel | PolarOptionsModel | IntervalOptionsModel): void;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { select } from "d3-selection";
|
|
2
1
|
import { ColorReader } from "../../colorReader/colorReader";
|
|
3
2
|
import { SelectionCondition } from "../../helpers/domHelper";
|
|
4
3
|
import { LegendDomHelper } from "./legendDomHelper";
|
|
@@ -41,8 +40,8 @@ export class Legend {
|
|
|
41
40
|
static setContent(block, data, options, legendObject) {
|
|
42
41
|
const items = LegendHelper.getLegendItemsContent(options, data);
|
|
43
42
|
const colors = LegendHelper.getMarksColor(options, data[options.data.dataSource]);
|
|
44
|
-
const
|
|
45
|
-
const itemBlocks = this.renderContent(legendObject, items, colors,
|
|
43
|
+
const renderingOptions = LegendHelper.getContentRenderingOptions(options.type, options.legend.position);
|
|
44
|
+
const itemBlocks = this.renderContent(legendObject, items, colors, renderingOptions);
|
|
46
45
|
if (options.type === 'polar') {
|
|
47
46
|
LegendEventsManager.setListeners(block, options.data.keyField.name, itemBlocks, options.selectable);
|
|
48
47
|
}
|
|
@@ -58,36 +57,25 @@ export class Legend {
|
|
|
58
57
|
this.fillCoordinate(legendObject, legendCoordinate);
|
|
59
58
|
return legendObject;
|
|
60
59
|
}
|
|
61
|
-
static renderContent(
|
|
62
|
-
const wrapper =
|
|
63
|
-
|
|
64
|
-
wrapper
|
|
65
|
-
.style('height', '100%')
|
|
66
|
-
.style('display', 'flex');
|
|
67
|
-
if (itemsDirection === 'column') {
|
|
68
|
-
wrapper.style('flex-direction', 'column');
|
|
69
|
-
if (position === 'right')
|
|
70
|
-
wrapper.style('justify-content', 'center');
|
|
71
|
-
}
|
|
60
|
+
static renderContent(foreignObject, items, colorPalette, options) {
|
|
61
|
+
const wrapper = foreignObject.append('xhtml:div');
|
|
62
|
+
wrapper.classed(options.wrapperClasses.join(" "), true);
|
|
72
63
|
const itemWrappers = wrapper
|
|
73
64
|
.selectAll(`.${this.itemClass}`)
|
|
74
65
|
.data(items)
|
|
75
66
|
.enter()
|
|
76
67
|
.append('div');
|
|
77
|
-
|
|
78
|
-
itemWrappers.each(function (d, i) {
|
|
79
|
-
select(this).attr('class', `${thisClass.itemClass} ${LegendHelper.getItemClasses(itemsDirection, position, i)}`);
|
|
80
|
-
});
|
|
68
|
+
itemWrappers.classed(options.itemsOptions.wrapperClasses.join(" "), true);
|
|
81
69
|
itemWrappers
|
|
82
70
|
.append('span')
|
|
83
|
-
.
|
|
71
|
+
.classed(options.itemsOptions.markerClass, true);
|
|
84
72
|
LegendDomHelper.setItemsColors(itemWrappers, colorPalette);
|
|
85
73
|
itemWrappers
|
|
86
74
|
.append('span')
|
|
87
|
-
.attr('class',
|
|
75
|
+
.attr('class', options.itemsOptions.labelClass)
|
|
88
76
|
.text(d => d);
|
|
89
|
-
if (
|
|
90
|
-
LegendDomHelper.cropRowLabels(
|
|
77
|
+
if (options.shouldCropLabels)
|
|
78
|
+
LegendDomHelper.cropRowLabels(foreignObject, itemWrappers);
|
|
91
79
|
return itemWrappers;
|
|
92
80
|
}
|
|
93
81
|
static getObject(block) {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ChartNotation, MdtChartsDataRow, MdtChartsDataSource, Size } from "../../../config/config";
|
|
2
2
|
import { LegendItemsDirection } from "../../../model/featuresModel/legendModel/legendCanvasModel";
|
|
3
3
|
import { IntervalOptionsModel, LegendBlockModel, LegendPosition, Orient, PolarOptionsModel, TwoDimensionalOptionsModel } from "../../../model/model";
|
|
4
|
+
import { LegendContentRenderingOptions } from "./legend";
|
|
5
|
+
import { LegendHelperService } from "./legendHelperService";
|
|
4
6
|
export interface LegendCoordinate {
|
|
5
7
|
x: number;
|
|
6
8
|
y: number;
|
|
@@ -8,14 +10,11 @@ export interface LegendCoordinate {
|
|
|
8
10
|
width: number;
|
|
9
11
|
}
|
|
10
12
|
export declare class LegendHelper {
|
|
13
|
+
static service: LegendHelperService;
|
|
11
14
|
static getLegendItemsContent(options: TwoDimensionalOptionsModel | PolarOptionsModel | IntervalOptionsModel, data: MdtChartsDataSource): string[];
|
|
12
15
|
static getMarksColor(options: TwoDimensionalOptionsModel | PolarOptionsModel | IntervalOptionsModel, dataRows?: MdtChartsDataRow[]): string[];
|
|
13
16
|
static getMaxItemWidth(legendBlockWidth: string, marginsLeft: number[], itemsDirection: LegendItemsDirection): number;
|
|
14
|
-
static getItemClasses(itemsDirection: LegendItemsDirection, position: LegendPosition, index: number): string;
|
|
15
|
-
static getLegendItemClassByDirection(itemsDirection: LegendItemsDirection): string;
|
|
16
|
-
static getLegendItemsMarginClass(legendPosition: LegendPosition): string;
|
|
17
|
-
static getLegendLabelClassByPosition(position: LegendPosition): string;
|
|
18
|
-
static getLegendItemsDirection(chartNotation: ChartNotation, legendPosition: LegendPosition): LegendItemsDirection;
|
|
19
17
|
static getSumOfItemsWidths(itemsWidth: number[], marginsLeft: number[]): number;
|
|
20
18
|
static getLegendCoordinateByPosition(legendPosition: Orient, legendBlockModel: LegendBlockModel, blockSize: Size): LegendCoordinate;
|
|
19
|
+
static getContentRenderingOptions(chartNotation: ChartNotation, legendPosition: LegendPosition): LegendContentRenderingOptions;
|
|
21
20
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Helper } from '../../helpers/helper';
|
|
2
2
|
import { Legend } from "./legend";
|
|
3
|
+
import { LegendHelperService } from "./legendHelperService";
|
|
3
4
|
export class LegendHelper {
|
|
4
5
|
static getLegendItemsContent(options, data) {
|
|
5
6
|
if (options.type === '2d') {
|
|
@@ -40,29 +41,6 @@ export class LegendHelper {
|
|
|
40
41
|
}
|
|
41
42
|
return parseFloat(legendBlockWidth);
|
|
42
43
|
}
|
|
43
|
-
static getItemClasses(itemsDirection, position, index) {
|
|
44
|
-
let cssClasses = this.getLegendItemClassByDirection(itemsDirection);
|
|
45
|
-
if (itemsDirection === 'column' && index !== 0)
|
|
46
|
-
cssClasses += ` ${this.getLegendItemsMarginClass(position)}`;
|
|
47
|
-
return cssClasses;
|
|
48
|
-
}
|
|
49
|
-
static getLegendItemClassByDirection(itemsDirection) {
|
|
50
|
-
return itemsDirection === 'column' ? 'legend-item-row' : 'legend-item-inline';
|
|
51
|
-
}
|
|
52
|
-
static getLegendItemsMarginClass(legendPosition) {
|
|
53
|
-
return legendPosition === 'right' ? 'mt-15' : 'mt-10';
|
|
54
|
-
}
|
|
55
|
-
static getLegendLabelClassByPosition(position) {
|
|
56
|
-
if (position === 'top' || position === 'bottom')
|
|
57
|
-
return `${Legend.labelClass} ${Legend.labelClass + '-nowrap'}`;
|
|
58
|
-
return Legend.labelClass;
|
|
59
|
-
}
|
|
60
|
-
static getLegendItemsDirection(chartNotation, legendPosition) {
|
|
61
|
-
if (legendPosition === 'right' || legendPosition === 'left')
|
|
62
|
-
return 'column';
|
|
63
|
-
else
|
|
64
|
-
return chartNotation === 'polar' ? 'column' : 'row';
|
|
65
|
-
}
|
|
66
44
|
static getSumOfItemsWidths(itemsWidth, marginsLeft) {
|
|
67
45
|
let sumOfItemsWidth = Helper.getSumOfNumeric(itemsWidth);
|
|
68
46
|
sumOfItemsWidth += Helper.getSumOfNumeric(marginsLeft);
|
|
@@ -96,4 +74,22 @@ export class LegendHelper {
|
|
|
96
74
|
coordinate.y = blockSize.height - legendModel.size - legendModel.margin.bottom;
|
|
97
75
|
return coordinate;
|
|
98
76
|
}
|
|
77
|
+
static getContentRenderingOptions(chartNotation, legendPosition) {
|
|
78
|
+
const itemsDirection = this.service.getLegendItemsDirection(legendPosition);
|
|
79
|
+
return {
|
|
80
|
+
wrapperClasses: [
|
|
81
|
+
Legend.legendBlockClass,
|
|
82
|
+
this.service.getWrapperClassByItemsDirection(itemsDirection),
|
|
83
|
+
this.service.getWrapperJustifyContentClass(itemsDirection, legendPosition),
|
|
84
|
+
this.service.getWrapperClassByWrappingItems(legendPosition, chartNotation)
|
|
85
|
+
],
|
|
86
|
+
shouldCropLabels: chartNotation === "2d",
|
|
87
|
+
itemsOptions: {
|
|
88
|
+
markerClass: Legend.markerClass,
|
|
89
|
+
labelClass: this.service.getLegendLabelClassByPosition(legendPosition, chartNotation, Legend.labelClass),
|
|
90
|
+
wrapperClasses: [Legend.itemClass, this.service.getItemClasses(itemsDirection)]
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
}
|
|
99
94
|
}
|
|
95
|
+
LegendHelper.service = new LegendHelperService();
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ChartNotation } from "../../../config/config";
|
|
2
|
+
import { LegendItemsDirection } from "../../../model/featuresModel/legendModel/legendCanvasModel";
|
|
3
|
+
import { LegendPosition } from "../../../model/model";
|
|
4
|
+
export declare class LegendHelperService {
|
|
5
|
+
getWrapperClassByItemsDirection(itemsDirection: LegendItemsDirection): "legend-block-column" | "legend-block-row";
|
|
6
|
+
getWrapperJustifyContentClass(itemsDirection: LegendItemsDirection, legendPosition: LegendPosition): "" | "legend-block-centered";
|
|
7
|
+
getWrapperClassByWrappingItems(legendPosition: LegendPosition, chartNotation: ChartNotation): "legend-wrapper-with-wrap" | "legend-wrapper-without-wrap";
|
|
8
|
+
getLegendLabelClassByPosition(legendPosition: LegendPosition, chartNotation: ChartNotation, initialLabelClass: string): string;
|
|
9
|
+
getItemClasses(itemsDirection: LegendItemsDirection): string;
|
|
10
|
+
getLegendItemsDirection(legendPosition: LegendPosition): LegendItemsDirection;
|
|
11
|
+
private doesLegendInTopBy2d;
|
|
12
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export class LegendHelperService {
|
|
2
|
+
getWrapperClassByItemsDirection(itemsDirection) {
|
|
3
|
+
return itemsDirection === "column" ? "legend-block-column" : "legend-block-row";
|
|
4
|
+
}
|
|
5
|
+
getWrapperJustifyContentClass(itemsDirection, legendPosition) {
|
|
6
|
+
return itemsDirection === "column" && legendPosition === "right" ? "legend-block-centered" : "";
|
|
7
|
+
}
|
|
8
|
+
getWrapperClassByWrappingItems(legendPosition, chartNotation) {
|
|
9
|
+
if (this.doesLegendInTopBy2d(legendPosition, chartNotation)) {
|
|
10
|
+
return "legend-wrapper-without-wrap";
|
|
11
|
+
}
|
|
12
|
+
return "legend-wrapper-with-wrap";
|
|
13
|
+
}
|
|
14
|
+
getLegendLabelClassByPosition(legendPosition, chartNotation, initialLabelClass) {
|
|
15
|
+
if (this.doesLegendInTopBy2d(legendPosition, chartNotation))
|
|
16
|
+
return `${initialLabelClass} ${initialLabelClass + '-nowrap'}`;
|
|
17
|
+
return initialLabelClass;
|
|
18
|
+
}
|
|
19
|
+
getItemClasses(itemsDirection) {
|
|
20
|
+
return itemsDirection === 'column' ? 'legend-item-row' : 'legend-item-inline';
|
|
21
|
+
}
|
|
22
|
+
getLegendItemsDirection(legendPosition) {
|
|
23
|
+
if (legendPosition === 'right' || legendPosition === 'left')
|
|
24
|
+
return 'column';
|
|
25
|
+
return "row";
|
|
26
|
+
}
|
|
27
|
+
doesLegendInTopBy2d(legendPosition, chartNotation) {
|
|
28
|
+
return legendPosition === 'top' && chartNotation === "2d";
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Block } from "../../block/block";
|
|
2
|
+
export interface RecordOverflowAlertOptions {
|
|
3
|
+
hidedRecordsAmount: number;
|
|
4
|
+
text: RecordOverflowAlertText;
|
|
5
|
+
positionAttrs: AlertBlockPositionAttrs;
|
|
6
|
+
}
|
|
7
|
+
export interface RecordOverflowAlertText {
|
|
8
|
+
one: string;
|
|
9
|
+
twoToFour: string;
|
|
10
|
+
tenToTwenty: string;
|
|
11
|
+
other: string;
|
|
12
|
+
}
|
|
13
|
+
export interface AlertBlockPositionAttrs {
|
|
14
|
+
top?: string;
|
|
15
|
+
bottom?: string;
|
|
16
|
+
right?: string;
|
|
17
|
+
left?: string;
|
|
18
|
+
}
|
|
19
|
+
declare class RecordOverflowAlertCoreClass {
|
|
20
|
+
private readonly blockClass;
|
|
21
|
+
render(block: Block, options: RecordOverflowAlertOptions): void;
|
|
22
|
+
update(block: Block, options: RecordOverflowAlertOptions): void;
|
|
23
|
+
private getAlertText;
|
|
24
|
+
private getWordTextEndingByAmount;
|
|
25
|
+
private setAlertPosition;
|
|
26
|
+
}
|
|
27
|
+
export declare const RecordOverflowAlertCore: RecordOverflowAlertCoreClass;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
class RecordOverflowAlertCoreClass {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.blockClass = 'record-overflow-alert';
|
|
4
|
+
}
|
|
5
|
+
render(block, options) {
|
|
6
|
+
const alertBlock = block.getWrapper()
|
|
7
|
+
.append('div')
|
|
8
|
+
.attr('class', this.blockClass)
|
|
9
|
+
.text(this.getAlertText(options));
|
|
10
|
+
this.setAlertPosition(alertBlock, options.positionAttrs);
|
|
11
|
+
}
|
|
12
|
+
update(block, options) {
|
|
13
|
+
let alertBlock = block.getWrapper()
|
|
14
|
+
.select(`div.${this.blockClass}`);
|
|
15
|
+
if (alertBlock.empty()) {
|
|
16
|
+
if (options.hidedRecordsAmount === 0)
|
|
17
|
+
return;
|
|
18
|
+
else
|
|
19
|
+
this.render(block, options);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
if (options.hidedRecordsAmount === 0)
|
|
23
|
+
alertBlock.remove();
|
|
24
|
+
else
|
|
25
|
+
alertBlock.text(this.getAlertText(options));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
getAlertText(options) {
|
|
29
|
+
return `+ ${options.hidedRecordsAmount} ${this.getWordTextEndingByAmount(options.hidedRecordsAmount, options.text)}`;
|
|
30
|
+
}
|
|
31
|
+
getWordTextEndingByAmount(hidedRecordsAmount, text) {
|
|
32
|
+
const lastDigit = hidedRecordsAmount % 10;
|
|
33
|
+
if (hidedRecordsAmount >= 10 && hidedRecordsAmount <= 20)
|
|
34
|
+
return text.tenToTwenty;
|
|
35
|
+
if (lastDigit === 1)
|
|
36
|
+
return text.one;
|
|
37
|
+
if (lastDigit >= 2 && lastDigit <= 4)
|
|
38
|
+
return text.twoToFour;
|
|
39
|
+
return text.other;
|
|
40
|
+
}
|
|
41
|
+
setAlertPosition(alertBlock, attrs) {
|
|
42
|
+
alertBlock
|
|
43
|
+
.style('position', 'absolute')
|
|
44
|
+
.style('left', attrs.left)
|
|
45
|
+
.style('right', attrs.right)
|
|
46
|
+
.style('top', attrs.top)
|
|
47
|
+
.style('bottom', attrs.bottom);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export const RecordOverflowAlertCore = new RecordOverflowAlertCoreClass();
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Axis } from "../features/axis/axis";
|
|
2
2
|
import { GridLine } from "../features/gridLine/gridLine";
|
|
3
3
|
import { Legend } from "../features/legend/legend";
|
|
4
|
-
import { RecordOverflowAlert } from "../features/recordOverflowAlert/recordOverflowAlert";
|
|
5
4
|
import { Scale } from "../features/scale/scale";
|
|
6
5
|
import { Title } from "../features/title/title";
|
|
7
6
|
import { Tooltip } from "../features/tolltip/tooltip";
|
|
@@ -17,8 +16,6 @@ export class IntervalManager {
|
|
|
17
16
|
Title.render(block, options.title, model.otherComponents.titleBlock, model.blockCanvas.size);
|
|
18
17
|
Legend.render(block, data, options, model);
|
|
19
18
|
Tooltip.render(block, model, data, model.otherComponents.tooltipBlock, scales);
|
|
20
|
-
if (model.dataSettings.scope.hidedRecordsAmount !== 0)
|
|
21
|
-
RecordOverflowAlert.render(block, model.dataSettings.scope.hidedRecordsAmount, 'top', options.orient);
|
|
22
19
|
}
|
|
23
20
|
static renderCharts(block, charts, scales, data, dataOptions, margin, keyAxisOrient, chartSettings) {
|
|
24
21
|
block.renderChartsBlock();
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { LegendPosition } from "../../../model/model";
|
|
2
|
+
import { Block } from "../../block/block";
|
|
3
|
+
interface PolarRecordOverflowAlertOptions {
|
|
4
|
+
hidedRecordsAmount: number;
|
|
5
|
+
legendPosition: LegendPosition;
|
|
6
|
+
}
|
|
7
|
+
declare class PolarRecordOverflowAlertClass {
|
|
8
|
+
private readonly text;
|
|
9
|
+
render(block: Block, options: PolarRecordOverflowAlertOptions): void;
|
|
10
|
+
update(block: Block, options: PolarRecordOverflowAlertOptions): void;
|
|
11
|
+
private buildCoreOptions;
|
|
12
|
+
private getPositionAttrs;
|
|
13
|
+
}
|
|
14
|
+
export declare const PolarRecordOverflowAlert: PolarRecordOverflowAlertClass;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { RecordOverflowAlertCore } from "../../features/recordOverflowAlert/recordOverflowAlertCore";
|
|
2
|
+
class PolarRecordOverflowAlertClass {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.text = {
|
|
5
|
+
one: 'категория',
|
|
6
|
+
twoToFour: 'категории',
|
|
7
|
+
tenToTwenty: 'категорий',
|
|
8
|
+
other: 'категорий'
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
render(block, options) {
|
|
12
|
+
RecordOverflowAlertCore.render(block, this.buildCoreOptions(options));
|
|
13
|
+
}
|
|
14
|
+
update(block, options) {
|
|
15
|
+
RecordOverflowAlertCore.update(block, this.buildCoreOptions(options));
|
|
16
|
+
}
|
|
17
|
+
buildCoreOptions(options) {
|
|
18
|
+
return {
|
|
19
|
+
hidedRecordsAmount: options.hidedRecordsAmount,
|
|
20
|
+
text: this.text,
|
|
21
|
+
positionAttrs: this.getPositionAttrs(options)
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
getPositionAttrs(options) {
|
|
25
|
+
const position = options.legendPosition === 'off' ? 'bottom' : options.legendPosition;
|
|
26
|
+
if (position === 'right') {
|
|
27
|
+
return {
|
|
28
|
+
bottom: '0',
|
|
29
|
+
right: '0'
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
if (position === 'bottom') {
|
|
33
|
+
return {
|
|
34
|
+
bottom: '0',
|
|
35
|
+
left: '0'
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export const PolarRecordOverflowAlert = new PolarRecordOverflowAlertClass();
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Legend } from "../features/legend/legend";
|
|
2
|
-
import { RecordOverflowAlert } from "../features/recordOverflowAlert/recordOverflowAlert";
|
|
3
2
|
import { Title } from "../features/title/title";
|
|
4
3
|
import { ElementHighlighter } from "../elementHighlighter/elementHighlighter";
|
|
5
4
|
import { Tooltip } from "../features/tolltip/tooltip";
|
|
6
5
|
import { Aggregator } from "../features/aggregator/aggregator";
|
|
7
6
|
import { Donut } from "./donut/donut";
|
|
7
|
+
import { PolarRecordOverflowAlert } from "./extenders/polarRecordOverflowAlert";
|
|
8
8
|
export class PolarManager {
|
|
9
9
|
static render(engine, model) {
|
|
10
10
|
const options = model.options;
|
|
@@ -14,8 +14,11 @@ export class PolarManager {
|
|
|
14
14
|
Legend.render(engine.block, engine.data, options, model);
|
|
15
15
|
Tooltip.render(engine.block, model, engine.data, model.otherComponents.tooltipBlock);
|
|
16
16
|
engine.block.filterEventManager.setListenerPolar(model.chartBlock.margin, model.blockCanvas.size, options);
|
|
17
|
-
if (model.dataSettings.scope.hidedRecordsAmount !== 0
|
|
18
|
-
|
|
17
|
+
if (model.dataSettings.scope.hidedRecordsAmount !== 0)
|
|
18
|
+
PolarRecordOverflowAlert.render(engine.block, {
|
|
19
|
+
hidedRecordsAmount: model.dataSettings.scope.hidedRecordsAmount,
|
|
20
|
+
legendPosition: model.options.legend.position
|
|
21
|
+
});
|
|
19
22
|
engine.block.getSvg()
|
|
20
23
|
.on('click', (e) => {
|
|
21
24
|
if (e.target === engine.block.getSvg().node())
|
|
@@ -38,8 +41,10 @@ export class PolarManager {
|
|
|
38
41
|
});
|
|
39
42
|
Aggregator.update(block, data[options.data.dataSource], options.charts[0].data.valueField, options.chartCanvas.aggregator);
|
|
40
43
|
Legend.update(block, data, model);
|
|
41
|
-
|
|
42
|
-
|
|
44
|
+
PolarRecordOverflowAlert.update(block, {
|
|
45
|
+
hidedRecordsAmount: model.dataSettings.scope.hidedRecordsAmount,
|
|
46
|
+
legendPosition: model.options.legend.position
|
|
47
|
+
});
|
|
43
48
|
}
|
|
44
49
|
static updateColors(block, model) {
|
|
45
50
|
Legend.updateColors(block, model.options);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ChartOrientation } from "../../../config/config";
|
|
2
|
+
import { Block } from "../../block/block";
|
|
3
|
+
interface TwoDimRecordOverflowAlertOptions {
|
|
4
|
+
hidedRecordsAmount: number;
|
|
5
|
+
chartOrientation: ChartOrientation;
|
|
6
|
+
}
|
|
7
|
+
declare class TwoDimRecordOverflowAlertClass {
|
|
8
|
+
render(block: Block, options: TwoDimRecordOverflowAlertOptions): void;
|
|
9
|
+
update(block: Block, options: TwoDimRecordOverflowAlertOptions): void;
|
|
10
|
+
private buildCoreOptions;
|
|
11
|
+
private getText;
|
|
12
|
+
private getPositionAttrs;
|
|
13
|
+
}
|
|
14
|
+
export declare const TwoDimRecordOverflowAlert: TwoDimRecordOverflowAlertClass;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { RecordOverflowAlertCore } from "../../features/recordOverflowAlert/recordOverflowAlertCore";
|
|
2
|
+
class TwoDimRecordOverflowAlertClass {
|
|
3
|
+
render(block, options) {
|
|
4
|
+
RecordOverflowAlertCore.render(block, this.buildCoreOptions(options));
|
|
5
|
+
}
|
|
6
|
+
update(block, options) {
|
|
7
|
+
RecordOverflowAlertCore.update(block, this.buildCoreOptions(options));
|
|
8
|
+
}
|
|
9
|
+
buildCoreOptions(options) {
|
|
10
|
+
return {
|
|
11
|
+
hidedRecordsAmount: options.hidedRecordsAmount,
|
|
12
|
+
text: this.getText(options.chartOrientation),
|
|
13
|
+
positionAttrs: this.getPositionAttrs()
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
getText(chartOrientation) {
|
|
17
|
+
const isHorizontal = chartOrientation === 'horizontal';
|
|
18
|
+
return {
|
|
19
|
+
one: isHorizontal ? 'строка' : 'столбец',
|
|
20
|
+
twoToFour: isHorizontal ? 'строки' : 'столбца',
|
|
21
|
+
tenToTwenty: isHorizontal ? 'строк' : 'столбцов',
|
|
22
|
+
other: isHorizontal ? 'строк' : 'столбцов'
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
getPositionAttrs() {
|
|
26
|
+
return {
|
|
27
|
+
right: '17px',
|
|
28
|
+
top: '1rem'
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export const TwoDimRecordOverflowAlert = new TwoDimRecordOverflowAlertClass();
|
|
@@ -3,7 +3,6 @@ import { Axis } from "../features/axis/axis";
|
|
|
3
3
|
import { EmbeddedLabels } from "../features/embeddedLabels/embeddedLabels";
|
|
4
4
|
import { GridLine } from "../features/gridLine/gridLine";
|
|
5
5
|
import { Legend } from "../features/legend/legend";
|
|
6
|
-
import { RecordOverflowAlert } from "../features/recordOverflowAlert/recordOverflowAlert";
|
|
7
6
|
import { Scale } from "../features/scale/scale";
|
|
8
7
|
import { TipBox } from "../features/tipBox/tipBox";
|
|
9
8
|
import { Title } from "../features/title/title";
|
|
@@ -12,6 +11,7 @@ import { Helper } from "../helpers/helper";
|
|
|
12
11
|
import { Area } from "./area/area";
|
|
13
12
|
import { Bar } from "./bar/bar";
|
|
14
13
|
import { BarHelper } from "./bar/barHelper";
|
|
14
|
+
import { TwoDimRecordOverflowAlert } from "./extenders/twoDimRecordOverflowAlert";
|
|
15
15
|
import { Line } from "./line/line";
|
|
16
16
|
export class TwoDimensionalManager {
|
|
17
17
|
static render(engine, model) {
|
|
@@ -28,7 +28,10 @@ export class TwoDimensionalManager {
|
|
|
28
28
|
Legend.render(engine.block, engine.data, options, model);
|
|
29
29
|
Tooltip.render(engine.block, model, engine.data, model.otherComponents.tooltipBlock, scales);
|
|
30
30
|
if (model.dataSettings.scope.hidedRecordsAmount !== 0)
|
|
31
|
-
|
|
31
|
+
TwoDimRecordOverflowAlert.render(engine.block, {
|
|
32
|
+
hidedRecordsAmount: model.dataSettings.scope.hidedRecordsAmount,
|
|
33
|
+
chartOrientation: options.orient
|
|
34
|
+
});
|
|
32
35
|
engine.block.getSvg()
|
|
33
36
|
.on('click', (e) => {
|
|
34
37
|
if (e.target === engine.block.getSvg().node())
|
|
@@ -54,7 +57,10 @@ export class TwoDimensionalManager {
|
|
|
54
57
|
block.filterEventManager.registerEventFor2D(scales.key, model.chartBlock.margin, model.blockCanvas.size, options);
|
|
55
58
|
Tooltip.render(block, model, data, model.otherComponents.tooltipBlock, scales);
|
|
56
59
|
});
|
|
57
|
-
|
|
60
|
+
TwoDimRecordOverflowAlert.update(block, {
|
|
61
|
+
hidedRecordsAmount: model.dataSettings.scope.hidedRecordsAmount,
|
|
62
|
+
chartOrientation: options.orient
|
|
63
|
+
});
|
|
58
64
|
}
|
|
59
65
|
static updateColors(block, model) {
|
|
60
66
|
Legend.updateColors(block, model.options);
|
|
@@ -1,13 +1,24 @@
|
|
|
1
|
-
import { MdtChartsConfig, MdtChartsDataSource } from "
|
|
2
|
-
import { DesignerConfig } from "
|
|
3
|
-
import {
|
|
4
|
-
import { ModelInstance } from "
|
|
1
|
+
import { MdtChartsConfig, MdtChartsDataSource } from "../../config/config";
|
|
2
|
+
import { DesignerConfig } from "../../designer/designerConfig";
|
|
3
|
+
import { LegendBlockModel } from "../model";
|
|
4
|
+
import { ModelInstance } from "../modelInstance/modelInstance";
|
|
5
|
+
export interface DataLegendParams {
|
|
6
|
+
amount: number;
|
|
7
|
+
size: {
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
5
12
|
export declare class DataManagerModel {
|
|
13
|
+
private static service;
|
|
6
14
|
static getPreparedData(data: MdtChartsDataSource, allowableKeys: string[], config: MdtChartsConfig): MdtChartsDataSource;
|
|
7
|
-
static
|
|
15
|
+
static initDataScope(config: MdtChartsConfig, data: MdtChartsDataSource, designerConfig: DesignerConfig, legendBlock: LegendBlockModel, modelInstance: ModelInstance): void;
|
|
8
16
|
static getDataValuesByKeyField(data: MdtChartsDataSource, dataSourceName: string, keyFieldName: string): string[];
|
|
9
|
-
private static
|
|
10
|
-
private static
|
|
17
|
+
private static initDataScopeFor2D;
|
|
18
|
+
private static initDataScopeForPolar;
|
|
19
|
+
private static getLegendDataParams;
|
|
20
|
+
private static getMaximumPossibleScope;
|
|
21
|
+
private static limitAllowableKeys;
|
|
11
22
|
/**
|
|
12
23
|
* Выводит количество элементов (преимущественно баров) в одной группе. Группа - один ключ
|
|
13
24
|
* @param configOptions
|