@cashub/ui 0.48.2 → 0.48.4
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/chart/BarChart.js
CHANGED
|
@@ -26,13 +26,17 @@ const BarChart = _ref => {
|
|
|
26
26
|
_reactChartjs.defaults.color = theme.fontOnBg;
|
|
27
27
|
_reactChartjs.defaults.plugins.tooltip.external = (0, _customTooltip.default)(theme);
|
|
28
28
|
const customOptions = (0, _react.useMemo)(() => {
|
|
29
|
+
const {
|
|
30
|
+
tooltips = {}
|
|
31
|
+
} = options;
|
|
29
32
|
return {
|
|
30
33
|
onlyFirstTooltips: options.onlyFirstTooltips === undefined ? true : options.onlyFirstTooltips,
|
|
31
34
|
maxBarNumber: options.maxBarNumber === undefined ? 5 : options.maxBarNumber,
|
|
32
35
|
stacked: options.stacked === undefined ? true : options.stacked,
|
|
33
36
|
suggestedMax: options.suggestedMax === undefined ? 10 : options.suggestedMax,
|
|
34
37
|
showLegend: options.showLegend === undefined ? false : options.showLegend,
|
|
35
|
-
rotateLabel: options.rotateLabel === undefined ? true : options.rotateLabel
|
|
38
|
+
rotateLabel: options.rotateLabel === undefined ? true : options.rotateLabel,
|
|
39
|
+
tooltipLabelPostfix: tooltips.labelPostfix || ''
|
|
36
40
|
};
|
|
37
41
|
}, [options]);
|
|
38
42
|
const defaultOptions = (0, _react.useMemo)(() => {
|
|
@@ -63,7 +67,7 @@ const BarChart = _ref => {
|
|
|
63
67
|
if (context.dataset.customLabel) {
|
|
64
68
|
return context.dataset.customLabel[context.dataIndex].toString();
|
|
65
69
|
}
|
|
66
|
-
return label.toString()
|
|
70
|
+
return `${label.toString()}${customOptions.tooltipLabelPostfix}`;
|
|
67
71
|
},
|
|
68
72
|
labelTextColor(context) {
|
|
69
73
|
const {
|
|
@@ -37,7 +37,7 @@ const customTooltip = theme => {
|
|
|
37
37
|
if (tooltipModel.body) {
|
|
38
38
|
const titleLines = tooltipModel.title || [];
|
|
39
39
|
const bodyLines = tooltipModel.body.map(bodyItem => {
|
|
40
|
-
return bodyItem.lines;
|
|
40
|
+
return bodyItem.lines || [];
|
|
41
41
|
});
|
|
42
42
|
let innerHtml = '<thead>';
|
|
43
43
|
titleLines.forEach(title => {
|
|
@@ -45,7 +45,13 @@ const customTooltip = theme => {
|
|
|
45
45
|
});
|
|
46
46
|
innerHtml += '</thead><tbody>';
|
|
47
47
|
bodyLines.forEach(body => {
|
|
48
|
-
|
|
48
|
+
if (Array.isArray(body)) {
|
|
49
|
+
body.forEach(line => {
|
|
50
|
+
innerHtml += `<tr><td>${line}</td></tr>`;
|
|
51
|
+
});
|
|
52
|
+
} else {
|
|
53
|
+
innerHtml += `<tr><td>${body}</td></tr>`;
|
|
54
|
+
}
|
|
49
55
|
});
|
|
50
56
|
innerHtml += '</tbody>';
|
|
51
57
|
const tableRoot = tooltipEl.querySelector('table');
|