mdt-charts 1.27.1 → 1.27.3
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/.prettierrc +6 -0
- package/lib/config/config.d.ts +13 -13
- package/lib/designer/designerConfig.d.ts +1 -1
- package/lib/engine/block/block.js +14 -14
- package/lib/engine/block/blockHelper.js +2 -2
- package/lib/engine/block/blockSvg.js +25 -28
- package/lib/engine/block/defs/LinearGradientDef.js +9 -8
- package/lib/engine/contentManager/contentManagerFactory.js +1 -1
- package/lib/engine/elementHighlighter/elementHighlighter.d.ts +3 -3
- package/lib/engine/elementHighlighter/elementHighlighter.js +52 -54
- package/lib/engine/elementHighlighter/selectHighlighter.js +7 -7
- package/lib/engine/engine.d.ts +4 -4
- package/lib/engine/engine.js +5 -5
- package/lib/engine/features/aggregator/aggregator.d.ts +1 -1
- package/lib/engine/features/aggregator/aggregator.js +43 -45
- package/lib/engine/features/axis/axis.d.ts +1 -1
- package/lib/engine/features/axis/axis.js +53 -48
- package/lib/engine/features/axis/axisDomHelper.d.ts +3 -3
- package/lib/engine/features/axis/axisDomHelper.js +6 -8
- package/lib/engine/features/axis/axisHelper.d.ts +2 -2
- package/lib/engine/features/axis/axisHelper.js +14 -21
- package/lib/engine/features/axis/axisLabelDomHelper.d.ts +3 -3
- package/lib/engine/features/axis/axisLabelDomHelper.js +74 -66
- package/lib/engine/features/axis/axisLabelsEventManager.js +11 -11
- package/lib/engine/features/embeddedLabels/embeddedLabels.d.ts +3 -3
- package/lib/engine/features/embeddedLabels/embeddedLabels.js +44 -44
- package/lib/engine/features/embeddedLabels/embeddedLabelsDomHelper.d.ts +1 -1
- package/lib/engine/features/embeddedLabels/embeddedLabelsDomHelper.js +3 -6
- package/lib/engine/features/embeddedLabels/embeddedLabelsHelper.d.ts +2 -2
- package/lib/engine/features/embeddedLabels/embeddedLabelsHelper.js +22 -20
- package/lib/engine/features/gridLine/gidLineHelper.d.ts +1 -1
- package/lib/engine/features/gridLine/gidLineHelper.js +5 -5
- package/lib/engine/features/gridLine/gridLine.js +14 -23
- package/lib/engine/features/legend/legend.js +27 -36
- package/lib/engine/features/legend/legendDomHelper.js +18 -9
- package/lib/engine/features/legend/legendEventsManager.js +18 -13
- package/lib/engine/features/legend/legendHelper.js +19 -19
- package/lib/engine/features/legend/legendHelperService.js +5 -5
- package/lib/engine/features/legend/legendMarkerCreator.js +23 -22
- package/lib/engine/features/legend/legendWidthCalculator.js +5 -7
- package/lib/engine/features/markDots/markDot.d.ts +2 -2
- package/lib/engine/features/markDots/markDot.js +35 -34
- package/lib/engine/features/markDots/markDotsHelper.js +6 -6
- package/lib/engine/features/recordOverflowAlert/recordOverflowAlertCore.js +11 -11
- package/lib/engine/features/scale/scale.d.ts +4 -5
- package/lib/engine/features/scale/scale.js +16 -25
- package/lib/engine/features/tipBox/tipBox.d.ts +2 -2
- package/lib/engine/features/tipBox/tipBox.js +13 -17
- package/lib/engine/features/tipBox/tipBoxHelper.js +5 -5
- package/lib/engine/features/title/title.d.ts +1 -1
- package/lib/engine/features/title/title.js +8 -11
- package/lib/engine/features/tolltip/newTooltip/newTooltip.d.ts +1 -1
- package/lib/engine/features/tolltip/newTooltip/newTooltip.js +6 -8
- package/lib/engine/features/tolltip/tooltip.d.ts +2 -2
- package/lib/engine/features/tolltip/tooltip.js +47 -42
- package/lib/engine/features/tolltip/tooltipComponentsManager.d.ts +2 -2
- package/lib/engine/features/tolltip/tooltipComponentsManager.js +49 -52
- package/lib/engine/features/tolltip/tooltipDomHelper.d.ts +1 -1
- package/lib/engine/features/tolltip/tooltipDomHelper.js +41 -33
- package/lib/engine/features/tolltip/tooltipHelper.js +15 -11
- package/lib/engine/features/valueLabels/valueLabels.d.ts +3 -2
- package/lib/engine/features/valueLabels/valueLabels.js +33 -44
- package/lib/engine/features/valueLabels/valueLabelsHelper.js +6 -6
- package/lib/engine/features/valueLabelsCollision/valueLabelsCollision.js +9 -10
- package/lib/engine/features/valueLabelsCollision/valueLabelsCollisionHelper.js +4 -4
- package/lib/engine/filterManager/filterEventManager.js +18 -15
- package/lib/engine/helpers/domHelper.d.ts +3 -4
- package/lib/engine/helpers/domHelper.js +9 -13
- package/lib/engine/helpers/fontResizer/fontResizer.js +2 -2
- package/lib/engine/helpers/helper.js +14 -9
- package/lib/engine/helpers/namesHelper.js +2 -2
- package/lib/engine/polarNotation/donut/DonutHelper.js +6 -8
- package/lib/engine/polarNotation/donut/donut.d.ts +3 -3
- package/lib/engine/polarNotation/donut/donut.js +47 -58
- package/lib/engine/polarNotation/extenders/polarRecordOverflowAlert.js +11 -11
- package/lib/engine/polarNotation/polarManager.js +3 -5
- package/lib/engine/transitionManager.js +4 -7
- package/lib/engine/twoDimensionalNotation/area/area.d.ts +1 -1
- package/lib/engine/twoDimensionalNotation/area/area.js +77 -62
- package/lib/engine/twoDimensionalNotation/area/areaGenerator.js +4 -10
- package/lib/engine/twoDimensionalNotation/area/areaHelper.d.ts +3 -3
- package/lib/engine/twoDimensionalNotation/area/areaHelper.js +21 -13
- package/lib/engine/twoDimensionalNotation/bar/bar.d.ts +2 -2
- package/lib/engine/twoDimensionalNotation/bar/bar.js +70 -67
- package/lib/engine/twoDimensionalNotation/bar/barHelper.js +40 -35
- package/lib/engine/twoDimensionalNotation/dot/dotChart.js +60 -42
- package/lib/engine/twoDimensionalNotation/extenders/twoDimRecordOverflowAlert.js +7 -7
- package/lib/engine/twoDimensionalNotation/line/line.d.ts +4 -4
- package/lib/engine/twoDimensionalNotation/line/line.js +45 -28
- package/lib/engine/twoDimensionalNotation/line/lineBuilder.js +18 -16
- package/lib/engine/twoDimensionalNotation/line/lineGenerator.js +2 -4
- package/lib/engine/twoDimensionalNotation/line/lineHelper.d.ts +6 -6
- package/lib/engine/twoDimensionalNotation/line/lineHelper.js +26 -17
- package/lib/engine/twoDimensionalNotation/lineLike/generatorMiddleware/lineLikeGeneratorDefineMiddleware.js +1 -1
- package/lib/engine/twoDimensionalNotation/twoDimensionalManager.js +25 -21
- package/lib/engine/valueFormatter.d.ts +1 -1
- package/lib/main.d.ts +1 -0
- package/lib/main.js +8 -7
- package/lib/model/chartStyleModel/chartStyleModel.js +5 -3
- package/lib/model/chartStyleModel/colorRange.js +1 -3
- package/lib/model/chartStyleModel/twoDimensionalChartStyleModel.js +9 -7
- package/lib/model/dataManagerModel/dataManagerModel.js +28 -16
- package/lib/model/featuresModel/axisModel.d.ts +6 -3
- package/lib/model/featuresModel/axisModel.js +59 -32
- package/lib/model/featuresModel/axisModelService.js +2 -2
- package/lib/model/featuresModel/legendModel/legendCanvasModel.d.ts +1 -1
- package/lib/model/featuresModel/legendModel/legendCanvasModel.js +12 -12
- package/lib/model/featuresModel/legendModel/legendModel.js +2 -2
- package/lib/model/featuresModel/legendModel/polarMarginCalculator.js +1 -1
- package/lib/model/featuresModel/legendModel/twoDimLegendModel.js +4 -5
- package/lib/model/featuresModel/scaleModel/scaleAxisRecalcer.d.ts +4 -5
- package/lib/model/featuresModel/scaleModel/scaleAxisRecalcer.js +3 -5
- package/lib/model/featuresModel/scaleModel/scaleDomainService.js +10 -12
- package/lib/model/featuresModel/scaleModel/scaleModel.d.ts +8 -4
- package/lib/model/featuresModel/scaleModel/scaleModel.js +20 -12
- package/lib/model/featuresModel/scaleModel/scaleModelServices.js +5 -5
- package/lib/model/featuresModel/tooltipModel.js +1 -1
- package/lib/model/featuresModel/valueLabelsModel/valueLabelsModel.js +5 -5
- package/lib/model/helpers/modelHelper.js +6 -4
- package/lib/model/helpers/twoDimensionalModelHelper.d.ts +1 -1
- package/lib/model/helpers/twoDimensionalModelHelper.js +23 -23
- package/lib/model/helpers/unitsReader.js +1 -1
- package/lib/model/margin/marginModel.js +1 -1
- package/lib/model/margin/twoDim/twoDimMarginModel.d.ts +1 -0
- package/lib/model/margin/twoDim/twoDimMarginModel.js +38 -28
- package/lib/model/model.d.ts +17 -4
- package/lib/model/modelBuilder.d.ts +4 -4
- package/lib/model/modelBuilder.js +19 -18
- package/lib/model/modelInstance/canvasModel/canvasSizesModel/marginModelService.js +1 -1
- package/lib/model/modelInstance/chartBlockVersion/chartBlockVersion.d.ts +5 -0
- package/lib/model/modelInstance/chartBlockVersion/chartBlockVersion.js +8 -0
- package/lib/model/modelInstance/configReader.js +11 -10
- package/lib/model/modelInstance/dataModel/dataRepository.js +5 -5
- package/lib/model/modelInstance/modelInstance.d.ts +4 -2
- package/lib/model/modelInstance/modelInstance.js +5 -3
- package/lib/model/modelInstance/titleConfigReader.js +5 -5
- package/lib/model/notations/polar/donut/donutModel.js +1 -1
- package/lib/model/notations/polar/polarModel.js +6 -6
- package/lib/model/notations/twoDimensional/styles.d.ts +2 -2
- package/lib/model/notations/twoDimensional/styles.js +8 -8
- package/lib/model/notations/twoDimensionalModel.d.ts +0 -1
- package/lib/model/notations/twoDimensionalModel.js +32 -29
- package/package.json +59 -59
- package/tsconfig.production.json +14 -24
- package/README.md +0 -2
|
@@ -13,11 +13,9 @@ export class ChartValueLabels {
|
|
|
13
13
|
this.chart = chart;
|
|
14
14
|
this.renderPipeline = new Pipeline();
|
|
15
15
|
this.attrsProvider = new ValueLabelsAttrsProvider();
|
|
16
|
+
this.options = chart.valueLabels;
|
|
16
17
|
this.renderPipeline.push((valueLabels, { style }) => {
|
|
17
|
-
valueLabels
|
|
18
|
-
.attr('fill', 'currentColor')
|
|
19
|
-
.style('font-size', style.fontSize)
|
|
20
|
-
.style('color', style.color);
|
|
18
|
+
valueLabels.attr("fill", "currentColor").style("font-size", style.fontSize).style("color", style.color);
|
|
21
19
|
if (style.cssClassName)
|
|
22
20
|
valueLabels.classed(style.cssClassName, true);
|
|
23
21
|
return valueLabels;
|
|
@@ -27,83 +25,75 @@ export class ChartValueLabels {
|
|
|
27
25
|
if (this.chart.isSegmented) {
|
|
28
26
|
const preparedData = getStackedData(data, this.chart);
|
|
29
27
|
preparedData.forEach((segment, segmentIndex) => {
|
|
30
|
-
this.renderByGroupIndex(scales, segmentIndex, segment, segment[0].fieldName,
|
|
28
|
+
this.renderByGroupIndex(scales, segmentIndex, segment, segment[0].fieldName, "1", (d) => d.data);
|
|
31
29
|
});
|
|
32
30
|
}
|
|
33
31
|
else {
|
|
34
32
|
this.chart.data.valueFields.forEach((valueField, vfIndex) => {
|
|
35
|
-
this.renderByGroupIndex(scales, vfIndex, data, valueField.name, valueField.name, d => d);
|
|
33
|
+
this.renderByGroupIndex(scales, vfIndex, data, valueField.name, valueField.name, (d) => d);
|
|
36
34
|
});
|
|
37
35
|
}
|
|
38
36
|
}
|
|
39
|
-
update(scales, newData) {
|
|
37
|
+
update(scales, newData, updatedOptions) {
|
|
40
38
|
const updatePromises = [];
|
|
39
|
+
this.options = updatedOptions;
|
|
41
40
|
if (this.chart.isSegmented) {
|
|
42
41
|
const preparedData = getStackedData(newData, this.chart);
|
|
43
42
|
preparedData.forEach((segment, segmentIndex) => {
|
|
44
|
-
const promise = this.updateByGroupIndex(scales, segmentIndex, segment, segment[0].fieldName,
|
|
43
|
+
const promise = this.updateByGroupIndex(scales, segmentIndex, segment, segment[0].fieldName, "1", (d) => d.data);
|
|
45
44
|
updatePromises.push(promise);
|
|
46
45
|
});
|
|
47
46
|
}
|
|
48
47
|
else {
|
|
49
48
|
this.chart.data.valueFields.forEach((valueField, vfIndex) => {
|
|
50
|
-
const promise = this.updateByGroupIndex(scales, vfIndex, newData, valueField.name, valueField.name, d => d);
|
|
49
|
+
const promise = this.updateByGroupIndex(scales, vfIndex, newData, valueField.name, valueField.name, (d) => d);
|
|
51
50
|
updatePromises.push(promise);
|
|
52
51
|
});
|
|
53
52
|
}
|
|
54
53
|
return Promise.all(updatePromises);
|
|
55
54
|
}
|
|
56
55
|
renderByGroupIndex(scales, groupIndex, data, valueFieldName, datumField, dataRowAccessor) {
|
|
57
|
-
let valueLabels = this.getAllValueLabelsOfChart(groupIndex)
|
|
58
|
-
.data(data)
|
|
59
|
-
.enter()
|
|
60
|
-
.append('text');
|
|
56
|
+
let valueLabels = this.getAllValueLabelsOfChart(groupIndex).data(data).enter().append("text");
|
|
61
57
|
valueLabels = this.renderPipeline.execute(valueLabels, { style: this.globalOptions.canvas.style });
|
|
62
|
-
const attrs = this.attrsProvider.getAttrs(this.globalOptions, this.
|
|
63
|
-
this.setAttrs(valueLabels, attrs, valueFieldName, this.
|
|
58
|
+
const attrs = this.attrsProvider.getAttrs(this.globalOptions, this.options, scales, datumField, dataRowAccessor);
|
|
59
|
+
this.setAttrs(valueLabels, attrs, valueFieldName, this.options.format, dataRowAccessor);
|
|
64
60
|
this.setClasses(valueLabels, this.chart.cssClasses, groupIndex);
|
|
65
61
|
}
|
|
66
62
|
updateByGroupIndex(scales, groupIndex, data, valueFieldName, datumField, dataRowAccessor) {
|
|
67
63
|
return new Promise((resolve) => {
|
|
68
|
-
const valueLabels = this.getAllValueLabelsOfChart(groupIndex)
|
|
69
|
-
.data(data);
|
|
64
|
+
const valueLabels = this.getAllValueLabelsOfChart(groupIndex).data(data);
|
|
70
65
|
valueLabels.exit().remove();
|
|
71
|
-
const attrs = this.attrsProvider.getAttrs(this.globalOptions, this.
|
|
72
|
-
let newValueLabels = valueLabels
|
|
73
|
-
.enter()
|
|
74
|
-
.append('text');
|
|
66
|
+
const attrs = this.attrsProvider.getAttrs(this.globalOptions, this.options, scales, datumField, dataRowAccessor);
|
|
67
|
+
let newValueLabels = valueLabels.enter().append("text");
|
|
75
68
|
newValueLabels = this.renderPipeline.execute(newValueLabels, { style: this.globalOptions.canvas.style });
|
|
76
69
|
const mergedValueLabels = newValueLabels.merge(valueLabels);
|
|
77
|
-
this.setAttrs(newValueLabels, attrs, valueFieldName, this.
|
|
70
|
+
this.setAttrs(newValueLabels, attrs, valueFieldName, this.options.format, dataRowAccessor);
|
|
78
71
|
this.setClasses(mergedValueLabels, this.chart.cssClasses, groupIndex);
|
|
79
|
-
this.setAttrs(valueLabels, attrs, valueFieldName, this.
|
|
72
|
+
this.setAttrs(valueLabels, attrs, valueFieldName, this.options.format, dataRowAccessor, true, resolve);
|
|
80
73
|
});
|
|
81
74
|
}
|
|
82
75
|
getAllValueLabelsOfChart(vfIndex) {
|
|
83
76
|
const block = this.globalOptions.elementAccessors.getBlock().svg.getChartBlock();
|
|
84
|
-
return block
|
|
85
|
-
.selectAll(`.${ChartValueLabels.valueLabelClass}.${CLASSES.dataLabel}${Helper.getCssClassesLine(this.chart.cssClasses)}.chart-element-${vfIndex}`);
|
|
77
|
+
return block.selectAll(`.${ChartValueLabels.valueLabelClass}.${CLASSES.dataLabel}${Helper.getCssClassesLine(this.chart.cssClasses)}.chart-element-${vfIndex}`);
|
|
86
78
|
}
|
|
87
79
|
setAttrs(valueLabels, attrs, valueFieldName, formatter, dataRowAccessor, animate = false, onEndAnimation) {
|
|
88
|
-
const animationName =
|
|
80
|
+
const animationName = "labels-updating";
|
|
89
81
|
valueLabels
|
|
90
|
-
.text(d => formatter(dataRowAccessor(d)[valueFieldName]))
|
|
91
|
-
.attr(
|
|
92
|
-
.attr(
|
|
82
|
+
.text((d) => formatter(dataRowAccessor(d)[valueFieldName]))
|
|
83
|
+
.attr("dominant-baseline", attrs.dominantBaseline)
|
|
84
|
+
.attr("text-anchor", attrs.textAnchor);
|
|
93
85
|
if (animate) {
|
|
94
86
|
const transition = valueLabels
|
|
95
87
|
.interrupt(animationName)
|
|
96
88
|
.transition(animationName)
|
|
97
89
|
.duration(this.globalOptions.elementAccessors.getBlock().transitionManager.durations.chartUpdate)
|
|
98
|
-
.attr(
|
|
99
|
-
.attr(
|
|
90
|
+
.attr("x", (d) => attrs.x(d))
|
|
91
|
+
.attr("y", (d) => attrs.y(d));
|
|
100
92
|
if (onEndAnimation)
|
|
101
|
-
transition.on(
|
|
93
|
+
transition.on("end", onEndAnimation);
|
|
102
94
|
}
|
|
103
95
|
else {
|
|
104
|
-
valueLabels
|
|
105
|
-
.attr('x', d => attrs.x(d))
|
|
106
|
-
.attr('y', d => attrs.y(d));
|
|
96
|
+
valueLabels.attr("x", (d) => attrs.x(d)).attr("y", (d) => attrs.y(d));
|
|
107
97
|
}
|
|
108
98
|
}
|
|
109
99
|
setClasses(textLabels, cssClasses, vfIndex) {
|
|
@@ -120,10 +110,10 @@ export class CanvasValueLabels {
|
|
|
120
110
|
}
|
|
121
111
|
render(scales, charts, data, dataOptions) {
|
|
122
112
|
const valueLabelsSettings = this.options.canvas.valueLabels;
|
|
123
|
-
const chartsWithLabels = charts.filter(chart => { var _a; return (_a = chart.valueLabels) === null || _a === void 0 ? void 0 : _a.show; });
|
|
113
|
+
const chartsWithLabels = charts.filter((chart) => { var _a; return (_a = chart.valueLabels) === null || _a === void 0 ? void 0 : _a.show; });
|
|
124
114
|
if (chartsWithLabels.length === 0)
|
|
125
115
|
return;
|
|
126
|
-
chartsWithLabels.forEach(chart => {
|
|
116
|
+
chartsWithLabels.forEach((chart) => {
|
|
127
117
|
const chartScales = this.getChartScales(scales, chart);
|
|
128
118
|
const chartValueLabels = new ChartValueLabels(this.options, chart);
|
|
129
119
|
this.chartsValueLabels.push(chartValueLabels);
|
|
@@ -134,14 +124,14 @@ export class CanvasValueLabels {
|
|
|
134
124
|
}
|
|
135
125
|
update(scales, charts, data, dataOptions) {
|
|
136
126
|
const valueLabelsSettings = this.options.canvas.valueLabels;
|
|
137
|
-
const chartsWithLabels = charts.filter(chart => { var _a; return (_a = chart.valueLabels) === null || _a === void 0 ? void 0 : _a.show; });
|
|
127
|
+
const chartsWithLabels = charts.filter((chart) => { var _a; return (_a = chart.valueLabels) === null || _a === void 0 ? void 0 : _a.show; });
|
|
138
128
|
if (chartsWithLabels.length === 0)
|
|
139
129
|
return;
|
|
140
|
-
if (this.options.canvas.valueLabels.collision.otherValueLables.mode ===
|
|
130
|
+
if (this.options.canvas.valueLabels.collision.otherValueLables.mode === "hide")
|
|
141
131
|
this.toggleOldValueLabelsVisibility();
|
|
142
132
|
const chartsUpdatePromises = chartsWithLabels.map((chart, index) => {
|
|
143
133
|
const chartScales = this.getChartScales(scales, chart);
|
|
144
|
-
return this.chartsValueLabels[index].update(chartScales, data[dataOptions.dataSource]);
|
|
134
|
+
return this.chartsValueLabels[index].update(chartScales, data[dataOptions.dataSource], chart.valueLabels);
|
|
145
135
|
});
|
|
146
136
|
Promise.all(chartsUpdatePromises).then(() => {
|
|
147
137
|
const newValueLabels = this.getAllValueLabels();
|
|
@@ -151,14 +141,13 @@ export class CanvasValueLabels {
|
|
|
151
141
|
toggleOldValueLabelsVisibility() {
|
|
152
142
|
const oldValueLabels = this.getAllValueLabels();
|
|
153
143
|
oldValueLabels.each(function () {
|
|
154
|
-
if (this.style.display ===
|
|
155
|
-
select(this).style(
|
|
144
|
+
if (this.style.display === "none")
|
|
145
|
+
select(this).style("display", "block");
|
|
156
146
|
});
|
|
157
147
|
}
|
|
158
148
|
getAllValueLabels() {
|
|
159
149
|
const block = this.options.elementAccessors.getBlock().svg.getChartBlock();
|
|
160
|
-
return block
|
|
161
|
-
.selectAll(`.${ChartValueLabels.valueLabelClass}`);
|
|
150
|
+
return block.selectAll(`.${ChartValueLabels.valueLabelClass}`);
|
|
162
151
|
}
|
|
163
152
|
getChartScales(scales, chart) {
|
|
164
153
|
return {
|
|
@@ -8,13 +8,13 @@ export class ValueLabelsAttrsProvider {
|
|
|
8
8
|
textAnchor: valueLabels.textAnchor
|
|
9
9
|
};
|
|
10
10
|
const orient = globalOptions.canvas.keyAxisOrient;
|
|
11
|
-
if (orient ===
|
|
12
|
-
attrs.x = d => valueLabels.handleX(scales.value(valueLabels.handleScaledValue(d, datumField)));
|
|
13
|
-
attrs.y = d => valueLabels.handleY(Scale.getScaledValue(scales.key, dataRowAccessor(d)[globalOptions.data.keyFieldName]));
|
|
11
|
+
if (orient === "left" || orient === "right") {
|
|
12
|
+
attrs.x = (d) => valueLabels.handleX(scales.value(valueLabels.handleScaledValue(d, datumField)));
|
|
13
|
+
attrs.y = (d) => valueLabels.handleY(Scale.getScaledValue(scales.key, dataRowAccessor(d)[globalOptions.data.keyFieldName]));
|
|
14
14
|
}
|
|
15
|
-
else if (orient ===
|
|
16
|
-
attrs.x = d => valueLabels.handleX(Scale.getScaledValue(scales.key, dataRowAccessor(d)[globalOptions.data.keyFieldName]));
|
|
17
|
-
attrs.y = d => valueLabels.handleY(scales.value(valueLabels.handleScaledValue(d, datumField)));
|
|
15
|
+
else if (orient === "bottom" || orient === "top") {
|
|
16
|
+
attrs.x = (d) => valueLabels.handleX(Scale.getScaledValue(scales.key, dataRowAccessor(d)[globalOptions.data.keyFieldName]));
|
|
17
|
+
attrs.y = (d) => valueLabels.handleY(scales.value(valueLabels.handleScaledValue(d, datumField)));
|
|
18
18
|
}
|
|
19
19
|
return attrs;
|
|
20
20
|
}
|
|
@@ -4,7 +4,7 @@ export class ValueLabelsCollision {
|
|
|
4
4
|
static resolveValueLabelsCollisions(newValueLabels, valueLabelsSettings) {
|
|
5
5
|
const valueLabelElementsRectInfo = this.getValueLabelElementsRectInfo(newValueLabels);
|
|
6
6
|
this.shiftValueLabelsCollision(valueLabelElementsRectInfo, valueLabelsSettings.collision.chartBlock);
|
|
7
|
-
if (valueLabelsSettings.collision.otherValueLables.mode ===
|
|
7
|
+
if (valueLabelsSettings.collision.otherValueLables.mode === "hide")
|
|
8
8
|
this.toggleValueLabelElementsVisibility(valueLabelElementsRectInfo);
|
|
9
9
|
}
|
|
10
10
|
static getValueLabelElementsRectInfo(valueLabels) {
|
|
@@ -22,16 +22,16 @@ export class ValueLabelsCollision {
|
|
|
22
22
|
return ValueLabelElementsReactInfo;
|
|
23
23
|
}
|
|
24
24
|
static shiftValueLabelsCollision(valueLabelElementsRectInfo, chartBlock) {
|
|
25
|
-
valueLabelElementsRectInfo.forEach(element => {
|
|
25
|
+
valueLabelElementsRectInfo.forEach((element) => {
|
|
26
26
|
this.handleCollisionShift(chartBlock, element);
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
static handleCollisionShift(chartBlock, element) {
|
|
30
30
|
const sides = Object.keys(chartBlock);
|
|
31
|
-
sides.forEach(side => {
|
|
31
|
+
sides.forEach((side) => {
|
|
32
32
|
const blockSide = chartBlock[side];
|
|
33
|
-
const axisCoordinate = side ===
|
|
34
|
-
if (blockSide.mode ===
|
|
33
|
+
const axisCoordinate = side === "left" || side === "right" ? "x" : "y";
|
|
34
|
+
if (blockSide.mode === "shift" && blockSide.hasCollision(element.boundingClientRect)) {
|
|
35
35
|
blockSide.shiftCoordinate(element.boundingClientRect);
|
|
36
36
|
this.changeLabelElementCoordinateByAxis(element, axisCoordinate);
|
|
37
37
|
}
|
|
@@ -39,14 +39,13 @@ export class ValueLabelsCollision {
|
|
|
39
39
|
}
|
|
40
40
|
static toggleValueLabelElementsVisibility(elements) {
|
|
41
41
|
const labelsVisibility = ValueLabelsCollisionHelper.calculateValueLabelsVisibility(elements);
|
|
42
|
-
labelsVisibility.forEach(label => {
|
|
43
|
-
const labelInfo = elements.find(element => element.index === label.index);
|
|
42
|
+
labelsVisibility.forEach((label) => {
|
|
43
|
+
const labelInfo = elements.find((element) => element.index === label.index);
|
|
44
44
|
if (labelInfo && !label.isVisible)
|
|
45
|
-
select(labelInfo.svgElement).style(
|
|
45
|
+
select(labelInfo.svgElement).style("display", "none");
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
static changeLabelElementCoordinateByAxis(element, axis) {
|
|
49
|
-
select(element.svgElement)
|
|
50
|
-
.attr(axis, element.boundingClientRect[axis]);
|
|
49
|
+
select(element.svgElement).attr(axis, element.boundingClientRect[axis]);
|
|
51
50
|
}
|
|
52
51
|
}
|
|
@@ -3,13 +3,14 @@ export class ValueLabelsCollisionHelper {
|
|
|
3
3
|
const sortedLabels = elements.sort((label1, label2) => label1.boundingClientRect.x - label2.boundingClientRect.x);
|
|
4
4
|
const activeLabels = [];
|
|
5
5
|
const labelsVisibility = new Map();
|
|
6
|
-
elements.forEach(label => {
|
|
6
|
+
elements.forEach((label) => {
|
|
7
7
|
labelsVisibility.set(label.index, { index: label.index, isVisible: true });
|
|
8
8
|
});
|
|
9
|
-
sortedLabels.forEach(currentLabel => {
|
|
9
|
+
sortedLabels.forEach((currentLabel) => {
|
|
10
10
|
for (let i = activeLabels.length - 1; i >= 0; i--) {
|
|
11
11
|
const activeLabel = activeLabels[i];
|
|
12
|
-
if (activeLabel.boundingClientRect.x + activeLabel.boundingClientRect.width <
|
|
12
|
+
if (activeLabel.boundingClientRect.x + activeLabel.boundingClientRect.width <
|
|
13
|
+
currentLabel.boundingClientRect.x) {
|
|
13
14
|
activeLabels.splice(i, 1);
|
|
14
15
|
}
|
|
15
16
|
}
|
|
@@ -43,5 +44,4 @@ export class ValueLabelsCollisionHelper {
|
|
|
43
44
|
rect1.y + rect1.height < rect2.y ||
|
|
44
45
|
rect1.y > rect2.y + rect2.height);
|
|
45
46
|
}
|
|
46
|
-
;
|
|
47
47
|
}
|
|
@@ -23,20 +23,20 @@ export class FilterEventManager {
|
|
|
23
23
|
this.fullDataset = newDataset;
|
|
24
24
|
}
|
|
25
25
|
isSelected(keyValue) {
|
|
26
|
-
return this.selectedKeys.findIndex(key => key === keyValue) !== -1;
|
|
26
|
+
return this.selectedKeys.findIndex((key) => key === keyValue) !== -1;
|
|
27
27
|
}
|
|
28
28
|
clearKeysFor2D(options) {
|
|
29
29
|
this.selectedKeys = [];
|
|
30
30
|
if (this.callback)
|
|
31
31
|
this.callback([]);
|
|
32
|
-
this.eventEmitter.emit(
|
|
32
|
+
this.eventEmitter.emit("change", this.selectedKeys);
|
|
33
33
|
SelectHighlighter.clear2D(this.block, options);
|
|
34
34
|
}
|
|
35
35
|
clearKeysForPolar(margin, blockSize, options) {
|
|
36
36
|
this.selectedKeys = [];
|
|
37
37
|
if (this.callback)
|
|
38
38
|
this.callback([]);
|
|
39
|
-
this.eventEmitter.emit(
|
|
39
|
+
this.eventEmitter.emit("change", this.selectedKeys);
|
|
40
40
|
SelectHighlighter.clearPolar(margin, blockSize, this.block, options, Donut.getAllArcGroups(this.block), options.chartCanvas);
|
|
41
41
|
}
|
|
42
42
|
setKey(key) {
|
|
@@ -46,11 +46,11 @@ export class FilterEventManager {
|
|
|
46
46
|
this.selectedKeys.push(key);
|
|
47
47
|
}
|
|
48
48
|
removeId(key) {
|
|
49
|
-
this.selectedKeys.splice(this.selectedKeys.findIndex(k => k === key), 1);
|
|
49
|
+
this.selectedKeys.splice(this.selectedKeys.findIndex((k) => k === key), 1);
|
|
50
50
|
}
|
|
51
51
|
processKey(multySelect, keyValue) {
|
|
52
52
|
if (multySelect) {
|
|
53
|
-
if (this.getSelectedKeys().findIndex(key => key === keyValue) === -1) {
|
|
53
|
+
if (this.getSelectedKeys().findIndex((key) => key === keyValue) === -1) {
|
|
54
54
|
this.addId(keyValue);
|
|
55
55
|
return true;
|
|
56
56
|
}
|
|
@@ -73,22 +73,22 @@ export class FilterEventManager {
|
|
|
73
73
|
setListenerPolar(margin, blockSize, options) {
|
|
74
74
|
if (this.filterable) {
|
|
75
75
|
this.registerEventToDonut(margin, blockSize, options, options.chartCanvas);
|
|
76
|
-
const selectedElems = Donut.getAllArcGroups(this.block).filter(d => this.selectedKeys.findIndex(sid => sid === d.data[options.data.keyField.name]) !== -1);
|
|
76
|
+
const selectedElems = Donut.getAllArcGroups(this.block).filter((d) => this.selectedKeys.findIndex((sid) => sid === d.data[options.data.keyField.name]) !== -1);
|
|
77
77
|
this.selectedKeys = [];
|
|
78
|
-
selectedElems.dispatch(
|
|
78
|
+
selectedElems.dispatch("click", { bubbles: false, cancelable: true, detail: { multySelect: true } });
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
event2DUpdate(options) {
|
|
82
82
|
if (this.filterable) {
|
|
83
83
|
const removedKeys = [];
|
|
84
|
-
this.selectedKeys.forEach(key => {
|
|
85
|
-
if (this.fullDataset.findIndex(row => row[options.data.keyField.name] === key) === -1)
|
|
84
|
+
this.selectedKeys.forEach((key) => {
|
|
85
|
+
if (this.fullDataset.findIndex((row) => row[options.data.keyField.name] === key) === -1)
|
|
86
86
|
removedKeys.push(key);
|
|
87
87
|
});
|
|
88
|
-
removedKeys.forEach(rKey => this.selectedKeys.splice(this.selectedKeys.findIndex(sKey => sKey === rKey), 1));
|
|
88
|
+
removedKeys.forEach((rKey) => this.selectedKeys.splice(this.selectedKeys.findIndex((sKey) => sKey === rKey), 1));
|
|
89
89
|
if (removedKeys.length > 0)
|
|
90
90
|
this.eventEmitter.emit("change", this.selectedKeys);
|
|
91
|
-
this.selectedKeys.forEach(key => {
|
|
91
|
+
this.selectedKeys.forEach((key) => {
|
|
92
92
|
SelectHighlighter.click2DHandler(true, true, key, this.selectedKeys, this.block, options);
|
|
93
93
|
});
|
|
94
94
|
}
|
|
@@ -97,9 +97,10 @@ export class FilterEventManager {
|
|
|
97
97
|
if (this.filterable) {
|
|
98
98
|
const tipBox = TipBox.renderOrGet(this.block, margin, blockSize);
|
|
99
99
|
const thisClass = this;
|
|
100
|
-
tipBox.on(
|
|
100
|
+
tipBox.on("click", function (e) {
|
|
101
101
|
const multySelect = thisClass.getMultySelectParam(e);
|
|
102
|
-
const keyValue = e.detail.keyValue ||
|
|
102
|
+
const keyValue = e.detail.keyValue ||
|
|
103
|
+
TipBoxHelper.getKeyValueByPointer(pointer(e, this), options.orient, margin, blockSize, scaleKey, options.scale.key.type);
|
|
103
104
|
const appended = thisClass.processKey(multySelect, keyValue);
|
|
104
105
|
SelectHighlighter.click2DHandler(multySelect, appended, keyValue, thisClass.selectedKeys, thisClass.block, options);
|
|
105
106
|
if (thisClass.callback) {
|
|
@@ -112,7 +113,7 @@ export class FilterEventManager {
|
|
|
112
113
|
registerEventToDonut(margin, blockSize, options, donutSettings) {
|
|
113
114
|
const arcItems = Donut.getAllArcGroups(this.block);
|
|
114
115
|
const thisClass = this;
|
|
115
|
-
arcItems.on(
|
|
116
|
+
arcItems.on("click", function (e, dataRow) {
|
|
116
117
|
const multySelect = thisClass.getMultySelectParam(e);
|
|
117
118
|
const keyValue = dataRow.data[options.data.keyField.name];
|
|
118
119
|
const appended = thisClass.processKey(multySelect, keyValue);
|
|
@@ -129,7 +130,9 @@ export class FilterEventManager {
|
|
|
129
130
|
getMultySelectParam(e) {
|
|
130
131
|
const isMultyButtonToggle = this.getMultyParamByEvent(e);
|
|
131
132
|
return isMultyButtonToggle === undefined
|
|
132
|
-
?
|
|
133
|
+
? e.detail.multySelect === undefined
|
|
134
|
+
? false
|
|
135
|
+
: e.detail.multySelect
|
|
133
136
|
: isMultyButtonToggle;
|
|
134
137
|
}
|
|
135
138
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Selection, BaseType } from
|
|
2
|
-
import { MdtChartsDataRow } from
|
|
1
|
+
import { Selection, BaseType } from "d3-selection";
|
|
2
|
+
import { MdtChartsDataRow } from "../../config/config";
|
|
3
3
|
import { ChartStyle, TwoDimensionalChartModel } from "../../model/model";
|
|
4
4
|
import { Block } from "../block/block";
|
|
5
|
-
declare type StyleColorType =
|
|
5
|
+
declare type StyleColorType = "fill" | "stroke";
|
|
6
6
|
export declare enum SelectionCondition {
|
|
7
7
|
Include = 0,
|
|
8
8
|
Exclude = 1
|
|
@@ -25,7 +25,6 @@ export declare class DomHelper {
|
|
|
25
25
|
* @returns Выборка по ключам
|
|
26
26
|
*/
|
|
27
27
|
static getChartElementsByKeys<T extends BaseType>(initialSelection: Selection<T, MdtChartsDataRow, BaseType, unknown>, dataWrapped: boolean, keyFieldName: string, keyValues: string[], condition?: SelectionCondition): Selection<T, any, BaseType, unknown>;
|
|
28
|
-
static setChartGradientStyle(element: Selection<BaseType, unknown, BaseType, unknown>, chartIndex: number, valueIndex: number): void;
|
|
29
28
|
private static setChartOpacity;
|
|
30
29
|
}
|
|
31
30
|
export {};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { MarkDot } from "../features/markDots/markDot";
|
|
2
2
|
import { Bar } from "../twoDimensionalNotation/bar/bar";
|
|
3
|
-
import { getGradientId } from "../../model/notations/twoDimensional/styles";
|
|
4
3
|
export var SelectionCondition;
|
|
5
4
|
(function (SelectionCondition) {
|
|
6
5
|
SelectionCondition[SelectionCondition["Include"] = 0] = "Include";
|
|
@@ -8,12 +7,12 @@ export var SelectionCondition;
|
|
|
8
7
|
})(SelectionCondition || (SelectionCondition = {}));
|
|
9
8
|
export class DomHelper {
|
|
10
9
|
static setCssClasses(elem, cssClasses) {
|
|
11
|
-
cssClasses.forEach(cssClass => {
|
|
10
|
+
cssClasses.forEach((cssClass) => {
|
|
12
11
|
elem.classed(cssClass, true);
|
|
13
12
|
});
|
|
14
13
|
}
|
|
15
14
|
static get2DChartElements(block, chart) {
|
|
16
|
-
if (chart.type ===
|
|
15
|
+
if (chart.type === "line" || chart.type === "area")
|
|
17
16
|
return MarkDot.getMarkDotForChart(block, chart.cssClasses);
|
|
18
17
|
else
|
|
19
18
|
return Bar.get().getAllBarsForChart(block, chart.cssClasses);
|
|
@@ -32,15 +31,15 @@ export class DomHelper {
|
|
|
32
31
|
elements.style(styleType, colorPalette[fieldIndex % colorPalette.length]);
|
|
33
32
|
}
|
|
34
33
|
static cropSvgLabels(labelBlocks, maxWidth) {
|
|
35
|
-
labelBlocks.nodes().forEach(node => {
|
|
34
|
+
labelBlocks.nodes().forEach((node) => {
|
|
36
35
|
if (node.getBBox().width > maxWidth) {
|
|
37
36
|
const text = node.textContent;
|
|
38
37
|
let textLength = text.length;
|
|
39
38
|
while (node.getBBox().width > maxWidth && textLength > 0) {
|
|
40
|
-
node.textContent = text.substring(0, --textLength) +
|
|
39
|
+
node.textContent = text.substring(0, --textLength) + "...";
|
|
41
40
|
}
|
|
42
41
|
if (textLength === 0)
|
|
43
|
-
node.textContent =
|
|
42
|
+
node.textContent = "";
|
|
44
43
|
}
|
|
45
44
|
});
|
|
46
45
|
}
|
|
@@ -54,19 +53,16 @@ export class DomHelper {
|
|
|
54
53
|
* @returns Выборка по ключам
|
|
55
54
|
*/
|
|
56
55
|
static getChartElementsByKeys(initialSelection, dataWrapped, keyFieldName, keyValues, condition = SelectionCondition.Include) {
|
|
57
|
-
return initialSelection.filter(d => {
|
|
56
|
+
return initialSelection.filter((d) => {
|
|
58
57
|
let i;
|
|
59
58
|
if (dataWrapped)
|
|
60
|
-
i = keyValues.findIndex(kv => kv === d.data[keyFieldName]);
|
|
59
|
+
i = keyValues.findIndex((kv) => kv === d.data[keyFieldName]);
|
|
61
60
|
else
|
|
62
|
-
i = keyValues.findIndex(kv => kv === d[keyFieldName]);
|
|
61
|
+
i = keyValues.findIndex((kv) => kv === d[keyFieldName]);
|
|
63
62
|
return condition === SelectionCondition.Exclude ? i === -1 : i !== -1;
|
|
64
63
|
});
|
|
65
64
|
}
|
|
66
|
-
static setChartGradientStyle(element, chartIndex, valueIndex) {
|
|
67
|
-
element.style('fill', `url(#${getGradientId(chartIndex, valueIndex)})`);
|
|
68
|
-
}
|
|
69
65
|
static setChartOpacity(elements, opacity) {
|
|
70
|
-
elements.attr(
|
|
66
|
+
elements.attr("opacity", opacity);
|
|
71
67
|
}
|
|
72
68
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { resizeFont } from "./fontResizerService";
|
|
2
|
-
export const FontResizer = new class {
|
|
2
|
+
export const FontResizer = new (class {
|
|
3
3
|
setSize(el, options) {
|
|
4
4
|
const wrappedEl = new ResizedElement(el);
|
|
5
5
|
resizeFont(wrappedEl, Object.assign(Object.assign({}, options), { elWrapper: new ResizedElement(options.elWrapper) }));
|
|
6
6
|
}
|
|
7
|
-
};
|
|
7
|
+
})();
|
|
8
8
|
export class ResizedElement {
|
|
9
9
|
constructor(el) {
|
|
10
10
|
this.el = el;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
export class Helper {
|
|
2
2
|
static getRowsByKeys(keys, keyFieldName, dataSet) {
|
|
3
|
-
return dataSet.filter(row => keys.findIndex(key => key === row[keyFieldName]) !== -1);
|
|
3
|
+
return dataSet.filter((row) => keys.findIndex((key) => key === row[keyFieldName]) !== -1);
|
|
4
4
|
}
|
|
5
5
|
static getKeysByIds(ids, keyFieldName, dataSet) {
|
|
6
6
|
return this.extractKeysFromRows(keyFieldName, this.getRowsByIds(ids, dataSet));
|
|
7
7
|
}
|
|
8
8
|
static extractKeysFromRows(keyFieldName, dataSet) {
|
|
9
|
-
return dataSet.map(row => row[keyFieldName]);
|
|
9
|
+
return dataSet.map((row) => row[keyFieldName]);
|
|
10
10
|
}
|
|
11
11
|
static getRowsByIds(ids, dataSet) {
|
|
12
|
-
return dataSet.filter(row => ids.findIndex(id => id === row.$id) !== -1);
|
|
12
|
+
return dataSet.filter((row) => ids.findIndex((id) => id === row.$id) !== -1);
|
|
13
13
|
}
|
|
14
14
|
static getCssClassesLine(cssClasses) {
|
|
15
|
-
return
|
|
15
|
+
return "." + cssClasses.join(".");
|
|
16
16
|
}
|
|
17
17
|
static getCssClassesArray(cssClass) {
|
|
18
|
-
return cssClass.split(
|
|
18
|
+
return cssClass.split(" ");
|
|
19
19
|
}
|
|
20
20
|
static getCssClassesWithElementIndex(cssClasses, index) {
|
|
21
21
|
return cssClasses.concat([`chart-element-${index}`]);
|
|
@@ -27,7 +27,7 @@ export class Helper {
|
|
|
27
27
|
static getTranslateNumbers(transformValue) {
|
|
28
28
|
if (!transformValue)
|
|
29
29
|
return [0, 0];
|
|
30
|
-
const translateNumbers = transformValue.substring(10, transformValue.length - 1).split(
|
|
30
|
+
const translateNumbers = transformValue.substring(10, transformValue.length - 1).split(", ");
|
|
31
31
|
const translateX = parseFloat(translateNumbers[0]);
|
|
32
32
|
const translateY = parseFloat(translateNumbers[1]);
|
|
33
33
|
return [translateX, translateY];
|
|
@@ -36,11 +36,11 @@ export class Helper {
|
|
|
36
36
|
return numbers.reduce((acc, value) => acc + value, 0);
|
|
37
37
|
}
|
|
38
38
|
static parseFormattedToNumber(value, rankSpliter) {
|
|
39
|
-
return parseFloat(value.replace(rankSpliter,
|
|
39
|
+
return parseFloat(value.replace(rankSpliter, ".").split(/\s/).join(""));
|
|
40
40
|
}
|
|
41
41
|
static calcDigitsAfterDot(value) {
|
|
42
42
|
const valueInString = value.toString();
|
|
43
|
-
const dotIndex = valueInString.lastIndexOf(
|
|
43
|
+
const dotIndex = valueInString.lastIndexOf(".") === -1 ? valueInString.length : valueInString.lastIndexOf(".") + 1;
|
|
44
44
|
return valueInString.substring(dotIndex).length;
|
|
45
45
|
}
|
|
46
46
|
static checkDomainsEquality(oldDomain, newDomain) {
|
|
@@ -73,7 +73,12 @@ export class Helper {
|
|
|
73
73
|
* Сравнивает старые и новые данные
|
|
74
74
|
*/
|
|
75
75
|
static compareData(oldSource, newSource, sourceName) {
|
|
76
|
-
if (!oldSource ||
|
|
76
|
+
if (!oldSource ||
|
|
77
|
+
!newSource ||
|
|
78
|
+
!sourceName ||
|
|
79
|
+
!oldSource[sourceName] ||
|
|
80
|
+
!newSource[sourceName] ||
|
|
81
|
+
oldSource[sourceName].length !== newSource[sourceName].length)
|
|
77
82
|
return false;
|
|
78
83
|
const oldData = oldSource[sourceName];
|
|
79
84
|
const newData = newSource[sourceName];
|
|
@@ -3,7 +3,7 @@ export class NamesHelper {
|
|
|
3
3
|
return this.prefix + classOfElem;
|
|
4
4
|
}
|
|
5
5
|
static getId(idName, blockId) {
|
|
6
|
-
return this.prefix + idName +
|
|
6
|
+
return this.prefix + idName + "-" + blockId;
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
|
-
NamesHelper.prefix =
|
|
9
|
+
NamesHelper.prefix = "mdt-charts-";
|
|
@@ -21,7 +21,7 @@ export class DonutHelper {
|
|
|
21
21
|
return arc;
|
|
22
22
|
}
|
|
23
23
|
static getOuterRadius(margin, blockSize) {
|
|
24
|
-
return Math.min(blockSize.width - margin.left - margin.right, blockSize.height - margin.top - margin.bottom) / 2;
|
|
24
|
+
return (Math.min(blockSize.width - margin.left - margin.right, blockSize.height - margin.top - margin.bottom) / 2);
|
|
25
25
|
}
|
|
26
26
|
static getInnerRadius(outerRadius, thickness) {
|
|
27
27
|
return outerRadius - thickness;
|
|
@@ -33,23 +33,21 @@ export class DonutHelper {
|
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
static getArcGenerator(outerRadius, innerRadius) {
|
|
36
|
-
return arc()
|
|
37
|
-
.innerRadius(innerRadius)
|
|
38
|
-
.outerRadius(outerRadius);
|
|
36
|
+
return arc().innerRadius(innerRadius).outerRadius(outerRadius);
|
|
39
37
|
}
|
|
40
38
|
static getPieGenerator(valueField, padAngle) {
|
|
41
39
|
return pie()
|
|
42
40
|
.padAngle(padAngle)
|
|
43
41
|
.sort(null)
|
|
44
|
-
.value(d => d[valueField]);
|
|
42
|
+
.value((d) => d[valueField]);
|
|
45
43
|
}
|
|
46
44
|
static mergeDataWithZeros(firstDataset, secondDataset, keyField, colorField) {
|
|
47
45
|
const secondSet = new Set();
|
|
48
|
-
secondDataset.forEach(dataRow => {
|
|
46
|
+
secondDataset.forEach((dataRow) => {
|
|
49
47
|
secondSet.add(dataRow[keyField]);
|
|
50
48
|
});
|
|
51
49
|
const onlyNew = firstDataset
|
|
52
|
-
.filter(d => !secondSet.has(d[keyField]))
|
|
50
|
+
.filter((d) => !secondSet.has(d[keyField]))
|
|
53
51
|
.map((d, index, array) => {
|
|
54
52
|
const data = {
|
|
55
53
|
keyField: array[index][keyField],
|
|
@@ -66,7 +64,7 @@ export class DonutHelper {
|
|
|
66
64
|
if (unit === "px")
|
|
67
65
|
return valueInPx;
|
|
68
66
|
const minSideSize = Math.min(chartBlockSize.width, chartBlockSize.height);
|
|
69
|
-
return minSideSize / 2 * (valueInPx / 100);
|
|
67
|
+
return (minSideSize / 2) * (valueInPx / 100);
|
|
70
68
|
}
|
|
71
69
|
static getChartBlockSize(blockSize, margin) {
|
|
72
70
|
return {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { PieArcDatum } from
|
|
2
|
-
import { Selection } from
|
|
1
|
+
import { PieArcDatum } from "d3-shape";
|
|
2
|
+
import { Selection } from "d3-selection";
|
|
3
3
|
import { BlockMargin, DonutChartSettings, PolarChartModel } from "../../../model/model";
|
|
4
4
|
import { Block } from "../../block/block";
|
|
5
|
-
import { MdtChartsDataRow, Size } from
|
|
5
|
+
import { MdtChartsDataRow, Size } from "../../../config/config";
|
|
6
6
|
export interface Translate {
|
|
7
7
|
x: number;
|
|
8
8
|
y: number;
|