mdt-charts 1.27.2 → 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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Block } from "../../../engine/block/block";
|
|
2
|
-
import { OptionsModelData, Orient, TwoDimensionalChartModel, TwoDimensionalValueLabels, ValueLabelAnchor, ValueLabelDominantBaseline, ValueLabelsStyleModel } from "../../../model/model";
|
|
2
|
+
import { OptionsModelData, Orient, TwoDimChartValueLabelsOptions, TwoDimensionalChartModel, TwoDimensionalValueLabels, ValueLabelAnchor, ValueLabelDominantBaseline, ValueLabelsStyleModel } from "../../../model/model";
|
|
3
3
|
import { MdtChartsDataRow, MdtChartsDataSource } from "../../../config/config";
|
|
4
4
|
import { Scales, ScalesWithSecondary } from "../../../engine/features/scale/scale";
|
|
5
5
|
export interface ValueLabelsOptions {
|
|
@@ -27,9 +27,10 @@ export declare class ChartValueLabels {
|
|
|
27
27
|
static readonly valueLabelClass: string;
|
|
28
28
|
private readonly renderPipeline;
|
|
29
29
|
private readonly attrsProvider;
|
|
30
|
+
private options;
|
|
30
31
|
constructor(globalOptions: ValueLabelsOptions, chart: TwoDimensionalChartModel);
|
|
31
32
|
render(scales: Scales, data: MdtChartsDataRow[]): void;
|
|
32
|
-
update(scales: Scales, newData: MdtChartsDataRow[]): Promise<void[]>;
|
|
33
|
+
update(scales: Scales, newData: MdtChartsDataRow[], updatedOptions: TwoDimChartValueLabelsOptions): Promise<void[]>;
|
|
33
34
|
private renderByGroupIndex;
|
|
34
35
|
private updateByGroupIndex;
|
|
35
36
|
private getAllValueLabelsOfChart;
|
|
@@ -13,6 +13,7 @@ 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
18
|
valueLabels.attr("fill", "currentColor").style("font-size", style.fontSize).style("color", style.color);
|
|
18
19
|
if (style.cssClassName)
|
|
@@ -33,8 +34,9 @@ export class ChartValueLabels {
|
|
|
33
34
|
});
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
|
-
update(scales, newData) {
|
|
37
|
+
update(scales, newData, updatedOptions) {
|
|
37
38
|
const updatePromises = [];
|
|
39
|
+
this.options = updatedOptions;
|
|
38
40
|
if (this.chart.isSegmented) {
|
|
39
41
|
const preparedData = getStackedData(newData, this.chart);
|
|
40
42
|
preparedData.forEach((segment, segmentIndex) => {
|
|
@@ -53,21 +55,21 @@ export class ChartValueLabels {
|
|
|
53
55
|
renderByGroupIndex(scales, groupIndex, data, valueFieldName, datumField, dataRowAccessor) {
|
|
54
56
|
let valueLabels = this.getAllValueLabelsOfChart(groupIndex).data(data).enter().append("text");
|
|
55
57
|
valueLabels = this.renderPipeline.execute(valueLabels, { style: this.globalOptions.canvas.style });
|
|
56
|
-
const attrs = this.attrsProvider.getAttrs(this.globalOptions, this.
|
|
57
|
-
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);
|
|
58
60
|
this.setClasses(valueLabels, this.chart.cssClasses, groupIndex);
|
|
59
61
|
}
|
|
60
62
|
updateByGroupIndex(scales, groupIndex, data, valueFieldName, datumField, dataRowAccessor) {
|
|
61
63
|
return new Promise((resolve) => {
|
|
62
64
|
const valueLabels = this.getAllValueLabelsOfChart(groupIndex).data(data);
|
|
63
65
|
valueLabels.exit().remove();
|
|
64
|
-
const attrs = this.attrsProvider.getAttrs(this.globalOptions, this.
|
|
66
|
+
const attrs = this.attrsProvider.getAttrs(this.globalOptions, this.options, scales, datumField, dataRowAccessor);
|
|
65
67
|
let newValueLabels = valueLabels.enter().append("text");
|
|
66
68
|
newValueLabels = this.renderPipeline.execute(newValueLabels, { style: this.globalOptions.canvas.style });
|
|
67
69
|
const mergedValueLabels = newValueLabels.merge(valueLabels);
|
|
68
|
-
this.setAttrs(newValueLabels, attrs, valueFieldName, this.
|
|
70
|
+
this.setAttrs(newValueLabels, attrs, valueFieldName, this.options.format, dataRowAccessor);
|
|
69
71
|
this.setClasses(mergedValueLabels, this.chart.cssClasses, groupIndex);
|
|
70
|
-
this.setAttrs(valueLabels, attrs, valueFieldName, this.
|
|
72
|
+
this.setAttrs(valueLabels, attrs, valueFieldName, this.options.format, dataRowAccessor, true, resolve);
|
|
71
73
|
});
|
|
72
74
|
}
|
|
73
75
|
getAllValueLabelsOfChart(vfIndex) {
|
|
@@ -129,7 +131,7 @@ export class CanvasValueLabels {
|
|
|
129
131
|
this.toggleOldValueLabelsVisibility();
|
|
130
132
|
const chartsUpdatePromises = chartsWithLabels.map((chart, index) => {
|
|
131
133
|
const chartScales = this.getChartScales(scales, chart);
|
|
132
|
-
return this.chartsValueLabels[index].update(chartScales, data[dataOptions.dataSource]);
|
|
134
|
+
return this.chartsValueLabels[index].update(chartScales, data[dataOptions.dataSource], chart.valueLabels);
|
|
133
135
|
});
|
|
134
136
|
Promise.all(chartsUpdatePromises).then(() => {
|
|
135
137
|
const newValueLabels = this.getAllValueLabels();
|