mdt-charts 1.35.1 → 1.36.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/engine/features/groupLabels/groupLabels.d.ts +3 -3
- package/lib/engine/features/groupLabels/groupLabels.js +4 -8
- package/lib/engine/features/groupLines/groupLines.d.ts +23 -0
- package/lib/engine/features/groupLines/groupLines.js +67 -0
- package/lib/engine/twoDimensionalNotation/twoDimensionalManager.d.ts +2 -1
- package/lib/engine/twoDimensionalNotation/twoDimensionalManager.js +20 -7
- package/lib/model/featuresModel/grouping/groupingCanvasCalculator/groupingCanvasCalculator.d.ts +21 -0
- package/lib/model/featuresModel/grouping/groupingCanvasCalculator/groupingCanvasCalculator.js +41 -0
- package/lib/model/featuresModel/grouping/groupingEdgeLines/groupingEdgeLinesGenerator.d.ts +14 -0
- package/lib/model/featuresModel/grouping/groupingEdgeLines/groupingEdgeLinesGenerator.js +51 -0
- package/lib/model/featuresModel/grouping/groupingLabels/groupingLabelsCoordinateHandlers.d.ts +2 -5
- package/lib/model/featuresModel/grouping/groupingLabels/groupingLabelsCoordinateHandlers.js +1 -14
- package/lib/model/featuresModel/grouping/groupingLabels/groupingLabelsScaler.d.ts +3 -6
- package/lib/model/featuresModel/grouping/groupingLabels/groupingLabelsScaler.js +5 -31
- package/lib/model/featuresModel/grouping/groupingLabels/staticCoordinateCalculator.d.ts +17 -0
- package/lib/model/featuresModel/grouping/groupingLabels/staticCoordinateCalculator.js +28 -0
- package/lib/model/featuresModel/grouping/groupingSplitLines/groupingSplitLines.d.ts +17 -0
- package/lib/model/featuresModel/grouping/groupingSplitLines/groupingSplitLines.js +47 -0
- package/lib/model/featuresModel/legendModel/twoDimLegendModel.d.ts +1 -1
- package/lib/model/featuresModel/scaleModel/scaleModel.d.ts +1 -1
- package/lib/model/margin/twoDim/twoDimMarginModel.d.ts +1 -1
- package/lib/model/margin/twoDim/twoDimMarginModel.js +3 -1
- package/lib/model/model.d.ts +11 -1
- package/lib/model/modelBuilder.js +1 -1
- package/lib/model/modelInstance/configReader/baseConfigReader.js +1 -1
- package/lib/model/modelInstance/configReader/{twoDimConfigReader.ts → twoDimConfigReader}/groupingConfigReader/groupingConfigReader.d.ts +6 -8
- package/lib/model/modelInstance/configReader/{twoDimConfigReader.ts → twoDimConfigReader}/groupingConfigReader/groupingConfigReader.js +7 -27
- package/lib/model/modelInstance/configReader/{twoDimConfigReader.ts → twoDimConfigReader}/twoDimConfigReader.js +2 -2
- package/lib/model/notations/twoDimensionalModel.d.ts +1 -1
- package/lib/model/notations/twoDimensionalModel.js +38 -15
- package/lib/style/charts-main.css +6 -0
- package/lib/style/charts-main.less +6 -0
- package/package.json +1 -1
- /package/lib/model/modelInstance/configReader/{twoDimConfigReader.ts → twoDimConfigReader}/twoDimConfigReader.d.ts +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GroupingItemLabelsModel } from "../../../model/model";
|
|
2
2
|
import { Block } from "../../block/block";
|
|
3
3
|
interface GroupAxisLabelsOptions {
|
|
4
4
|
elementAccessors: {
|
|
@@ -10,8 +10,8 @@ export declare class GroupAxisLabels {
|
|
|
10
10
|
private readonly renderPipeline;
|
|
11
11
|
private groupsForLabels;
|
|
12
12
|
constructor(options: GroupAxisLabelsOptions);
|
|
13
|
-
render(
|
|
14
|
-
update(
|
|
13
|
+
render(items: GroupingItemLabelsModel[]): void;
|
|
14
|
+
update(items: GroupingItemLabelsModel[]): void;
|
|
15
15
|
private setAttrs;
|
|
16
16
|
}
|
|
17
17
|
export {};
|
|
@@ -8,10 +8,8 @@ export class GroupAxisLabels {
|
|
|
8
8
|
return this.setAttrs(groupLabels.classed("group-label data-label", true), item);
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
|
-
render(
|
|
12
|
-
|
|
13
|
-
return;
|
|
14
|
-
model.items.forEach((item, index) => {
|
|
11
|
+
render(items) {
|
|
12
|
+
items.forEach((item, index) => {
|
|
15
13
|
const group = this.options.elementAccessors
|
|
16
14
|
.getBlock()
|
|
17
15
|
.getSvg()
|
|
@@ -27,10 +25,8 @@ export class GroupAxisLabels {
|
|
|
27
25
|
this.renderPipeline.execute(labels, { item });
|
|
28
26
|
});
|
|
29
27
|
}
|
|
30
|
-
update(
|
|
31
|
-
|
|
32
|
-
return;
|
|
33
|
-
model.items.forEach((item, index) => {
|
|
28
|
+
update(items) {
|
|
29
|
+
items.forEach((item, index) => {
|
|
34
30
|
const group = this.groupsForLabels[index];
|
|
35
31
|
if (!group)
|
|
36
32
|
return;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { GroupingSplitLineAttributes } from "../../../model/model";
|
|
2
|
+
import { Block } from "../../block/block";
|
|
3
|
+
interface GroupLinesOptions {
|
|
4
|
+
elementAccessors: {
|
|
5
|
+
getBlock: () => Block;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
export declare class GroupLines {
|
|
9
|
+
private readonly options;
|
|
10
|
+
private edgeLinesGroup;
|
|
11
|
+
private splitLinesGroups;
|
|
12
|
+
private readonly edgeLinesGroupCssClass;
|
|
13
|
+
private readonly splitLinesGroupCssClass;
|
|
14
|
+
constructor(options: GroupLinesOptions);
|
|
15
|
+
render(edgeLines: GroupingSplitLineAttributes[], splitLinesByItems: GroupingSplitLineAttributes[][]): void;
|
|
16
|
+
update(edgeLines: GroupingSplitLineAttributes[], splitLinesByItems: GroupingSplitLineAttributes[][]): void;
|
|
17
|
+
private renderEdgeLines;
|
|
18
|
+
private renderSplitLines;
|
|
19
|
+
private updateEdgeLines;
|
|
20
|
+
private updateSplitLines;
|
|
21
|
+
private setAttrs;
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export class GroupLines {
|
|
2
|
+
constructor(options) {
|
|
3
|
+
this.options = options;
|
|
4
|
+
this.splitLinesGroups = [];
|
|
5
|
+
this.edgeLinesGroupCssClass = "group-edge-lines";
|
|
6
|
+
this.splitLinesGroupCssClass = "group-split-lines";
|
|
7
|
+
}
|
|
8
|
+
render(edgeLines, splitLinesByItems) {
|
|
9
|
+
this.renderEdgeLines(edgeLines);
|
|
10
|
+
this.renderSplitLines(splitLinesByItems);
|
|
11
|
+
}
|
|
12
|
+
update(edgeLines, splitLinesByItems) {
|
|
13
|
+
this.updateEdgeLines(edgeLines);
|
|
14
|
+
this.updateSplitLines(splitLinesByItems);
|
|
15
|
+
}
|
|
16
|
+
renderEdgeLines(edgeLines) {
|
|
17
|
+
const block = this.options.elementAccessors.getBlock();
|
|
18
|
+
this.edgeLinesGroup = block.getSvg().append("g").classed(this.edgeLinesGroupCssClass, true);
|
|
19
|
+
const lines = this.edgeLinesGroup.selectAll("line").data(edgeLines).enter().append("line");
|
|
20
|
+
this.setAttrs(lines);
|
|
21
|
+
}
|
|
22
|
+
renderSplitLines(splitLinesByItems) {
|
|
23
|
+
splitLinesByItems.forEach((splitLines) => {
|
|
24
|
+
const group = this.options.elementAccessors
|
|
25
|
+
.getBlock()
|
|
26
|
+
.getSvg()
|
|
27
|
+
.append("g")
|
|
28
|
+
.classed(this.splitLinesGroupCssClass, true);
|
|
29
|
+
this.splitLinesGroups.push(group);
|
|
30
|
+
const lines = group.selectAll("line").data(splitLines).enter().append("line");
|
|
31
|
+
this.setAttrs(lines);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
updateEdgeLines(edgeLines) {
|
|
35
|
+
const animationName = "grouping-edge-lines-animation";
|
|
36
|
+
const lines = this.edgeLinesGroup
|
|
37
|
+
.selectAll("line")
|
|
38
|
+
.data(edgeLines)
|
|
39
|
+
.interrupt(animationName)
|
|
40
|
+
.transition(animationName)
|
|
41
|
+
.duration(this.options.elementAccessors.getBlock().transitionManager.durations.chartUpdate);
|
|
42
|
+
this.setAttrs(lines);
|
|
43
|
+
}
|
|
44
|
+
updateSplitLines(splitLinesByItems) {
|
|
45
|
+
splitLinesByItems.forEach((splitLines, index) => {
|
|
46
|
+
const existedLines = this.splitLinesGroups[index]
|
|
47
|
+
.selectAll("line")
|
|
48
|
+
.data(splitLines);
|
|
49
|
+
existedLines.exit().remove();
|
|
50
|
+
const newLines = existedLines.enter().append("line");
|
|
51
|
+
this.setAttrs(newLines);
|
|
52
|
+
const animationName = "grouping-split-lines-animation";
|
|
53
|
+
this.setAttrs(existedLines
|
|
54
|
+
.interrupt(animationName)
|
|
55
|
+
.transition(animationName)
|
|
56
|
+
.duration(this.options.elementAccessors.getBlock().transitionManager.durations.chartUpdate));
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
setAttrs(lines) {
|
|
60
|
+
//TODO: make though render and update pipeline
|
|
61
|
+
return lines
|
|
62
|
+
.attr("x1", (d) => d.x1)
|
|
63
|
+
.attr("y1", (d) => d.y1)
|
|
64
|
+
.attr("x2", (d) => d.x2)
|
|
65
|
+
.attr("y2", (d) => d.y2);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -8,7 +8,8 @@ export declare class TwoDimensionalManager implements ChartContentManager {
|
|
|
8
8
|
private canvasValueLabels?;
|
|
9
9
|
private linearGradientDef?;
|
|
10
10
|
private dotChart;
|
|
11
|
-
private groupLabels
|
|
11
|
+
private groupLabels?;
|
|
12
|
+
private groupLines?;
|
|
12
13
|
render(engine: Engine, model: Model<TwoDimensionalOptionsModel>): void;
|
|
13
14
|
updateData(block: Block, model: Model<TwoDimensionalOptionsModel>, data: MdtChartsDataSource): void;
|
|
14
15
|
updateColors(block: Block, model: Model<TwoDimensionalOptionsModel>): void;
|
|
@@ -17,6 +17,7 @@ import { LinearGradientDef } from "../../engine/block/defs/LinearGradientDef";
|
|
|
17
17
|
import { CanvasDotChart } from "./dot/dotChart";
|
|
18
18
|
import { RecordOverflowAlertCore } from "../features/recordOverflowAlert/recordOverflowAlertCore";
|
|
19
19
|
import { GroupAxisLabels } from "../features/groupLabels/groupLabels";
|
|
20
|
+
import { GroupLines } from "../features/groupLines/groupLines";
|
|
20
21
|
export class TwoDimensionalManager {
|
|
21
22
|
render(engine, model) {
|
|
22
23
|
const options = model.options;
|
|
@@ -39,12 +40,20 @@ export class TwoDimensionalManager {
|
|
|
39
40
|
settings: options.chartSettings.bar
|
|
40
41
|
}
|
|
41
42
|
});
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
if (options.grouping.enabled) {
|
|
44
|
+
this.groupLabels = new GroupAxisLabels({
|
|
45
|
+
elementAccessors: {
|
|
46
|
+
getBlock: () => engine.block
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
this.groupLabels.render(options.grouping.items.map((item) => item.labels));
|
|
50
|
+
this.groupLines = new GroupLines({
|
|
51
|
+
elementAccessors: {
|
|
52
|
+
getBlock: () => engine.block
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
this.groupLines.render(options.grouping.edgeLines, options.grouping.items.map((item) => item.splitLines));
|
|
56
|
+
}
|
|
48
57
|
this.renderCharts(engine.block, options.charts, scales, engine.data, options.data, model.chartBlock.margin, options.axis.key.orient, options.chartSettings, model.blockCanvas.size);
|
|
49
58
|
Axis.raiseKeyAxis(engine.block, options.axis.key);
|
|
50
59
|
engine.block.filterEventManager.registerEventFor2D(scales.key, model.chartBlock.margin, model.blockCanvas.size, options);
|
|
@@ -78,6 +87,7 @@ export class TwoDimensionalManager {
|
|
|
78
87
|
}
|
|
79
88
|
}
|
|
80
89
|
updateData(block, model, data) {
|
|
90
|
+
var _a, _b;
|
|
81
91
|
block.transitionManager.interruptTransitions();
|
|
82
92
|
block.filterEventManager.updateData(data[model.options.data.dataSource]);
|
|
83
93
|
Title.updateData(block, model.options.title);
|
|
@@ -90,7 +100,10 @@ export class TwoDimensionalManager {
|
|
|
90
100
|
block.scales = scales;
|
|
91
101
|
Axis.update(block, scales, options.scale, options.axis, model.blockCanvas.size, keyDomainEquality);
|
|
92
102
|
GridLine.update(block, options.additionalElements.gridLine, options.axis, model.blockCanvas.size, model.chartBlock.margin, scales);
|
|
93
|
-
|
|
103
|
+
if (options.grouping.enabled) {
|
|
104
|
+
(_a = this.groupLabels) === null || _a === void 0 ? void 0 : _a.update(options.grouping.items.map((item) => item.labels));
|
|
105
|
+
(_b = this.groupLines) === null || _b === void 0 ? void 0 : _b.update(options.grouping.edgeLines, options.grouping.items.map((item) => item.splitLines));
|
|
106
|
+
}
|
|
94
107
|
const promises = this.updateCharts(block, options.charts, scales, data, model.options.data, model.chartBlock.margin, options.axis.key.orient, model.blockCanvas.size, options.chartSettings);
|
|
95
108
|
Promise.all(promises).then(() => {
|
|
96
109
|
block.filterEventManager.event2DUpdate(options);
|
package/lib/model/featuresModel/grouping/groupingCanvasCalculator/groupingCanvasCalculator.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { MdtChartsBaseField, MdtChartsDataRow } from "../../../../config/config";
|
|
2
|
+
import { GroupingLabelKey, RangeModel } from "../../../model";
|
|
3
|
+
import { KeyScaleInfoForGroupingLabelsScaler } from "../groupingLabels/groupingLabelsScaler";
|
|
4
|
+
interface GroupingCanvasCalculatorOptions {
|
|
5
|
+
keyScaleInfo: KeyScaleInfoForGroupingLabelsScaler;
|
|
6
|
+
dataRows: MdtChartsDataRow[];
|
|
7
|
+
field: MdtChartsBaseField;
|
|
8
|
+
range: RangeModel;
|
|
9
|
+
}
|
|
10
|
+
export declare class GroupingCanvasCalculator {
|
|
11
|
+
private readonly options;
|
|
12
|
+
constructor(options: GroupingCanvasCalculatorOptions);
|
|
13
|
+
calculate(): {
|
|
14
|
+
rowsCountsPerGroups: number[];
|
|
15
|
+
oneShareSize: number;
|
|
16
|
+
keyAxisOuterPadding: number;
|
|
17
|
+
keyAxisInnerPadding: number;
|
|
18
|
+
groupDomain: GroupingLabelKey[];
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export class GroupingCanvasCalculator {
|
|
2
|
+
constructor(options) {
|
|
3
|
+
this.options = options;
|
|
4
|
+
}
|
|
5
|
+
calculate() {
|
|
6
|
+
let keyAxisInnerPadding = 0;
|
|
7
|
+
let keyAxisOuterPadding = 0;
|
|
8
|
+
if (this.options.keyScaleInfo.type === "band") {
|
|
9
|
+
keyAxisInnerPadding = this.options.keyScaleInfo.keyAxisInnerPadding;
|
|
10
|
+
keyAxisOuterPadding = this.options.keyScaleInfo.keyAxisOuterPadding;
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
keyAxisInnerPadding =
|
|
14
|
+
(this.options.range.end - this.options.range.start) / (this.options.dataRows.length - 1);
|
|
15
|
+
keyAxisOuterPadding = 0;
|
|
16
|
+
}
|
|
17
|
+
const domainWithRowsCount = new Map();
|
|
18
|
+
this.options.dataRows.forEach((row) => {
|
|
19
|
+
const key = row[this.options.field.name];
|
|
20
|
+
if (key) {
|
|
21
|
+
if (domainWithRowsCount.has(key))
|
|
22
|
+
domainWithRowsCount.set(key, domainWithRowsCount.get(key) + 1);
|
|
23
|
+
else
|
|
24
|
+
domainWithRowsCount.set(key, 1);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
const rangeOfKeyAxis = Math.abs(this.options.range.end - this.options.range.start) -
|
|
28
|
+
keyAxisOuterPadding * 2 -
|
|
29
|
+
keyAxisInnerPadding * (this.options.dataRows.length - 1);
|
|
30
|
+
const totalShares = Array.from(domainWithRowsCount.values()).reduce((acc, curr) => acc + curr, 0);
|
|
31
|
+
const oneShareSize = rangeOfKeyAxis / totalShares;
|
|
32
|
+
const rowsCounts = Array.from(domainWithRowsCount.values());
|
|
33
|
+
return {
|
|
34
|
+
rowsCountsPerGroups: rowsCounts,
|
|
35
|
+
oneShareSize,
|
|
36
|
+
keyAxisInnerPadding,
|
|
37
|
+
keyAxisOuterPadding,
|
|
38
|
+
groupDomain: Array.from(domainWithRowsCount.keys())
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { GroupingSplitLineAttributes, Orient } from "../../../model";
|
|
2
|
+
import { CanvasModel } from "../../../modelInstance/canvasModel/canvasModel";
|
|
3
|
+
import { GroupingStaticCoordinateCalculator } from "../groupingLabels/staticCoordinateCalculator";
|
|
4
|
+
interface GroupingEdgeLinesGeneratorOptions {
|
|
5
|
+
orients: Iterable<Orient>;
|
|
6
|
+
staticCoordinateCalculator: GroupingStaticCoordinateCalculator;
|
|
7
|
+
canvasModel: CanvasModel;
|
|
8
|
+
}
|
|
9
|
+
export declare class GroupingEdgeLinesGenerator {
|
|
10
|
+
private readonly options;
|
|
11
|
+
constructor(options: GroupingEdgeLinesGeneratorOptions);
|
|
12
|
+
generate(): GroupingSplitLineAttributes[];
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export class GroupingEdgeLinesGenerator {
|
|
2
|
+
constructor(options) {
|
|
3
|
+
this.options = options;
|
|
4
|
+
}
|
|
5
|
+
generate() {
|
|
6
|
+
let edgeLines = [];
|
|
7
|
+
for (const orient of this.options.orients) {
|
|
8
|
+
if (orient === "top") {
|
|
9
|
+
const y1 = this.options.staticCoordinateCalculator.calculate(orient, 0);
|
|
10
|
+
const y2 = this.options.canvasModel.getMarginSide("top");
|
|
11
|
+
const leftX = this.options.canvasModel.getMarginSide("left");
|
|
12
|
+
const rightX = this.options.canvasModel.getBlockSize().width - this.options.canvasModel.getMarginSide("right");
|
|
13
|
+
edgeLines = edgeLines.concat([
|
|
14
|
+
{ x1: leftX, x2: leftX, y1, y2 },
|
|
15
|
+
{ x1: rightX, x2: rightX, y1, y2 }
|
|
16
|
+
]);
|
|
17
|
+
}
|
|
18
|
+
if (orient === "bottom") {
|
|
19
|
+
const y1 = this.options.canvasModel.getBlockSize().height - this.options.canvasModel.getMarginSide("bottom");
|
|
20
|
+
const y2 = this.options.staticCoordinateCalculator.calculate(orient, 0);
|
|
21
|
+
const leftX = this.options.canvasModel.getMarginSide("left");
|
|
22
|
+
const rightX = this.options.canvasModel.getBlockSize().width - this.options.canvasModel.getMarginSide("right");
|
|
23
|
+
edgeLines = edgeLines.concat([
|
|
24
|
+
{ x1: leftX, x2: leftX, y1, y2 },
|
|
25
|
+
{ x1: rightX, x2: rightX, y1, y2 }
|
|
26
|
+
]);
|
|
27
|
+
}
|
|
28
|
+
if (orient === "left") {
|
|
29
|
+
const x1 = this.options.staticCoordinateCalculator.calculate(orient, 0);
|
|
30
|
+
const x2 = this.options.canvasModel.getMarginSide("left");
|
|
31
|
+
const topY = this.options.canvasModel.getMarginSide("top");
|
|
32
|
+
const bottomY = this.options.canvasModel.getBlockSize().height - this.options.canvasModel.getMarginSide("bottom");
|
|
33
|
+
edgeLines = edgeLines.concat([
|
|
34
|
+
{ x1, x2, y1: topY, y2: topY },
|
|
35
|
+
{ x1, x2, y1: bottomY, y2: bottomY }
|
|
36
|
+
]);
|
|
37
|
+
}
|
|
38
|
+
if (orient === "right") {
|
|
39
|
+
const x1 = this.options.canvasModel.getBlockSize().width - this.options.canvasModel.getMarginSide("right");
|
|
40
|
+
const x2 = this.options.staticCoordinateCalculator.calculate(orient, 0);
|
|
41
|
+
const topY = this.options.canvasModel.getMarginSide("top");
|
|
42
|
+
const bottomY = this.options.canvasModel.getBlockSize().height - this.options.canvasModel.getMarginSide("bottom");
|
|
43
|
+
edgeLines = edgeLines.concat([
|
|
44
|
+
{ x1, x2, y1: topY, y2: topY },
|
|
45
|
+
{ x1, x2, y1: bottomY, y2: bottomY }
|
|
46
|
+
]);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return edgeLines;
|
|
50
|
+
}
|
|
51
|
+
}
|
package/lib/model/featuresModel/grouping/groupingLabels/groupingLabelsCoordinateHandlers.d.ts
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
import { Orient } from "../../../model";
|
|
2
2
|
import { CanvasModel } from "../../../modelInstance/canvasModel/canvasModel";
|
|
3
|
+
import { GroupingStaticCoordinateCalculator } from "./staticCoordinateCalculator";
|
|
3
4
|
interface GroupingLabelsCoordinateHandlerOptions {
|
|
4
5
|
orient: Orient;
|
|
5
6
|
sideIndex: number;
|
|
6
|
-
|
|
7
|
-
titleTotalNeededSpace: number;
|
|
8
|
-
legendTotalNeededSpace: number;
|
|
9
|
-
};
|
|
7
|
+
staticCoordinateCalculator: GroupingStaticCoordinateCalculator;
|
|
10
8
|
}
|
|
11
9
|
export declare class GroupingLabelsCoordinateHandler {
|
|
12
10
|
private readonly canvasModel;
|
|
13
11
|
private readonly options;
|
|
14
12
|
private readonly staticCoordinate;
|
|
15
|
-
private readonly verticalLabelSize;
|
|
16
13
|
constructor(canvasModel: CanvasModel, options: GroupingLabelsCoordinateHandlerOptions);
|
|
17
14
|
handleX(scaledCoordinate: number): number;
|
|
18
15
|
handleY(scaledCoordinate: number): number;
|
|
@@ -2,20 +2,7 @@ export class GroupingLabelsCoordinateHandler {
|
|
|
2
2
|
constructor(canvasModel, options) {
|
|
3
3
|
this.canvasModel = canvasModel;
|
|
4
4
|
this.options = options;
|
|
5
|
-
this.
|
|
6
|
-
if (this.options.orient === "top")
|
|
7
|
-
this.staticCoordinate =
|
|
8
|
-
options.otherComponentSizes.titleTotalNeededSpace + this.verticalLabelSize * this.options.sideIndex;
|
|
9
|
-
if (this.options.orient === "bottom")
|
|
10
|
-
this.staticCoordinate =
|
|
11
|
-
this.canvasModel.getBlockSize().height -
|
|
12
|
-
options.otherComponentSizes.legendTotalNeededSpace -
|
|
13
|
-
this.verticalLabelSize * this.options.sideIndex;
|
|
14
|
-
//TODO: padding should be got from other components
|
|
15
|
-
if (this.options.orient === "left")
|
|
16
|
-
this.staticCoordinate = 20 * this.options.sideIndex;
|
|
17
|
-
if (this.options.orient === "right")
|
|
18
|
-
this.staticCoordinate = this.canvasModel.getBlockSize().width - 20 * this.options.sideIndex;
|
|
5
|
+
this.staticCoordinate = this.options.staticCoordinateCalculator.calculate(this.options.orient, this.options.sideIndex);
|
|
19
6
|
}
|
|
20
7
|
handleX(scaledCoordinate) {
|
|
21
8
|
let x;
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { GroupingLabelKey } from "../../../model";
|
|
2
|
+
import { GroupingCanvasCalculator } from "../groupingCanvasCalculator/groupingCanvasCalculator";
|
|
3
3
|
interface GroupingLabelsCoordinateScalerOptions {
|
|
4
|
-
|
|
5
|
-
field: MdtChartsBaseField;
|
|
6
|
-
keyScaleInfo: KeyScaleInfoForGroupingLabelsScaler;
|
|
7
|
-
range: RangeModel;
|
|
4
|
+
groupingCanvasCalculator: GroupingCanvasCalculator;
|
|
8
5
|
}
|
|
9
6
|
export declare type KeyScaleInfoForGroupingLabelsScaler = {
|
|
10
7
|
type: "band";
|
|
@@ -2,37 +2,11 @@ import { scaleOrdinal } from "d3-scale";
|
|
|
2
2
|
export class GroupingLabelsCoordinateScaler {
|
|
3
3
|
constructor(options) {
|
|
4
4
|
this.options = options;
|
|
5
|
-
|
|
6
|
-
let keyAxisOuterPadding = 0;
|
|
7
|
-
if (this.options.keyScaleInfo.type === "band") {
|
|
8
|
-
keyAxisInnerPadding = this.options.keyScaleInfo.keyAxisInnerPadding;
|
|
9
|
-
keyAxisOuterPadding = this.options.keyScaleInfo.keyAxisOuterPadding;
|
|
10
|
-
}
|
|
11
|
-
else {
|
|
12
|
-
keyAxisInnerPadding =
|
|
13
|
-
(this.options.range.end - this.options.range.start) / (this.options.dataRows.length - 1);
|
|
14
|
-
keyAxisOuterPadding = 0;
|
|
15
|
-
}
|
|
16
|
-
const domainWithRowsCount = new Map();
|
|
17
|
-
this.options.dataRows.forEach((row) => {
|
|
18
|
-
const key = row[this.options.field.name];
|
|
19
|
-
if (key) {
|
|
20
|
-
if (domainWithRowsCount.has(key))
|
|
21
|
-
domainWithRowsCount.set(key, domainWithRowsCount.get(key) + 1);
|
|
22
|
-
else
|
|
23
|
-
domainWithRowsCount.set(key, 1);
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
const rangeOfKeyAxis = Math.abs(this.options.range.end - this.options.range.start) -
|
|
27
|
-
keyAxisOuterPadding * 2 -
|
|
28
|
-
keyAxisInnerPadding * (this.options.dataRows.length - 1);
|
|
29
|
-
const totalShares = Array.from(domainWithRowsCount.values()).reduce((acc, curr) => acc + curr, 0);
|
|
30
|
-
const oneShareSize = rangeOfKeyAxis / totalShares;
|
|
31
|
-
const coordinates = [];
|
|
5
|
+
const { keyAxisInnerPadding, keyAxisOuterPadding, oneShareSize, rowsCountsPerGroups, groupDomain } = this.options.groupingCanvasCalculator.calculate();
|
|
32
6
|
let previousTotalShares = 0;
|
|
33
|
-
const
|
|
34
|
-
for (let rowIndex = 0; rowIndex <
|
|
35
|
-
const rowsAmount =
|
|
7
|
+
const coordinates = [];
|
|
8
|
+
for (let rowIndex = 0; rowIndex < rowsCountsPerGroups.length; rowIndex++) {
|
|
9
|
+
const rowsAmount = rowsCountsPerGroups[rowIndex];
|
|
36
10
|
let previousShift = previousTotalShares * (oneShareSize + keyAxisInnerPadding);
|
|
37
11
|
const centerOfDomainItem = previousShift +
|
|
38
12
|
(rowsAmount * oneShareSize + (rowsAmount - 1) * keyAxisInnerPadding) / 2 +
|
|
@@ -40,7 +14,7 @@ export class GroupingLabelsCoordinateScaler {
|
|
|
40
14
|
coordinates.push(centerOfDomainItem);
|
|
41
15
|
previousTotalShares += rowsAmount;
|
|
42
16
|
}
|
|
43
|
-
const d3Scale = scaleOrdinal(
|
|
17
|
+
const d3Scale = scaleOrdinal(groupDomain, coordinates);
|
|
44
18
|
this.scaleFn = (key) => d3Scale(key);
|
|
45
19
|
}
|
|
46
20
|
scaleForKey(groupingKey) {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Orient } from "../../../model";
|
|
2
|
+
import { CanvasModel } from "../../../modelInstance/canvasModel/canvasModel";
|
|
3
|
+
import { GroupingItemSize } from "../../../modelInstance/configReader/twoDimConfigReader/groupingConfigReader/groupingConfigReader";
|
|
4
|
+
interface GroupingStaticCoordinateCalculatorOptions {
|
|
5
|
+
otherComponentSizes: {
|
|
6
|
+
titleTotalNeededSpace: number;
|
|
7
|
+
legendTotalNeededSpace: number;
|
|
8
|
+
};
|
|
9
|
+
groupingItemSizes: GroupingItemSize[];
|
|
10
|
+
}
|
|
11
|
+
export declare class GroupingStaticCoordinateCalculator {
|
|
12
|
+
private readonly canvasModel;
|
|
13
|
+
private readonly options;
|
|
14
|
+
constructor(canvasModel: CanvasModel, options: GroupingStaticCoordinateCalculatorOptions);
|
|
15
|
+
calculate(orient: Orient, sideIndex: number): number;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export class GroupingStaticCoordinateCalculator {
|
|
2
|
+
constructor(canvasModel, options) {
|
|
3
|
+
this.canvasModel = canvasModel;
|
|
4
|
+
this.options = options;
|
|
5
|
+
}
|
|
6
|
+
calculate(orient, sideIndex) {
|
|
7
|
+
const slicesSizesByCurrentOrient = this.options.groupingItemSizes.filter((item) => item.orient === orient);
|
|
8
|
+
const prevSlicesSizes = slicesSizesByCurrentOrient
|
|
9
|
+
.slice(0, sideIndex)
|
|
10
|
+
.reduce((acc, item) => acc + item.size, 0);
|
|
11
|
+
let staticCoordinate;
|
|
12
|
+
if (orient === "top")
|
|
13
|
+
staticCoordinate = this.options.otherComponentSizes.titleTotalNeededSpace + prevSlicesSizes * sideIndex;
|
|
14
|
+
if (orient === "bottom")
|
|
15
|
+
staticCoordinate =
|
|
16
|
+
this.canvasModel.getBlockSize().height -
|
|
17
|
+
this.options.otherComponentSizes.legendTotalNeededSpace -
|
|
18
|
+
prevSlicesSizes * sideIndex;
|
|
19
|
+
if (orient === "left")
|
|
20
|
+
staticCoordinate = prevSlicesSizes * sideIndex;
|
|
21
|
+
if (orient === "right")
|
|
22
|
+
staticCoordinate = this.canvasModel.getBlockSize().width - prevSlicesSizes * sideIndex;
|
|
23
|
+
if (staticCoordinate === undefined) {
|
|
24
|
+
throw new Error(`Static coordinate for orient ${orient} and sideIndex ${sideIndex} is undefined`);
|
|
25
|
+
}
|
|
26
|
+
return staticCoordinate;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { GroupingSplitLineAttributes, Orient } from "../../../model";
|
|
2
|
+
import { CanvasModel } from "../../../modelInstance/canvasModel/canvasModel";
|
|
3
|
+
import { GroupingCanvasCalculator } from "../groupingCanvasCalculator/groupingCanvasCalculator";
|
|
4
|
+
import { GroupingStaticCoordinateCalculator } from "../groupingLabels/staticCoordinateCalculator";
|
|
5
|
+
interface GroupingSplitLinesGeneratorOptions {
|
|
6
|
+
groupingCanvasCalculator: GroupingCanvasCalculator;
|
|
7
|
+
orient: Orient;
|
|
8
|
+
sideIndex: number;
|
|
9
|
+
staticCoordinateCalculator: GroupingStaticCoordinateCalculator;
|
|
10
|
+
canvasModel: CanvasModel;
|
|
11
|
+
}
|
|
12
|
+
export declare class GroupingSplitLinesGenerator {
|
|
13
|
+
private readonly options;
|
|
14
|
+
constructor(options: GroupingSplitLinesGeneratorOptions);
|
|
15
|
+
generate(): GroupingSplitLineAttributes[];
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export class GroupingSplitLinesGenerator {
|
|
2
|
+
constructor(options) {
|
|
3
|
+
this.options = options;
|
|
4
|
+
}
|
|
5
|
+
generate() {
|
|
6
|
+
let previousTotalShares = 0;
|
|
7
|
+
const coordinates = [];
|
|
8
|
+
const { keyAxisInnerPadding, keyAxisOuterPadding, oneShareSize, rowsCountsPerGroups } = this.options.groupingCanvasCalculator.calculate();
|
|
9
|
+
for (let rowIndex = 0; rowIndex < rowsCountsPerGroups.length - 1; rowIndex++) {
|
|
10
|
+
const rowsAmount = rowsCountsPerGroups[rowIndex];
|
|
11
|
+
let previousShift = previousTotalShares * (oneShareSize + keyAxisInnerPadding);
|
|
12
|
+
const coordinate = previousShift +
|
|
13
|
+
keyAxisOuterPadding +
|
|
14
|
+
rowsAmount * (oneShareSize + keyAxisInnerPadding) -
|
|
15
|
+
keyAxisInnerPadding / 2;
|
|
16
|
+
coordinates.push(coordinate);
|
|
17
|
+
previousTotalShares += rowsAmount;
|
|
18
|
+
}
|
|
19
|
+
return coordinates.map((coordinate) => {
|
|
20
|
+
if (this.options.orient === "bottom") {
|
|
21
|
+
const y1 = this.options.canvasModel.getBlockSize().height - this.options.canvasModel.getMarginSide("bottom");
|
|
22
|
+
const y2 = this.options.staticCoordinateCalculator.calculate(this.options.orient, this.options.sideIndex);
|
|
23
|
+
const coordinateWithMargin = coordinate + this.options.canvasModel.getMarginSide("left");
|
|
24
|
+
return { x1: coordinateWithMargin, x2: coordinateWithMargin, y1, y2 };
|
|
25
|
+
}
|
|
26
|
+
if (this.options.orient === "top") {
|
|
27
|
+
const y1 = this.options.staticCoordinateCalculator.calculate(this.options.orient, this.options.sideIndex);
|
|
28
|
+
const y2 = this.options.canvasModel.getMarginSide("top");
|
|
29
|
+
const coordinateWithMargin = coordinate + this.options.canvasModel.getMarginSide("left");
|
|
30
|
+
return { x1: coordinateWithMargin, x2: coordinateWithMargin, y1, y2 };
|
|
31
|
+
}
|
|
32
|
+
if (this.options.orient === "left") {
|
|
33
|
+
const x1 = this.options.staticCoordinateCalculator.calculate(this.options.orient, this.options.sideIndex);
|
|
34
|
+
const x2 = this.options.canvasModel.getMarginSide("left");
|
|
35
|
+
const coordinateWithMargin = coordinate + this.options.canvasModel.getMarginSide("top");
|
|
36
|
+
return { x1, x2, y1: coordinateWithMargin, y2: coordinateWithMargin };
|
|
37
|
+
}
|
|
38
|
+
if (this.options.orient === "right") {
|
|
39
|
+
const x1 = this.options.staticCoordinateCalculator.calculate(this.options.orient, this.options.sideIndex);
|
|
40
|
+
const x2 = this.options.canvasModel.getBlockSize().width - this.options.canvasModel.getMarginSide("right");
|
|
41
|
+
const coordinateWithMargin = coordinate + this.options.canvasModel.getMarginSide("top");
|
|
42
|
+
return { x1, x2, y1: coordinateWithMargin, y2: coordinateWithMargin };
|
|
43
|
+
}
|
|
44
|
+
throw new Error("Got unknown orient when generate grouping split lines");
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MdtChartsTwoDimLegend } from "../../../config/config";
|
|
2
2
|
import { LegendBlockModel } from "../../model";
|
|
3
|
-
import { TwoDimConfigReader } from "../../modelInstance/configReader/twoDimConfigReader
|
|
3
|
+
import { TwoDimConfigReader } from "../../modelInstance/configReader/twoDimConfigReader/twoDimConfigReader";
|
|
4
4
|
import { ModelInstance } from "../../modelInstance/modelInstance";
|
|
5
5
|
export declare class TwoDimLegendModel {
|
|
6
6
|
private configReader;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ScaleKeyModel, ScaleValueModel } from "../../model";
|
|
2
2
|
import { MdtChartsTwoDimensionalOptions, MdtChartsDataRow } from "../../../config/config";
|
|
3
3
|
import { CanvasModel } from "../../modelInstance/canvasModel/canvasModel";
|
|
4
|
-
import { TwoDimConfigReader } from "../../modelInstance/configReader/twoDimConfigReader
|
|
4
|
+
import { TwoDimConfigReader } from "../../modelInstance/configReader/twoDimConfigReader/twoDimConfigReader";
|
|
5
5
|
import { BarOptionsCanvas } from "../../../designer/designerConfig";
|
|
6
6
|
export declare enum ScaleType {
|
|
7
7
|
Key = 0,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DesignerConfig } from "../../../designer/designerConfig";
|
|
2
2
|
import { OtherCommonComponents } from "../../model";
|
|
3
|
-
import { TwoDimConfigReader } from "../../modelInstance/configReader/twoDimConfigReader
|
|
3
|
+
import { TwoDimConfigReader } from "../../modelInstance/configReader/twoDimConfigReader/twoDimConfigReader";
|
|
4
4
|
import { ModelInstance } from "../../modelInstance/modelInstance";
|
|
5
5
|
export declare const AXIS_HORIZONTAL_LABEL_PADDING = 12;
|
|
6
6
|
export declare const AXIS_VERTICAL_LABEL_PADDING = 8;
|
|
@@ -113,7 +113,9 @@ export class TwoDimMarginModel {
|
|
|
113
113
|
top: "bottom",
|
|
114
114
|
bottom: "top"
|
|
115
115
|
};
|
|
116
|
-
canvasModel.increaseMarginSide(axisMarginMapping[keyAxisOrient],
|
|
116
|
+
canvasModel.increaseMarginSide(axisMarginMapping[keyAxisOrient],
|
|
117
|
+
//TODO: calculate according to offsetSize from config for each chart
|
|
118
|
+
valueLabelFontSize + VALUE_LABEL_OFFSET_ABS_SIZE_PX);
|
|
117
119
|
}
|
|
118
120
|
getValueAxisLabels(scaleModel) {
|
|
119
121
|
const scale = Scale.getScaleValue(scaleModel);
|
package/lib/model/model.d.ts
CHANGED
|
@@ -312,6 +312,7 @@ export declare type ValueLabelsChartBlockSide = {
|
|
|
312
312
|
export interface TwoDimGroupingModel {
|
|
313
313
|
enabled: boolean;
|
|
314
314
|
items: TwoDimGroupingItemModel[];
|
|
315
|
+
edgeLines: GroupingSplitLineAttributes[];
|
|
315
316
|
}
|
|
316
317
|
export interface GroupingLabelCoordinate {
|
|
317
318
|
x: number;
|
|
@@ -319,8 +320,11 @@ export interface GroupingLabelCoordinate {
|
|
|
319
320
|
}
|
|
320
321
|
export declare type GroupingLabelKey = string | number;
|
|
321
322
|
export interface TwoDimGroupingItemModel {
|
|
323
|
+
labels: GroupingItemLabelsModel;
|
|
324
|
+
splitLines: GroupingSplitLineAttributes[];
|
|
325
|
+
}
|
|
326
|
+
export interface GroupingItemLabelsModel {
|
|
322
327
|
domain: GroupingLabelKey[];
|
|
323
|
-
orient: Orient;
|
|
324
328
|
textAnchor: TextAnchor;
|
|
325
329
|
dominantBaseline: DominantBaseline;
|
|
326
330
|
coordinate: {
|
|
@@ -328,6 +332,12 @@ export interface TwoDimGroupingItemModel {
|
|
|
328
332
|
handleY: (key: GroupingLabelKey) => number;
|
|
329
333
|
};
|
|
330
334
|
}
|
|
335
|
+
export interface GroupingSplitLineAttributes {
|
|
336
|
+
x1: number;
|
|
337
|
+
x2: number;
|
|
338
|
+
y1: number;
|
|
339
|
+
y2: number;
|
|
340
|
+
}
|
|
331
341
|
export interface DonutChartSettings extends Omit<DonutOptionsCanvas, "aggregatorPad" | "thickness"> {
|
|
332
342
|
aggregator: DonutAggregatorModel;
|
|
333
343
|
thickness: DonutThicknessOptions;
|
|
@@ -5,7 +5,7 @@ import { DataManagerModel } from "./dataManagerModel/dataManagerModel";
|
|
|
5
5
|
import { OtherComponentsModel } from "./featuresModel/otherComponents";
|
|
6
6
|
import { ConfigValidator } from "./configsValidator/configValidator";
|
|
7
7
|
import { ModelInstance } from "./modelInstance/modelInstance";
|
|
8
|
-
import { TwoDimConfigReader } from "./modelInstance/configReader/twoDimConfigReader
|
|
8
|
+
import { TwoDimConfigReader } from "./modelInstance/configReader/twoDimConfigReader/twoDimConfigReader";
|
|
9
9
|
import { TitleConfigReader } from "./modelInstance/titleConfigReader";
|
|
10
10
|
export var AxisType;
|
|
11
11
|
(function (AxisType) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PolarConfigReader } from "./polarConfigReader/polarConfigReader";
|
|
2
|
-
import { TwoDimConfigReader } from "./twoDimConfigReader
|
|
2
|
+
import { TwoDimConfigReader } from "./twoDimConfigReader/twoDimConfigReader";
|
|
3
3
|
export function getConfigReader(config, designerConfig) {
|
|
4
4
|
if (config.options.type === "2d")
|
|
5
5
|
return new TwoDimConfigReader(config, designerConfig);
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { ChartOrientation, DiscreteAxisOptions, MdtChartsBaseField, MdtChartsDataRow, TwoDimGroupingOptions } from "../../../../../config/config";
|
|
2
2
|
import { DominantBaseline, Orient, TextAnchor } from "../../../../model";
|
|
3
|
+
export interface GroupingItemSize {
|
|
4
|
+
orient: Orient;
|
|
5
|
+
size: number;
|
|
6
|
+
}
|
|
3
7
|
export declare class GroupingConfigReader {
|
|
4
8
|
private readonly keyAxisOptions;
|
|
5
9
|
private readonly chartOrientation;
|
|
@@ -7,14 +11,8 @@ export declare class GroupingConfigReader {
|
|
|
7
11
|
private readonly maxLabelSize;
|
|
8
12
|
constructor(keyAxisOptions: DiscreteAxisOptions, chartOrientation: ChartOrientation, groupingOptions?: TwoDimGroupingOptions);
|
|
9
13
|
isEnabled(): boolean;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
amount: number;
|
|
13
|
-
}[];
|
|
14
|
-
getSlicesSizesByOrients(dataRows: MdtChartsDataRow[]): {
|
|
15
|
-
orient: Orient;
|
|
16
|
-
size: number;
|
|
17
|
-
}[];
|
|
14
|
+
getUsingOrients(): Set<Orient>;
|
|
15
|
+
getSlicesSizesByOrients(dataRows: MdtChartsDataRow[]): GroupingItemSize[];
|
|
18
16
|
getPreparedOptions(scopedDatasourceRows: MdtChartsDataRow[]): {
|
|
19
17
|
domain: string[];
|
|
20
18
|
orient: Orient;
|
|
@@ -7,35 +7,15 @@ export class GroupingConfigReader {
|
|
|
7
7
|
this.maxLabelSize = 60;
|
|
8
8
|
}
|
|
9
9
|
isEnabled() {
|
|
10
|
-
return
|
|
10
|
+
return !!this.groupingOptions && this.groupingOptions.items.length > 0;
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
var _a, _b, _c
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
const pushIfAmountIsNotZero = (orient, amount) => {
|
|
18
|
-
if (amount > 0) {
|
|
19
|
-
slices.push({ orient, amount });
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
if (this.chartOrientation === "vertical") {
|
|
23
|
-
pushIfAmountIsNotZero("top", this.keyAxisOptions.position === "start"
|
|
24
|
-
? slicesAmountFromKeyAxisSide
|
|
25
|
-
: slicesAmountOppositeToKeyAxisSide);
|
|
26
|
-
pushIfAmountIsNotZero("bottom", this.keyAxisOptions.position === "start"
|
|
27
|
-
? slicesAmountOppositeToKeyAxisSide
|
|
28
|
-
: slicesAmountFromKeyAxisSide);
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
pushIfAmountIsNotZero("left", this.keyAxisOptions.position === "start"
|
|
32
|
-
? slicesAmountFromKeyAxisSide
|
|
33
|
-
: slicesAmountOppositeToKeyAxisSide);
|
|
34
|
-
pushIfAmountIsNotZero("right", this.keyAxisOptions.position === "start"
|
|
35
|
-
? slicesAmountOppositeToKeyAxisSide
|
|
36
|
-
: slicesAmountFromKeyAxisSide);
|
|
12
|
+
getUsingOrients() {
|
|
13
|
+
var _a, _b, _c;
|
|
14
|
+
const usingOrients = new Set();
|
|
15
|
+
for (const item of (_b = (_a = this.groupingOptions) === null || _a === void 0 ? void 0 : _a.items) !== null && _b !== void 0 ? _b : []) {
|
|
16
|
+
usingOrients.add(this.getLabelOrient((_c = item.labels) === null || _c === void 0 ? void 0 : _c.position));
|
|
37
17
|
}
|
|
38
|
-
return
|
|
18
|
+
return usingOrients;
|
|
39
19
|
}
|
|
40
20
|
getSlicesSizesByOrients(dataRows) {
|
|
41
21
|
var _a;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ChartOrientation, MdtChartsTwoDimensionalChart } from "../../config/config";
|
|
2
2
|
import { ChartOptionsCanvas, DesignerConfig } from "../../designer/designerConfig";
|
|
3
3
|
import { TwoDimensionalOptionsModel, TwoDimChartElementsSettings } from "../model";
|
|
4
|
-
import { TwoDimConfigReader } from "../modelInstance/configReader/twoDimConfigReader
|
|
4
|
+
import { TwoDimConfigReader } from "../modelInstance/configReader/twoDimConfigReader/twoDimConfigReader";
|
|
5
5
|
import { ModelInstance } from "../modelInstance/modelInstance";
|
|
6
6
|
export declare class TwoDimensionalModel {
|
|
7
7
|
static getOptions(configReader: TwoDimConfigReader, designerConfig: DesignerConfig, modelInstance: ModelInstance): TwoDimensionalOptionsModel;
|
|
@@ -12,6 +12,10 @@ import { TwoDimTooltipContentGenerator } from "../featuresModel/tooltipModel/too
|
|
|
12
12
|
import { TwoDimInitialRowsProvider } from "../featuresModel/tooltipModel/contentByNotations/twoDimInitialRowsProvider";
|
|
13
13
|
import { GroupingLabelsCoordinateHandler } from "../featuresModel/grouping/groupingLabels/groupingLabelsCoordinateHandlers";
|
|
14
14
|
import { GroupingLabelsCoordinateScaler } from "../featuresModel/grouping/groupingLabels/groupingLabelsScaler";
|
|
15
|
+
import { GroupingStaticCoordinateCalculator } from "../featuresModel/grouping/groupingLabels/staticCoordinateCalculator";
|
|
16
|
+
import { GroupingEdgeLinesGenerator } from "../featuresModel/grouping/groupingEdgeLines/groupingEdgeLinesGenerator";
|
|
17
|
+
import { GroupingSplitLinesGenerator } from "../featuresModel/grouping/groupingSplitLines/groupingSplitLines";
|
|
18
|
+
import { GroupingCanvasCalculator } from "../featuresModel/grouping/groupingCanvasCalculator/groupingCanvasCalculator";
|
|
15
19
|
export class TwoDimensionalModel {
|
|
16
20
|
static getOptions(configReader, designerConfig, modelInstance) {
|
|
17
21
|
const options = configReader.options;
|
|
@@ -31,6 +35,18 @@ export class TwoDimensionalModel {
|
|
|
31
35
|
const titleConfig = TitleConfigReader.create(options.title, modelInstance);
|
|
32
36
|
const keyScale = scaleModel.getScaleKey(modelInstance.dataModel.getAllowableKeys());
|
|
33
37
|
const isHorizontal = options.orientation === "horizontal";
|
|
38
|
+
const groupingStaticCoordinateCalculator = new GroupingStaticCoordinateCalculator(canvasModel, {
|
|
39
|
+
otherComponentSizes: {
|
|
40
|
+
titleTotalNeededSpace: canvasModel.titleCanvas.getAllNeededSpace(),
|
|
41
|
+
legendTotalNeededSpace: canvasModel.legendCanvas.getAllNeededSpace()
|
|
42
|
+
},
|
|
43
|
+
groupingItemSizes: configReader.grouping.getSlicesSizesByOrients(modelInstance.dataModel.repository.getScopedRows())
|
|
44
|
+
});
|
|
45
|
+
const groupingEdgeLinesGenerator = new GroupingEdgeLinesGenerator({
|
|
46
|
+
canvasModel,
|
|
47
|
+
orients: configReader.grouping.getUsingOrients(),
|
|
48
|
+
staticCoordinateCalculator: groupingStaticCoordinateCalculator
|
|
49
|
+
});
|
|
34
50
|
return {
|
|
35
51
|
legend: canvasModel.legendCanvas.getModel(),
|
|
36
52
|
title: {
|
|
@@ -39,6 +55,7 @@ export class TwoDimensionalModel {
|
|
|
39
55
|
},
|
|
40
56
|
grouping: {
|
|
41
57
|
enabled: configReader.grouping.isEnabled(),
|
|
58
|
+
edgeLines: groupingEdgeLinesGenerator.generate(),
|
|
42
59
|
items: configReader.grouping
|
|
43
60
|
.getPreparedOptions(modelInstance.dataModel.repository.getScopedRows())
|
|
44
61
|
.map((prepared) => {
|
|
@@ -50,32 +67,38 @@ export class TwoDimensionalModel {
|
|
|
50
67
|
keyAxisInnerPadding: keyScale.sizes.paddingInner
|
|
51
68
|
};
|
|
52
69
|
}
|
|
53
|
-
else
|
|
70
|
+
else
|
|
54
71
|
keyScaleInfo = { type: "point" };
|
|
55
|
-
|
|
56
|
-
const scaler = new GroupingLabelsCoordinateScaler({
|
|
72
|
+
const groupingCanvasCalculator = new GroupingCanvasCalculator({
|
|
57
73
|
dataRows: modelInstance.dataModel.repository.getScopedRows(),
|
|
58
74
|
field: prepared.field,
|
|
59
75
|
keyScaleInfo,
|
|
60
76
|
range: keyScale.range
|
|
61
77
|
});
|
|
78
|
+
const scaler = new GroupingLabelsCoordinateScaler({ groupingCanvasCalculator });
|
|
62
79
|
const coordinateHandler = new GroupingLabelsCoordinateHandler(canvasModel, {
|
|
63
80
|
orient: prepared.orient,
|
|
64
81
|
sideIndex: prepared.sideIndex,
|
|
65
|
-
|
|
66
|
-
titleTotalNeededSpace: canvasModel.titleCanvas.getAllNeededSpace(),
|
|
67
|
-
legendTotalNeededSpace: canvasModel.legendCanvas.getAllNeededSpace()
|
|
68
|
-
}
|
|
82
|
+
staticCoordinateCalculator: groupingStaticCoordinateCalculator
|
|
69
83
|
});
|
|
70
|
-
|
|
84
|
+
const splitLinesGenerator = new GroupingSplitLinesGenerator({
|
|
85
|
+
canvasModel,
|
|
71
86
|
orient: prepared.orient,
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
87
|
+
sideIndex: prepared.sideIndex,
|
|
88
|
+
staticCoordinateCalculator: groupingStaticCoordinateCalculator,
|
|
89
|
+
groupingCanvasCalculator
|
|
90
|
+
});
|
|
91
|
+
return {
|
|
92
|
+
labels: {
|
|
93
|
+
domain: prepared.domain,
|
|
94
|
+
textAnchor: prepared.textAnchor,
|
|
95
|
+
dominantBaseline: prepared.dominantBaseline,
|
|
96
|
+
coordinate: {
|
|
97
|
+
handleX: (groupKey) => coordinateHandler.handleX(scaler.scaleForKey(groupKey)),
|
|
98
|
+
handleY: (groupKey) => coordinateHandler.handleY(scaler.scaleForKey(groupKey))
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
splitLines: splitLinesGenerator.generate()
|
|
79
102
|
};
|
|
80
103
|
})
|
|
81
104
|
},
|
|
@@ -213,6 +213,12 @@
|
|
|
213
213
|
stroke: rgba(231, 229, 228, 0.8);
|
|
214
214
|
}
|
|
215
215
|
|
|
216
|
+
/* Group lines */
|
|
217
|
+
.group-edge-lines line,
|
|
218
|
+
.group-split-lines line {
|
|
219
|
+
stroke: rgba(231, 229, 228, 0.8);
|
|
220
|
+
}
|
|
221
|
+
|
|
216
222
|
/* Aggregator */
|
|
217
223
|
.aggregator-value, .aggregator-name {
|
|
218
224
|
color: #000000;
|
|
@@ -213,6 +213,12 @@
|
|
|
213
213
|
stroke: rgba(231, 229, 228, 0.8);
|
|
214
214
|
}
|
|
215
215
|
|
|
216
|
+
/* Group lines */
|
|
217
|
+
.group-edge-lines line,
|
|
218
|
+
.group-split-lines line {
|
|
219
|
+
stroke: rgba(231, 229, 228, 0.8);
|
|
220
|
+
}
|
|
221
|
+
|
|
216
222
|
/* Aggregator */
|
|
217
223
|
.aggregator-value, .aggregator-name {
|
|
218
224
|
color: #000000;
|
package/package.json
CHANGED
|
File without changes
|