mdt-charts 1.41.1 → 1.43.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 +9 -8
- package/lib/engine/polarNotation/donut/donut.js +6 -4
- package/lib/engine/{sunburstNotation/sunburstSegmentLabel.d.ts → polarNotation/polarLikeSegmentLabel/polarLikeSegmentLabel.d.ts} +8 -4
- package/lib/engine/{sunburstNotation/sunburstSegmentLabel.js → polarNotation/polarLikeSegmentLabel/polarLikeSegmentLabel.js} +21 -10
- package/lib/engine/sunburstNotation/sunburst.js +8 -4
- package/lib/engine/sunburstNotation/sunburstHighlightState/sunburstHighlightState.d.ts +3 -3
- package/lib/engine/sunburstNotation/sunburstHighlightState/sunburstHighlightState.js +2 -2
- package/lib/engine/sunburstNotation/sunburstSegmentEventDispatcher.d.ts +5 -5
- package/lib/model/dataManagerModel/dataManagerModel.js +1 -1
- package/lib/model/featuresModel/grouping/groupingLabels/staticCoordinateCalculator.d.ts +2 -1
- package/lib/model/featuresModel/grouping/groupingLabels/staticCoordinateCalculator.js +9 -2
- package/lib/model/featuresModel/legendModel/legendCanvasModel.d.ts +1 -1
- package/lib/model/featuresModel/legendModel/legendCanvasModel.js +9 -7
- package/lib/model/featuresModel/legendModel/legendModel.d.ts +6 -1
- package/lib/model/featuresModel/legendModel/legendModel.js +31 -1
- package/lib/model/featuresModel/legendModel/polarLikeLegendParamsBuilder.d.ts +3 -3
- package/lib/model/featuresModel/legendModel/polarLikeLegendParamsBuilder.js +9 -17
- package/lib/model/featuresModel/legendModel/polarMarginCalculator.d.ts +2 -4
- package/lib/model/featuresModel/legendModel/polarMarginCalculator.js +2 -11
- package/lib/model/featuresModel/legendModel/twoDimLegendModel.d.ts +3 -2
- package/lib/model/featuresModel/legendModel/twoDimLegendModel.js +14 -13
- package/lib/model/margin/sunburst/sunburstMarginModel.js +4 -3
- package/lib/model/margin/twoDim/twoDimMarginModel.js +1 -1
- package/lib/model/model.d.ts +8 -1
- package/lib/model/modelInstance/configReader/configReaderFactory.js +1 -1
- package/lib/model/modelInstance/configReader/sunburstConifgReader/sunburstConifgReader.d.ts +9 -4
- package/lib/model/modelInstance/configReader/sunburstConifgReader/sunburstConifgReader.js +15 -4
- package/lib/model/notations/polar/polarModel.d.ts +2 -2
- package/lib/model/notations/polar/polarModel.js +0 -1
- package/lib/model/notations/sunburst/sunburstLegendValuesExtractor.d.ts +1 -1
- package/lib/model/notations/sunburst/sunburstLegendValuesExtractor.js +10 -6
- package/lib/model/notations/sunburst/sunburstModel.js +16 -8
- package/lib/model/notations/twoDimensionalModel.js +2 -1
- package/package.json +1 -1
package/lib/config/config.d.ts
CHANGED
|
@@ -44,7 +44,7 @@ interface GraphicNotationOptions {
|
|
|
44
44
|
}
|
|
45
45
|
export interface MdtChartsTwoDimensionalOptions extends GraphicNotationOptions {
|
|
46
46
|
type: "2d";
|
|
47
|
-
legend:
|
|
47
|
+
legend: LegendConfig;
|
|
48
48
|
axis: TwoDimensionalAxis;
|
|
49
49
|
additionalElements: AdditionalElements;
|
|
50
50
|
charts: MdtChartsTwoDimensionalChart[];
|
|
@@ -74,14 +74,14 @@ export interface CanvasKeyItemOptions {
|
|
|
74
74
|
export declare type PolarChartType = DonutChart["type"];
|
|
75
75
|
export interface MdtChartsPolarOptions extends GraphicNotationOptions {
|
|
76
76
|
type: "polar";
|
|
77
|
-
legend:
|
|
77
|
+
legend: LegendConfig;
|
|
78
78
|
chart: DonutChart;
|
|
79
79
|
}
|
|
80
80
|
export interface MdtChartsSunburstOptions {
|
|
81
81
|
type: "sunburst";
|
|
82
82
|
title?: Title;
|
|
83
83
|
selectable?: boolean;
|
|
84
|
-
legend?:
|
|
84
|
+
legend?: LegendConfig;
|
|
85
85
|
aggregator?: MdtChartsDonutAggregator;
|
|
86
86
|
data: {
|
|
87
87
|
dataSource: string;
|
|
@@ -106,14 +106,15 @@ export interface MdtChartsSunburstLevel {
|
|
|
106
106
|
thickness?: MdtChartsDonutThicknessOptions;
|
|
107
107
|
};
|
|
108
108
|
valueLabels?: SunburstChartValueLabelsConfig;
|
|
109
|
+
legend?: {
|
|
110
|
+
show: boolean;
|
|
111
|
+
};
|
|
109
112
|
}
|
|
110
|
-
export interface
|
|
113
|
+
export interface LegendConfig {
|
|
111
114
|
show: boolean;
|
|
115
|
+
position?: LegendPublicPosition;
|
|
112
116
|
}
|
|
113
|
-
export declare type
|
|
114
|
-
export interface MdtChartsTwoDimLegend extends Legend {
|
|
115
|
-
position?: TwoDimLegendPosition;
|
|
116
|
-
}
|
|
117
|
+
export declare type LegendPublicPosition = "top" | "bottom" | "left" | "right";
|
|
117
118
|
export interface RecordOverflowAlertOptions {
|
|
118
119
|
textContent: RecordOverflowBlockTextContent;
|
|
119
120
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { interpolate } from "d3-interpolate";
|
|
2
2
|
import { DonutHelper } from "./donutHelper";
|
|
3
3
|
import { DomSelectionHelper } from "../../helpers/domSelectionHelper";
|
|
4
|
-
import {
|
|
4
|
+
import { PolarLikeSegmentLabel } from "../polarLikeSegmentLabel/polarLikeSegmentLabel";
|
|
5
5
|
export class Donut {
|
|
6
6
|
static getAllArcGroups(block) {
|
|
7
7
|
return block.getSvg().selectAll(`.${this.arcItemClass}`);
|
|
@@ -25,13 +25,14 @@ export class Donut {
|
|
|
25
25
|
this.renderNewArcItems(arcGenerator, pieGenerator, donutBlock, chart.data.segments, chart.cssClasses);
|
|
26
26
|
this.renderClonesG(donutBlock);
|
|
27
27
|
if (chart.valueLabels.on) {
|
|
28
|
-
this.segmentLabels = new
|
|
28
|
+
this.segmentLabels = new PolarLikeSegmentLabel(block);
|
|
29
29
|
this.segmentLabels.render({
|
|
30
30
|
sizesForGenerators: {
|
|
31
31
|
innerRadius: chart.sizes.innerRadius,
|
|
32
32
|
outerRadius: chart.sizes.outerRadius,
|
|
33
33
|
padAngle: settings.padAngle
|
|
34
|
-
}
|
|
34
|
+
},
|
|
35
|
+
wrapperTranslate: chart.sizes.translate
|
|
35
36
|
}, chart.valueLabels.items);
|
|
36
37
|
}
|
|
37
38
|
}
|
|
@@ -82,7 +83,8 @@ export class Donut {
|
|
|
82
83
|
innerRadius: chart.sizes.innerRadius,
|
|
83
84
|
outerRadius: chart.sizes.outerRadius,
|
|
84
85
|
padAngle: donutSettings.padAngle
|
|
85
|
-
}
|
|
86
|
+
},
|
|
87
|
+
wrapperTranslate: chart.sizes.translate
|
|
86
88
|
}, chart.valueLabels.items, block.transitionManager.durations.chartUpdate).then((labels) => labels.raise());
|
|
87
89
|
promises.push(updateLabelsPromise);
|
|
88
90
|
}
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import { PieArcDatum } from "d3-shape";
|
|
2
2
|
import { BaseType, Selection } from "d3-selection";
|
|
3
|
-
import { PolarSegmentLabelDataItem } from "
|
|
3
|
+
import { PolarSegmentLabelDataItem } from "../../../model/modelTypes/valueLabelsModel";
|
|
4
|
+
import { DonutChartTranslateModel } from "../../../model/model";
|
|
5
|
+
import { Block } from "../../block/block";
|
|
4
6
|
interface SunburstSegmentLabelOptions {
|
|
5
7
|
sizesForGenerators: {
|
|
6
8
|
innerRadius: number;
|
|
7
9
|
outerRadius: number;
|
|
8
10
|
padAngle?: number;
|
|
9
11
|
};
|
|
12
|
+
wrapperTranslate: DonutChartTranslateModel;
|
|
10
13
|
}
|
|
11
|
-
export declare class
|
|
12
|
-
private readonly
|
|
14
|
+
export declare class PolarLikeSegmentLabel {
|
|
15
|
+
private readonly block;
|
|
13
16
|
private static readonly arcLabelClass;
|
|
14
|
-
|
|
17
|
+
private readonly wrapperCssClassName;
|
|
18
|
+
constructor(block: Block, index?: number);
|
|
15
19
|
render(options: SunburstSegmentLabelOptions, segments: PolarSegmentLabelDataItem[]): void;
|
|
16
20
|
update(options: SunburstSegmentLabelOptions, segments: PolarSegmentLabelDataItem[], animationDuration: number): Promise<Selection<SVGTextElement, PieArcDatum<PolarSegmentLabelDataItem>, BaseType, unknown>>;
|
|
17
21
|
private getTransformAttrValue;
|
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
import { arc, pie } from "d3-shape";
|
|
2
2
|
import { select } from "d3-selection";
|
|
3
3
|
import { interpolate } from "d3-interpolate";
|
|
4
|
-
import { DonutHelper } from "../
|
|
5
|
-
export class
|
|
6
|
-
constructor(
|
|
7
|
-
this.
|
|
4
|
+
import { DonutHelper } from "../donut/donutHelper";
|
|
5
|
+
export class PolarLikeSegmentLabel {
|
|
6
|
+
constructor(block, index = 0) {
|
|
7
|
+
this.block = block;
|
|
8
|
+
this.wrapperCssClassName = `mdt-charts-donut-label-wrapper-${index}`;
|
|
8
9
|
}
|
|
9
10
|
render(options, segments) {
|
|
10
11
|
const { arcGenerator, pieGenerator } = this.getGenerators(options);
|
|
11
|
-
this.
|
|
12
|
+
let parentSelection = this.block.getSvg().select(`.${this.wrapperCssClassName}`);
|
|
13
|
+
if (parentSelection.empty()) {
|
|
14
|
+
parentSelection = this.block
|
|
15
|
+
.getSvg()
|
|
16
|
+
.append("g")
|
|
17
|
+
.classed(this.wrapperCssClassName, true)
|
|
18
|
+
.attr("transform", `translate(${options.wrapperTranslate.x}, ${options.wrapperTranslate.y})`);
|
|
19
|
+
}
|
|
20
|
+
parentSelection
|
|
12
21
|
.selectAll("text")
|
|
13
22
|
.data(pieGenerator(segments), (d) => d.data.key)
|
|
14
23
|
.enter()
|
|
@@ -16,7 +25,7 @@ export class SunburstSegmentLabel {
|
|
|
16
25
|
.attr("transform", (d) => {
|
|
17
26
|
return this.getTransformAttrValue(arcGenerator, d);
|
|
18
27
|
})
|
|
19
|
-
.classed(
|
|
28
|
+
.classed(PolarLikeSegmentLabel.arcLabelClass, true)
|
|
20
29
|
.text((d) => d.data.textContent)
|
|
21
30
|
.each(function (d) {
|
|
22
31
|
if (d.data.cssClass)
|
|
@@ -25,17 +34,19 @@ export class SunburstSegmentLabel {
|
|
|
25
34
|
});
|
|
26
35
|
}
|
|
27
36
|
update(options, segments, animationDuration) {
|
|
28
|
-
const
|
|
37
|
+
const parentSelection = this.block.getSvg().select(`.${this.wrapperCssClassName}`);
|
|
38
|
+
parentSelection.attr("transform", `translate(${options.wrapperTranslate.x}, ${options.wrapperTranslate.y})`);
|
|
39
|
+
const oldLabels = parentSelection
|
|
29
40
|
.selectAll("text")
|
|
30
41
|
.data()
|
|
31
42
|
.map((d) => d.data);
|
|
32
43
|
const valueLabelsZeroRows = DonutHelper.mergeDataWithZeros(segments, oldLabels);
|
|
33
44
|
this.render(options, segments);
|
|
34
45
|
const { arcGenerator, pieGenerator } = this.getGenerators(options);
|
|
35
|
-
const labelsNewAndOld =
|
|
46
|
+
const labelsNewAndOld = parentSelection
|
|
36
47
|
.selectAll("text")
|
|
37
48
|
.data(pieGenerator(valueLabelsZeroRows), (d) => d.data.key);
|
|
38
|
-
const onlyNewLabels =
|
|
49
|
+
const onlyNewLabels = parentSelection
|
|
39
50
|
.selectAll("text")
|
|
40
51
|
.data(pieGenerator(segments), (d) => d.data.key);
|
|
41
52
|
onlyNewLabels.text((d) => d.data.textContent);
|
|
@@ -83,4 +94,4 @@ export class SunburstSegmentLabel {
|
|
|
83
94
|
return { arcGenerator, pieGenerator };
|
|
84
95
|
}
|
|
85
96
|
}
|
|
86
|
-
|
|
97
|
+
PolarLikeSegmentLabel.arcLabelClass = "mdt-charts-arc-label";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { arc, pie } from "d3-shape";
|
|
2
2
|
import { merge } from "d3-array";
|
|
3
3
|
import { interpolate } from "d3-interpolate";
|
|
4
|
-
import {
|
|
4
|
+
import { PolarLikeSegmentLabel } from "../polarNotation/polarLikeSegmentLabel/polarLikeSegmentLabel";
|
|
5
5
|
export class Sunburst {
|
|
6
6
|
constructor(block) {
|
|
7
7
|
this.block = block;
|
|
@@ -28,14 +28,17 @@ export class Sunburst {
|
|
|
28
28
|
.attr("y", level.sizes.translate.y)
|
|
29
29
|
.attr("transform", `translate(${level.sizes.translate.x}, ${level.sizes.translate.y})`);
|
|
30
30
|
this.renderNewArcItems(levelDonutBlock, pieGenerator, arcGenerator, level.segments);
|
|
31
|
+
});
|
|
32
|
+
levels.forEach((level, levelIndex) => {
|
|
31
33
|
if (level.valueLabels.on) {
|
|
32
|
-
this.sunburstSegmentLabels[levelIndex] = new
|
|
34
|
+
this.sunburstSegmentLabels[levelIndex] = new PolarLikeSegmentLabel(this.block, levelIndex);
|
|
33
35
|
this.sunburstSegmentLabels[levelIndex].render({
|
|
34
36
|
sizesForGenerators: {
|
|
35
37
|
innerRadius: level.sizes.innerRadius,
|
|
36
38
|
outerRadius: level.sizes.outerRadius,
|
|
37
39
|
padAngle: this.pagAngle
|
|
38
|
-
}
|
|
40
|
+
},
|
|
41
|
+
wrapperTranslate: level.sizes.translate
|
|
39
42
|
}, level.valueLabels.items);
|
|
40
43
|
}
|
|
41
44
|
});
|
|
@@ -85,7 +88,8 @@ export class Sunburst {
|
|
|
85
88
|
innerRadius: level.sizes.innerRadius,
|
|
86
89
|
outerRadius: level.sizes.outerRadius,
|
|
87
90
|
padAngle: this.pagAngle
|
|
88
|
-
}
|
|
91
|
+
},
|
|
92
|
+
wrapperTranslate: level.sizes.translate
|
|
89
93
|
}, level.valueLabels.items, this.block.transitionManager.durations.chartUpdate)
|
|
90
94
|
.then(() => undefined);
|
|
91
95
|
promises.push(updateLabelsPromise);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SunburstLegendItemModel, SunburstLevel, SunburstLevelSegment } from "../../../model/model";
|
|
2
2
|
import { FilterCallback } from "../../filterManager/filterEventManager";
|
|
3
3
|
export declare class SunburstHighlightState {
|
|
4
4
|
private publicSelectEventCallback;
|
|
@@ -19,8 +19,8 @@ export declare class SunburstHighlightState {
|
|
|
19
19
|
setHoverHighlightedSegment(segment: SunburstLevelSegment): void;
|
|
20
20
|
clearHoverHighlightedSegment(): void;
|
|
21
21
|
changeSegmentSelection(segment: SunburstLevelSegment, multiMode: boolean): void;
|
|
22
|
-
setHoverSegmentLegendItem(legendItem:
|
|
23
|
-
changeLegendItemSelection(legendItem:
|
|
22
|
+
setHoverSegmentLegendItem(legendItem: SunburstLegendItemModel): void;
|
|
23
|
+
changeLegendItemSelection(legendItem: SunburstLegendItemModel, multiModeKeyPressed: boolean): void;
|
|
24
24
|
clearSelection(firePublicEvent?: boolean): void;
|
|
25
25
|
private getAllChildSegments;
|
|
26
26
|
}
|
|
@@ -87,7 +87,7 @@ export class SunburstHighlightState {
|
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
89
|
setHoverSegmentLegendItem(legendItem) {
|
|
90
|
-
const segment = this.levels[
|
|
90
|
+
const segment = this.levels[legendItem.levelIndex].segments.find((segment) => segment.key === legendItem.textContent);
|
|
91
91
|
if (segment) {
|
|
92
92
|
const highlightSegments = [segment];
|
|
93
93
|
const childSegments = this.getAllChildSegments(segment);
|
|
@@ -98,7 +98,7 @@ export class SunburstHighlightState {
|
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
changeLegendItemSelection(legendItem, multiModeKeyPressed) {
|
|
101
|
-
const segment = this.levels[
|
|
101
|
+
const segment = this.levels[legendItem.levelIndex].segments.find((segment) => segment.key === legendItem.textContent);
|
|
102
102
|
if (segment) {
|
|
103
103
|
this.changeSegmentSelection(segment, multiModeKeyPressed);
|
|
104
104
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Selection } from "d3-selection";
|
|
2
|
-
import {
|
|
2
|
+
import { SunburstLegendItemModel, SunburstLevelSegment } from "../../model/model";
|
|
3
3
|
import { DonutOverDetails } from "../features/tolltip/tooltip";
|
|
4
4
|
import { PieArcDatum } from "d3-shape";
|
|
5
5
|
import { LegendItemSelection } from "../features/legend/legendDomHelper";
|
|
@@ -24,19 +24,19 @@ export declare class SunburstSegmentEventDispatcher {
|
|
|
24
24
|
};
|
|
25
25
|
legendItemMousemove: {
|
|
26
26
|
e: MouseEvent;
|
|
27
|
-
legendItem:
|
|
27
|
+
legendItem: SunburstLegendItemModel;
|
|
28
28
|
};
|
|
29
29
|
legendItemMouseover: {
|
|
30
30
|
e: MouseEvent;
|
|
31
|
-
legendItem:
|
|
31
|
+
legendItem: SunburstLegendItemModel;
|
|
32
32
|
};
|
|
33
33
|
legendItemMouseleave: {
|
|
34
34
|
e: MouseEvent;
|
|
35
|
-
legendItem:
|
|
35
|
+
legendItem: SunburstLegendItemModel;
|
|
36
36
|
};
|
|
37
37
|
legendItemClick: {
|
|
38
38
|
multiModeKeyPressed: boolean;
|
|
39
|
-
legendItem:
|
|
39
|
+
legendItem: SunburstLegendItemModel;
|
|
40
40
|
};
|
|
41
41
|
}[T]) => void) => () => void;
|
|
42
42
|
private clearListenersInSelection;
|
|
@@ -52,7 +52,7 @@ export class DataManagerModel {
|
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
54
54
|
const valuesInLegend = data[configOptions.data.dataSource].map((dataRow) => dataRow[configOptions.data.keyField.name]);
|
|
55
|
-
const { shownKeys, hiddenKeysAmount } = this.polarLegendParamsBuilder.calculateParamsAndSetMargin(modelInstance, valuesInLegend, legendBlock, legendCanvas);
|
|
55
|
+
const { shownKeys, hiddenKeysAmount } = this.polarLegendParamsBuilder.calculateParamsAndSetMargin(modelInstance.canvasModel, valuesInLegend, legendBlock, legendCanvas, configOptions.legend.position);
|
|
56
56
|
const limitParams = this.service.limitAllowableKeys(shownKeys, hiddenKeysAmount, modelInstance.dataModel.getMaxRecordsAmount());
|
|
57
57
|
modelInstance.dataModel.initScope({
|
|
58
58
|
hiddenRecordsAmount: limitParams.hiddenRecordsAmount,
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { Orient } from "../../../model";
|
|
1
|
+
import { LegendPosition, Orient } from "../../../model";
|
|
2
2
|
import { CanvasModel } from "../../../modelInstance/canvasModel/canvasModel";
|
|
3
3
|
import { GroupingItemSize } from "../../../modelInstance/configReader/twoDimConfigReader/groupingConfigReader/groupingConfigReader";
|
|
4
4
|
interface GroupingStaticCoordinateCalculatorOptions {
|
|
5
5
|
otherComponentSizes: {
|
|
6
6
|
titleTotalNeededSpace: number;
|
|
7
7
|
legendTotalNeededSpace: number;
|
|
8
|
+
legendPosition: LegendPosition;
|
|
8
9
|
};
|
|
9
10
|
groupingItemSizes: GroupingItemSize[];
|
|
10
11
|
canvasModel: CanvasModel;
|
|
@@ -9,11 +9,18 @@ export class GroupingStaticCoordinateCalculator {
|
|
|
9
9
|
.reduce((acc, item) => acc + item.size, 0);
|
|
10
10
|
let staticCoordinate;
|
|
11
11
|
if (orient === "top")
|
|
12
|
-
staticCoordinate =
|
|
12
|
+
staticCoordinate =
|
|
13
|
+
this.options.otherComponentSizes.titleTotalNeededSpace +
|
|
14
|
+
prevSlicesSizes * sideIndex +
|
|
15
|
+
(this.options.otherComponentSizes.legendPosition === "top"
|
|
16
|
+
? this.options.otherComponentSizes.legendTotalNeededSpace
|
|
17
|
+
: 0);
|
|
13
18
|
if (orient === "bottom")
|
|
14
19
|
staticCoordinate =
|
|
15
20
|
this.options.canvasModel.getBlockSize().height -
|
|
16
|
-
this.options.otherComponentSizes.
|
|
21
|
+
(this.options.otherComponentSizes.legendPosition === "bottom"
|
|
22
|
+
? this.options.otherComponentSizes.legendTotalNeededSpace
|
|
23
|
+
: 0) -
|
|
17
24
|
prevSlicesSizes * sideIndex;
|
|
18
25
|
if (orient === "left")
|
|
19
26
|
staticCoordinate = prevSlicesSizes * sideIndex;
|
|
@@ -13,6 +13,6 @@ export interface LegendItemContentOptions {
|
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
15
|
export declare class LegendCanvasModel {
|
|
16
|
-
static findElementsAmountByLegendSize(items: LegendItemContentOptions[], position: LegendPosition,
|
|
16
|
+
static findElementsAmountByLegendSize(items: LegendItemContentOptions[], position: LegendPosition, legendBlockMaxWidth: number, legendBlockMaxHeight: number): DataLegendParams;
|
|
17
17
|
private static getLegendWrapperEl;
|
|
18
18
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { CLASSES } from "../../modelBuilder";
|
|
2
2
|
export class LegendCanvasModel {
|
|
3
|
-
//TODO: find better solution
|
|
4
|
-
static findElementsAmountByLegendSize(items, position,
|
|
5
|
-
const legendWrapper = this.getLegendWrapperEl(
|
|
3
|
+
//TODO: find better solution to calculate legend size
|
|
4
|
+
static findElementsAmountByLegendSize(items, position, legendBlockMaxWidth, legendBlockMaxHeight) {
|
|
5
|
+
const legendWrapper = this.getLegendWrapperEl(legendBlockMaxWidth, position === "right" || position === "left" ? "column" : "row");
|
|
6
6
|
document.body.append(legendWrapper);
|
|
7
7
|
let amount = 0;
|
|
8
8
|
for (let i = 0; i < items.length; i++) {
|
|
@@ -28,9 +28,11 @@ export class LegendCanvasModel {
|
|
|
28
28
|
itemWrapper.append(colorBlock, textBlock);
|
|
29
29
|
legendWrapper.append(itemWrapper);
|
|
30
30
|
amount++;
|
|
31
|
-
if (legendWrapper.offsetHeight >
|
|
31
|
+
if (legendWrapper.offsetHeight > legendBlockMaxHeight) {
|
|
32
32
|
itemWrapper.remove();
|
|
33
|
-
if (
|
|
33
|
+
if (legendBlockMaxHeight - legendWrapper.offsetHeight >= 15 &&
|
|
34
|
+
position !== "bottom" &&
|
|
35
|
+
position !== "top")
|
|
34
36
|
amount = amount; //TODO: remove
|
|
35
37
|
else
|
|
36
38
|
amount -= 1;
|
|
@@ -47,7 +49,7 @@ export class LegendCanvasModel {
|
|
|
47
49
|
size
|
|
48
50
|
};
|
|
49
51
|
}
|
|
50
|
-
static getLegendWrapperEl(
|
|
52
|
+
static getLegendWrapperEl(legendBlockMaxWidth, itemsDirection) {
|
|
51
53
|
const legendWrapper = document.createElement("div");
|
|
52
54
|
legendWrapper.style.opacity = "0";
|
|
53
55
|
legendWrapper.style.position = "absolute";
|
|
@@ -56,7 +58,7 @@ export class LegendCanvasModel {
|
|
|
56
58
|
legendWrapper.classList.add("legend-block-column");
|
|
57
59
|
else
|
|
58
60
|
legendWrapper.classList.add("legend-block-row", "legend-wrapper-with-wrap");
|
|
59
|
-
legendWrapper.style.maxWidth =
|
|
61
|
+
legendWrapper.style.maxWidth = legendBlockMaxWidth + "px";
|
|
60
62
|
return legendWrapper;
|
|
61
63
|
}
|
|
62
64
|
}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { LegendBlockCanvas } from "../../../designer/designerConfig";
|
|
2
|
-
import { LegendBlockModel, Orient } from "../../model";
|
|
2
|
+
import { LegendBlockModel, LegendPosition, Orient } from "../../model";
|
|
3
3
|
import { CanvasModel } from "../../modelInstance/canvasModel/canvasModel";
|
|
4
4
|
export declare class LegendModel {
|
|
5
5
|
static getBaseLegendBlockModel(canvasModel: CanvasModel, legendConfig: LegendBlockCanvas): LegendBlockModel;
|
|
6
6
|
static getLegendTotalMargin(position: Orient, legendBlockModel: LegendBlockModel): number;
|
|
7
7
|
}
|
|
8
|
+
export declare function getMaxLegendWidth(legendCanvas: LegendBlockCanvas, blockWidth: number): number;
|
|
9
|
+
export declare function calculateLegendMaxSize(legendBlock: LegendBlockModel, canvasModel: CanvasModel, position: LegendPosition, legendCanvas: LegendBlockCanvas): {
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getPxPercentUnitByValue } from "../../helpers/unitsFromConfigReader";
|
|
1
2
|
export class LegendModel {
|
|
2
3
|
static getBaseLegendBlockModel(canvasModel, legendConfig) {
|
|
3
4
|
var _a, _b;
|
|
@@ -6,7 +7,7 @@ export class LegendModel {
|
|
|
6
7
|
coordinate: {
|
|
7
8
|
left: {
|
|
8
9
|
size: 0,
|
|
9
|
-
margin: { top:
|
|
10
|
+
margin: { top: canvasModel.titleCanvas.getAllNeededSpace(), bottom: mb, left: 0, right: 15 },
|
|
10
11
|
pad: 0
|
|
11
12
|
},
|
|
12
13
|
bottom: {
|
|
@@ -38,3 +39,32 @@ export class LegendModel {
|
|
|
38
39
|
return legendCoordinate[position].margin.top + legendCoordinate[position].margin.bottom;
|
|
39
40
|
}
|
|
40
41
|
}
|
|
42
|
+
export function getMaxLegendWidth(legendCanvas, blockWidth) {
|
|
43
|
+
const maxWidth = legendCanvas.maxWidth;
|
|
44
|
+
if (typeof maxWidth === "number")
|
|
45
|
+
return maxWidth;
|
|
46
|
+
const unit = getPxPercentUnitByValue(maxWidth);
|
|
47
|
+
const maxWidthNumber = parseInt(maxWidth);
|
|
48
|
+
if (unit === "px")
|
|
49
|
+
return maxWidthNumber;
|
|
50
|
+
return (maxWidthNumber / 100) * blockWidth;
|
|
51
|
+
}
|
|
52
|
+
export function calculateLegendMaxSize(legendBlock, canvasModel, position, legendCanvas) {
|
|
53
|
+
if (position === "right" || position === "left") {
|
|
54
|
+
return {
|
|
55
|
+
width: getMaxLegendWidth(legendCanvas, canvasModel.getBlockSize().width),
|
|
56
|
+
height: canvasModel.getChartBlockHeight() - legendBlock.coordinate.right.margin.bottom
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
if (position === "top" || position === "bottom") {
|
|
60
|
+
return {
|
|
61
|
+
width: canvasModel.getChartBlockWidth() -
|
|
62
|
+
legendBlock.coordinate.bottom.margin.left -
|
|
63
|
+
legendBlock.coordinate.bottom.margin.right,
|
|
64
|
+
height: canvasModel.getChartBlockHeight() -
|
|
65
|
+
legendBlock.coordinate.bottom.margin.bottom -
|
|
66
|
+
legendBlock.coordinate.bottom.margin.top
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
throw new Error(`No legend size for orient: ${position}`);
|
|
70
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { LegendBlockCanvas } from "../../../designer/designerConfig";
|
|
2
|
-
import { LegendBlockModel } from "../../model";
|
|
3
|
-
import {
|
|
2
|
+
import { LegendBlockModel, LegendPosition } from "../../model";
|
|
3
|
+
import { CanvasModel } from "../../modelInstance/canvasModel/canvasModel";
|
|
4
4
|
export declare class PolarLikeLegendParamsBuilder {
|
|
5
5
|
private polarMarginCalculator;
|
|
6
|
-
calculateParamsAndSetMargin(
|
|
6
|
+
calculateParamsAndSetMargin(canvasModel: CanvasModel, valuesInLegend: string[], legendBlock: LegendBlockModel, legendCanvas: LegendBlockCanvas, presetPosition: LegendPosition | undefined): {
|
|
7
7
|
shownKeys: string[];
|
|
8
8
|
hiddenKeysAmount: number;
|
|
9
9
|
};
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { styledElementValues } from "../../modelBuilder";
|
|
2
|
-
import {
|
|
2
|
+
import { PolarModel } from "../../notations/polar/polarModel";
|
|
3
3
|
import { LegendCanvasModel } from "./legendCanvasModel";
|
|
4
|
+
import { calculateLegendMaxSize } from "./legendModel";
|
|
4
5
|
import { LegendPolarMarginCalculator } from "./polarMarginCalculator";
|
|
5
6
|
export class PolarLikeLegendParamsBuilder {
|
|
6
7
|
constructor() {
|
|
7
8
|
this.polarMarginCalculator = new LegendPolarMarginCalculator();
|
|
8
9
|
}
|
|
9
|
-
calculateParamsAndSetMargin(
|
|
10
|
-
|
|
11
|
-
let position = PolarModel.getLegendPositionByBlockSize(modelInstance.canvasModel);
|
|
10
|
+
calculateParamsAndSetMargin(canvasModel, valuesInLegend, legendBlock, legendCanvas, presetPosition) {
|
|
11
|
+
let position = presetPosition !== null && presetPosition !== void 0 ? presetPosition : PolarModel.getLegendPositionByBlockSize(canvasModel);
|
|
12
12
|
let { amount: maxItemsNumber, size } = this.getLegendDataParams(position, valuesInLegend, legendCanvas, canvasModel, legendBlock);
|
|
13
|
-
if (
|
|
13
|
+
if (!presetPosition &&
|
|
14
|
+
(position === "right" || position === "left") &&
|
|
14
15
|
!PolarModel.doesChartBlockHasEnoughWidthForContainsLegend(canvasModel.getChartBlockWidth(), size.width, legendBlock.coordinate)) {
|
|
15
16
|
const doesFreeSpaceExist = PolarModel.doesChartBlockHasEnoughHeightForContainsLegend(canvasModel.getChartBlockHeight(), legendBlock.coordinate);
|
|
16
17
|
if (doesFreeSpaceExist) {
|
|
@@ -24,7 +25,7 @@ export class PolarLikeLegendParamsBuilder {
|
|
|
24
25
|
const shownKeys = valuesInLegend.slice(0, maxItemsNumber);
|
|
25
26
|
const hiddenKeysAmount = valuesInLegend.length - maxItemsNumber;
|
|
26
27
|
canvasModel.legendCanvas.setPosition(position);
|
|
27
|
-
this.polarMarginCalculator.updateMargin(position, canvasModel, legendBlock, position === "bottom" ? size.height : size.width);
|
|
28
|
+
this.polarMarginCalculator.updateMargin(position, canvasModel, legendBlock, position === "bottom" || position === "top" ? size.height : size.width);
|
|
28
29
|
return { shownKeys, hiddenKeysAmount };
|
|
29
30
|
}
|
|
30
31
|
//TODO: position type
|
|
@@ -34,16 +35,7 @@ export class PolarLikeLegendParamsBuilder {
|
|
|
34
35
|
markerSize: styledElementValues.defaultLegendMarkerSizes,
|
|
35
36
|
wrapperSize: { marginRightPx: styledElementValues.legend.inlineDynamicItemWrapperMarginRightPx }
|
|
36
37
|
}));
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
return LegendCanvasModel.findElementsAmountByLegendSize(legendItemContentOptions, position, canvasModel.getChartBlockWidth() -
|
|
42
|
-
legendBlock.coordinate.bottom.margin.left -
|
|
43
|
-
legendBlock.coordinate.bottom.margin.right, canvasModel.getChartBlockHeight() -
|
|
44
|
-
legendBlock.coordinate.bottom.margin.bottom -
|
|
45
|
-
legendBlock.coordinate.bottom.margin.top -
|
|
46
|
-
MIN_DONUT_BLOCK_SIZE);
|
|
47
|
-
}
|
|
38
|
+
const legendMaxSize = calculateLegendMaxSize(legendBlock, canvasModel, position, legendCanvas);
|
|
39
|
+
return LegendCanvasModel.findElementsAmountByLegendSize(legendItemContentOptions, position, legendMaxSize.width, legendMaxSize.height);
|
|
48
40
|
}
|
|
49
41
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { LegendBlockModel } from "../../model";
|
|
1
|
+
import { LegendBlockModel, LegendPosition } from "../../model";
|
|
3
2
|
import { CanvasModel } from "../../modelInstance/canvasModel/canvasModel";
|
|
4
3
|
export declare class LegendPolarMarginCalculator {
|
|
5
|
-
updateMargin(legendPosition:
|
|
6
|
-
getMaxLegendWidth(legendCanvas: LegendBlockCanvas, blockWidth: number): number;
|
|
4
|
+
updateMargin(legendPosition: LegendPosition, canvasModel: CanvasModel, legendBlockModel: LegendBlockModel, size: number): void;
|
|
7
5
|
private updateMarginObj;
|
|
8
6
|
}
|
|
@@ -1,20 +1,11 @@
|
|
|
1
|
-
import { getPxPercentUnitByValue } from "../../helpers/unitsFromConfigReader";
|
|
2
1
|
import { LegendModel } from "./legendModel";
|
|
3
2
|
export class LegendPolarMarginCalculator {
|
|
4
3
|
updateMargin(legendPosition, canvasModel, legendBlockModel, size) {
|
|
5
4
|
this.updateMarginObj(legendBlockModel, legendPosition, size, canvasModel);
|
|
6
5
|
}
|
|
7
|
-
getMaxLegendWidth(legendCanvas, blockWidth) {
|
|
8
|
-
const maxWidth = legendCanvas.maxWidth;
|
|
9
|
-
if (typeof maxWidth === "number")
|
|
10
|
-
return maxWidth;
|
|
11
|
-
const unit = getPxPercentUnitByValue(maxWidth);
|
|
12
|
-
const maxWidthNumber = parseInt(maxWidth);
|
|
13
|
-
if (unit === "px")
|
|
14
|
-
return maxWidthNumber;
|
|
15
|
-
return (maxWidthNumber / 100) * blockWidth;
|
|
16
|
-
}
|
|
17
6
|
updateMarginObj(legendBlockModel, legendPosition, legendSize, canvasModel) {
|
|
7
|
+
if (legendPosition === "off")
|
|
8
|
+
return;
|
|
18
9
|
if (legendSize !== 0) {
|
|
19
10
|
canvasModel.increaseMarginSide(legendPosition, legendSize);
|
|
20
11
|
canvasModel.increaseMarginSide(legendPosition, LegendModel.getLegendTotalMargin(legendPosition, legendBlockModel));
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LegendConfig } from "../../../config/config";
|
|
2
|
+
import { LegendBlockCanvas } from "../../../designer/designerConfig";
|
|
2
3
|
import { LegendBlockModel } from "../../model";
|
|
3
4
|
import { TwoDimConfigReader } from "../../modelInstance/configReader/twoDimConfigReader/twoDimConfigReader";
|
|
4
5
|
import { ModelInstance } from "../../modelInstance/modelInstance";
|
|
5
6
|
export declare class TwoDimLegendModel {
|
|
6
7
|
private configReader;
|
|
7
8
|
constructor(configReader: TwoDimConfigReader);
|
|
8
|
-
recalcMarginWith2DLegend(modelInstance: ModelInstance, legendBlockModel: LegendBlockModel, legendOptions:
|
|
9
|
+
recalcMarginWith2DLegend(modelInstance: ModelInstance, legendBlockModel: LegendBlockModel, legendOptions: LegendConfig, legendCanvas: LegendBlockCanvas): void;
|
|
9
10
|
private getLegendPosition;
|
|
10
11
|
}
|
|
@@ -1,33 +1,34 @@
|
|
|
1
1
|
import { styledElementValues } from "../../modelBuilder";
|
|
2
2
|
import { getWidthOfLegendMarkerByType } from "../../notations/twoDimensional/styles";
|
|
3
3
|
import { LegendCanvasModel } from "./legendCanvasModel";
|
|
4
|
-
import { LegendModel } from "./legendModel";
|
|
4
|
+
import { calculateLegendMaxSize, LegendModel } from "./legendModel";
|
|
5
5
|
export class TwoDimLegendModel {
|
|
6
6
|
constructor(configReader) {
|
|
7
7
|
this.configReader = configReader;
|
|
8
8
|
}
|
|
9
|
-
recalcMarginWith2DLegend(modelInstance, legendBlockModel, legendOptions) {
|
|
9
|
+
recalcMarginWith2DLegend(modelInstance, legendBlockModel, legendOptions, legendCanvas) {
|
|
10
10
|
const canvasModel = modelInstance.canvasModel;
|
|
11
11
|
const legendPosition = this.getLegendPosition(legendOptions);
|
|
12
12
|
modelInstance.canvasModel.legendCanvas.setPosition(legendPosition);
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const
|
|
13
|
+
const legendItemInfo = this.configReader.getLegendItemInfo();
|
|
14
|
+
if (legendPosition !== "off" && legendItemInfo.length > 0) {
|
|
15
|
+
const legendMaxSize = calculateLegendMaxSize(legendBlockModel, canvasModel, legendPosition, legendCanvas);
|
|
16
|
+
const legendBlockSize = LegendCanvasModel.findElementsAmountByLegendSize(legendItemInfo.map((i) => ({
|
|
16
17
|
text: i.text,
|
|
17
18
|
markerSize: Object.assign(Object.assign({}, styledElementValues.defaultLegendMarkerSizes), { widthPx: getWidthOfLegendMarkerByType(i.chartType) }),
|
|
18
19
|
wrapperSize: { marginRightPx: styledElementValues.legend.inlineItemWrapperMarginRightPx }
|
|
19
|
-
})),
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
})), legendPosition, legendMaxSize.width, legendMaxSize.height).size;
|
|
21
|
+
const legendSize = legendPosition === "top" || legendPosition === "bottom"
|
|
22
|
+
? legendBlockSize.height
|
|
23
|
+
: legendBlockSize.width;
|
|
24
|
+
const legendTotalMargin = LegendModel.getLegendTotalMargin(legendPosition, legendBlockModel);
|
|
25
|
+
modelInstance.canvasModel.legendCanvas.initSizeAndPad(legendSize, legendTotalMargin);
|
|
26
|
+
canvasModel.increaseMarginSide(legendPosition, modelInstance.canvasModel.legendCanvas.getAllNeededSpace());
|
|
25
27
|
legendBlockModel.coordinate[legendPosition].size = legendSize;
|
|
26
28
|
}
|
|
27
29
|
}
|
|
28
30
|
getLegendPosition(legendOptions) {
|
|
29
31
|
var _a;
|
|
30
|
-
|
|
31
|
-
return position;
|
|
32
|
+
return legendOptions.show ? ((_a = legendOptions.position) !== null && _a !== void 0 ? _a : "top") : "off";
|
|
32
33
|
}
|
|
33
34
|
}
|
|
@@ -7,8 +7,9 @@ export class SunburstMarginModel {
|
|
|
7
7
|
this.polarLegendParamsBuilder = new PolarLikeLegendParamsBuilder();
|
|
8
8
|
}
|
|
9
9
|
recalcMargin(otherComponents, modelInstance) {
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
10
|
+
var _a;
|
|
11
|
+
const fieldNamesInLegend = this.configReader.getFieldsInLegend();
|
|
12
|
+
const legendValues = extractLegendValues(modelInstance.dataModel.repository.getRawRows(), fieldNamesInLegend);
|
|
13
|
+
this.polarLegendParamsBuilder.calculateParamsAndSetMargin(modelInstance.canvasModel, legendValues, otherComponents.legendBlock, this.designerConfig.canvas.legendBlock, (_a = this.configReader.options.legend) === null || _a === void 0 ? void 0 : _a.position);
|
|
13
14
|
}
|
|
14
15
|
}
|
|
@@ -16,7 +16,7 @@ export class TwoDimMarginModel {
|
|
|
16
16
|
}
|
|
17
17
|
recalcMargin(otherComponents, modelInstance) {
|
|
18
18
|
const canvasModel = modelInstance.canvasModel;
|
|
19
|
-
this.twoDimLegendModel.recalcMarginWith2DLegend(modelInstance, otherComponents.legendBlock, this.configReader.options.legend);
|
|
19
|
+
this.twoDimLegendModel.recalcMarginWith2DLegend(modelInstance, otherComponents.legendBlock, this.configReader.options.legend, this.designerConfig.canvas.legendBlock);
|
|
20
20
|
this.recalcVerticalMarginByAxisLabelHeight(LABEL_ELEMENT_HEIGHT_PX, canvasModel);
|
|
21
21
|
const labelSize = this.getMaxLabelSize(modelInstance);
|
|
22
22
|
// Если встроенный лейбл показывает ключи, то лейблы оси ключей не показываются
|
package/lib/model/model.d.ts
CHANGED
|
@@ -92,7 +92,7 @@ export interface SunburstOptionsModel {
|
|
|
92
92
|
levels: SunburstLevel[];
|
|
93
93
|
title: OptionsModelTitle;
|
|
94
94
|
selectable: boolean;
|
|
95
|
-
legend:
|
|
95
|
+
legend: SunburstLegendModel;
|
|
96
96
|
}
|
|
97
97
|
export interface ILegendModel {
|
|
98
98
|
position: LegendPosition;
|
|
@@ -106,6 +106,13 @@ export interface LegendItemModel {
|
|
|
106
106
|
content: TooltipContent;
|
|
107
107
|
};
|
|
108
108
|
}
|
|
109
|
+
export interface SunburstLegendModel {
|
|
110
|
+
position: LegendPosition;
|
|
111
|
+
items: SunburstLegendItemModel[];
|
|
112
|
+
}
|
|
113
|
+
export interface SunburstLegendItemModel extends LegendItemModel {
|
|
114
|
+
levelIndex: number;
|
|
115
|
+
}
|
|
109
116
|
export interface BasicOptionsModelData {
|
|
110
117
|
dataSource: string;
|
|
111
118
|
}
|
|
@@ -7,6 +7,6 @@ export function getConfigReader(config, designerConfig) {
|
|
|
7
7
|
if (config.options.type === "polar")
|
|
8
8
|
return new PolarConfigReader(config, designerConfig);
|
|
9
9
|
if (config.options.type === "sunburst")
|
|
10
|
-
return
|
|
10
|
+
return SunburstConfigReader.createFromGlobalConfig(config, designerConfig);
|
|
11
11
|
throw new Error(`Config reader for type "${config.options.type}" not exists`);
|
|
12
12
|
}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
import { BlockMargin, MdtChartsConfig, MdtChartsField } from "../../../../config/config";
|
|
1
|
+
import { BlockMargin, MdtChartsConfig, MdtChartsField, MdtChartsSunburstLevel, MdtChartsSunburstOptions } from "../../../../config/config";
|
|
2
2
|
import { DesignerConfig } from "../../../../designer/designerConfig";
|
|
3
3
|
import { BaseConfigReader } from "../baseConfigReader";
|
|
4
4
|
export declare class SunburstConfigReader implements BaseConfigReader {
|
|
5
|
+
readonly options: MdtChartsSunburstOptions;
|
|
5
6
|
private readonly designerConfig;
|
|
6
|
-
|
|
7
|
-
constructor(
|
|
8
|
-
|
|
7
|
+
static createFromGlobalConfig(config: MdtChartsConfig, designerConfig: DesignerConfig): SunburstConfigReader;
|
|
8
|
+
constructor(options: MdtChartsSunburstOptions, designerConfig: DesignerConfig);
|
|
9
|
+
getFieldsInLegend(): string[];
|
|
10
|
+
getLevelsWithLegendTurnedOn(): {
|
|
11
|
+
level: MdtChartsSunburstLevel;
|
|
12
|
+
levelIndex: number;
|
|
13
|
+
}[];
|
|
9
14
|
getValueFields(): MdtChartsField[];
|
|
10
15
|
getChartBlockMargin(): BlockMargin;
|
|
11
16
|
}
|
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
export class SunburstConfigReader {
|
|
2
|
-
constructor(
|
|
2
|
+
constructor(options, designerConfig) {
|
|
3
|
+
this.options = options;
|
|
3
4
|
this.designerConfig = designerConfig;
|
|
4
|
-
this.options = config.options;
|
|
5
5
|
}
|
|
6
|
-
|
|
7
|
-
return
|
|
6
|
+
static createFromGlobalConfig(config, designerConfig) {
|
|
7
|
+
return new SunburstConfigReader(config.options, designerConfig);
|
|
8
|
+
}
|
|
9
|
+
getFieldsInLegend() {
|
|
10
|
+
const levelsWithLegendTurnedOn = this.getLevelsWithLegendTurnedOn();
|
|
11
|
+
return levelsWithLegendTurnedOn.map(({ level }) => level.data.keyField.name);
|
|
12
|
+
}
|
|
13
|
+
getLevelsWithLegendTurnedOn() {
|
|
14
|
+
const levelsWithIndexes = this.options.levels.map((level, levelIndex) => ({ level, levelIndex }));
|
|
15
|
+
const levelsWithLegendConfig = levelsWithIndexes.filter(({ level }) => { var _a; return ((_a = level.legend) === null || _a === void 0 ? void 0 : _a.show) != null; });
|
|
16
|
+
if (levelsWithLegendConfig.length === 0)
|
|
17
|
+
return [{ level: this.options.levels[0], levelIndex: 0 }];
|
|
18
|
+
return levelsWithLegendConfig.filter(({ level }) => { var _a; return (_a = level.legend) === null || _a === void 0 ? void 0 : _a.show; });
|
|
8
19
|
}
|
|
9
20
|
getValueFields() {
|
|
10
21
|
return [this.options.data.valueField];
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { MdtChartsPolarOptions } from "../../../config/config";
|
|
2
2
|
import { DesignerConfig } from "../../../designer/designerConfig";
|
|
3
|
-
import { PolarOptionsModel, LegendCoordinate } from "../../model";
|
|
3
|
+
import { PolarOptionsModel, LegendCoordinate, LegendPosition } from "../../model";
|
|
4
4
|
import { CanvasModel } from "../../modelInstance/canvasModel/canvasModel";
|
|
5
5
|
import { ModelInstance } from "../../modelInstance/modelInstance";
|
|
6
6
|
export declare const MIN_DONUT_BLOCK_SIZE = 120;
|
|
7
7
|
export declare class PolarModel {
|
|
8
8
|
private static donutModel;
|
|
9
9
|
static getOptions(options: MdtChartsPolarOptions, designerConfig: DesignerConfig, modelInstance: ModelInstance): PolarOptionsModel;
|
|
10
|
-
static getLegendPositionByBlockSize(canvasModel: CanvasModel):
|
|
10
|
+
static getLegendPositionByBlockSize(canvasModel: CanvasModel): LegendPosition;
|
|
11
11
|
static doesChartBlockHasEnoughWidthForContainsLegend(chartBlockWidth: number, legendWidth: number, legendCoordinate: LegendCoordinate): boolean;
|
|
12
12
|
static doesChartBlockHasEnoughHeightForContainsLegend(chartBlockHeight: number, legendCoordinate: LegendCoordinate): boolean;
|
|
13
13
|
private static getChartsModel;
|
|
@@ -59,7 +59,6 @@ export class PolarModel {
|
|
|
59
59
|
}, { positionAttrs: { bottom: "0", right: "0" } }, options.recordOverflowAlert)
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
|
-
//TODO: type for returned value
|
|
63
62
|
static getLegendPositionByBlockSize(canvasModel) {
|
|
64
63
|
const widthCoefficientWhenLegendShouldInBottom = 1.5;
|
|
65
64
|
const avgLegendWidth = 100;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { MdtChartsDataRow } from "../../../config/config";
|
|
2
|
-
export declare function extractLegendValues(dataRows: MdtChartsDataRow[],
|
|
2
|
+
export declare function extractLegendValues(dataRows: MdtChartsDataRow[], fieldNamesInLegend: string[]): string[];
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
export function extractLegendValues(dataRows,
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
export function extractLegendValues(dataRows, fieldNamesInLegend) {
|
|
2
|
+
const totalLegendValues = [];
|
|
3
|
+
for (const fieldName of fieldNamesInLegend) {
|
|
4
|
+
const values = dataRows.map((dataRow) => dataRow[fieldName]);
|
|
5
|
+
const uniqueValues = values.filter((value, index) => {
|
|
6
|
+
return values.indexOf(value) === index;
|
|
7
|
+
});
|
|
8
|
+
totalLegendValues.push(...uniqueValues);
|
|
9
|
+
}
|
|
10
|
+
return totalLegendValues;
|
|
7
11
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { ChartStyleModelService } from "../../chartStyleModel/chartStyleModel";
|
|
2
|
+
import { SunburstConfigReader } from "../../modelInstance/configReader/sunburstConifgReader/sunburstConifgReader";
|
|
2
3
|
import { TitleConfigReader } from "../../modelInstance/titleConfigReader";
|
|
3
4
|
import { DonutAggregatorService } from "../polar/donut/donutAggregatorService";
|
|
4
5
|
import { POLAR_LEGEND_MARKER } from "../polar/modelConstants/polarLegendMarker";
|
|
5
6
|
import { LevelModelBuilder } from "./levelModelBuilder/levelModelBuilder";
|
|
6
7
|
export class SunburstModel {
|
|
7
8
|
static getOptions(options, designerConfig, modelInstance) {
|
|
9
|
+
const configReader = new SunburstConfigReader(options, designerConfig);
|
|
8
10
|
const titleConfig = TitleConfigReader.create(options.title, modelInstance);
|
|
9
11
|
//TODO: extract to function and remove duplicate with levelModelBuilder
|
|
10
12
|
const topLevelValues = modelInstance.dataModel.repository
|
|
@@ -23,6 +25,19 @@ export class SunburstModel {
|
|
|
23
25
|
data: options.data,
|
|
24
26
|
levels: options.levels
|
|
25
27
|
});
|
|
28
|
+
const totalLegendItems = [];
|
|
29
|
+
for (const { levelIndex } of configReader.getLevelsWithLegendTurnedOn()) {
|
|
30
|
+
const levelLegendItems = levels[levelIndex].segments.map((segment) => ({
|
|
31
|
+
marker: POLAR_LEGEND_MARKER,
|
|
32
|
+
markerColor: segment.color,
|
|
33
|
+
textContent: segment.key.toString(),
|
|
34
|
+
levelIndex,
|
|
35
|
+
tooltip: {
|
|
36
|
+
content: segment.tooltip.content
|
|
37
|
+
}
|
|
38
|
+
}));
|
|
39
|
+
totalLegendItems.push(...levelLegendItems);
|
|
40
|
+
}
|
|
26
41
|
return {
|
|
27
42
|
type: "sunburst",
|
|
28
43
|
title: {
|
|
@@ -32,14 +47,7 @@ export class SunburstModel {
|
|
|
32
47
|
selectable: !!options.selectable,
|
|
33
48
|
legend: {
|
|
34
49
|
position: modelInstance.canvasModel.legendCanvas.getPosition(),
|
|
35
|
-
items:
|
|
36
|
-
marker: POLAR_LEGEND_MARKER,
|
|
37
|
-
markerColor: segment.color,
|
|
38
|
-
textContent: segment.key.toString(),
|
|
39
|
-
tooltip: {
|
|
40
|
-
content: segment.tooltip.content
|
|
41
|
-
}
|
|
42
|
-
}))
|
|
50
|
+
items: totalLegendItems
|
|
43
51
|
},
|
|
44
52
|
aggregator: options.aggregator
|
|
45
53
|
? {
|
|
@@ -45,7 +45,8 @@ export class TwoDimensionalModel {
|
|
|
45
45
|
canvasModel,
|
|
46
46
|
otherComponentSizes: {
|
|
47
47
|
titleTotalNeededSpace: canvasModel.titleCanvas.getAllNeededSpace(),
|
|
48
|
-
legendTotalNeededSpace: canvasModel.legendCanvas.getAllNeededSpace()
|
|
48
|
+
legendTotalNeededSpace: canvasModel.legendCanvas.getAllNeededSpace(),
|
|
49
|
+
legendPosition: canvasModel.legendCanvas.getPosition()
|
|
49
50
|
},
|
|
50
51
|
groupingItemSizes: configReader.grouping.getSlicesSizesByOrients(modelInstance.dataModel.repository.getScopedRows())
|
|
51
52
|
});
|