@hitachivantara/uikit-react-viz 3.1.23 → 3.2.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.
- package/dist/Chart/Chart.d.ts +8 -0
- package/dist/Chart/Chart.js +9 -2
- package/dist/Chart/Chart.js.map +1 -1
- package/dist/Chart/Tooltip/Tooltip.js +21 -8
- package/dist/Chart/Tooltip/Tooltip.js.map +1 -1
- package/dist/legacy/Chart/Chart.d.ts +8 -0
- package/dist/legacy/Chart/Chart.js +9 -2
- package/dist/legacy/Chart/Chart.js.map +1 -1
- package/dist/legacy/Chart/Tooltip/Tooltip.js +22 -9
- package/dist/legacy/Chart/Tooltip/Tooltip.js.map +1 -1
- package/dist/modern/Chart/Chart.d.ts +8 -0
- package/dist/modern/Chart/Chart.js +9 -2
- package/dist/modern/Chart/Chart.js.map +1 -1
- package/dist/modern/Chart/Tooltip/Tooltip.js +22 -9
- package/dist/modern/Chart/Tooltip/Tooltip.js.map +1 -1
- package/package.json +3 -3
package/dist/Chart/Chart.d.ts
CHANGED
|
@@ -4,10 +4,18 @@ import { HvPlotProps } from "./Plot";
|
|
|
4
4
|
export type HvChartClassKey = "root";
|
|
5
5
|
|
|
6
6
|
export interface HvChartProps extends StandardProps<HvPlotProps, HvChartClassKey> {
|
|
7
|
+
/**
|
|
8
|
+
* An Id passed on to the component
|
|
9
|
+
*/
|
|
10
|
+
id?: string;
|
|
7
11
|
/**
|
|
8
12
|
* Defines if should use a single or multiline tooltip.
|
|
9
13
|
*/
|
|
10
14
|
tooltipType?: "single" | "multiple";
|
|
15
|
+
/**
|
|
16
|
+
* Custom tooltip element to be displayed
|
|
17
|
+
*/
|
|
18
|
+
tooltip?: React.ReactNode;
|
|
11
19
|
/**
|
|
12
20
|
* Defines the X axis title.
|
|
13
21
|
*/
|
package/dist/Chart/Chart.js
CHANGED
|
@@ -47,7 +47,7 @@ var _Plot = _interopRequireDefault(require("./Plot"));
|
|
|
47
47
|
|
|
48
48
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
49
49
|
|
|
50
|
-
var _excluded = ["id", "classes", "data", "layout", "config", "tooltipType", "afterPlot", "xAxisTitle", "yAxisTitle"];
|
|
50
|
+
var _excluded = ["id", "classes", "data", "layout", "config", "tooltipType", "tooltip", "afterPlot", "xAxisTitle", "yAxisTitle"];
|
|
51
51
|
|
|
52
52
|
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); }
|
|
53
53
|
|
|
@@ -61,6 +61,7 @@ var Chart = function Chart(_ref) {
|
|
|
61
61
|
config = _ref.config,
|
|
62
62
|
_ref$tooltipType = _ref.tooltipType,
|
|
63
63
|
tooltipType = _ref$tooltipType === void 0 ? "multiple" : _ref$tooltipType,
|
|
64
|
+
tooltip = _ref.tooltip,
|
|
64
65
|
afterPlot = _ref.afterPlot,
|
|
65
66
|
xAxisTitle = _ref.xAxisTitle,
|
|
66
67
|
yAxisTitle = _ref.yAxisTitle,
|
|
@@ -137,7 +138,8 @@ var Chart = function Chart(_ref) {
|
|
|
137
138
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, isHover && /*#__PURE__*/_react.default.createElement(_Tooltip.default, {
|
|
138
139
|
coordinates: coordinates,
|
|
139
140
|
data: dataTooltip,
|
|
140
|
-
useSingle: useSingle
|
|
141
|
+
useSingle: useSingle,
|
|
142
|
+
tooltip: tooltip
|
|
141
143
|
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
142
144
|
id: id,
|
|
143
145
|
className: classes.root
|
|
@@ -186,6 +188,11 @@ process.env.NODE_ENV !== "production" ? Chart.propTypes = {
|
|
|
186
188
|
*/
|
|
187
189
|
tooltipType: _propTypes.default.oneOf(["single", "multiple"]),
|
|
188
190
|
|
|
191
|
+
/**
|
|
192
|
+
* Custom tooltip element to be displayed
|
|
193
|
+
*/
|
|
194
|
+
tooltip: _propTypes.default.func,
|
|
195
|
+
|
|
189
196
|
/**
|
|
190
197
|
* Function to be called after plot render.
|
|
191
198
|
*/
|
package/dist/Chart/Chart.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chart.js","names":["Chart","id","classes","data","layout","config","tooltipType","afterPlot","xAxisTitle","yAxisTitle","others","theme","useTheme","isHorizontal","useMemo","isNil","orientation","toUpperCase","chartLayout","applyLayoutDefaults","chartConfig","applyConfigDefaults","useSingle","useState","isHover","setIsHover","x","y","coordinates","setCoordinates","dataTooltip","setDataTooltip","onHover","useCallback","event","points","dataFromPoints","title","elements","forEach","p","i","fData","fullData","pNumber","pointNumber","name","push","color","marker","line","labels","value","onUnHover","onMouseMove","clientX","clientY","root","propTypes","PropTypes","string","shape","arrayOf","instanceOf","Object","isRequired","oneOf","func","subtitle","withStyles","styles"],"sources":["../../src/Chart/Chart.js"],"sourcesContent":["import React, { useState, useMemo, useCallback } from \"react\";\nimport PropTypes from \"prop-types\";\nimport isNil from \"lodash/isNil\";\nimport { useTheme, withStyles } from \"@material-ui/core\";\nimport Tooltip from \"./Tooltip\";\nimport { applyLayoutDefaults, applyConfigDefaults } from \"./chartPlotlyOverrides\";\n\nimport Plot from \"./Plot\";\nimport styles from \"./styles\";\n\nconst Chart = ({\n id,\n classes,\n data,\n layout,\n config,\n tooltipType = \"multiple\",\n afterPlot,\n xAxisTitle,\n yAxisTitle,\n ...others\n}) => {\n const theme = useTheme();\n\n /* Values derived from props */\n\n // Check if the barchart is horizontal or vertical.\n const isHorizontal = useMemo(\n () => (!isNil(data[0]?.orientation) ? data[0].orientation.toUpperCase() === \"H\" : false),\n [data]\n );\n\n const chartLayout = useMemo(\n () => applyLayoutDefaults(layout, theme, isHorizontal, xAxisTitle, yAxisTitle),\n [isHorizontal, layout, theme, xAxisTitle, yAxisTitle]\n );\n\n const chartConfig = useMemo(() => applyConfigDefaults(config), [config]);\n\n const useSingle = tooltipType === \"single\";\n\n /* State */\n\n const [isHover, setIsHover] = useState(false);\n const [coordinates, setCoordinates] = useState({ x: 0, y: 0 });\n const [dataTooltip, setDataTooltip] = useState();\n\n /* Callbacks */\n\n // Extract data from the plotly onHover event to be used to create the tooltip.\n const onHover = useCallback(\n (event) => {\n const { points } = event;\n\n const dataFromPoints = {\n title: \"\",\n elements: [],\n };\n\n points.forEach((p, i) => {\n const fData = p.fullData;\n const pNumber = p.pointNumber;\n\n if (i === 0) dataFromPoints.title = isHorizontal ? p.y : p.x || fData.name;\n\n dataFromPoints.elements.push({\n color: fData.marker?.color || fData.line?.color || p.color,\n name: fData.labels?.[pNumber] || fData.name,\n value: isHorizontal ? p.x : p.y || p.value,\n });\n });\n\n setDataTooltip(dataFromPoints);\n setIsHover(true);\n },\n [isHorizontal]\n );\n\n const onUnHover = useCallback(() => {\n setIsHover(false);\n }, []);\n\n const onMouseMove = useCallback((event) => {\n setCoordinates({\n x: event.clientX,\n y: event.clientY,\n });\n }, []);\n\n return (\n <>\n {isHover && <Tooltip
|
|
1
|
+
{"version":3,"file":"Chart.js","names":["Chart","id","classes","data","layout","config","tooltipType","tooltip","afterPlot","xAxisTitle","yAxisTitle","others","theme","useTheme","isHorizontal","useMemo","isNil","orientation","toUpperCase","chartLayout","applyLayoutDefaults","chartConfig","applyConfigDefaults","useSingle","useState","isHover","setIsHover","x","y","coordinates","setCoordinates","dataTooltip","setDataTooltip","onHover","useCallback","event","points","dataFromPoints","title","elements","forEach","p","i","fData","fullData","pNumber","pointNumber","name","push","color","marker","line","labels","value","onUnHover","onMouseMove","clientX","clientY","root","propTypes","PropTypes","string","shape","arrayOf","instanceOf","Object","isRequired","oneOf","func","subtitle","withStyles","styles"],"sources":["../../src/Chart/Chart.js"],"sourcesContent":["import React, { useState, useMemo, useCallback } from \"react\";\nimport PropTypes from \"prop-types\";\nimport isNil from \"lodash/isNil\";\nimport { useTheme, withStyles } from \"@material-ui/core\";\nimport Tooltip from \"./Tooltip\";\nimport { applyLayoutDefaults, applyConfigDefaults } from \"./chartPlotlyOverrides\";\n\nimport Plot from \"./Plot\";\nimport styles from \"./styles\";\n\nconst Chart = ({\n id,\n classes,\n data,\n layout,\n config,\n tooltipType = \"multiple\",\n tooltip,\n afterPlot,\n xAxisTitle,\n yAxisTitle,\n ...others\n}) => {\n const theme = useTheme();\n\n /* Values derived from props */\n\n // Check if the barchart is horizontal or vertical.\n const isHorizontal = useMemo(\n () => (!isNil(data[0]?.orientation) ? data[0].orientation.toUpperCase() === \"H\" : false),\n [data]\n );\n\n const chartLayout = useMemo(\n () => applyLayoutDefaults(layout, theme, isHorizontal, xAxisTitle, yAxisTitle),\n [isHorizontal, layout, theme, xAxisTitle, yAxisTitle]\n );\n\n const chartConfig = useMemo(() => applyConfigDefaults(config), [config]);\n\n const useSingle = tooltipType === \"single\";\n\n /* State */\n\n const [isHover, setIsHover] = useState(false);\n const [coordinates, setCoordinates] = useState({ x: 0, y: 0 });\n const [dataTooltip, setDataTooltip] = useState();\n\n /* Callbacks */\n\n // Extract data from the plotly onHover event to be used to create the tooltip.\n const onHover = useCallback(\n (event) => {\n const { points } = event;\n\n const dataFromPoints = {\n title: \"\",\n elements: [],\n };\n\n points.forEach((p, i) => {\n const fData = p.fullData;\n const pNumber = p.pointNumber;\n\n if (i === 0) dataFromPoints.title = isHorizontal ? p.y : p.x || fData.name;\n\n dataFromPoints.elements.push({\n color: fData.marker?.color || fData.line?.color || p.color,\n name: fData.labels?.[pNumber] || fData.name,\n value: isHorizontal ? p.x : p.y || p.value,\n });\n });\n\n setDataTooltip(dataFromPoints);\n setIsHover(true);\n },\n [isHorizontal]\n );\n\n const onUnHover = useCallback(() => {\n setIsHover(false);\n }, []);\n\n const onMouseMove = useCallback((event) => {\n setCoordinates({\n x: event.clientX,\n y: event.clientY,\n });\n }, []);\n\n return (\n <>\n {isHover && (\n <Tooltip\n coordinates={coordinates}\n data={dataTooltip}\n useSingle={useSingle}\n tooltip={tooltip}\n />\n )}\n <div id={id} className={classes.root}>\n <div onMouseMove={onMouseMove}>\n <Plot\n data={data}\n layout={chartLayout}\n config={chartConfig}\n onHover={onHover}\n onUnHover={onUnHover}\n afterPlot={afterPlot}\n {...others}\n />\n </div>\n </div>\n </>\n );\n};\n\nChart.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 /**\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).isRequired,\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\nexport default withStyles(styles, { name: \"HvChart\" })(Chart);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;;;;;;;AAEA,IAAMA,KAAK,GAAG,SAARA,KAAQ,OAYR;EAAA,IAXJC,EAWI,QAXJA,EAWI;EAAA,IAVJC,OAUI,QAVJA,OAUI;EAAA,IATJC,IASI,QATJA,IASI;EAAA,IARJC,MAQI,QARJA,MAQI;EAAA,IAPJC,MAOI,QAPJA,MAOI;EAAA,4BANJC,WAMI;EAAA,IANJA,WAMI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AAW,UAAX,CAAhB,CA3BG;;EA4BhB;AACF;AACA;EACE5D,OAAO,EAAEqD,kBAAA,CAAUQ,IA/BH;;EAgChB;AACF;AACA;EACE5D,SAAS,EAAEoD,kBAAA,CAAUQ,IAnCL;;EAoChB;AACF;AACA;EACE3D,UAAU,EAAEmD,kBAAA,CAAUC,MAvCN;;EAwChB;AACF;AACA;EACEnD,UAAU,EAAEkD,kBAAA,CAAUC,MA3CN;;EA4ChB;AACF;AACA;EACEQ,QAAQ,EAAET,kBAAA,CAAUC;AA/CJ,CAAlB;;eAkDe,IAAAS,gBAAA,EAAWC,eAAX,EAAmB;EAAExB,IAAI,EAAE;AAAR,CAAnB,EAAwC/C,KAAxC,C"}
|
|
@@ -46,10 +46,13 @@ var offset = 20;
|
|
|
46
46
|
*/
|
|
47
47
|
|
|
48
48
|
var MainToolTip = function MainToolTip(_ref) {
|
|
49
|
+
var _MultipleTooltip;
|
|
50
|
+
|
|
49
51
|
var classes = _ref.classes,
|
|
50
52
|
coordinates = _ref.coordinates,
|
|
51
53
|
data = _ref.data,
|
|
52
|
-
useSingle = _ref.useSingle
|
|
54
|
+
useSingle = _ref.useSingle,
|
|
55
|
+
tooltip = _ref.tooltip;
|
|
53
56
|
var x = coordinates.x,
|
|
54
57
|
y = coordinates.y;
|
|
55
58
|
|
|
@@ -80,16 +83,21 @@ var MainToolTip = function MainToolTip(_ref) {
|
|
|
80
83
|
top: y - height - offset
|
|
81
84
|
});
|
|
82
85
|
}, [x, y]);
|
|
86
|
+
var renderTooltip = (0, _react.useCallback)(function (CustomTooltip) {
|
|
87
|
+
if (CustomTooltip) return CustomTooltip(data);
|
|
88
|
+
if (useSingle) return /*#__PURE__*/_react.default.createElement(_SingleTooltip.default, {
|
|
89
|
+
title: data.title,
|
|
90
|
+
value: data.elements[0].value
|
|
91
|
+
});
|
|
92
|
+
return _MultipleTooltip || (_MultipleTooltip = /*#__PURE__*/_react.default.createElement(_MultiTooltip.default, {
|
|
93
|
+
data: data
|
|
94
|
+
}));
|
|
95
|
+
}, [data, useSingle]);
|
|
83
96
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
84
97
|
ref: ref,
|
|
85
98
|
className: classes.root,
|
|
86
99
|
style: style
|
|
87
|
-
},
|
|
88
|
-
title: data.title,
|
|
89
|
-
value: data.elements[0].value
|
|
90
|
-
}) || /*#__PURE__*/_react.default.createElement(_MultiTooltip.default, {
|
|
91
|
-
data: data
|
|
92
|
-
}));
|
|
100
|
+
}, renderTooltip(tooltip));
|
|
93
101
|
};
|
|
94
102
|
|
|
95
103
|
process.env.NODE_ENV !== "production" ? MainToolTip.propTypes = {
|
|
@@ -151,7 +159,12 @@ process.env.NODE_ENV !== "production" ? MainToolTip.propTypes = {
|
|
|
151
159
|
/**
|
|
152
160
|
* Defines if should use a single or multiline tooltip.
|
|
153
161
|
*/
|
|
154
|
-
useSingle: _propTypes.default.bool
|
|
162
|
+
useSingle: _propTypes.default.bool,
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Custom tooltip element to be displayed
|
|
166
|
+
*/
|
|
167
|
+
tooltip: _propTypes.default.func
|
|
155
168
|
} : void 0;
|
|
156
169
|
MainToolTip.defaultProps = {
|
|
157
170
|
useSingle: false
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.js","names":["offset","MainToolTip","classes","coordinates","data","useSingle","x","y","useState","left","top","visibility","style","setStyle","ref","useRef","useEffect","current","getBoundingClientRect","width","height","
|
|
1
|
+
{"version":3,"file":"Tooltip.js","names":["offset","MainToolTip","classes","coordinates","data","useSingle","tooltip","x","y","useState","left","top","visibility","style","setStyle","ref","useRef","useEffect","current","getBoundingClientRect","width","height","renderTooltip","useCallback","CustomTooltip","title","elements","value","root","propTypes","PropTypes","shape","string","isRequired","arrayOf","color","name","number","bool","func","defaultProps","withStyles","styles"],"sources":["../../../src/Chart/Tooltip/Tooltip.js"],"sourcesContent":["import React, { useEffect, useRef, useState, useCallback } from \"react\";\nimport PropTypes from \"prop-types\";\nimport { withStyles } from \"@material-ui/core\";\nimport SingleTooltip from \"./SingleTooltip\";\nimport MultipleTooltip from \"./MultiTooltip\";\nimport styles from \"./styles\";\n\nconst offset = 20;\n\n/**\n * Component responsible for deciding which tooltip should be use and to calculate\n * the exact position where it should be render.\n */\nconst MainToolTip = ({ classes, coordinates, data, useSingle, tooltip }) => {\n const { x, y } = coordinates;\n const [style, setStyle] = useState({ left: x, top: y, visibility: \"hidden\" });\n const ref = useRef(null);\n\n /**\n * Calculate the position where the tooltip has to render, having in account\n * the dimensions.\n */\n useEffect(() => {\n if (!ref.current || !ref.current.getBoundingClientRect().width) return;\n\n const { width, height } = ref.current.getBoundingClientRect();\n\n setStyle({ left: x - width / 2, top: y - height - offset });\n }, [x, y]);\n\n const renderTooltip = useCallback(\n (CustomTooltip) => {\n if (CustomTooltip) return CustomTooltip(data);\n if (useSingle) return <SingleTooltip title={data.title} value={data.elements[0].value} />;\n return <MultipleTooltip data={data} />;\n },\n [data, useSingle]\n );\n\n return (\n <div ref={ref} className={classes.root} style={style}>\n {renderTooltip(tooltip)}\n </div>\n );\n};\n\nMainToolTip.propTypes = {\n /**\n * A Jss Object used to override or extend the styles applied.\n */\n classes: PropTypes.shape({\n /**\n * Styles applied to the barchart root class.\n */\n root: PropTypes.string,\n }).isRequired,\n /**\n * Data of the tooltip.\n */\n data: PropTypes.shape({\n /**\n * Title.\n */\n title: PropTypes.string,\n /**\n * Values of the tooltip.\n */\n elements: PropTypes.arrayOf(\n PropTypes.shape({\n /**\n * Color of the bar.\n */\n color: PropTypes.string,\n /**\n * Name.\n */\n name: PropTypes.string,\n /**\n * Value.\n */\n value: PropTypes.number,\n })\n ),\n }).isRequired,\n /**\n * Coordinates.\n */\n coordinates: PropTypes.shape({\n /**\n * xx's coordinate.\n */\n x: PropTypes.number.isRequired,\n /**\n * yy's coordinate.\n */\n y: PropTypes.number.isRequired,\n }).isRequired,\n /**\n * Defines if should use a single or multiline tooltip.\n */\n useSingle: PropTypes.bool,\n /**\n * Custom tooltip element to be displayed\n */\n tooltip: PropTypes.func,\n};\n\nMainToolTip.defaultProps = {\n useSingle: false,\n};\n\nexport default withStyles(styles, { name: \"HvChartTooltip\" })(MainToolTip);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAMA,MAAM,GAAG,EAAf;AAEA;AACA;AACA;AACA;;AACA,IAAMC,WAAW,GAAG,SAAdA,WAAc,OAAwD;EAAA;;EAAA,IAArDC,OAAqD,QAArDA,OAAqD;EAAA,IAA5CC,WAA4C,QAA5CA,WAA4C;EAAA,IAA/BC,IAA+B,QAA/BA,IAA+B;EAAA,IAAzBC,SAAyB,QAAzBA,SAAyB;EAAA,IAAdC,OAAc,QAAdA,OAAc;EAC1E,IAAQC,CAAR,GAAiBJ,WAAjB,CAAQI,CAAR;EAAA,IAAWC,CAAX,GAAiBL,WAAjB,CAAWK,CAAX;;EACA,gBAA0B,IAAAC,eAAA,EAAS;IAAEC,IAAI,EAAEH,CAAR;IAAWI,GAAG,EAAEH,CAAhB;IAAmBI,UAAU,EAAE;EAA/B,CAAT,CAA1B;EAAA;EAAA,IAAOC,KAAP;EAAA,IAAcC,QAAd;;EACA,IAAMC,GAAG,GAAG,IAAAC,aAAA,EAAO,IAAP,CAAZ;EAEA;AACF;AACA;AACA;;EACE,IAAAC,gBAAA,EAAU,YAAM;IACd,IAAI,CAACF,GAAG,CAACG,OAAL,IAAgB,CAACH,GAAG,CAACG,OAAJ,CAAYC,qBAAZ,GAAoCC,KAAzD,EAAgE;;IAEhE,4BAA0BL,GAAG,CAACG,OAAJ,CAAYC,qBAAZ,EAA1B;IAAA,IAAQC,KAAR,yBAAQA,KAAR;IAAA,IAAeC,MAAf,yBAAeA,MAAf;;IAEAP,QAAQ,CAAC;MAAEJ,IAAI,EAAEH,CAAC,GAAGa,KAAK,GAAG,CAApB;MAAuBT,GAAG,EAAEH,CAAC,GAAG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AhB,EAwBHJ,UArCmB;;EAsCtB;AACF;AACA;EACE9B,WAAW,EAAE2B,kBAAA,CAAUC,KAAV,CAAgB;IAC3B;AACJ;AACA;IACIxB,CAAC,EAAEuB,kBAAA,CAAUO,MAAV,CAAiBJ,UAJO;;IAK3B;AACJ;AACA;IACIzB,CAAC,EAAEsB,kBAAA,CAAUO,MAAV,CAAiBJ;EARO,CAAhB,EASVA,UAlDmB;;EAmDtB;AACF;AACA;EACE5B,SAAS,EAAEyB,kBAAA,CAAUQ,IAtDC;;EAuDtB;AACF;AACA;EACEhC,OAAO,EAAEwB,kBAAA,CAAUS;AA1DG,CAAxB;AA6DAtC,WAAW,CAACuC,YAAZ,GAA2B;EACzBnC,SAAS,EAAE;AADc,CAA3B;;eAIe,IAAAoC,gBAAA,EAAWC,eAAX,EAAmB;EAAEN,IAAI,EAAE;AAAR,CAAnB,EAA+CnC,WAA/C,C"}
|
|
@@ -4,10 +4,18 @@ import { HvPlotProps } from "./Plot";
|
|
|
4
4
|
export type HvChartClassKey = "root";
|
|
5
5
|
|
|
6
6
|
export interface HvChartProps extends StandardProps<HvPlotProps, HvChartClassKey> {
|
|
7
|
+
/**
|
|
8
|
+
* An Id passed on to the component
|
|
9
|
+
*/
|
|
10
|
+
id?: string;
|
|
7
11
|
/**
|
|
8
12
|
* Defines if should use a single or multiline tooltip.
|
|
9
13
|
*/
|
|
10
14
|
tooltipType?: "single" | "multiple";
|
|
15
|
+
/**
|
|
16
|
+
* Custom tooltip element to be displayed
|
|
17
|
+
*/
|
|
18
|
+
tooltip?: React.ReactNode;
|
|
11
19
|
/**
|
|
12
20
|
* Defines the X axis title.
|
|
13
21
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
|
-
var _excluded = ["id", "classes", "data", "layout", "config", "tooltipType", "afterPlot", "xAxisTitle", "yAxisTitle"];
|
|
4
|
+
var _excluded = ["id", "classes", "data", "layout", "config", "tooltipType", "tooltip", "afterPlot", "xAxisTitle", "yAxisTitle"];
|
|
5
5
|
import "core-js/modules/es.object.to-string.js";
|
|
6
6
|
import "core-js/modules/web.dom-collections.for-each.js";
|
|
7
7
|
import "core-js/modules/es.function.name.js";
|
|
@@ -22,6 +22,7 @@ var Chart = function Chart(_ref) {
|
|
|
22
22
|
config = _ref.config,
|
|
23
23
|
_ref$tooltipType = _ref.tooltipType,
|
|
24
24
|
tooltipType = _ref$tooltipType === void 0 ? "multiple" : _ref$tooltipType,
|
|
25
|
+
tooltip = _ref.tooltip,
|
|
25
26
|
afterPlot = _ref.afterPlot,
|
|
26
27
|
xAxisTitle = _ref.xAxisTitle,
|
|
27
28
|
yAxisTitle = _ref.yAxisTitle,
|
|
@@ -99,7 +100,8 @@ var Chart = function Chart(_ref) {
|
|
|
99
100
|
return /*#__PURE__*/React.createElement(React.Fragment, null, isHover && /*#__PURE__*/React.createElement(Tooltip, {
|
|
100
101
|
coordinates: coordinates,
|
|
101
102
|
data: dataTooltip,
|
|
102
|
-
useSingle: useSingle
|
|
103
|
+
useSingle: useSingle,
|
|
104
|
+
tooltip: tooltip
|
|
103
105
|
}), /*#__PURE__*/React.createElement("div", {
|
|
104
106
|
id: id,
|
|
105
107
|
className: classes.root
|
|
@@ -148,6 +150,11 @@ process.env.NODE_ENV !== "production" ? Chart.propTypes = {
|
|
|
148
150
|
*/
|
|
149
151
|
tooltipType: PropTypes.oneOf(["single", "multiple"]),
|
|
150
152
|
|
|
153
|
+
/**
|
|
154
|
+
* Custom tooltip element to be displayed
|
|
155
|
+
*/
|
|
156
|
+
tooltip: PropTypes.func,
|
|
157
|
+
|
|
151
158
|
/**
|
|
152
159
|
* Function to be called after plot render.
|
|
153
160
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chart.js","names":["React","useState","useMemo","useCallback","PropTypes","isNil","useTheme","withStyles","Tooltip","applyLayoutDefaults","applyConfigDefaults","Plot","styles","Chart","id","classes","data","layout","config","tooltipType","afterPlot","xAxisTitle","yAxisTitle","others","theme","isHorizontal","orientation","toUpperCase","chartLayout","chartConfig","useSingle","isHover","setIsHover","x","y","coordinates","setCoordinates","dataTooltip","setDataTooltip","onHover","event","points","dataFromPoints","title","elements","forEach","p","i","fData","fullData","pNumber","pointNumber","name","push","color","marker","line","labels","value","onUnHover","onMouseMove","clientX","clientY","root","propTypes","string","shape","arrayOf","instanceOf","Object","isRequired","oneOf","func","subtitle"],"sources":["../../../src/Chart/Chart.js"],"sourcesContent":["import React, { useState, useMemo, useCallback } from \"react\";\nimport PropTypes from \"prop-types\";\nimport isNil from \"lodash/isNil\";\nimport { useTheme, withStyles } from \"@material-ui/core\";\nimport Tooltip from \"./Tooltip\";\nimport { applyLayoutDefaults, applyConfigDefaults } from \"./chartPlotlyOverrides\";\n\nimport Plot from \"./Plot\";\nimport styles from \"./styles\";\n\nconst Chart = ({\n id,\n classes,\n data,\n layout,\n config,\n tooltipType = \"multiple\",\n afterPlot,\n xAxisTitle,\n yAxisTitle,\n ...others\n}) => {\n const theme = useTheme();\n\n /* Values derived from props */\n\n // Check if the barchart is horizontal or vertical.\n const isHorizontal = useMemo(\n () => (!isNil(data[0]?.orientation) ? data[0].orientation.toUpperCase() === \"H\" : false),\n [data]\n );\n\n const chartLayout = useMemo(\n () => applyLayoutDefaults(layout, theme, isHorizontal, xAxisTitle, yAxisTitle),\n [isHorizontal, layout, theme, xAxisTitle, yAxisTitle]\n );\n\n const chartConfig = useMemo(() => applyConfigDefaults(config), [config]);\n\n const useSingle = tooltipType === \"single\";\n\n /* State */\n\n const [isHover, setIsHover] = useState(false);\n const [coordinates, setCoordinates] = useState({ x: 0, y: 0 });\n const [dataTooltip, setDataTooltip] = useState();\n\n /* Callbacks */\n\n // Extract data from the plotly onHover event to be used to create the tooltip.\n const onHover = useCallback(\n (event) => {\n const { points } = event;\n\n const dataFromPoints = {\n title: \"\",\n elements: [],\n };\n\n points.forEach((p, i) => {\n const fData = p.fullData;\n const pNumber = p.pointNumber;\n\n if (i === 0) dataFromPoints.title = isHorizontal ? p.y : p.x || fData.name;\n\n dataFromPoints.elements.push({\n color: fData.marker?.color || fData.line?.color || p.color,\n name: fData.labels?.[pNumber] || fData.name,\n value: isHorizontal ? p.x : p.y || p.value,\n });\n });\n\n setDataTooltip(dataFromPoints);\n setIsHover(true);\n },\n [isHorizontal]\n );\n\n const onUnHover = useCallback(() => {\n setIsHover(false);\n }, []);\n\n const onMouseMove = useCallback((event) => {\n setCoordinates({\n x: event.clientX,\n y: event.clientY,\n });\n }, []);\n\n return (\n <>\n {isHover && <Tooltip
|
|
1
|
+
{"version":3,"file":"Chart.js","names":["React","useState","useMemo","useCallback","PropTypes","isNil","useTheme","withStyles","Tooltip","applyLayoutDefaults","applyConfigDefaults","Plot","styles","Chart","id","classes","data","layout","config","tooltipType","tooltip","afterPlot","xAxisTitle","yAxisTitle","others","theme","isHorizontal","orientation","toUpperCase","chartLayout","chartConfig","useSingle","isHover","setIsHover","x","y","coordinates","setCoordinates","dataTooltip","setDataTooltip","onHover","event","points","dataFromPoints","title","elements","forEach","p","i","fData","fullData","pNumber","pointNumber","name","push","color","marker","line","labels","value","onUnHover","onMouseMove","clientX","clientY","root","propTypes","string","shape","arrayOf","instanceOf","Object","isRequired","oneOf","func","subtitle"],"sources":["../../../src/Chart/Chart.js"],"sourcesContent":["import React, { useState, useMemo, useCallback } from \"react\";\nimport PropTypes from \"prop-types\";\nimport isNil from \"lodash/isNil\";\nimport { useTheme, withStyles } from \"@material-ui/core\";\nimport Tooltip from \"./Tooltip\";\nimport { applyLayoutDefaults, applyConfigDefaults } from \"./chartPlotlyOverrides\";\n\nimport Plot from \"./Plot\";\nimport styles from \"./styles\";\n\nconst Chart = ({\n id,\n classes,\n data,\n layout,\n config,\n tooltipType = \"multiple\",\n tooltip,\n afterPlot,\n xAxisTitle,\n yAxisTitle,\n ...others\n}) => {\n const theme = useTheme();\n\n /* Values derived from props */\n\n // Check if the barchart is horizontal or vertical.\n const isHorizontal = useMemo(\n () => (!isNil(data[0]?.orientation) ? data[0].orientation.toUpperCase() === \"H\" : false),\n [data]\n );\n\n const chartLayout = useMemo(\n () => applyLayoutDefaults(layout, theme, isHorizontal, xAxisTitle, yAxisTitle),\n [isHorizontal, layout, theme, xAxisTitle, yAxisTitle]\n );\n\n const chartConfig = useMemo(() => applyConfigDefaults(config), [config]);\n\n const useSingle = tooltipType === \"single\";\n\n /* State */\n\n const [isHover, setIsHover] = useState(false);\n const [coordinates, setCoordinates] = useState({ x: 0, y: 0 });\n const [dataTooltip, setDataTooltip] = useState();\n\n /* Callbacks */\n\n // Extract data from the plotly onHover event to be used to create the tooltip.\n const onHover = useCallback(\n (event) => {\n const { points } = event;\n\n const dataFromPoints = {\n title: \"\",\n elements: [],\n };\n\n points.forEach((p, i) => {\n const fData = p.fullData;\n const pNumber = p.pointNumber;\n\n if (i === 0) dataFromPoints.title = isHorizontal ? p.y : p.x || fData.name;\n\n dataFromPoints.elements.push({\n color: fData.marker?.color || fData.line?.color || p.color,\n name: fData.labels?.[pNumber] || fData.name,\n value: isHorizontal ? p.x : p.y || p.value,\n });\n });\n\n setDataTooltip(dataFromPoints);\n setIsHover(true);\n },\n [isHorizontal]\n );\n\n const onUnHover = useCallback(() => {\n setIsHover(false);\n }, []);\n\n const onMouseMove = useCallback((event) => {\n setCoordinates({\n x: event.clientX,\n y: event.clientY,\n });\n }, []);\n\n return (\n <>\n {isHover && (\n <Tooltip\n coordinates={coordinates}\n data={dataTooltip}\n useSingle={useSingle}\n tooltip={tooltip}\n />\n )}\n <div id={id} className={classes.root}>\n <div onMouseMove={onMouseMove}>\n <Plot\n data={data}\n layout={chartLayout}\n config={chartConfig}\n onHover={onHover}\n onUnHover={onUnHover}\n afterPlot={afterPlot}\n {...others}\n />\n </div>\n </div>\n </>\n );\n};\n\nChart.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 /**\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).isRequired,\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\nexport default withStyles(styles, { name: \"HvChart\" })(Chart);\n"],"mappings":";;;;;;;AAAA,OAAOA,KAAP,IAAgBC,QAAhB,EAA0BC,OAA1B,EAAmCC,WAAnC,QAAsD,OAAtD;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,KAAP,MAAkB,cAAlB;AACA,SAASC,QAAT,EAAmBC,UAAnB,QAAqC,mBAArC;AACA,OAAOC,OAAP,MAAoB,WAApB;AACA,SAASC,mBAAT,EAA8BC,mBAA9B,QAAyD,wBAAzD;AAEA,OAAOC,IAAP,MAAiB,QAAjB;AACA,OAAOC,MAAP,MAAmB,UAAnB;;AAEA,IAAMC,KAAK,GAAG,SAARA,KAAQ,OAYR;EAAA,IAXJC,EAWI,QAXJA,EAWI;EAAA,IAVJC,OAUI,QAVJA,OAUI;EAAA,IATJC,IASI,QATJA,IASI;EAAA,IARJC,MAQI,QARJA,MAQI;EAAA,IAPJ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X,CAAhB,CA3BG;;EA4BhB;AACF;AACA;EACEpD,OAAO,EAAEhB,SAAS,CAACqE,IA/BH;;EAgChB;AACF;AACA;EACEpD,SAAS,EAAEjB,SAAS,CAACqE,IAnCL;;EAoChB;AACF;AACA;EACEnD,UAAU,EAAElB,SAAS,CAAC8D,MAvCN;;EAwChB;AACF;AACA;EACE3C,UAAU,EAAEnB,SAAS,CAAC8D,MA3CN;;EA4ChB;AACF;AACA;EACEQ,QAAQ,EAAEtE,SAAS,CAAC8D;AA/CJ,CAAlB;AAkDA,eAAe3D,UAAU,CAACK,MAAD,EAAS;EAAEyC,IAAI,EAAE;AAAR,CAAT,CAAV,CAAwCxC,KAAxC,CAAf"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
-
import React, { useEffect, useRef, useState } from "react";
|
|
2
|
+
import React, { useEffect, useRef, useState, useCallback } from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
4
|
import { withStyles } from "@material-ui/core";
|
|
5
5
|
import SingleTooltip from "./SingleTooltip";
|
|
@@ -12,10 +12,13 @@ var offset = 20;
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
var MainToolTip = function MainToolTip(_ref) {
|
|
15
|
+
var _MultipleTooltip;
|
|
16
|
+
|
|
15
17
|
var classes = _ref.classes,
|
|
16
18
|
coordinates = _ref.coordinates,
|
|
17
19
|
data = _ref.data,
|
|
18
|
-
useSingle = _ref.useSingle
|
|
20
|
+
useSingle = _ref.useSingle,
|
|
21
|
+
tooltip = _ref.tooltip;
|
|
19
22
|
var x = coordinates.x,
|
|
20
23
|
y = coordinates.y;
|
|
21
24
|
|
|
@@ -46,16 +49,21 @@ var MainToolTip = function MainToolTip(_ref) {
|
|
|
46
49
|
top: y - height - offset
|
|
47
50
|
});
|
|
48
51
|
}, [x, y]);
|
|
52
|
+
var renderTooltip = useCallback(function (CustomTooltip) {
|
|
53
|
+
if (CustomTooltip) return CustomTooltip(data);
|
|
54
|
+
if (useSingle) return /*#__PURE__*/React.createElement(SingleTooltip, {
|
|
55
|
+
title: data.title,
|
|
56
|
+
value: data.elements[0].value
|
|
57
|
+
});
|
|
58
|
+
return _MultipleTooltip || (_MultipleTooltip = /*#__PURE__*/React.createElement(MultipleTooltip, {
|
|
59
|
+
data: data
|
|
60
|
+
}));
|
|
61
|
+
}, [data, useSingle]);
|
|
49
62
|
return /*#__PURE__*/React.createElement("div", {
|
|
50
63
|
ref: ref,
|
|
51
64
|
className: classes.root,
|
|
52
65
|
style: style
|
|
53
|
-
},
|
|
54
|
-
title: data.title,
|
|
55
|
-
value: data.elements[0].value
|
|
56
|
-
}) || /*#__PURE__*/React.createElement(MultipleTooltip, {
|
|
57
|
-
data: data
|
|
58
|
-
}));
|
|
66
|
+
}, renderTooltip(tooltip));
|
|
59
67
|
};
|
|
60
68
|
|
|
61
69
|
process.env.NODE_ENV !== "production" ? MainToolTip.propTypes = {
|
|
@@ -117,7 +125,12 @@ process.env.NODE_ENV !== "production" ? MainToolTip.propTypes = {
|
|
|
117
125
|
/**
|
|
118
126
|
* Defines if should use a single or multiline tooltip.
|
|
119
127
|
*/
|
|
120
|
-
useSingle: PropTypes.bool
|
|
128
|
+
useSingle: PropTypes.bool,
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Custom tooltip element to be displayed
|
|
132
|
+
*/
|
|
133
|
+
tooltip: PropTypes.func
|
|
121
134
|
} : void 0;
|
|
122
135
|
MainToolTip.defaultProps = {
|
|
123
136
|
useSingle: false
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.js","names":["React","useEffect","useRef","useState","PropTypes","withStyles","SingleTooltip","MultipleTooltip","styles","offset","MainToolTip","classes","coordinates","data","useSingle","x","y","left","top","visibility","style","setStyle","ref","current","getBoundingClientRect","width","height","
|
|
1
|
+
{"version":3,"file":"Tooltip.js","names":["React","useEffect","useRef","useState","useCallback","PropTypes","withStyles","SingleTooltip","MultipleTooltip","styles","offset","MainToolTip","classes","coordinates","data","useSingle","tooltip","x","y","left","top","visibility","style","setStyle","ref","current","getBoundingClientRect","width","height","renderTooltip","CustomTooltip","title","elements","value","root","propTypes","shape","string","isRequired","arrayOf","color","name","number","bool","func","defaultProps"],"sources":["../../../../src/Chart/Tooltip/Tooltip.js"],"sourcesContent":["import React, { useEffect, useRef, useState, useCallback } from \"react\";\nimport PropTypes from \"prop-types\";\nimport { withStyles } from \"@material-ui/core\";\nimport SingleTooltip from \"./SingleTooltip\";\nimport MultipleTooltip from \"./MultiTooltip\";\nimport styles from \"./styles\";\n\nconst offset = 20;\n\n/**\n * Component responsible for deciding which tooltip should be use and to calculate\n * the exact position where it should be render.\n */\nconst MainToolTip = ({ classes, coordinates, data, useSingle, tooltip }) => {\n const { x, y } = coordinates;\n const [style, setStyle] = useState({ left: x, top: y, visibility: \"hidden\" });\n const ref = useRef(null);\n\n /**\n * Calculate the position where the tooltip has to render, having in account\n * the dimensions.\n */\n useEffect(() => {\n if (!ref.current || !ref.current.getBoundingClientRect().width) return;\n\n const { width, height } = ref.current.getBoundingClientRect();\n\n setStyle({ left: x - width / 2, top: y - height - offset });\n }, [x, y]);\n\n const renderTooltip = useCallback(\n (CustomTooltip) => {\n if (CustomTooltip) return CustomTooltip(data);\n if (useSingle) return <SingleTooltip title={data.title} value={data.elements[0].value} />;\n return <MultipleTooltip data={data} />;\n },\n [data, useSingle]\n );\n\n return (\n <div ref={ref} className={classes.root} style={style}>\n {renderTooltip(tooltip)}\n </div>\n );\n};\n\nMainToolTip.propTypes = {\n /**\n * A Jss Object used to override or extend the styles applied.\n */\n classes: PropTypes.shape({\n /**\n * Styles applied to the barchart root class.\n */\n root: PropTypes.string,\n }).isRequired,\n /**\n * Data of the tooltip.\n */\n data: PropTypes.shape({\n /**\n * Title.\n */\n title: PropTypes.string,\n /**\n * Values of the tooltip.\n */\n elements: PropTypes.arrayOf(\n PropTypes.shape({\n /**\n * Color of the bar.\n */\n color: PropTypes.string,\n /**\n * Name.\n */\n name: PropTypes.string,\n /**\n * Value.\n */\n value: PropTypes.number,\n })\n ),\n }).isRequired,\n /**\n * Coordinates.\n */\n coordinates: PropTypes.shape({\n /**\n * xx's coordinate.\n */\n x: PropTypes.number.isRequired,\n /**\n * yy's coordinate.\n */\n y: PropTypes.number.isRequired,\n }).isRequired,\n /**\n * Defines if should use a single or multiline tooltip.\n */\n useSingle: PropTypes.bool,\n /**\n * Custom tooltip element to be displayed\n */\n tooltip: PropTypes.func,\n};\n\nMainToolTip.defaultProps = {\n useSingle: false,\n};\n\nexport default withStyles(styles, { name: \"HvChartTooltip\" })(MainToolTip);\n"],"mappings":";AAAA,OAAOA,KAAP,IAAgBC,SAAhB,EAA2BC,MAA3B,EAAmCC,QAAnC,EAA6CC,WAA7C,QAAgE,OAAhE;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,SAASC,UAAT,QAA2B,mBAA3B;AACA,OAAOC,aAAP,MAA0B,iBAA1B;AACA,OAAOC,eAAP,MAA4B,gBAA5B;AACA,OAAOC,MAAP,MAAmB,UAAnB;AAEA,IAAMC,MAAM,GAAG,EAAf;AAEA;AACA;AACA;AACA;;AACA,IAAMC,WAAW,GAAG,SAAdA,WAAc,OAAwD;EAAA;;EAAA,IAArDC,OAAqD,QAArDA,OAAqD;EAAA,IAA5CC,WAA4C,QAA5CA,WAA4C;EAAA,IAA/BC,IAA+B,QAA/BA,IAA+B;EAAA,IAAzBC,SAAyB,QAAzBA,SAAyB;EAAA,IAAdC,OAAc,QAAdA,OAAc;EAC1E,IAAQC,CAAR,GAAiBJ,WAAjB,CAAQI,CAAR;EAAA,IAAWC,CAAX,GAAiBL,WAAjB,CAAWK,CAAX;;EACA,gBAA0Bf,QAAQ,CAAC;IAAEgB,IAAI,EAAEF,CAAR;IAAWG,GAAG,EAAEF,CAAhB;IAAmBG,UAAU,EAAE;EAA/B,CAAD,CAAlC;EAAA;EAAA,IAAOC,KAAP;EAAA,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I,EAAE7B,SAAS,CAACgC;EAJO,CAAhB,EAKNC,UATmB;;EAUtB;AACF;AACA;EACExB,IAAI,EAAET,SAAS,CAAC+B,KAAV,CAAgB;IACpB;AACJ;AACA;IACIL,KAAK,EAAE1B,SAAS,CAACgC,MAJG;;IAKpB;AACJ;AACA;IACIL,QAAQ,EAAE3B,SAAS,CAACkC,OAAV,CACRlC,SAAS,CAAC+B,KAAV,CAAgB;MACd;AACR;AACA;MACQI,KAAK,EAAEnC,SAAS,CAACgC,MAJH;;MAKd;AACR;AACA;MACQI,IAAI,EAAEpC,SAAS,CAACgC,MARF;;MASd;AACR;AACA;MACQJ,KAAK,EAAE5B,SAAS,CAACqC;IAZH,CAAhB,CADQ;EARU,CAAhB,EAwBHJ,UArCmB;;EAsCtB;AACF;AACA;EACEzB,WAAW,EAAER,SAAS,CAAC+B,KAAV,CAAgB;IAC3B;AACJ;AACA;IACInB,CAAC,EAAEZ,SAAS,CAACqC,MAAV,CAAiBJ,UAJO;;IAK3B;AACJ;AACA;IACIpB,CAAC,EAAEb,SAAS,CAACqC,MAAV,CAAiBJ;EARO,CAAhB,EASVA,UAlDmB;;EAmDtB;AACF;AACA;EACEvB,SAAS,EAAEV,SAAS,CAACsC,IAtDC;;EAuDtB;AACF;AACA;EACE3B,OAAO,EAAEX,SAAS,CAACuC;AA1DG,CAAxB;AA6DAjC,WAAW,CAACkC,YAAZ,GAA2B;EACzB9B,SAAS,EAAE;AADc,CAA3B;AAIA,eAAeT,UAAU,CAACG,MAAD,EAAS;EAAEgC,IAAI,EAAE;AAAR,CAAT,CAAV,CAA+C9B,WAA/C,CAAf"}
|
|
@@ -4,10 +4,18 @@ import { HvPlotProps } from "./Plot";
|
|
|
4
4
|
export type HvChartClassKey = "root";
|
|
5
5
|
|
|
6
6
|
export interface HvChartProps extends StandardProps<HvPlotProps, HvChartClassKey> {
|
|
7
|
+
/**
|
|
8
|
+
* An Id passed on to the component
|
|
9
|
+
*/
|
|
10
|
+
id?: string;
|
|
7
11
|
/**
|
|
8
12
|
* Defines if should use a single or multiline tooltip.
|
|
9
13
|
*/
|
|
10
14
|
tooltipType?: "single" | "multiple";
|
|
15
|
+
/**
|
|
16
|
+
* Custom tooltip element to be displayed
|
|
17
|
+
*/
|
|
18
|
+
tooltip?: React.ReactNode;
|
|
11
19
|
/**
|
|
12
20
|
* Defines the X axis title.
|
|
13
21
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
-
const _excluded = ["id", "classes", "data", "layout", "config", "tooltipType", "afterPlot", "xAxisTitle", "yAxisTitle"];
|
|
3
|
+
const _excluded = ["id", "classes", "data", "layout", "config", "tooltipType", "tooltip", "afterPlot", "xAxisTitle", "yAxisTitle"];
|
|
4
4
|
import "core-js/modules/web.dom-collections.iterator.js";
|
|
5
5
|
import React, { useState, useMemo, useCallback } from "react";
|
|
6
6
|
import PropTypes from "prop-types";
|
|
@@ -19,6 +19,7 @@ const Chart = _ref => {
|
|
|
19
19
|
layout,
|
|
20
20
|
config,
|
|
21
21
|
tooltipType = "multiple",
|
|
22
|
+
tooltip,
|
|
22
23
|
afterPlot,
|
|
23
24
|
xAxisTitle,
|
|
24
25
|
yAxisTitle
|
|
@@ -83,7 +84,8 @@ const Chart = _ref => {
|
|
|
83
84
|
return /*#__PURE__*/React.createElement(React.Fragment, null, isHover && /*#__PURE__*/React.createElement(Tooltip, {
|
|
84
85
|
coordinates: coordinates,
|
|
85
86
|
data: dataTooltip,
|
|
86
|
-
useSingle: useSingle
|
|
87
|
+
useSingle: useSingle,
|
|
88
|
+
tooltip: tooltip
|
|
87
89
|
}), /*#__PURE__*/React.createElement("div", {
|
|
88
90
|
id: id,
|
|
89
91
|
className: classes.root
|
|
@@ -132,6 +134,11 @@ process.env.NODE_ENV !== "production" ? Chart.propTypes = {
|
|
|
132
134
|
*/
|
|
133
135
|
tooltipType: PropTypes.oneOf(["single", "multiple"]),
|
|
134
136
|
|
|
137
|
+
/**
|
|
138
|
+
* Custom tooltip element to be displayed
|
|
139
|
+
*/
|
|
140
|
+
tooltip: PropTypes.func,
|
|
141
|
+
|
|
135
142
|
/**
|
|
136
143
|
* Function to be called after plot render.
|
|
137
144
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chart.js","names":["React","useState","useMemo","useCallback","PropTypes","isNil","useTheme","withStyles","Tooltip","applyLayoutDefaults","applyConfigDefaults","Plot","styles","Chart","id","classes","data","layout","config","tooltipType","afterPlot","xAxisTitle","yAxisTitle","others","theme","isHorizontal","orientation","toUpperCase","chartLayout","chartConfig","useSingle","isHover","setIsHover","coordinates","setCoordinates","x","y","dataTooltip","setDataTooltip","onHover","event","points","dataFromPoints","title","elements","forEach","p","i","fData","fullData","pNumber","pointNumber","name","push","color","marker","line","labels","value","onUnHover","onMouseMove","clientX","clientY","root","propTypes","string","shape","arrayOf","instanceOf","Object","isRequired","oneOf","func","subtitle"],"sources":["../../../src/Chart/Chart.js"],"sourcesContent":["import React, { useState, useMemo, useCallback } from \"react\";\nimport PropTypes from \"prop-types\";\nimport isNil from \"lodash/isNil\";\nimport { useTheme, withStyles } from \"@material-ui/core\";\nimport Tooltip from \"./Tooltip\";\nimport { applyLayoutDefaults, applyConfigDefaults } from \"./chartPlotlyOverrides\";\n\nimport Plot from \"./Plot\";\nimport styles from \"./styles\";\n\nconst Chart = ({\n id,\n classes,\n data,\n layout,\n config,\n tooltipType = \"multiple\",\n afterPlot,\n xAxisTitle,\n yAxisTitle,\n ...others\n}) => {\n const theme = useTheme();\n\n /* Values derived from props */\n\n // Check if the barchart is horizontal or vertical.\n const isHorizontal = useMemo(\n () => (!isNil(data[0]?.orientation) ? data[0].orientation.toUpperCase() === \"H\" : false),\n [data]\n );\n\n const chartLayout = useMemo(\n () => applyLayoutDefaults(layout, theme, isHorizontal, xAxisTitle, yAxisTitle),\n [isHorizontal, layout, theme, xAxisTitle, yAxisTitle]\n );\n\n const chartConfig = useMemo(() => applyConfigDefaults(config), [config]);\n\n const useSingle = tooltipType === \"single\";\n\n /* State */\n\n const [isHover, setIsHover] = useState(false);\n const [coordinates, setCoordinates] = useState({ x: 0, y: 0 });\n const [dataTooltip, setDataTooltip] = useState();\n\n /* Callbacks */\n\n // Extract data from the plotly onHover event to be used to create the tooltip.\n const onHover = useCallback(\n (event) => {\n const { points } = event;\n\n const dataFromPoints = {\n title: \"\",\n elements: [],\n };\n\n points.forEach((p, i) => {\n const fData = p.fullData;\n const pNumber = p.pointNumber;\n\n if (i === 0) dataFromPoints.title = isHorizontal ? p.y : p.x || fData.name;\n\n dataFromPoints.elements.push({\n color: fData.marker?.color || fData.line?.color || p.color,\n name: fData.labels?.[pNumber] || fData.name,\n value: isHorizontal ? p.x : p.y || p.value,\n });\n });\n\n setDataTooltip(dataFromPoints);\n setIsHover(true);\n },\n [isHorizontal]\n );\n\n const onUnHover = useCallback(() => {\n setIsHover(false);\n }, []);\n\n const onMouseMove = useCallback((event) => {\n setCoordinates({\n x: event.clientX,\n y: event.clientY,\n });\n }, []);\n\n return (\n <>\n {isHover && <Tooltip
|
|
1
|
+
{"version":3,"file":"Chart.js","names":["React","useState","useMemo","useCallback","PropTypes","isNil","useTheme","withStyles","Tooltip","applyLayoutDefaults","applyConfigDefaults","Plot","styles","Chart","id","classes","data","layout","config","tooltipType","tooltip","afterPlot","xAxisTitle","yAxisTitle","others","theme","isHorizontal","orientation","toUpperCase","chartLayout","chartConfig","useSingle","isHover","setIsHover","coordinates","setCoordinates","x","y","dataTooltip","setDataTooltip","onHover","event","points","dataFromPoints","title","elements","forEach","p","i","fData","fullData","pNumber","pointNumber","name","push","color","marker","line","labels","value","onUnHover","onMouseMove","clientX","clientY","root","propTypes","string","shape","arrayOf","instanceOf","Object","isRequired","oneOf","func","subtitle"],"sources":["../../../src/Chart/Chart.js"],"sourcesContent":["import React, { useState, useMemo, useCallback } from \"react\";\nimport PropTypes from \"prop-types\";\nimport isNil from \"lodash/isNil\";\nimport { useTheme, withStyles } from \"@material-ui/core\";\nimport Tooltip from \"./Tooltip\";\nimport { applyLayoutDefaults, applyConfigDefaults } from \"./chartPlotlyOverrides\";\n\nimport Plot from \"./Plot\";\nimport styles from \"./styles\";\n\nconst Chart = ({\n id,\n classes,\n data,\n layout,\n config,\n tooltipType = \"multiple\",\n tooltip,\n afterPlot,\n xAxisTitle,\n yAxisTitle,\n ...others\n}) => {\n const theme = useTheme();\n\n /* Values derived from props */\n\n // Check if the barchart is horizontal or vertical.\n const isHorizontal = useMemo(\n () => (!isNil(data[0]?.orientation) ? data[0].orientation.toUpperCase() === \"H\" : false),\n [data]\n );\n\n const chartLayout = useMemo(\n () => applyLayoutDefaults(layout, theme, isHorizontal, xAxisTitle, yAxisTitle),\n [isHorizontal, layout, theme, xAxisTitle, yAxisTitle]\n );\n\n const chartConfig = useMemo(() => applyConfigDefaults(config), [config]);\n\n const useSingle = tooltipType === \"single\";\n\n /* State */\n\n const [isHover, setIsHover] = useState(false);\n const [coordinates, setCoordinates] = useState({ x: 0, y: 0 });\n const [dataTooltip, setDataTooltip] = useState();\n\n /* Callbacks */\n\n // Extract data from the plotly onHover event to be used to create the tooltip.\n const onHover = useCallback(\n (event) => {\n const { points } = event;\n\n const dataFromPoints = {\n title: \"\",\n elements: [],\n };\n\n points.forEach((p, i) => {\n const fData = p.fullData;\n const pNumber = p.pointNumber;\n\n if (i === 0) dataFromPoints.title = isHorizontal ? p.y : p.x || fData.name;\n\n dataFromPoints.elements.push({\n color: fData.marker?.color || fData.line?.color || p.color,\n name: fData.labels?.[pNumber] || fData.name,\n value: isHorizontal ? p.x : p.y || p.value,\n });\n });\n\n setDataTooltip(dataFromPoints);\n setIsHover(true);\n },\n [isHorizontal]\n );\n\n const onUnHover = useCallback(() => {\n setIsHover(false);\n }, []);\n\n const onMouseMove = useCallback((event) => {\n setCoordinates({\n x: event.clientX,\n y: event.clientY,\n });\n }, []);\n\n return (\n <>\n {isHover && (\n <Tooltip\n coordinates={coordinates}\n data={dataTooltip}\n useSingle={useSingle}\n tooltip={tooltip}\n />\n )}\n <div id={id} className={classes.root}>\n <div onMouseMove={onMouseMove}>\n <Plot\n data={data}\n layout={chartLayout}\n config={chartConfig}\n onHover={onHover}\n onUnHover={onUnHover}\n afterPlot={afterPlot}\n {...others}\n />\n </div>\n </div>\n </>\n );\n};\n\nChart.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 /**\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).isRequired,\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\nexport default withStyles(styles, { name: \"HvChart\" })(Chart);\n"],"mappings":";;;;AAAA,OAAOA,KAAP,IAAgBC,QAAhB,EAA0BC,OAA1B,EAAmCC,WAAnC,QAAsD,OAAtD;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,KAAP,MAAkB,cAAlB;AACA,SAASC,QAAT,EAAmBC,UAAnB,QAAqC,mBAArC;AACA,OAAOC,OAAP,MAAoB,WAApB;AACA,SAASC,mBAAT,EAA8BC,mBAA9B,Q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OAAO,EAAEhB,SAAS,CAACqE,IA/BH;;EAgChB;AACF;AACA;EACEpD,SAAS,EAAEjB,SAAS,CAACqE,IAnCL;;EAoChB;AACF;AACA;EACEnD,UAAU,EAAElB,SAAS,CAAC8D,MAvCN;;EAwChB;AACF;AACA;EACE3C,UAAU,EAAEnB,SAAS,CAAC8D,MA3CN;;EA4ChB;AACF;AACA;EACEQ,QAAQ,EAAEtE,SAAS,CAAC8D;AA/CJ,CAAlB;AAkDA,eAAe3D,UAAU,CAACK,MAAD,EAAS;EAAEyC,IAAI,EAAE;AAAR,CAAT,CAAV,CAAwCxC,KAAxC,CAAf"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "core-js/modules/web.dom-collections.iterator.js";
|
|
2
|
-
import React, { useEffect, useRef, useState } from "react";
|
|
2
|
+
import React, { useEffect, useRef, useState, useCallback } from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
4
|
import { withStyles } from "@material-ui/core";
|
|
5
5
|
import SingleTooltip from "./SingleTooltip";
|
|
@@ -15,8 +15,11 @@ const MainToolTip = ({
|
|
|
15
15
|
classes,
|
|
16
16
|
coordinates,
|
|
17
17
|
data,
|
|
18
|
-
useSingle
|
|
18
|
+
useSingle,
|
|
19
|
+
tooltip
|
|
19
20
|
}) => {
|
|
21
|
+
var _MultipleTooltip;
|
|
22
|
+
|
|
20
23
|
const {
|
|
21
24
|
x,
|
|
22
25
|
y
|
|
@@ -43,16 +46,21 @@ const MainToolTip = ({
|
|
|
43
46
|
top: y - height - offset
|
|
44
47
|
});
|
|
45
48
|
}, [x, y]);
|
|
49
|
+
const renderTooltip = useCallback(CustomTooltip => {
|
|
50
|
+
if (CustomTooltip) return CustomTooltip(data);
|
|
51
|
+
if (useSingle) return /*#__PURE__*/React.createElement(SingleTooltip, {
|
|
52
|
+
title: data.title,
|
|
53
|
+
value: data.elements[0].value
|
|
54
|
+
});
|
|
55
|
+
return _MultipleTooltip || (_MultipleTooltip = /*#__PURE__*/React.createElement(MultipleTooltip, {
|
|
56
|
+
data: data
|
|
57
|
+
}));
|
|
58
|
+
}, [data, useSingle]);
|
|
46
59
|
return /*#__PURE__*/React.createElement("div", {
|
|
47
60
|
ref: ref,
|
|
48
61
|
className: classes.root,
|
|
49
62
|
style: style
|
|
50
|
-
},
|
|
51
|
-
title: data.title,
|
|
52
|
-
value: data.elements[0].value
|
|
53
|
-
}) || /*#__PURE__*/React.createElement(MultipleTooltip, {
|
|
54
|
-
data: data
|
|
55
|
-
}));
|
|
63
|
+
}, renderTooltip(tooltip));
|
|
56
64
|
};
|
|
57
65
|
|
|
58
66
|
process.env.NODE_ENV !== "production" ? MainToolTip.propTypes = {
|
|
@@ -114,7 +122,12 @@ process.env.NODE_ENV !== "production" ? MainToolTip.propTypes = {
|
|
|
114
122
|
/**
|
|
115
123
|
* Defines if should use a single or multiline tooltip.
|
|
116
124
|
*/
|
|
117
|
-
useSingle: PropTypes.bool
|
|
125
|
+
useSingle: PropTypes.bool,
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Custom tooltip element to be displayed
|
|
129
|
+
*/
|
|
130
|
+
tooltip: PropTypes.func
|
|
118
131
|
} : void 0;
|
|
119
132
|
MainToolTip.defaultProps = {
|
|
120
133
|
useSingle: false
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.js","names":["React","useEffect","useRef","useState","PropTypes","withStyles","SingleTooltip","MultipleTooltip","styles","offset","MainToolTip","classes","coordinates","data","useSingle","x","y","style","setStyle","left","top","visibility","ref","current","getBoundingClientRect","width","height","
|
|
1
|
+
{"version":3,"file":"Tooltip.js","names":["React","useEffect","useRef","useState","useCallback","PropTypes","withStyles","SingleTooltip","MultipleTooltip","styles","offset","MainToolTip","classes","coordinates","data","useSingle","tooltip","x","y","style","setStyle","left","top","visibility","ref","current","getBoundingClientRect","width","height","renderTooltip","CustomTooltip","title","elements","value","root","propTypes","shape","string","isRequired","arrayOf","color","name","number","bool","func","defaultProps"],"sources":["../../../../src/Chart/Tooltip/Tooltip.js"],"sourcesContent":["import React, { useEffect, useRef, useState, useCallback } from \"react\";\nimport PropTypes from \"prop-types\";\nimport { withStyles } from \"@material-ui/core\";\nimport SingleTooltip from \"./SingleTooltip\";\nimport MultipleTooltip from \"./MultiTooltip\";\nimport styles from \"./styles\";\n\nconst offset = 20;\n\n/**\n * Component responsible for deciding which tooltip should be use and to calculate\n * the exact position where it should be render.\n */\nconst MainToolTip = ({ classes, coordinates, data, useSingle, tooltip }) => {\n const { x, y } = coordinates;\n const [style, setStyle] = useState({ left: x, top: y, visibility: \"hidden\" });\n const ref = useRef(null);\n\n /**\n * Calculate the position where the tooltip has to render, having in account\n * the dimensions.\n */\n useEffect(() => {\n if (!ref.current || !ref.current.getBoundingClientRect().width) return;\n\n const { width, height } = ref.current.getBoundingClientRect();\n\n setStyle({ left: x - width / 2, top: y - height - offset });\n }, [x, y]);\n\n const renderTooltip = useCallback(\n (CustomTooltip) => {\n if (CustomTooltip) return CustomTooltip(data);\n if (useSingle) return <SingleTooltip title={data.title} value={data.elements[0].value} />;\n return <MultipleTooltip data={data} />;\n },\n [data, useSingle]\n );\n\n return (\n <div ref={ref} className={classes.root} style={style}>\n {renderTooltip(tooltip)}\n </div>\n );\n};\n\nMainToolTip.propTypes = {\n /**\n * A Jss Object used to override or extend the styles applied.\n */\n classes: PropTypes.shape({\n /**\n * Styles applied to the barchart root class.\n */\n root: PropTypes.string,\n }).isRequired,\n /**\n * Data of the tooltip.\n */\n data: PropTypes.shape({\n /**\n * Title.\n */\n title: PropTypes.string,\n /**\n * Values of the tooltip.\n */\n elements: PropTypes.arrayOf(\n PropTypes.shape({\n /**\n * Color of the bar.\n */\n color: PropTypes.string,\n /**\n * Name.\n */\n name: PropTypes.string,\n /**\n * Value.\n */\n value: PropTypes.number,\n })\n ),\n }).isRequired,\n /**\n * Coordinates.\n */\n coordinates: PropTypes.shape({\n /**\n * xx's coordinate.\n */\n x: PropTypes.number.isRequired,\n /**\n * yy's coordinate.\n */\n y: PropTypes.number.isRequired,\n }).isRequired,\n /**\n * Defines if should use a single or multiline tooltip.\n */\n useSingle: PropTypes.bool,\n /**\n * Custom tooltip element to be displayed\n */\n tooltip: PropTypes.func,\n};\n\nMainToolTip.defaultProps = {\n useSingle: false,\n};\n\nexport default withStyles(styles, { name: \"HvChartTooltip\" })(MainToolTip);\n"],"mappings":";AAAA,OAAOA,KAAP,IAAgBC,SAAhB,EAA2BC,MAA3B,EAAmCC,QAAnC,EAA6CC,WAA7C,QAAgE,OAAhE;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,SAASC,UAAT,QAA2B,mBAA3B;AACA,OAAOC,aAAP,MAA0B,iBAA1B;AACA,OAAOC,eAAP,MAA4B,gBAA5B;AACA,OAAOC,MAAP,MAAmB,UAAnB;AAEA,MAAMC,MAAM,GAAG,EAAf;AAEA;AACA;AACA;AACA;;AACA,MAAMC,WAAW,GAAG,CAAC;EAAEC,OAAF;EAAWC,WAAX;EAAwBC,IAAxB;EAA8BC,SAA9B;EAAyCC;AAAzC,CAAD,KAAwD;EAAA;;EAC1E,MAAM;IAAEC,CAAF;IAAKC;EAAL,IAAWL,WAAjB;EACA,MAAM,CAACM,KAAD,EAAQC,QAAR,IAAoBjB,QAAQ,CAAC;IAAEkB,IAAI,EAAEJ,CAAR;IAAWK,GAAG,EAAEJ,CAAhB;IAAmBK,UAAU,EAAE;EAA/B,CAAD,CAAlC;EACA,MAAMC,GAAG,GAAGtB,MAAM,CAAC,IAAD,CAAlB;EAEA;AACF;AACA;AACA;;EACED,SAAS,CAAC,MAAM;IACd,IAAI,CAACuB,GAAG,CAACC,OAAL,IAAgB,CAACD,GAAG,CAACC,OAAJ,CAAYC,qBAAZ,GAAoCC,KAAzD,EAAgE;IAEhE,MAAM;MAAEA,KAAF;MAASC;IAAT,IAAoBJ,GAAG,CAACC,OAAJ,CAAYC,qBAAZ,EAA1B;IAEAN,QAAQ,CAAC;MAAEC,IAAI,EAAEJ,CAAC,G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K,EAAE5B,SAAS,CAACqC;IAZH,CAAhB,CADQ;EARU,CAAhB,EAwBHJ,UArCmB;;EAsCtB;AACF;AACA;EACEzB,WAAW,EAAER,SAAS,CAAC+B,KAAV,CAAgB;IAC3B;AACJ;AACA;IACInB,CAAC,EAAEZ,SAAS,CAACqC,MAAV,CAAiBJ,UAJO;;IAK3B;AACJ;AACA;IACIpB,CAAC,EAAEb,SAAS,CAACqC,MAAV,CAAiBJ;EARO,CAAhB,EASVA,UAlDmB;;EAmDtB;AACF;AACA;EACEvB,SAAS,EAAEV,SAAS,CAACsC,IAtDC;;EAuDtB;AACF;AACA;EACE3B,OAAO,EAAEX,SAAS,CAACuC;AA1DG,CAAxB;AA6DAjC,WAAW,CAACkC,YAAZ,GAA2B;EACzB9B,SAAS,EAAE;AADc,CAA3B;AAIA,eAAeT,UAAU,CAACG,MAAD,EAAS;EAAEgC,IAAI,EAAE;AAAR,CAAT,CAAV,CAA+C9B,WAA/C,CAAf"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hitachivantara/uikit-react-viz",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "A collection of React visualizations for the Hitachi Vantara's Design System.",
|
|
5
5
|
"homepage": "https://github.com/lumada-design/hv-uikit-react",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"react-dom": "^16.13.1 || ^17.0.2"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@hitachivantara/uikit-react-core": "^3.
|
|
45
|
+
"@hitachivantara/uikit-react-core": "^3.75.0",
|
|
46
46
|
"clsx": "^1.2.1",
|
|
47
47
|
"lodash": "^4.17.21",
|
|
48
48
|
"prop-types": "^15.8.1",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"publishConfig": {
|
|
60
60
|
"access": "public"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "033592c2297f208195c8d817561b11b88c3748da"
|
|
63
63
|
}
|