mdt-charts 1.32.0 → 1.33.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.
@@ -94,9 +94,22 @@ export class ChartValueLabels {
94
94
  setAttrs(valueLabels, attrs, valueFieldName, setContent, dataRowAccessor, animate = false, onEndAnimation) {
95
95
  const animationName = "labels-updating";
96
96
  let selection = valueLabels
97
- .text((d) => setContent({ dataRow: dataRowAccessor(d), fieldName: valueFieldName }).textContent)
98
97
  .attr("dominant-baseline", attrs.dominantBaseline)
99
98
  .attr("text-anchor", attrs.textAnchor);
99
+ selection.each(function (d) {
100
+ select(this).selectAll("tspan").remove();
101
+ const content = setContent({ dataRow: dataRowAccessor(d), fieldName: valueFieldName });
102
+ content.rows.forEach((row, rowIndex) => {
103
+ const tspan = document.createElementNS("http://www.w3.org/2000/svg", "tspan");
104
+ // Pass empty string to count this element for correct working of dy
105
+ // https://stackoverflow.com/questions/34078357/empty-tspan-not-rendered-dy-value-ignored
106
+ tspan.textContent = row.toString() || " ";
107
+ if (rowIndex !== 0)
108
+ tspan.setAttribute("dy", `1em`);
109
+ tspan.setAttribute("x", attrs.x(d).toString());
110
+ this.appendChild(tspan);
111
+ });
112
+ });
100
113
  if (animate) {
101
114
  selection = selection
102
115
  .interrupt(animationName)
@@ -403,7 +403,7 @@ export interface ValueLabelsInnerContentSetterOptions {
403
403
  fieldName: MdtChartsFieldName;
404
404
  }
405
405
  export declare type ValueLabelsInnerContentSetter = (options: ValueLabelsInnerContentSetterOptions) => {
406
- textContent: string | number;
406
+ rows: (string | number)[];
407
407
  };
408
408
  export interface TwoDimChartValueLabelsOptions {
409
409
  show: boolean;
@@ -146,12 +146,14 @@ export class TwoDimensionalModel {
146
146
  forFields: (_x = (_w = chart.valueLabels) === null || _w === void 0 ? void 0 : _w.renderForFields) !== null && _x !== void 0 ? _x : chart.data.valueFields.map((field) => field.name),
147
147
  setContent: ({ dataRow, fieldName }) => {
148
148
  var _a;
149
- if ((_a = chart.valueLabels) === null || _a === void 0 ? void 0 : _a.setContent)
150
- return chart.valueLabels.setContent({
149
+ if ((_a = chart.valueLabels) === null || _a === void 0 ? void 0 : _a.setContent) {
150
+ const content = chart.valueLabels.setContent({
151
151
  dataRow,
152
152
  field: chart.data.valueFields.find((field) => field.name === fieldName)
153
153
  });
154
- return { textContent: configReader.getValueLabelFormatterForChart(index)(dataRow[fieldName]) };
154
+ return { rows: content.textContent.toString().split("\n") };
155
+ }
156
+ return { rows: [configReader.getValueLabelFormatterForChart(index)(dataRow[fieldName])] };
155
157
  }
156
158
  },
157
159
  areaViewOptions: getAreaViewOptions(chart, index, style, modelInstance.version.getVersionNumber()),
@@ -290,4 +290,4 @@
290
290
  /* Value Labels */
291
291
  .mdt-charts-value-label {
292
292
  letter-spacing: -0.4px;
293
- }
293
+ }
@@ -290,4 +290,4 @@
290
290
  /* Value Labels */
291
291
  .mdt-charts-value-label {
292
292
  letter-spacing: -0.4px;
293
- }
293
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mdt-charts",
3
- "version": "1.32.0",
3
+ "version": "1.33.0",
4
4
  "description": "",
5
5
  "main": "lib/main.js",
6
6
  "scripts": {