@hitachivantara/uikit-react-viz 4.0.3 → 4.0.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/dist/Barchart/Barchart.js +45 -72
- package/dist/Barchart/Barchart.js.map +1 -1
- package/dist/Barchart/barchartPlotlyOverrides.js +1 -13
- package/dist/Barchart/barchartPlotlyOverrides.js.map +1 -1
- package/dist/Barchart/index.js +0 -2
- package/dist/Barchart/index.js.map +1 -1
- package/dist/Barchart/styles.js.map +1 -1
- package/dist/Chart/Chart.js +28 -75
- package/dist/Chart/Chart.js.map +1 -1
- package/dist/Chart/Plot/Plot.js +10 -47
- package/dist/Chart/Plot/Plot.js.map +1 -1
- package/dist/Chart/Plot/index.js +0 -2
- package/dist/Chart/Plot/index.js.map +1 -1
- package/dist/Chart/Plot/styles.js.map +1 -1
- package/dist/Chart/Tooltip/MultiTooltip/MultiTooltip.js +1 -36
- package/dist/Chart/Tooltip/MultiTooltip/MultiTooltip.js.map +1 -1
- package/dist/Chart/Tooltip/MultiTooltip/index.js +0 -2
- package/dist/Chart/Tooltip/MultiTooltip/index.js.map +1 -1
- package/dist/Chart/Tooltip/MultiTooltip/styles.js +0 -2
- package/dist/Chart/Tooltip/MultiTooltip/styles.js.map +1 -1
- package/dist/Chart/Tooltip/SingleTooltip/SingleTooltip.js +2 -26
- package/dist/Chart/Tooltip/SingleTooltip/SingleTooltip.js.map +1 -1
- package/dist/Chart/Tooltip/SingleTooltip/index.js +0 -2
- package/dist/Chart/Tooltip/SingleTooltip/index.js.map +1 -1
- package/dist/Chart/Tooltip/SingleTooltip/styles.js +0 -2
- package/dist/Chart/Tooltip/SingleTooltip/styles.js.map +1 -1
- package/dist/Chart/Tooltip/Tooltip.js +16 -51
- package/dist/Chart/Tooltip/Tooltip.js.map +1 -1
- package/dist/Chart/Tooltip/index.js +0 -2
- package/dist/Chart/Tooltip/index.js.map +1 -1
- package/dist/Chart/Tooltip/styles.js.map +1 -1
- package/dist/Chart/chartPlotlyOverrides.js +9 -33
- package/dist/Chart/chartPlotlyOverrides.js.map +1 -1
- package/dist/Chart/index.js +0 -2
- package/dist/Chart/index.js.map +1 -1
- package/dist/Chart/styles.js +0 -13
- package/dist/Chart/styles.js.map +1 -1
- package/dist/Donutchart/Donutchart.js +10 -47
- package/dist/Donutchart/Donutchart.js.map +1 -1
- package/dist/Donutchart/donutchartPlotlyOverrides.js +1 -13
- package/dist/Donutchart/donutchartPlotlyOverrides.js.map +1 -1
- package/dist/Donutchart/index.js +0 -2
- package/dist/Donutchart/index.js.map +1 -1
- package/dist/Donutchart/styles.js.map +1 -1
- package/dist/Linechart/Linechart.js +12 -50
- package/dist/Linechart/Linechart.js.map +1 -1
- package/dist/Linechart/index.js +0 -2
- package/dist/Linechart/index.js.map +1 -1
- package/dist/Linechart/lineChartPlotlyOverrides.js +1 -17
- package/dist/Linechart/lineChartPlotlyOverrides.js.map +1 -1
- package/dist/Linechart/styles.js.map +1 -1
- package/dist/index.js +0 -4
- package/dist/index.js.map +1 -1
- package/dist/legacy/Barchart/Barchart.js +45 -43
- package/dist/legacy/Barchart/Barchart.js.map +1 -1
- package/dist/legacy/Barchart/barchartPlotlyOverrides.js +1 -6
- package/dist/legacy/Barchart/barchartPlotlyOverrides.js.map +1 -1
- package/dist/legacy/Barchart/index.js.map +1 -1
- package/dist/legacy/Barchart/styles.js.map +1 -1
- package/dist/legacy/Chart/Chart.js +28 -46
- package/dist/legacy/Chart/Chart.js.map +1 -1
- package/dist/legacy/Chart/Plot/Plot.js +10 -21
- package/dist/legacy/Chart/Plot/Plot.js.map +1 -1
- package/dist/legacy/Chart/Plot/index.js.map +1 -1
- package/dist/legacy/Chart/Plot/styles.js.map +1 -1
- package/dist/legacy/Chart/Tooltip/MultiTooltip/MultiTooltip.js +1 -17
- package/dist/legacy/Chart/Tooltip/MultiTooltip/MultiTooltip.js.map +1 -1
- package/dist/legacy/Chart/Tooltip/MultiTooltip/index.js.map +1 -1
- package/dist/legacy/Chart/Tooltip/MultiTooltip/styles.js +0 -1
- package/dist/legacy/Chart/Tooltip/MultiTooltip/styles.js.map +1 -1
- package/dist/legacy/Chart/Tooltip/SingleTooltip/SingleTooltip.js +2 -9
- package/dist/legacy/Chart/Tooltip/SingleTooltip/SingleTooltip.js.map +1 -1
- package/dist/legacy/Chart/Tooltip/SingleTooltip/index.js.map +1 -1
- package/dist/legacy/Chart/Tooltip/SingleTooltip/styles.js +0 -1
- package/dist/legacy/Chart/Tooltip/SingleTooltip/styles.js.map +1 -1
- package/dist/legacy/Chart/Tooltip/Tooltip.js +16 -30
- package/dist/legacy/Chart/Tooltip/Tooltip.js.map +1 -1
- package/dist/legacy/Chart/Tooltip/index.js.map +1 -1
- package/dist/legacy/Chart/Tooltip/styles.js.map +1 -1
- package/dist/legacy/Chart/chartPlotlyOverrides.js +9 -20
- package/dist/legacy/Chart/chartPlotlyOverrides.js.map +1 -1
- package/dist/legacy/Chart/index.js.map +1 -1
- package/dist/legacy/Chart/styles.js +0 -4
- package/dist/legacy/Chart/styles.js.map +1 -1
- package/dist/legacy/Donutchart/Donutchart.js +11 -22
- package/dist/legacy/Donutchart/Donutchart.js.map +1 -1
- package/dist/legacy/Donutchart/donutchartPlotlyOverrides.js +1 -6
- package/dist/legacy/Donutchart/donutchartPlotlyOverrides.js.map +1 -1
- package/dist/legacy/Donutchart/index.js.map +1 -1
- package/dist/legacy/Donutchart/styles.js.map +1 -1
- package/dist/legacy/Linechart/Linechart.js +13 -25
- package/dist/legacy/Linechart/Linechart.js.map +1 -1
- package/dist/legacy/Linechart/index.js.map +1 -1
- package/dist/legacy/Linechart/lineChartPlotlyOverrides.js +1 -10
- package/dist/legacy/Linechart/lineChartPlotlyOverrides.js.map +1 -1
- package/dist/legacy/Linechart/styles.js.map +1 -1
- package/dist/legacy/index.js.map +1 -1
- package/dist/modern/Barchart/Barchart.js +38 -31
- package/dist/modern/Barchart/Barchart.js.map +1 -1
- package/dist/modern/Barchart/barchartPlotlyOverrides.js +1 -6
- package/dist/modern/Barchart/barchartPlotlyOverrides.js.map +1 -1
- package/dist/modern/Barchart/index.js.map +1 -1
- package/dist/modern/Barchart/styles.js.map +1 -1
- package/dist/modern/Chart/Chart.js +17 -33
- package/dist/modern/Chart/Chart.js.map +1 -1
- package/dist/modern/Chart/Plot/Plot.js +11 -22
- package/dist/modern/Chart/Plot/Plot.js.map +1 -1
- package/dist/modern/Chart/Plot/index.js.map +1 -1
- package/dist/modern/Chart/Plot/styles.js.map +1 -1
- package/dist/modern/Chart/Tooltip/MultiTooltip/MultiTooltip.js +0 -17
- package/dist/modern/Chart/Tooltip/MultiTooltip/MultiTooltip.js.map +1 -1
- package/dist/modern/Chart/Tooltip/MultiTooltip/index.js.map +1 -1
- package/dist/modern/Chart/Tooltip/MultiTooltip/styles.js +0 -1
- package/dist/modern/Chart/Tooltip/MultiTooltip/styles.js.map +1 -1
- package/dist/modern/Chart/Tooltip/SingleTooltip/SingleTooltip.js +0 -7
- package/dist/modern/Chart/Tooltip/SingleTooltip/SingleTooltip.js.map +1 -1
- package/dist/modern/Chart/Tooltip/SingleTooltip/index.js.map +1 -1
- package/dist/modern/Chart/Tooltip/SingleTooltip/styles.js +0 -1
- package/dist/modern/Chart/Tooltip/SingleTooltip/styles.js.map +1 -1
- package/dist/modern/Chart/Tooltip/Tooltip.js +2 -13
- package/dist/modern/Chart/Tooltip/Tooltip.js.map +1 -1
- package/dist/modern/Chart/Tooltip/index.js.map +1 -1
- package/dist/modern/Chart/Tooltip/styles.js.map +1 -1
- package/dist/modern/Chart/chartPlotlyOverrides.js +9 -20
- package/dist/modern/Chart/chartPlotlyOverrides.js.map +1 -1
- package/dist/modern/Chart/index.js.map +1 -1
- package/dist/modern/Chart/styles.js +0 -4
- package/dist/modern/Chart/styles.js.map +1 -1
- package/dist/modern/Donutchart/Donutchart.js +11 -22
- package/dist/modern/Donutchart/Donutchart.js.map +1 -1
- package/dist/modern/Donutchart/donutchartPlotlyOverrides.js +1 -6
- package/dist/modern/Donutchart/donutchartPlotlyOverrides.js.map +1 -1
- package/dist/modern/Donutchart/index.js.map +1 -1
- package/dist/modern/Donutchart/styles.js.map +1 -1
- package/dist/modern/Linechart/Linechart.js +12 -24
- package/dist/modern/Linechart/Linechart.js.map +1 -1
- package/dist/modern/Linechart/index.js.map +1 -1
- package/dist/modern/Linechart/lineChartPlotlyOverrides.js +1 -10
- package/dist/modern/Linechart/lineChartPlotlyOverrides.js.map +1 -1
- package/dist/modern/Linechart/styles.js.map +1 -1
- package/dist/modern/index.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,108 +1,79 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
require("core-js/modules/es.object.keys.js");
|
|
4
|
-
|
|
5
4
|
require("core-js/modules/es.symbol.js");
|
|
6
|
-
|
|
7
5
|
require("core-js/modules/es.array.filter.js");
|
|
8
|
-
|
|
9
6
|
require("core-js/modules/es.object.to-string.js");
|
|
10
|
-
|
|
11
7
|
require("core-js/modules/es.object.get-own-property-descriptor.js");
|
|
12
|
-
|
|
13
8
|
require("core-js/modules/web.dom-collections.for-each.js");
|
|
14
|
-
|
|
15
9
|
require("core-js/modules/es.object.get-own-property-descriptors.js");
|
|
16
|
-
|
|
17
10
|
require("core-js/modules/es.array.iterator.js");
|
|
18
|
-
|
|
19
11
|
require("core-js/modules/es.string.iterator.js");
|
|
20
|
-
|
|
21
12
|
require("core-js/modules/es.weak-map.js");
|
|
22
|
-
|
|
23
13
|
require("core-js/modules/web.dom-collections.iterator.js");
|
|
24
|
-
|
|
25
14
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
26
|
-
|
|
27
15
|
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
28
|
-
|
|
29
16
|
Object.defineProperty(exports, "__esModule", {
|
|
30
17
|
value: true
|
|
31
18
|
});
|
|
32
19
|
exports.default = void 0;
|
|
33
|
-
|
|
34
20
|
require("core-js/modules/es.array.map.js");
|
|
35
|
-
|
|
36
21
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
37
|
-
|
|
38
22
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
39
|
-
|
|
40
23
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
41
|
-
|
|
42
24
|
var _react = _interopRequireWildcard(require("react"));
|
|
43
|
-
|
|
44
25
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
45
|
-
|
|
46
26
|
var _styles = require("@mui/styles");
|
|
47
|
-
|
|
48
27
|
var _Chart = _interopRequireDefault(require("../Chart"));
|
|
49
|
-
|
|
50
28
|
var _barchartPlotlyOverrides = require("./barchartPlotlyOverrides");
|
|
51
|
-
|
|
52
29
|
var _styles2 = _interopRequireDefault(require("./styles"));
|
|
53
|
-
|
|
54
30
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
55
|
-
|
|
56
31
|
var _excluded = ["id", "classes", "data", "layout", "config", "tooltipType", "stack", "horizontal"];
|
|
57
|
-
|
|
58
32
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
59
|
-
|
|
60
33
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
61
|
-
|
|
62
34
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
63
|
-
|
|
64
35
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
65
|
-
|
|
66
36
|
var MARGIN = 50;
|
|
67
37
|
var MAX_BAR_WIDTH = 90;
|
|
68
38
|
var MIN_BAR_WIDTH = 3;
|
|
69
39
|
var MIN_WIDTH = 75;
|
|
40
|
+
|
|
70
41
|
/**
|
|
71
42
|
* A Bar chart is a chart or graph that presents categorical data with rectangular bars.
|
|
72
43
|
*
|
|
73
44
|
* Our implementation leverages the Plotly charting library. If you have a specific case
|
|
74
45
|
* that we don't cover, the Plotly [documentation](https://plotly.com/javascript/) is a good starting point.
|
|
75
46
|
*/
|
|
76
|
-
|
|
77
47
|
var Barchart = function Barchart(_ref) {
|
|
78
48
|
var id = _ref.id,
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
49
|
+
classes = _ref.classes,
|
|
50
|
+
data = _ref.data,
|
|
51
|
+
layout = _ref.layout,
|
|
52
|
+
config = _ref.config,
|
|
53
|
+
_ref$tooltipType = _ref.tooltipType,
|
|
54
|
+
tooltipType = _ref$tooltipType === void 0 ? "multiple" : _ref$tooltipType,
|
|
55
|
+
_ref$stack = _ref.stack,
|
|
56
|
+
stack = _ref$stack === void 0 ? false : _ref$stack,
|
|
57
|
+
_ref$horizontal = _ref.horizontal,
|
|
58
|
+
horizontal = _ref$horizontal === void 0 ? false : _ref$horizontal,
|
|
59
|
+
others = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
91
60
|
/* Values derived from props */
|
|
61
|
+
|
|
92
62
|
var dataWithDefaults = (0, _react.useMemo)(function () {
|
|
93
63
|
return (0, _barchartPlotlyOverrides.applyDataDefaults)(data, horizontal);
|
|
94
64
|
}, [data, horizontal]);
|
|
95
65
|
var chartLayout = (0, _react.useMemo)(function () {
|
|
96
66
|
return (0, _barchartPlotlyOverrides.applyLayoutDefaults)(layout, stack, horizontal);
|
|
97
67
|
}, [layout, stack, horizontal]);
|
|
68
|
+
|
|
98
69
|
/* State */
|
|
99
70
|
|
|
100
71
|
var _useState = (0, _react.useState)(dataWithDefaults),
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
/* Effects */
|
|
72
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
73
|
+
chartData = _useState2[0],
|
|
74
|
+
setChartData = _useState2[1];
|
|
105
75
|
|
|
76
|
+
/* Effects */
|
|
106
77
|
|
|
107
78
|
var firstRender = (0, _react.useRef)(true);
|
|
108
79
|
(0, _react.useEffect)(function () {
|
|
@@ -112,32 +83,28 @@ var Barchart = function Barchart(_ref) {
|
|
|
112
83
|
if (!firstRender.current) {
|
|
113
84
|
setChartData(dataWithDefaults);
|
|
114
85
|
}
|
|
115
|
-
|
|
116
86
|
firstRender.current = false;
|
|
117
87
|
}, [dataWithDefaults]);
|
|
88
|
+
|
|
118
89
|
/**
|
|
119
90
|
* Used to force the max width of each bar with 90px.
|
|
120
91
|
*
|
|
121
92
|
* (this is effectively more an effect than a callback)
|
|
122
93
|
*/
|
|
123
|
-
|
|
124
94
|
var recalculateBarWidth = (0, _react.useCallback)(function (ref) {
|
|
125
95
|
// use the data and layout info directly from the plotly ref
|
|
126
96
|
// as it's always the most uptodate version.
|
|
127
97
|
var plotData = ref.current.props.data;
|
|
128
98
|
var plotLayout = ref.current.props.layout;
|
|
129
|
-
|
|
130
99
|
if (plotData.length > 0) {
|
|
131
100
|
var barmode = plotLayout.barmode,
|
|
132
|
-
|
|
133
|
-
|
|
101
|
+
bargap = plotLayout.bargap,
|
|
102
|
+
bargroupgap = plotLayout.bargroupgap;
|
|
134
103
|
var isStack = barmode === "stack";
|
|
135
104
|
var numberOfBarsByGroup = isStack ? 1 : plotData.length;
|
|
136
105
|
var numberOfGroup = plotData[0].x.length;
|
|
137
|
-
|
|
138
106
|
var _ref$current$el$getBo = ref.current.el.getBoundingClientRect(),
|
|
139
|
-
|
|
140
|
-
|
|
107
|
+
boundingRect = _ref$current$el$getBo.width;
|
|
141
108
|
var width = boundingRect < MIN_WIDTH ? MIN_WIDTH : boundingRect;
|
|
142
109
|
var plotWidth = width - MARGIN;
|
|
143
110
|
var groupWidth = plotWidth / numberOfGroup;
|
|
@@ -146,7 +113,6 @@ var Barchart = function Barchart(_ref) {
|
|
|
146
113
|
var greaterThan90 = calculatedBarWidth > MAX_BAR_WIDTH;
|
|
147
114
|
var lessThan3 = calculatedBarWidth < MIN_BAR_WIDTH;
|
|
148
115
|
var isAlreadyGreaterThan90 = plotData[0].width !== undefined;
|
|
149
|
-
|
|
150
116
|
if (greaterThan90 && !isAlreadyGreaterThan90) {
|
|
151
117
|
var newWidth = MAX_BAR_WIDTH / plotWidth * numberOfGroup;
|
|
152
118
|
var newData = plotData.map(function (subData) {
|
|
@@ -156,26 +122,21 @@ var Barchart = function Barchart(_ref) {
|
|
|
156
122
|
});
|
|
157
123
|
setChartData(newData);
|
|
158
124
|
}
|
|
159
|
-
|
|
160
125
|
if (lessThan3 && !isAlreadyGreaterThan90) {
|
|
161
126
|
var _newWidth = MIN_BAR_WIDTH / plotWidth * numberOfGroup;
|
|
162
|
-
|
|
163
127
|
var _newData = plotData.map(function (subData) {
|
|
164
128
|
return _objectSpread(_objectSpread({}, subData), {}, {
|
|
165
129
|
width: _newWidth
|
|
166
130
|
});
|
|
167
131
|
});
|
|
168
|
-
|
|
169
132
|
setChartData(_newData);
|
|
170
133
|
}
|
|
171
|
-
|
|
172
134
|
if (!greaterThan90 && isAlreadyGreaterThan90) {
|
|
173
135
|
var _newData2 = plotData.map(function (subData) {
|
|
174
136
|
return _objectSpread(_objectSpread({}, subData), {}, {
|
|
175
137
|
width: undefined
|
|
176
138
|
});
|
|
177
139
|
});
|
|
178
|
-
|
|
179
140
|
setChartData(_newData2);
|
|
180
141
|
}
|
|
181
142
|
}
|
|
@@ -190,52 +151,64 @@ var Barchart = function Barchart(_ref) {
|
|
|
190
151
|
afterPlot: recalculateBarWidth
|
|
191
152
|
}, others));
|
|
192
153
|
};
|
|
193
|
-
|
|
194
154
|
process.env.NODE_ENV !== "production" ? Barchart.propTypes = {
|
|
195
155
|
/**
|
|
196
156
|
* An Id passed on to the component
|
|
197
157
|
*/
|
|
198
158
|
id: _propTypes.default.string,
|
|
199
|
-
|
|
200
159
|
/**
|
|
201
160
|
* A Jss Object used to override or extend the styles applied.
|
|
202
161
|
*/
|
|
203
|
-
classes: _propTypes.default.
|
|
204
|
-
|
|
162
|
+
classes: _propTypes.default.shape({
|
|
163
|
+
root: _propTypes.default.string
|
|
164
|
+
}),
|
|
205
165
|
/**
|
|
206
166
|
* Plotly data object (see https://plot.ly/javascript/reference/).
|
|
207
167
|
*/
|
|
208
168
|
data: _propTypes.default.arrayOf(_propTypes.default.instanceOf(Object)).isRequired,
|
|
209
|
-
|
|
210
169
|
/**
|
|
211
170
|
* Plotly layout object (see https://plot.ly/javascript/reference/#layout).
|
|
212
171
|
*/
|
|
213
172
|
layout: _propTypes.default.instanceOf(Object),
|
|
214
|
-
|
|
215
173
|
/**
|
|
216
174
|
* Plotly config object (see https://plot.ly/javascript/configuration-options/).
|
|
217
175
|
*/
|
|
218
176
|
config: _propTypes.default.instanceOf(Object),
|
|
219
|
-
|
|
220
177
|
/**
|
|
221
178
|
* Defines if should use a single or multiline tooltip.
|
|
222
179
|
*/
|
|
223
180
|
tooltipType: _propTypes.default.oneOf(["single", "multiple"]),
|
|
224
|
-
|
|
181
|
+
/**
|
|
182
|
+
* Custom tooltip element to be displayed
|
|
183
|
+
*/
|
|
184
|
+
tooltip: _propTypes.default.func,
|
|
185
|
+
/**
|
|
186
|
+
* Function to be called after plot render.
|
|
187
|
+
*/
|
|
188
|
+
afterPlot: _propTypes.default.func,
|
|
189
|
+
/**
|
|
190
|
+
* Defines the X axis title.
|
|
191
|
+
*/
|
|
192
|
+
xAxisTitle: _propTypes.default.string,
|
|
193
|
+
/**
|
|
194
|
+
* Defines the Y axis title.
|
|
195
|
+
*/
|
|
196
|
+
yAxisTitle: _propTypes.default.string,
|
|
197
|
+
/**
|
|
198
|
+
* Defines the chart subtitle.
|
|
199
|
+
*/
|
|
200
|
+
subtitle: _propTypes.default.string,
|
|
225
201
|
/**
|
|
226
202
|
* Sets is the chart is stack.
|
|
227
203
|
*/
|
|
228
204
|
stack: _propTypes.default.bool,
|
|
229
|
-
|
|
230
205
|
/**
|
|
231
206
|
* Sets is the chart is horizontal.
|
|
232
207
|
*/
|
|
233
208
|
horizontal: _propTypes.default.bool
|
|
234
209
|
} : void 0;
|
|
235
|
-
|
|
236
210
|
var _default = (0, _styles.withStyles)(_styles2.default, {
|
|
237
211
|
name: "HvBarchart"
|
|
238
212
|
})(Barchart);
|
|
239
|
-
|
|
240
213
|
exports.default = _default;
|
|
241
214
|
//# sourceMappingURL=Barchart.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Barchart.js","names":["MARGIN","MAX_BAR_WIDTH","MIN_BAR_WIDTH","MIN_WIDTH","Barchart","id","classes","data","layout","config","tooltipType","stack","horizontal","others","dataWithDefaults","useMemo","applyDataDefaults","chartLayout","applyLayoutDefaults","useState","chartData","setChartData","firstRender","useRef","useEffect","current","recalculateBarWidth","useCallback","ref","plotData","props","plotLayout","length","barmode","bargap","bargroupgap","isStack","numberOfBarsByGroup","numberOfGroup","x","el","getBoundingClientRect","boundingRect","width","plotWidth","groupWidth","colWidth","calculatedBarWidth","greaterThan90","lessThan3","isAlreadyGreaterThan90","undefined","newWidth","newData","map","subData","propTypes","PropTypes","string","instanceOf","Object","arrayOf","isRequired","oneOf","bool","withStyles","styles","name"],"sources":["../../src/Barchart/Barchart.js"],"sourcesContent":["import React, { useMemo, useEffect, useState, useCallback, useRef } from \"react\";\nimport PropTypes from \"prop-types\";\nimport { withStyles } from \"@mui/styles\";\nimport Chart from \"../Chart\";\nimport { applyLayoutDefaults, applyDataDefaults } from \"./barchartPlotlyOverrides\";\nimport styles from \"./styles\";\n\nconst MARGIN = 50;\nconst MAX_BAR_WIDTH = 90;\nconst MIN_BAR_WIDTH = 3;\nconst MIN_WIDTH = 75;\n\n/**\n * A Bar chart is a chart or graph that presents categorical data with rectangular bars.\n *\n * Our implementation leverages the Plotly charting library. If you have a specific case\n * that we don't cover, the Plotly [documentation](https://plotly.com/javascript/) is a good starting point.\n */\nconst Barchart = ({\n id,\n classes,\n data,\n layout,\n config,\n tooltipType = \"multiple\",\n stack = false,\n horizontal = false,\n ...others\n}) => {\n /* Values derived from props */\n\n const dataWithDefaults = useMemo(() => applyDataDefaults(data, horizontal), [data, horizontal]);\n const chartLayout = useMemo(\n () => applyLayoutDefaults(layout, stack, horizontal),\n [layout, stack, horizontal]\n );\n\n /* State */\n\n const [chartData, setChartData] = useState(dataWithDefaults);\n\n /* Effects */\n\n const firstRender = useRef(true);\n useEffect(() => {\n // only setChartData when prop value changes\n // not needed on first render because the\n // initial state is already properly set\n if (!firstRender.current) {\n setChartData(dataWithDefaults);\n }\n\n firstRender.current = false;\n }, [dataWithDefaults]);\n\n /**\n * Used to force the max width of each bar with 90px.\n *\n * (this is effectively more an effect than a callback)\n */\n const recalculateBarWidth = useCallback((ref) => {\n // use the data and layout info directly from the plotly ref\n // as it's always the most uptodate version.\n const plotData = ref.current.props.data;\n const plotLayout = ref.current.props.layout;\n\n if (plotData.length > 0) {\n const { barmode, bargap, bargroupgap } = plotLayout;\n\n const isStack = barmode === \"stack\";\n const numberOfBarsByGroup = isStack ? 1 : plotData.length;\n const numberOfGroup = plotData[0].x.length;\n\n const { width: boundingRect } = ref.current.el.getBoundingClientRect();\n const width = boundingRect < MIN_WIDTH ? MIN_WIDTH : boundingRect;\n const plotWidth = width - MARGIN;\n const groupWidth = plotWidth / numberOfGroup;\n const colWidth = groupWidth * (1 - bargap) - groupWidth * (1 - bargap) * bargroupgap;\n\n const calculatedBarWidth = colWidth / numberOfBarsByGroup;\n const greaterThan90 = calculatedBarWidth > MAX_BAR_WIDTH;\n const lessThan3 = calculatedBarWidth < MIN_BAR_WIDTH;\n const isAlreadyGreaterThan90 = plotData[0].width !== undefined;\n\n if (greaterThan90 && !isAlreadyGreaterThan90) {\n const newWidth = (MAX_BAR_WIDTH / plotWidth) * numberOfGroup;\n\n const newData = plotData.map((subData) => {\n return { ...subData, width: newWidth };\n });\n\n setChartData(newData);\n }\n\n if (lessThan3 && !isAlreadyGreaterThan90) {\n const newWidth = (MIN_BAR_WIDTH / plotWidth) * numberOfGroup;\n\n const newData = plotData.map((subData) => {\n return { ...subData, width: newWidth };\n });\n\n setChartData(newData);\n }\n\n if (!greaterThan90 && isAlreadyGreaterThan90) {\n const newData = plotData.map((subData) => {\n return { ...subData, width: undefined };\n });\n\n setChartData(newData);\n }\n }\n }, []);\n\n return (\n <Chart\n id={id}\n classes={classes}\n data={chartData}\n layout={chartLayout}\n config={config}\n tooltipType={tooltipType}\n afterPlot={recalculateBarWidth}\n {...others}\n />\n );\n};\nBarchart.propTypes = {\n /**\n * An Id passed on to the component\n */\n id: PropTypes.string,\n /**\n * A Jss Object used to override or extend the styles applied.\n */\n classes: PropTypes.instanceOf(Object),\n /**\n * Plotly data object (see https://plot.ly/javascript/reference/).\n */\n data: PropTypes.arrayOf(PropTypes.instanceOf(Object)).isRequired,\n /**\n * Plotly layout object (see https://plot.ly/javascript/reference/#layout).\n */\n layout: PropTypes.instanceOf(Object),\n /**\n * Plotly config object (see https://plot.ly/javascript/configuration-options/).\n */\n config: PropTypes.instanceOf(Object),\n /**\n * Defines if should use a single or multiline tooltip.\n */\n tooltipType: PropTypes.oneOf([\"single\", \"multiple\"]),\n /**\n * Sets is the chart is stack.\n */\n stack: PropTypes.bool,\n /**\n * Sets is the chart is horizontal.\n */\n horizontal: PropTypes.bool,\n};\n\nexport default withStyles(styles, { name: \"HvBarchart\" })(Barchart);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;AAEA,IAAMA,MAAM,GAAG,EAAf;AACA,IAAMC,aAAa,GAAG,EAAtB;AACA,IAAMC,aAAa,GAAG,CAAtB;AACA,IAAMC,SAAS,GAAG,EAAlB;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,IAAMC,QAAQ,GAAG,SAAXA,QAAW,OAUX;EAAA,IATJC,EASI,QATJA,EASI;EAAA,IARJC,OAQI,QARJA,OAQI;EAAA,IAPJC,IAOI,QAPJA,IAOI;EAAA,IANJC,MAMI,QANJA,MAMI;EAAA,IALJC,MAKI,QALJA,MAKI;EAAA,4BAJJC,WAII;EAAA,IAJJA,WAII,iCAJU,UAIV;EAAA,sBAHJC,KAGI;EAAA,IAHJA,KAGI,2BAHI,KAGJ;EAAA,2BAFJC,UAEI;EAAA,IAFJA,UAEI,gCAFS,KAET;EAAA,IADDC,MACC;;EACJ;EAEA,IAAMC,gBAAgB,GAAG,IAAAC,cAAA,EAAQ;IAAA,OAAM,IAAAC,0CAAA,EAAkBT,IAAlB,EAAwBK,UAAxB,CAAN;EAAA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O;AAhCH,CAArB;;eAmCe,IAAAC,kBAAA,EAAWC,gBAAX,EAAmB;EAAEC,IAAI,EAAE;AAAR,CAAnB,EAA2C/D,QAA3C,C"}
|
|
1
|
+
{"version":3,"file":"Barchart.js","names":["MARGIN","MAX_BAR_WIDTH","MIN_BAR_WIDTH","MIN_WIDTH","Barchart","id","classes","data","layout","config","tooltipType","stack","horizontal","others","dataWithDefaults","useMemo","applyDataDefaults","chartLayout","applyLayoutDefaults","useState","chartData","setChartData","firstRender","useRef","useEffect","current","recalculateBarWidth","useCallback","ref","plotData","props","plotLayout","length","barmode","bargap","bargroupgap","isStack","numberOfBarsByGroup","numberOfGroup","x","el","getBoundingClientRect","boundingRect","width","plotWidth","groupWidth","colWidth","calculatedBarWidth","greaterThan90","lessThan3","isAlreadyGreaterThan90","undefined","newWidth","newData","map","subData","propTypes","PropTypes","string","shape","root","arrayOf","instanceOf","Object","isRequired","oneOf","tooltip","func","afterPlot","xAxisTitle","yAxisTitle","subtitle","bool","withStyles","styles","name"],"sources":["../../src/Barchart/Barchart.js"],"sourcesContent":["import React, { useMemo, useEffect, useState, useCallback, useRef } from \"react\";\nimport PropTypes from \"prop-types\";\nimport { withStyles } from \"@mui/styles\";\nimport Chart from \"../Chart\";\nimport { applyLayoutDefaults, applyDataDefaults } from \"./barchartPlotlyOverrides\";\nimport styles from \"./styles\";\n\nconst MARGIN = 50;\nconst MAX_BAR_WIDTH = 90;\nconst MIN_BAR_WIDTH = 3;\nconst MIN_WIDTH = 75;\n\n/**\n * A Bar chart is a chart or graph that presents categorical data with rectangular bars.\n *\n * Our implementation leverages the Plotly charting library. If you have a specific case\n * that we don't cover, the Plotly [documentation](https://plotly.com/javascript/) is a good starting point.\n */\nconst Barchart = ({\n id,\n classes,\n data,\n layout,\n config,\n tooltipType = \"multiple\",\n stack = false,\n horizontal = false,\n ...others\n}) => {\n /* Values derived from props */\n\n const dataWithDefaults = useMemo(() => applyDataDefaults(data, horizontal), [data, horizontal]);\n const chartLayout = useMemo(\n () => applyLayoutDefaults(layout, stack, horizontal),\n [layout, stack, horizontal]\n );\n\n /* State */\n\n const [chartData, setChartData] = useState(dataWithDefaults);\n\n /* Effects */\n\n const firstRender = useRef(true);\n useEffect(() => {\n // only setChartData when prop value changes\n // not needed on first render because the\n // initial state is already properly set\n if (!firstRender.current) {\n setChartData(dataWithDefaults);\n }\n\n firstRender.current = false;\n }, [dataWithDefaults]);\n\n /**\n * Used to force the max width of each bar with 90px.\n *\n * (this is effectively more an effect than a callback)\n */\n const recalculateBarWidth = useCallback((ref) => {\n // use the data and layout info directly from the plotly ref\n // as it's always the most uptodate version.\n const plotData = ref.current.props.data;\n const plotLayout = ref.current.props.layout;\n\n if (plotData.length > 0) {\n const { barmode, bargap, bargroupgap } = plotLayout;\n\n const isStack = barmode === \"stack\";\n const numberOfBarsByGroup = isStack ? 1 : plotData.length;\n const numberOfGroup = plotData[0].x.length;\n\n const { width: boundingRect } = ref.current.el.getBoundingClientRect();\n const width = boundingRect < MIN_WIDTH ? MIN_WIDTH : boundingRect;\n const plotWidth = width - MARGIN;\n const groupWidth = plotWidth / numberOfGroup;\n const colWidth = groupWidth * (1 - bargap) - groupWidth * (1 - bargap) * bargroupgap;\n\n const calculatedBarWidth = colWidth / numberOfBarsByGroup;\n const greaterThan90 = calculatedBarWidth > MAX_BAR_WIDTH;\n const lessThan3 = calculatedBarWidth < MIN_BAR_WIDTH;\n const isAlreadyGreaterThan90 = plotData[0].width !== undefined;\n\n if (greaterThan90 && !isAlreadyGreaterThan90) {\n const newWidth = (MAX_BAR_WIDTH / plotWidth) * numberOfGroup;\n\n const newData = plotData.map((subData) => {\n return { ...subData, width: newWidth };\n });\n\n setChartData(newData);\n }\n\n if (lessThan3 && !isAlreadyGreaterThan90) {\n const newWidth = (MIN_BAR_WIDTH / plotWidth) * numberOfGroup;\n\n const newData = plotData.map((subData) => {\n return { ...subData, width: newWidth };\n });\n\n setChartData(newData);\n }\n\n if (!greaterThan90 && isAlreadyGreaterThan90) {\n const newData = plotData.map((subData) => {\n return { ...subData, width: undefined };\n });\n\n setChartData(newData);\n }\n }\n }, []);\n\n return (\n <Chart\n id={id}\n classes={classes}\n data={chartData}\n layout={chartLayout}\n config={config}\n tooltipType={tooltipType}\n afterPlot={recalculateBarWidth}\n {...others}\n />\n );\n};\nBarchart.propTypes = {\n /**\n * An Id passed on to the component\n */\n id: PropTypes.string,\n /**\n * A Jss Object used to override or extend the styles applied.\n */\n classes: PropTypes.shape({\n root: PropTypes.string,\n }),\n /**\n * Plotly data object (see https://plot.ly/javascript/reference/).\n */\n data: PropTypes.arrayOf(PropTypes.instanceOf(Object)).isRequired,\n /**\n * Plotly layout object (see https://plot.ly/javascript/reference/#layout).\n */\n layout: PropTypes.instanceOf(Object),\n /**\n * Plotly config object (see https://plot.ly/javascript/configuration-options/).\n */\n config: PropTypes.instanceOf(Object),\n /**\n * Defines if should use a single or multiline tooltip.\n */\n tooltipType: PropTypes.oneOf([\"single\", \"multiple\"]),\n /**\n * Custom tooltip element to be displayed\n */\n tooltip: PropTypes.func,\n /**\n * Function to be called after plot render.\n */\n afterPlot: PropTypes.func,\n /**\n * Defines the X axis title.\n */\n xAxisTitle: PropTypes.string,\n /**\n * Defines the Y axis title.\n */\n yAxisTitle: PropTypes.string,\n /**\n * Defines the chart subtitle.\n */\n subtitle: PropTypes.string,\n /**\n * Sets is the chart is stack.\n */\n stack: PropTypes.bool,\n /**\n * Sets is the chart is horizontal.\n */\n horizontal: PropTypes.bool,\n};\n\nexport default withStyles(styles, { name: \"HvBarchart\" })(Barchart);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AAA8B;AAAA;AAAA;AAAA;AAAA;AAAA;AAE9B,IAAMA,MAAM,GAAG,EAAE;AACjB,IAAMC,aAAa,GAAG,EAAE;AACxB,IAAMC,aAAa,GAAG,CAAC;AACvB,IAAMC,SAAS,GAAG,EAAE;;AAEpB;AACA;AACA;AACA;AACA;AACA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ACF;AACA;EACExD,MAAM,EAAEiD,kBAAS,CAACK,UAAU,CAACC,MAAM,CAAC;EACpC;AACF;AACA;EACEtD,MAAM,EAAEgD,kBAAS,CAACK,UAAU,CAACC,MAAM,CAAC;EACpC;AACF;AACA;EACErD,WAAW,EAAE+C,kBAAS,CAACQ,KAAK,CAAC,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;EACpD;AACF;AACA;EACEC,OAAO,EAAET,kBAAS,CAACU,IAAI;EACvB;AACF;AACA;EACEC,SAAS,EAAEX,kBAAS,CAACU,IAAI;EACzB;AACF;AACA;EACEE,UAAU,EAAEZ,kBAAS,CAACC,MAAM;EAC5B;AACF;AACA;EACEY,UAAU,EAAEb,kBAAS,CAACC,MAAM;EAC5B;AACF;AACA;EACEa,QAAQ,EAAEd,kBAAS,CAACC,MAAM;EAC1B;AACF;AACA;EACE/C,KAAK,EAAE8C,kBAAS,CAACe,IAAI;EACrB;AACF;AACA;EACE5D,UAAU,EAAE6C,kBAAS,CAACe;AACxB,CAAC;AAAC,eAEa,IAAAC,kBAAU,EAACC,gBAAM,EAAE;EAAEC,IAAI,EAAE;AAAa,CAAC,CAAC,CAACvE,QAAQ,CAAC;AAAA"}
|
|
@@ -1,29 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.applyLayoutDefaults = exports.applyDataDefaults = void 0;
|
|
9
|
-
|
|
10
8
|
require("core-js/modules/es.object.to-string.js");
|
|
11
|
-
|
|
12
9
|
require("core-js/modules/web.dom-collections.for-each.js");
|
|
13
|
-
|
|
14
10
|
var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
|
|
15
|
-
|
|
16
11
|
var setterIfNil = function setterIfNil(object, property, value) {
|
|
17
12
|
var _object$property;
|
|
18
|
-
|
|
19
13
|
// eslint-disable-next-line no-param-reassign
|
|
20
14
|
object[property] = (_object$property = object[property]) !== null && _object$property !== void 0 ? _object$property : value;
|
|
21
15
|
};
|
|
16
|
+
|
|
22
17
|
/**
|
|
23
18
|
* Auxiliary functions to set the layout in order to follow the DS guideline.
|
|
24
19
|
*/
|
|
25
|
-
|
|
26
|
-
|
|
27
20
|
var applyLayoutDefaults = function applyLayoutDefaults(inputLayout, stack, isHorizontal) {
|
|
28
21
|
var layout = inputLayout === undefined ? {} : (0, _cloneDeep.default)(inputLayout);
|
|
29
22
|
setterIfNil(layout, "bargap", 0.25);
|
|
@@ -32,19 +25,15 @@ var applyLayoutDefaults = function applyLayoutDefaults(inputLayout, stack, isHor
|
|
|
32
25
|
if (stack) setterIfNil(layout, "barmode", "stack");
|
|
33
26
|
setterIfNil(layout, "yaxis", {});
|
|
34
27
|
setterIfNil(layout, "xaxis", {});
|
|
35
|
-
|
|
36
28
|
if (isHorizontal) {
|
|
37
29
|
setterIfNil(layout.yaxis, "showline", true);
|
|
38
30
|
setterIfNil(layout.xaxis, "showline", false);
|
|
39
31
|
} else {
|
|
40
32
|
setterIfNil(layout.yaxis, "showline", false);
|
|
41
33
|
}
|
|
42
|
-
|
|
43
34
|
return layout;
|
|
44
35
|
};
|
|
45
|
-
|
|
46
36
|
exports.applyLayoutDefaults = applyLayoutDefaults;
|
|
47
|
-
|
|
48
37
|
var applyDataDefaults = function applyDataDefaults(inputData, isHorizontal) {
|
|
49
38
|
var data = inputData;
|
|
50
39
|
data.forEach(function (trace) {
|
|
@@ -54,6 +43,5 @@ var applyDataDefaults = function applyDataDefaults(inputData, isHorizontal) {
|
|
|
54
43
|
});
|
|
55
44
|
return data;
|
|
56
45
|
};
|
|
57
|
-
|
|
58
46
|
exports.applyDataDefaults = applyDataDefaults;
|
|
59
47
|
//# sourceMappingURL=barchartPlotlyOverrides.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"barchartPlotlyOverrides.js","names":["setterIfNil","object","property","value","applyLayoutDefaults","inputLayout","stack","isHorizontal","layout","undefined","clone","yaxis","xaxis","applyDataDefaults","inputData","data","forEach","trace"],"sources":["../../src/Barchart/barchartPlotlyOverrides.js"],"sourcesContent":["import clone from \"lodash/cloneDeep\";\n\nconst setterIfNil = (object, property, value) => {\n // eslint-disable-next-line no-param-reassign\n object[property] = object[property] ?? value;\n};\n\n/**\n * Auxiliary functions to set the layout in order to follow the DS guideline.\n */\nexport const applyLayoutDefaults = (inputLayout, stack, isHorizontal) => {\n const layout = inputLayout === undefined ? {} : clone(inputLayout);\n setterIfNil(layout, \"bargap\", 0.25);\n setterIfNil(layout, \"bargroupgap\", 0.25);\n setterIfNil(layout, \"hovermode\", \"closest\");\n if (stack) setterIfNil(layout, \"barmode\", \"stack\");\n\n setterIfNil(layout, \"yaxis\", {});\n setterIfNil(layout, \"xaxis\", {});\n\n if (isHorizontal) {\n setterIfNil(layout.yaxis, \"showline\", true);\n setterIfNil(layout.xaxis, \"showline\", false);\n } else {\n setterIfNil(layout.yaxis, \"showline\", false);\n }\n\n return layout;\n};\n\nexport const applyDataDefaults = (inputData, isHorizontal) => {\n const data = inputData;\n\n data.forEach((trace) => {\n setterIfNil(trace, \"type\", \"bar\");\n setterIfNil(trace, \"hoverinfo\", \"none\");\n if (isHorizontal) setterIfNil(trace, \"orientation\", \"h\");\n });\n\n return data;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"barchartPlotlyOverrides.js","names":["setterIfNil","object","property","value","applyLayoutDefaults","inputLayout","stack","isHorizontal","layout","undefined","clone","yaxis","xaxis","applyDataDefaults","inputData","data","forEach","trace"],"sources":["../../src/Barchart/barchartPlotlyOverrides.js"],"sourcesContent":["import clone from \"lodash/cloneDeep\";\n\nconst setterIfNil = (object, property, value) => {\n // eslint-disable-next-line no-param-reassign\n object[property] = object[property] ?? value;\n};\n\n/**\n * Auxiliary functions to set the layout in order to follow the DS guideline.\n */\nexport const applyLayoutDefaults = (inputLayout, stack, isHorizontal) => {\n const layout = inputLayout === undefined ? {} : clone(inputLayout);\n setterIfNil(layout, \"bargap\", 0.25);\n setterIfNil(layout, \"bargroupgap\", 0.25);\n setterIfNil(layout, \"hovermode\", \"closest\");\n if (stack) setterIfNil(layout, \"barmode\", \"stack\");\n\n setterIfNil(layout, \"yaxis\", {});\n setterIfNil(layout, \"xaxis\", {});\n\n if (isHorizontal) {\n setterIfNil(layout.yaxis, \"showline\", true);\n setterIfNil(layout.xaxis, \"showline\", false);\n } else {\n setterIfNil(layout.yaxis, \"showline\", false);\n }\n\n return layout;\n};\n\nexport const applyDataDefaults = (inputData, isHorizontal) => {\n const data = inputData;\n\n data.forEach((trace) => {\n setterIfNil(trace, \"type\", \"bar\");\n setterIfNil(trace, \"hoverinfo\", \"none\");\n if (isHorizontal) setterIfNil(trace, \"orientation\", \"h\");\n });\n\n return data;\n};\n"],"mappings":";;;;;;;;;AAAA;AAEA,IAAMA,WAAW,GAAG,SAAdA,WAAW,CAAIC,MAAM,EAAEC,QAAQ,EAAEC,KAAK,EAAK;EAAA;EAC/C;EACAF,MAAM,CAACC,QAAQ,CAAC,uBAAGD,MAAM,CAACC,QAAQ,CAAC,+DAAIC,KAAK;AAC9C,CAAC;;AAED;AACA;AACA;AACO,IAAMC,mBAAmB,GAAG,SAAtBA,mBAAmB,CAAIC,WAAW,EAAEC,KAAK,EAAEC,YAAY,EAAK;EACvE,IAAMC,MAAM,GAAGH,WAAW,KAAKI,SAAS,GAAG,CAAC,CAAC,GAAG,IAAAC,kBAAK,EAACL,WAAW,CAAC;EAClEL,WAAW,CAACQ,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC;EACnCR,WAAW,CAACQ,MAAM,EAAE,aAAa,EAAE,IAAI,CAAC;EACxCR,WAAW,CAACQ,MAAM,EAAE,WAAW,EAAE,SAAS,CAAC;EAC3C,IAAIF,KAAK,EAAEN,WAAW,CAACQ,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC;EAElDR,WAAW,CAACQ,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;EAChCR,WAAW,CAACQ,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;EAEhC,IAAID,YAAY,EAAE;IAChBP,WAAW,CAACQ,MAAM,CAACG,KAAK,EAAE,UAAU,EAAE,IAAI,CAAC;IAC3CX,WAAW,CAACQ,MAAM,CAACI,KAAK,EAAE,UAAU,EAAE,KAAK,CAAC;EAC9C,CAAC,MAAM;IACLZ,WAAW,CAACQ,MAAM,CAACG,KAAK,EAAE,UAAU,EAAE,KAAK,CAAC;EAC9C;EAEA,OAAOH,MAAM;AACf,CAAC;AAAC;AAEK,IAAMK,iBAAiB,GAAG,SAApBA,iBAAiB,CAAIC,SAAS,EAAEP,YAAY,EAAK;EAC5D,IAAMQ,IAAI,GAAGD,SAAS;EAEtBC,IAAI,CAACC,OAAO,CAAC,UAACC,KAAK,EAAK;IACtBjB,WAAW,CAACiB,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC;IACjCjB,WAAW,CAACiB,KAAK,EAAE,WAAW,EAAE,MAAM,CAAC;IACvC,IAAIV,YAAY,EAAEP,WAAW,CAACiB,KAAK,EAAE,aAAa,EAAE,GAAG,CAAC;EAC1D,CAAC,CAAC;EAEF,OAAOF,IAAI;AACb,CAAC;AAAC"}
|
package/dist/Barchart/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
@@ -11,6 +10,5 @@ Object.defineProperty(exports, "default", {
|
|
|
11
10
|
return _Barchart.default;
|
|
12
11
|
}
|
|
13
12
|
});
|
|
14
|
-
|
|
15
13
|
var _Barchart = _interopRequireDefault(require("./Barchart"));
|
|
16
14
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/Barchart/index.js"],"sourcesContent":["export { default } from \"./Barchart\";\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/Barchart/index.js"],"sourcesContent":["export { default } from \"./Barchart\";\n"],"mappings":";;;;;;;;;;;;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","names":["styles"],"sources":["../../src/Barchart/styles.js"],"sourcesContent":["const styles = {};\n\nexport default styles;\n"],"mappings":";;;;;;AAAA,IAAMA,MAAM,GAAG,
|
|
1
|
+
{"version":3,"file":"styles.js","names":["styles"],"sources":["../../src/Barchart/styles.js"],"sourcesContent":["const styles = {};\n\nexport default styles;\n"],"mappings":";;;;;;AAAA,IAAMA,MAAM,GAAG,CAAC,CAAC;AAAC,eAEHA,MAAM;AAAA"}
|
package/dist/Chart/Chart.js
CHANGED
|
@@ -1,92 +1,60 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
require("core-js/modules/es.object.keys.js");
|
|
4
|
-
|
|
5
4
|
require("core-js/modules/es.symbol.js");
|
|
6
|
-
|
|
7
5
|
require("core-js/modules/es.array.filter.js");
|
|
8
|
-
|
|
9
6
|
require("core-js/modules/es.object.get-own-property-descriptor.js");
|
|
10
|
-
|
|
11
7
|
require("core-js/modules/es.object.get-own-property-descriptors.js");
|
|
12
|
-
|
|
13
8
|
require("core-js/modules/es.array.iterator.js");
|
|
14
|
-
|
|
15
9
|
require("core-js/modules/es.string.iterator.js");
|
|
16
|
-
|
|
17
10
|
require("core-js/modules/es.weak-map.js");
|
|
18
|
-
|
|
19
11
|
require("core-js/modules/web.dom-collections.iterator.js");
|
|
20
|
-
|
|
21
12
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
22
|
-
|
|
23
13
|
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
24
|
-
|
|
25
14
|
Object.defineProperty(exports, "__esModule", {
|
|
26
15
|
value: true
|
|
27
16
|
});
|
|
28
17
|
exports.default = void 0;
|
|
29
|
-
|
|
30
18
|
require("core-js/modules/es.object.to-string.js");
|
|
31
|
-
|
|
32
19
|
require("core-js/modules/web.dom-collections.for-each.js");
|
|
33
|
-
|
|
34
20
|
require("core-js/modules/es.function.name.js");
|
|
35
|
-
|
|
36
21
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
37
|
-
|
|
38
22
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
39
|
-
|
|
40
23
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
41
|
-
|
|
42
24
|
var _react = _interopRequireWildcard(require("react"));
|
|
43
|
-
|
|
44
25
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
45
|
-
|
|
46
26
|
var _isNil = _interopRequireDefault(require("lodash/isNil"));
|
|
47
|
-
|
|
48
27
|
var _styles = require("@mui/styles");
|
|
49
|
-
|
|
50
28
|
var _Tooltip = _interopRequireDefault(require("./Tooltip"));
|
|
51
|
-
|
|
52
29
|
var _chartPlotlyOverrides = require("./chartPlotlyOverrides");
|
|
53
|
-
|
|
54
30
|
var _Plot = _interopRequireDefault(require("./Plot"));
|
|
55
|
-
|
|
56
31
|
var _styles2 = _interopRequireDefault(require("./styles"));
|
|
57
|
-
|
|
58
32
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
59
|
-
|
|
60
33
|
var _excluded = ["id", "classes", "data", "layout", "config", "tooltipType", "tooltip", "afterPlot", "xAxisTitle", "yAxisTitle"];
|
|
61
|
-
|
|
62
34
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
63
|
-
|
|
64
35
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
65
|
-
|
|
66
36
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
67
|
-
|
|
68
37
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
69
|
-
|
|
70
38
|
var Chart = function Chart(_ref) {
|
|
71
39
|
var id = _ref.id,
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
40
|
+
classes = _ref.classes,
|
|
41
|
+
data = _ref.data,
|
|
42
|
+
layout = _ref.layout,
|
|
43
|
+
config = _ref.config,
|
|
44
|
+
_ref$tooltipType = _ref.tooltipType,
|
|
45
|
+
tooltipType = _ref$tooltipType === void 0 ? "multiple" : _ref$tooltipType,
|
|
46
|
+
tooltip = _ref.tooltip,
|
|
47
|
+
afterPlot = _ref.afterPlot,
|
|
48
|
+
xAxisTitle = _ref.xAxisTitle,
|
|
49
|
+
yAxisTitle = _ref.yAxisTitle,
|
|
50
|
+
others = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
83
51
|
var theme = (0, _styles.useTheme)();
|
|
52
|
+
|
|
84
53
|
/* Values derived from props */
|
|
85
|
-
// Check if the barchart is horizontal or vertical.
|
|
86
54
|
|
|
55
|
+
// Check if the barchart is horizontal or vertical.
|
|
87
56
|
var isHorizontal = (0, _react.useMemo)(function () {
|
|
88
57
|
var _data$;
|
|
89
|
-
|
|
90
58
|
return !(0, _isNil.default)((_data$ = data[0]) === null || _data$ === void 0 ? void 0 : _data$.orientation) ? data[0].orientation.toUpperCase() === "H" : false;
|
|
91
59
|
}, [data]);
|
|
92
60
|
var chartLayout = (0, _react.useMemo)(function () {
|
|
@@ -96,29 +64,28 @@ var Chart = function Chart(_ref) {
|
|
|
96
64
|
return (0, _chartPlotlyOverrides.applyConfigDefaults)(config);
|
|
97
65
|
}, [config]);
|
|
98
66
|
var useSingle = tooltipType === "single";
|
|
67
|
+
|
|
99
68
|
/* State */
|
|
100
69
|
|
|
101
70
|
var _useState = (0, _react.useState)(false),
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
71
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
72
|
+
isHover = _useState2[0],
|
|
73
|
+
setIsHover = _useState2[1];
|
|
106
74
|
var _useState3 = (0, _react.useState)({
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
75
|
+
x: 0,
|
|
76
|
+
y: 0
|
|
77
|
+
}),
|
|
78
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
79
|
+
coordinates = _useState4[0],
|
|
80
|
+
setCoordinates = _useState4[1];
|
|
114
81
|
var _useState5 = (0, _react.useState)(),
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
/* Callbacks */
|
|
119
|
-
// Extract data from the plotly onHover event to be used to create the tooltip.
|
|
82
|
+
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
83
|
+
dataTooltip = _useState6[0],
|
|
84
|
+
setDataTooltip = _useState6[1];
|
|
120
85
|
|
|
86
|
+
/* Callbacks */
|
|
121
87
|
|
|
88
|
+
// Extract data from the plotly onHover event to be used to create the tooltip.
|
|
122
89
|
var onHover = (0, _react.useCallback)(function (event) {
|
|
123
90
|
var points = event.points;
|
|
124
91
|
var dataFromPoints = {
|
|
@@ -127,7 +94,6 @@ var Chart = function Chart(_ref) {
|
|
|
127
94
|
};
|
|
128
95
|
points.forEach(function (p, i) {
|
|
129
96
|
var _fData$marker, _fData$line, _fData$labels;
|
|
130
|
-
|
|
131
97
|
var fData = p.fullData;
|
|
132
98
|
var pNumber = p.pointNumber;
|
|
133
99
|
if (i === 0) dataFromPoints.title = isHorizontal ? p.y : p.x || fData.name;
|
|
@@ -172,69 +138,56 @@ var Chart = function Chart(_ref) {
|
|
|
172
138
|
})]
|
|
173
139
|
});
|
|
174
140
|
};
|
|
175
|
-
|
|
176
141
|
process.env.NODE_ENV !== "production" ? Chart.propTypes = {
|
|
177
142
|
/**
|
|
178
143
|
* An Id passed on to the component
|
|
179
144
|
*/
|
|
180
145
|
id: _propTypes.default.string,
|
|
181
|
-
|
|
182
146
|
/**
|
|
183
147
|
* A Jss Object used to override or extend the styles applied.
|
|
184
148
|
*/
|
|
185
149
|
classes: _propTypes.default.shape({
|
|
186
150
|
root: _propTypes.default.string
|
|
187
151
|
}),
|
|
188
|
-
|
|
189
152
|
/**
|
|
190
153
|
* Plotly data object (see https://plot.ly/javascript/reference/).
|
|
191
154
|
*/
|
|
192
155
|
data: _propTypes.default.arrayOf(_propTypes.default.instanceOf(Object)).isRequired,
|
|
193
|
-
|
|
194
156
|
/**
|
|
195
157
|
* Plotly layout object (see https://plot.ly/javascript/reference/#layout).
|
|
196
158
|
*/
|
|
197
159
|
layout: _propTypes.default.instanceOf(Object).isRequired,
|
|
198
|
-
|
|
199
160
|
/**
|
|
200
161
|
* Plotly config object (see https://plot.ly/javascript/configuration-options/).
|
|
201
162
|
*/
|
|
202
163
|
config: _propTypes.default.instanceOf(Object),
|
|
203
|
-
|
|
204
164
|
/**
|
|
205
165
|
* Defines if should use a single or multiline tooltip.
|
|
206
166
|
*/
|
|
207
167
|
tooltipType: _propTypes.default.oneOf(["single", "multiple"]),
|
|
208
|
-
|
|
209
168
|
/**
|
|
210
169
|
* Custom tooltip element to be displayed
|
|
211
170
|
*/
|
|
212
171
|
tooltip: _propTypes.default.func,
|
|
213
|
-
|
|
214
172
|
/**
|
|
215
173
|
* Function to be called after plot render.
|
|
216
174
|
*/
|
|
217
175
|
afterPlot: _propTypes.default.func,
|
|
218
|
-
|
|
219
176
|
/**
|
|
220
177
|
* Defines the X axis title.
|
|
221
178
|
*/
|
|
222
179
|
xAxisTitle: _propTypes.default.string,
|
|
223
|
-
|
|
224
180
|
/**
|
|
225
181
|
* Defines the Y axis title.
|
|
226
182
|
*/
|
|
227
183
|
yAxisTitle: _propTypes.default.string,
|
|
228
|
-
|
|
229
184
|
/**
|
|
230
185
|
* Defines the chart subtitle.
|
|
231
186
|
*/
|
|
232
187
|
subtitle: _propTypes.default.string
|
|
233
188
|
} : void 0;
|
|
234
|
-
|
|
235
189
|
var _default = (0, _styles.withStyles)(_styles2.default, {
|
|
236
190
|
name: "HvChart"
|
|
237
191
|
})(Chart);
|
|
238
|
-
|
|
239
192
|
exports.default = _default;
|
|
240
193
|
//# sourceMappingURL=Chart.js.map
|