@cashub/ui 0.48.3 → 0.48.5
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 +6 -2
- package/chart/LineChart.js +11 -2
- package/package.json +1 -1
package/chart/BarChart.js
CHANGED
|
@@ -34,13 +34,17 @@ const BarChart = _ref => {
|
|
|
34
34
|
_reactChartjs.defaults.color = theme.fontOnBg;
|
|
35
35
|
_reactChartjs.defaults.plugins.tooltip.external = (0, _customTooltip.default)(theme);
|
|
36
36
|
const customOptions = (0, _react.useMemo)(() => {
|
|
37
|
+
const {
|
|
38
|
+
tooltips = {}
|
|
39
|
+
} = options;
|
|
37
40
|
return {
|
|
38
41
|
onlyFirstTooltips: options.onlyFirstTooltips === undefined ? true : options.onlyFirstTooltips,
|
|
39
42
|
maxBarNumber: options.maxBarNumber === undefined ? 5 : options.maxBarNumber,
|
|
40
43
|
stacked: options.stacked === undefined ? true : options.stacked,
|
|
41
44
|
suggestedMax: options.suggestedMax === undefined ? 10 : options.suggestedMax,
|
|
42
45
|
showLegend: options.showLegend === undefined ? false : options.showLegend,
|
|
43
|
-
rotateLabel: options.rotateLabel === undefined ? true : options.rotateLabel
|
|
46
|
+
rotateLabel: options.rotateLabel === undefined ? true : options.rotateLabel,
|
|
47
|
+
tooltipLabelPostfix: tooltips.labelPostfix || ''
|
|
44
48
|
};
|
|
45
49
|
}, [options]);
|
|
46
50
|
const defaultOptions = (0, _react.useMemo)(() => {
|
|
@@ -71,7 +75,7 @@ const BarChart = _ref => {
|
|
|
71
75
|
if (context.dataset.customLabel) {
|
|
72
76
|
return context.dataset.customLabel[context.dataIndex].toString();
|
|
73
77
|
}
|
|
74
|
-
return label.toString();
|
|
78
|
+
return "".concat(label.toString()).concat(customOptions.tooltipLabelPostfix);
|
|
75
79
|
},
|
|
76
80
|
labelTextColor(context) {
|
|
77
81
|
const {
|
package/chart/LineChart.js
CHANGED
|
@@ -57,6 +57,10 @@ const LineChart = _ref => {
|
|
|
57
57
|
responsive: true,
|
|
58
58
|
maintainAspectRatio: false,
|
|
59
59
|
aspectRatio: 1,
|
|
60
|
+
interaction: {
|
|
61
|
+
mode: 'nearest',
|
|
62
|
+
intersect: false
|
|
63
|
+
},
|
|
60
64
|
plugins: {
|
|
61
65
|
legend: {
|
|
62
66
|
display: customOptions.showLegend
|
|
@@ -65,7 +69,7 @@ const LineChart = _ref => {
|
|
|
65
69
|
enabled: false,
|
|
66
70
|
intersect: false,
|
|
67
71
|
filter(context) {
|
|
68
|
-
return context.
|
|
72
|
+
return context.label !== 'null';
|
|
69
73
|
},
|
|
70
74
|
callbacks: {
|
|
71
75
|
title(context) {
|
|
@@ -73,8 +77,13 @@ const LineChart = _ref => {
|
|
|
73
77
|
return "".concat(customOptions.tooltipTitlePrefix).concat(content);
|
|
74
78
|
},
|
|
75
79
|
label(context) {
|
|
80
|
+
var _context$dataset$tool;
|
|
81
|
+
const tooltipLabel = (_context$dataset$tool = context.dataset.tooltipLabels) === null || _context$dataset$tool === void 0 ? void 0 : _context$dataset$tool[context.dataIndex];
|
|
82
|
+
if (tooltipLabel !== undefined) {
|
|
83
|
+
return "".concat(context.dataset.label, ": ").concat(tooltipLabel);
|
|
84
|
+
}
|
|
76
85
|
const content = context.dataset.data[context.dataIndex].toString();
|
|
77
|
-
return "".concat(customOptions.tooltipLabelPrefix).concat(content).concat(customOptions.tooltipLabelPostfix);
|
|
86
|
+
return "".concat(context.dataset.label, ": ").concat(customOptions.tooltipLabelPrefix).concat(content).concat(customOptions.tooltipLabelPostfix);
|
|
78
87
|
},
|
|
79
88
|
labelColor(context) {
|
|
80
89
|
const {
|