@cashub/ui 0.48.7 → 0.48.8
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 +12 -1
- package/chart/LineChart.js +3 -2
- package/package.json +1 -1
package/chart/BarChart.js
CHANGED
|
@@ -9,6 +9,7 @@ var _styledComponents = require("styled-components");
|
|
|
9
9
|
var _reactChartjs = require("react-chartjs-2");
|
|
10
10
|
var _customTooltip = _interopRequireDefault(require("./utils/customTooltip"));
|
|
11
11
|
var _padEmptyChartBar = _interopRequireDefault(require("./utils/padEmptyChartBar"));
|
|
12
|
+
var _yAxisTopTitlePlugin = _interopRequireDefault(require("./utils/yAxisTopTitlePlugin"));
|
|
12
13
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
14
|
const _excluded = ["height", "data", "options"];
|
|
14
15
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -35,6 +36,7 @@ const BarChart = _ref => {
|
|
|
35
36
|
_reactChartjs.defaults.plugins.tooltip.external = (0, _customTooltip.default)(theme);
|
|
36
37
|
const customOptions = (0, _react.useMemo)(() => {
|
|
37
38
|
const {
|
|
39
|
+
yAxisTopTitle,
|
|
38
40
|
tooltips = {}
|
|
39
41
|
} = options;
|
|
40
42
|
return {
|
|
@@ -44,6 +46,7 @@ const BarChart = _ref => {
|
|
|
44
46
|
suggestedMax: options.suggestedMax === undefined ? 10 : options.suggestedMax,
|
|
45
47
|
showLegend: options.showLegend === undefined ? false : options.showLegend,
|
|
46
48
|
rotateLabel: options.rotateLabel === undefined ? true : options.rotateLabel,
|
|
49
|
+
yAxisTopTitle: yAxisTopTitle ? yAxisTopTitle : '',
|
|
47
50
|
tooltipLabelPostfix: tooltips.labelPostfix || ''
|
|
48
51
|
};
|
|
49
52
|
}, [options]);
|
|
@@ -99,6 +102,9 @@ const BarChart = _ref => {
|
|
|
99
102
|
return color;
|
|
100
103
|
}
|
|
101
104
|
}
|
|
105
|
+
},
|
|
106
|
+
yAxisTopTitle: {
|
|
107
|
+
title: customOptions.yAxisTopTitle
|
|
102
108
|
}
|
|
103
109
|
},
|
|
104
110
|
scales: {
|
|
@@ -132,6 +138,11 @@ const BarChart = _ref => {
|
|
|
132
138
|
}
|
|
133
139
|
}
|
|
134
140
|
}
|
|
141
|
+
},
|
|
142
|
+
layout: {
|
|
143
|
+
padding: {
|
|
144
|
+
top: 32
|
|
145
|
+
}
|
|
135
146
|
}
|
|
136
147
|
};
|
|
137
148
|
}, [customOptions, theme.fontOnPrimary]);
|
|
@@ -139,7 +150,7 @@ const BarChart = _ref => {
|
|
|
139
150
|
height: height,
|
|
140
151
|
data: data,
|
|
141
152
|
options: defaultOptions,
|
|
142
|
-
plugins: [_padEmptyChartBar.default]
|
|
153
|
+
plugins: [_padEmptyChartBar.default, _yAxisTopTitlePlugin.default]
|
|
143
154
|
}, props));
|
|
144
155
|
};
|
|
145
156
|
var _default = exports.default = BarChart;
|
package/chart/LineChart.js
CHANGED
|
@@ -78,12 +78,13 @@ const LineChart = _ref => {
|
|
|
78
78
|
},
|
|
79
79
|
label(context) {
|
|
80
80
|
var _context$dataset$tool;
|
|
81
|
+
const datasetLabel = context.dataset.label || '';
|
|
81
82
|
const tooltipLabel = (_context$dataset$tool = context.dataset.tooltipLabels) === null || _context$dataset$tool === void 0 ? void 0 : _context$dataset$tool[context.dataIndex];
|
|
82
83
|
if (tooltipLabel !== undefined) {
|
|
83
|
-
return "".concat(
|
|
84
|
+
return datasetLabel ? "".concat(datasetLabel, ": ").concat(tooltipLabel) : "".concat(tooltipLabel);
|
|
84
85
|
}
|
|
85
86
|
const content = context.dataset.data[context.dataIndex].toString();
|
|
86
|
-
return "".concat(
|
|
87
|
+
return datasetLabel ? "".concat(datasetLabel, ": ").concat(customOptions.tooltipLabelPrefix).concat(content).concat(customOptions.tooltipLabelPostfix) : "".concat(customOptions.tooltipLabelPrefix).concat(content).concat(customOptions.tooltipLabelPostfix);
|
|
87
88
|
},
|
|
88
89
|
labelColor(context) {
|
|
89
90
|
const {
|