mdt-charts 1.28.0 → 1.28.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -42,7 +42,7 @@ export declare class CanvasValueLabels {
|
|
|
42
42
|
private chartsValueLabels;
|
|
43
43
|
constructor(options: ValueLabelsOptions);
|
|
44
44
|
render(scales: ScalesWithSecondary, charts: TwoDimensionalChartModel[], data: MdtChartsDataSource, dataOptions: OptionsModelData): void;
|
|
45
|
-
update(scales: ScalesWithSecondary, charts: TwoDimensionalChartModel[], data: MdtChartsDataSource, dataOptions: OptionsModelData): void;
|
|
45
|
+
update(scales: ScalesWithSecondary, charts: TwoDimensionalChartModel[], data: MdtChartsDataSource, dataOptions: OptionsModelData, newCanvasOptions: TwoDimensionalValueLabels): void;
|
|
46
46
|
private toggleOldValueLabelsVisibility;
|
|
47
47
|
private getAllValueLabels;
|
|
48
48
|
private getChartScales;
|
|
@@ -25,6 +25,8 @@ export class ChartValueLabels {
|
|
|
25
25
|
if (this.chart.isSegmented) {
|
|
26
26
|
const preparedData = getStackedData(data, this.chart);
|
|
27
27
|
preparedData.forEach((segment, segmentIndex) => {
|
|
28
|
+
if (!segment[0])
|
|
29
|
+
return;
|
|
28
30
|
this.renderByGroupIndex(scales, segmentIndex, segment, segment[0].fieldName, "1", (d) => d.data);
|
|
29
31
|
});
|
|
30
32
|
}
|
|
@@ -40,13 +42,14 @@ export class ChartValueLabels {
|
|
|
40
42
|
if (this.chart.isSegmented) {
|
|
41
43
|
const preparedData = getStackedData(newData, this.chart);
|
|
42
44
|
preparedData.forEach((segment, segmentIndex) => {
|
|
43
|
-
|
|
45
|
+
var _a;
|
|
46
|
+
const promise = this.updateByGroupIndex(scales, segmentIndex, segment, "1", (d) => d.data, (_a = segment[0]) === null || _a === void 0 ? void 0 : _a.fieldName);
|
|
44
47
|
updatePromises.push(promise);
|
|
45
48
|
});
|
|
46
49
|
}
|
|
47
50
|
else {
|
|
48
51
|
this.chart.data.valueFields.forEach((valueField, vfIndex) => {
|
|
49
|
-
const promise = this.updateByGroupIndex(scales, vfIndex, newData, valueField.name,
|
|
52
|
+
const promise = this.updateByGroupIndex(scales, vfIndex, newData, valueField.name, (d) => d, valueField.name);
|
|
50
53
|
updatePromises.push(promise);
|
|
51
54
|
});
|
|
52
55
|
}
|
|
@@ -59,11 +62,15 @@ export class ChartValueLabels {
|
|
|
59
62
|
this.setAttrs(valueLabels, attrs, valueFieldName, this.options.format, dataRowAccessor);
|
|
60
63
|
this.setClasses(valueLabels, this.chart.cssClasses, groupIndex);
|
|
61
64
|
}
|
|
62
|
-
updateByGroupIndex(scales, groupIndex, data,
|
|
65
|
+
updateByGroupIndex(scales, groupIndex, data, datumField, dataRowAccessor, valueFieldName) {
|
|
63
66
|
return new Promise((resolve) => {
|
|
64
67
|
const valueLabels = this.getAllValueLabelsOfChart(groupIndex).data(data);
|
|
65
68
|
valueLabels.exit().remove();
|
|
66
69
|
const attrs = this.attrsProvider.getAttrs(this.globalOptions, this.options, scales, datumField, dataRowAccessor);
|
|
70
|
+
if (!valueFieldName) {
|
|
71
|
+
resolve();
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
67
74
|
let newValueLabels = valueLabels.enter().append("text");
|
|
68
75
|
newValueLabels = this.renderPipeline.execute(newValueLabels, { style: this.globalOptions.canvas.style });
|
|
69
76
|
const mergedValueLabels = newValueLabels.merge(valueLabels);
|
|
@@ -141,8 +148,8 @@ export class CanvasValueLabels {
|
|
|
141
148
|
const valueLabels = this.getAllValueLabels();
|
|
142
149
|
ValueLabelsCollision.resolveValueLabelsCollisions(valueLabels, valueLabelsSettings);
|
|
143
150
|
}
|
|
144
|
-
update(scales, charts, data, dataOptions) {
|
|
145
|
-
|
|
151
|
+
update(scales, charts, data, dataOptions, newCanvasOptions) {
|
|
152
|
+
this.options.canvas.valueLabels = newCanvasOptions;
|
|
146
153
|
const chartsWithLabels = charts.filter((chart) => { var _a; return (_a = chart.valueLabels) === null || _a === void 0 ? void 0 : _a.show; });
|
|
147
154
|
if (chartsWithLabels.length === 0)
|
|
148
155
|
return;
|
|
@@ -153,7 +160,7 @@ export class CanvasValueLabels {
|
|
|
153
160
|
return this.chartsValueLabels[index].update(chartScales, data[dataOptions.dataSource], chart.valueLabels);
|
|
154
161
|
});
|
|
155
162
|
Promise.all(chartsUpdatePromises).then(() => {
|
|
156
|
-
ValueLabelsCollision.resolveValueLabelsCollisions(this.getAllValueLabels(),
|
|
163
|
+
ValueLabelsCollision.resolveValueLabelsCollisions(this.getAllValueLabels(), this.options.canvas.valueLabels);
|
|
157
164
|
});
|
|
158
165
|
}
|
|
159
166
|
toggleOldValueLabelsVisibility() {
|
|
@@ -97,7 +97,7 @@ export class TwoDimensionalManager {
|
|
|
97
97
|
chartOrientation: options.orient
|
|
98
98
|
});
|
|
99
99
|
if (this.canvasValueLabels)
|
|
100
|
-
this.canvasValueLabels.update(scales, options.charts, data, model.options.data);
|
|
100
|
+
this.canvasValueLabels.update(scales, options.charts, data, model.options.data, options.valueLabels);
|
|
101
101
|
}
|
|
102
102
|
updateColors(block, model) {
|
|
103
103
|
var _a;
|