@cloud-ru/uikit-product-charts 0.13.12 → 0.13.13
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/CHANGELOG.md +14 -1
- package/dist/cjs/components/BagelChart/BagelChart.d.ts +9 -0
- package/dist/cjs/components/BagelChart/BagelChart.js +31 -0
- package/dist/cjs/components/BagelChart/index.d.ts +1 -0
- package/dist/cjs/components/BagelChart/index.js +17 -0
- package/dist/cjs/components/BagelChart/styles.module.css +39 -0
- package/dist/cjs/components/BagelChart/utils.d.ts +4 -0
- package/dist/cjs/components/BagelChart/utils.js +15 -0
- package/dist/cjs/components/HeatMapChart/HeatMapChart.d.ts +7 -0
- package/dist/cjs/components/HeatMapChart/HeatMapChart.js +89 -0
- package/dist/cjs/components/HeatMapChart/constants.d.ts +4 -0
- package/dist/cjs/components/HeatMapChart/constants.js +8 -0
- package/dist/cjs/components/HeatMapChart/helpers/constants.d.ts +6 -0
- package/dist/cjs/components/HeatMapChart/helpers/constants.js +9 -0
- package/dist/cjs/components/HeatMapChart/helpers/getComputedColor.d.ts +1 -0
- package/dist/cjs/components/HeatMapChart/helpers/getComputedColor.js +7 -0
- package/dist/cjs/components/HeatMapChart/helpers/getContrastColor.d.ts +5 -0
- package/dist/cjs/components/HeatMapChart/helpers/getContrastColor.js +11 -0
- package/dist/cjs/components/HeatMapChart/helpers/getStyles.d.ts +3 -0
- package/dist/cjs/components/HeatMapChart/helpers/getStyles.js +33 -0
- package/dist/cjs/components/HeatMapChart/helpers/getTickValues.d.ts +2 -0
- package/dist/cjs/components/HeatMapChart/helpers/getTickValues.js +68 -0
- package/dist/cjs/components/HeatMapChart/helpers/index.d.ts +4 -0
- package/dist/cjs/components/HeatMapChart/helpers/index.js +20 -0
- package/dist/cjs/components/HeatMapChart/index.d.ts +2 -0
- package/dist/cjs/components/HeatMapChart/index.js +5 -0
- package/dist/cjs/components/HeatMapChart/styles.module.css +98 -0
- package/dist/cjs/components/HeatMapChart/types.d.ts +35 -0
- package/dist/cjs/components/HeatMapChart/types.js +2 -0
- package/dist/cjs/components/InteractiveChart/InteractiveChart.d.ts +12 -0
- package/dist/cjs/components/InteractiveChart/InteractiveChart.js +48 -0
- package/dist/cjs/components/InteractiveChart/configurations/boxPlot.d.ts +5 -0
- package/dist/cjs/components/InteractiveChart/configurations/boxPlot.js +75 -0
- package/dist/cjs/components/InteractiveChart/configurations/defaultPlot.d.ts +5 -0
- package/dist/cjs/components/InteractiveChart/configurations/defaultPlot.js +66 -0
- package/dist/cjs/components/InteractiveChart/configurations/index.d.ts +2 -0
- package/dist/cjs/components/InteractiveChart/configurations/index.js +18 -0
- package/dist/cjs/components/InteractiveChart/constants.d.ts +17 -0
- package/dist/cjs/components/InteractiveChart/constants.js +20 -0
- package/dist/cjs/components/InteractiveChart/helpers/pathRenderer.d.ts +3 -0
- package/dist/cjs/components/InteractiveChart/helpers/pathRenderer.js +45 -0
- package/dist/cjs/components/InteractiveChart/hooks/useComputedColors.d.ts +2 -0
- package/dist/cjs/components/InteractiveChart/hooks/useComputedColors.js +24 -0
- package/dist/cjs/components/InteractiveChart/hooks/useLayer.d.ts +12 -0
- package/dist/cjs/components/InteractiveChart/hooks/useLayer.js +22 -0
- package/dist/cjs/components/InteractiveChart/index.d.ts +2 -0
- package/dist/cjs/components/InteractiveChart/index.js +18 -0
- package/dist/cjs/components/InteractiveChart/plugins/boxPlotPlugin.d.ts +12 -0
- package/dist/cjs/components/InteractiveChart/plugins/boxPlotPlugin.js +90 -0
- package/dist/cjs/components/InteractiveChart/plugins/columnHighlightPlugin.d.ts +12 -0
- package/dist/cjs/components/InteractiveChart/plugins/columnHighlightPlugin.js +65 -0
- package/dist/cjs/components/InteractiveChart/plugins/legendAsTooltipPlugin.d.ts +11 -0
- package/dist/cjs/components/InteractiveChart/plugins/legendAsTooltipPlugin.js +58 -0
- package/dist/cjs/components/InteractiveChart/plugins/wheelZoomPlugin.d.ts +5 -0
- package/dist/cjs/components/InteractiveChart/plugins/wheelZoomPlugin.js +96 -0
- package/dist/cjs/components/InteractiveChart/styles.module.css +25 -0
- package/dist/cjs/components/InteractiveChart/types.d.ts +5 -0
- package/dist/cjs/components/InteractiveChart/types.js +2 -0
- package/dist/cjs/components/PieChart/Legend/Legend.d.ts +21 -0
- package/dist/cjs/components/PieChart/Legend/Legend.js +18 -0
- package/dist/cjs/components/PieChart/Legend/index.d.ts +1 -0
- package/dist/cjs/components/PieChart/Legend/index.js +17 -0
- package/dist/cjs/components/PieChart/Legend/styles.module.css +50 -0
- package/dist/cjs/components/PieChart/Pie.d.ts +17 -0
- package/dist/cjs/components/PieChart/Pie.js +24 -0
- package/dist/cjs/components/PieChart/PieChart.d.ts +3 -0
- package/dist/cjs/components/PieChart/PieChart.js +68 -0
- package/dist/cjs/components/PieChart/index.d.ts +2 -0
- package/dist/cjs/components/PieChart/index.js +17 -0
- package/dist/cjs/components/PieChart/styles.module.css +52 -0
- package/dist/cjs/components/PieChart/types.d.ts +36 -0
- package/dist/cjs/components/PieChart/types.js +2 -0
- package/dist/cjs/components/index.d.ts +4 -0
- package/dist/cjs/components/index.js +20 -0
- package/dist/cjs/constants/colors.d.ts +36 -0
- package/dist/cjs/constants/colors.js +59 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +17 -0
- package/dist/esm/components/BagelChart/BagelChart.d.ts +9 -0
- package/dist/esm/components/BagelChart/BagelChart.js +25 -0
- package/dist/esm/components/BagelChart/index.d.ts +1 -0
- package/dist/esm/components/BagelChart/index.js +1 -0
- package/dist/esm/components/BagelChart/styles.module.css +39 -0
- package/dist/esm/components/BagelChart/utils.d.ts +4 -0
- package/dist/esm/components/BagelChart/utils.js +12 -0
- package/dist/esm/components/HeatMapChart/HeatMapChart.d.ts +7 -0
- package/dist/esm/components/HeatMapChart/HeatMapChart.js +83 -0
- package/dist/esm/components/HeatMapChart/constants.d.ts +4 -0
- package/dist/esm/components/HeatMapChart/constants.js +5 -0
- package/dist/esm/components/HeatMapChart/helpers/constants.d.ts +6 -0
- package/dist/esm/components/HeatMapChart/helpers/constants.js +6 -0
- package/dist/esm/components/HeatMapChart/helpers/getComputedColor.d.ts +1 -0
- package/dist/esm/components/HeatMapChart/helpers/getComputedColor.js +4 -0
- package/dist/esm/components/HeatMapChart/helpers/getContrastColor.d.ts +5 -0
- package/dist/esm/components/HeatMapChart/helpers/getContrastColor.js +7 -0
- package/dist/esm/components/HeatMapChart/helpers/getStyles.d.ts +3 -0
- package/dist/esm/components/HeatMapChart/helpers/getStyles.js +29 -0
- package/dist/esm/components/HeatMapChart/helpers/getTickValues.d.ts +2 -0
- package/dist/esm/components/HeatMapChart/helpers/getTickValues.js +61 -0
- package/dist/esm/components/HeatMapChart/helpers/index.d.ts +4 -0
- package/dist/esm/components/HeatMapChart/helpers/index.js +4 -0
- package/dist/esm/components/HeatMapChart/index.d.ts +2 -0
- package/dist/esm/components/HeatMapChart/index.js +1 -0
- package/dist/esm/components/HeatMapChart/styles.module.css +98 -0
- package/dist/esm/components/HeatMapChart/types.d.ts +35 -0
- package/dist/esm/components/HeatMapChart/types.js +1 -0
- package/dist/esm/components/InteractiveChart/InteractiveChart.d.ts +12 -0
- package/dist/esm/components/InteractiveChart/InteractiveChart.js +42 -0
- package/dist/esm/components/InteractiveChart/configurations/boxPlot.d.ts +5 -0
- package/dist/esm/components/InteractiveChart/configurations/boxPlot.js +71 -0
- package/dist/esm/components/InteractiveChart/configurations/defaultPlot.d.ts +5 -0
- package/dist/esm/components/InteractiveChart/configurations/defaultPlot.js +59 -0
- package/dist/esm/components/InteractiveChart/configurations/index.d.ts +2 -0
- package/dist/esm/components/InteractiveChart/configurations/index.js +2 -0
- package/dist/esm/components/InteractiveChart/constants.d.ts +17 -0
- package/dist/esm/components/InteractiveChart/constants.js +17 -0
- package/dist/esm/components/InteractiveChart/helpers/pathRenderer.d.ts +3 -0
- package/dist/esm/components/InteractiveChart/helpers/pathRenderer.js +39 -0
- package/dist/esm/components/InteractiveChart/hooks/useComputedColors.d.ts +2 -0
- package/dist/esm/components/InteractiveChart/hooks/useComputedColors.js +21 -0
- package/dist/esm/components/InteractiveChart/hooks/useLayer.d.ts +12 -0
- package/dist/esm/components/InteractiveChart/hooks/useLayer.js +16 -0
- package/dist/esm/components/InteractiveChart/index.d.ts +2 -0
- package/dist/esm/components/InteractiveChart/index.js +2 -0
- package/dist/esm/components/InteractiveChart/plugins/boxPlotPlugin.d.ts +12 -0
- package/dist/esm/components/InteractiveChart/plugins/boxPlotPlugin.js +84 -0
- package/dist/esm/components/InteractiveChart/plugins/columnHighlightPlugin.d.ts +12 -0
- package/dist/esm/components/InteractiveChart/plugins/columnHighlightPlugin.js +59 -0
- package/dist/esm/components/InteractiveChart/plugins/legendAsTooltipPlugin.d.ts +11 -0
- package/dist/esm/components/InteractiveChart/plugins/legendAsTooltipPlugin.js +52 -0
- package/dist/esm/components/InteractiveChart/plugins/wheelZoomPlugin.d.ts +5 -0
- package/dist/esm/components/InteractiveChart/plugins/wheelZoomPlugin.js +93 -0
- package/dist/esm/components/InteractiveChart/styles.module.css +25 -0
- package/dist/esm/components/InteractiveChart/types.d.ts +5 -0
- package/dist/esm/components/InteractiveChart/types.js +1 -0
- package/dist/esm/components/PieChart/Legend/Legend.d.ts +21 -0
- package/dist/esm/components/PieChart/Legend/Legend.js +12 -0
- package/dist/esm/components/PieChart/Legend/index.d.ts +1 -0
- package/dist/esm/components/PieChart/Legend/index.js +1 -0
- package/dist/esm/components/PieChart/Legend/styles.module.css +50 -0
- package/dist/esm/components/PieChart/Pie.d.ts +17 -0
- package/dist/esm/components/PieChart/Pie.js +21 -0
- package/dist/esm/components/PieChart/PieChart.d.ts +3 -0
- package/dist/esm/components/PieChart/PieChart.js +62 -0
- package/dist/esm/components/PieChart/index.d.ts +2 -0
- package/dist/esm/components/PieChart/index.js +1 -0
- package/dist/esm/components/PieChart/styles.module.css +52 -0
- package/dist/esm/components/PieChart/types.d.ts +36 -0
- package/dist/esm/components/PieChart/types.js +1 -0
- package/dist/esm/components/index.d.ts +4 -0
- package/dist/esm/components/index.js +4 -0
- package/dist/esm/constants/colors.d.ts +36 -0
- package/dist/esm/constants/colors.js +56 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/package.json +5 -4
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.InteractiveChart = InteractiveChart;
|
|
18
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
|
+
require("uplot/dist/uPlot.min.css");
|
|
20
|
+
require('./styles.module.css');
|
|
21
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
22
|
+
const lodash_merge_1 = __importDefault(require("lodash.merge"));
|
|
23
|
+
const react_1 = require("react");
|
|
24
|
+
const uplot_react_1 = __importDefault(require("uplot-react"));
|
|
25
|
+
const uikit_product_utils_1 = require("@sbercloud/uikit-product-utils");
|
|
26
|
+
const colors_1 = require("../../constants/colors");
|
|
27
|
+
const configurations_1 = require("./configurations");
|
|
28
|
+
const constants_1 = require("./constants");
|
|
29
|
+
const useComputedColors_1 = require("./hooks/useComputedColors");
|
|
30
|
+
function chooseBaseOptions({ type, computedColors, }) {
|
|
31
|
+
switch (type) {
|
|
32
|
+
case constants_1.PLOT_TYPES.BoxPlot:
|
|
33
|
+
return (0, configurations_1.getBoxPlotOptions)({ computedColors });
|
|
34
|
+
case constants_1.PLOT_TYPES.Default:
|
|
35
|
+
default:
|
|
36
|
+
return (0, configurations_1.getDefaultPlotOptions)({ computedColors });
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function InteractiveChart(_a) {
|
|
40
|
+
var { data, options, type = constants_1.PLOT_TYPES.Default, className } = _a, rest = __rest(_a, ["data", "options", "type", "className"]);
|
|
41
|
+
const style = (0, react_1.useMemo)(() => Object.entries(Object.assign(Object.assign({}, colors_1.CHART_SERIES_COLORS), colors_1.CHART_OTHER_COLORS)).reduce((styles, [key, value]) => {
|
|
42
|
+
styles[`--${key}`] = value;
|
|
43
|
+
return styles;
|
|
44
|
+
}, {}), []);
|
|
45
|
+
const computedColors = (0, useComputedColors_1.useComputedColors)();
|
|
46
|
+
const resultOptions = (0, react_1.useMemo)(() => (0, lodash_merge_1.default)({}, chooseBaseOptions({ type, computedColors }), options), [computedColors, options, type]);
|
|
47
|
+
return ((0, jsx_runtime_1.jsx)("div", Object.assign({}, (0, uikit_product_utils_1.extractSupportProps)(rest), { className: (0, classnames_1.default)(colors_1.COLOR_CONTAINER_CLASSNAME, className), style: style, children: (0, jsx_runtime_1.jsx)(uplot_react_1.default, { options: resultOptions, data: data }) })));
|
|
48
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getBoxPlotOptions = void 0;
|
|
4
|
+
const boxPlotPlugin_1 = require("../plugins/boxPlotPlugin");
|
|
5
|
+
const columnHighlightPlugin_1 = require("../plugins/columnHighlightPlugin");
|
|
6
|
+
const legendAsTooltipPlugin_1 = require("../plugins/legendAsTooltipPlugin");
|
|
7
|
+
const getBoxPlotOptions = ({ computedColors }) => ({
|
|
8
|
+
id: 'boxPlot',
|
|
9
|
+
title: 'Distribution of object predictions by bin',
|
|
10
|
+
width: 800,
|
|
11
|
+
height: 600,
|
|
12
|
+
cursor: {
|
|
13
|
+
drag: {
|
|
14
|
+
x: false,
|
|
15
|
+
y: false,
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
plugins: [
|
|
19
|
+
(0, boxPlotPlugin_1.boxPlotPlugin)({ computedColors }),
|
|
20
|
+
(0, columnHighlightPlugin_1.columnHighlightPlugin)({ computedColors }),
|
|
21
|
+
(0, legendAsTooltipPlugin_1.legendAsTooltipPlugin)({ computedColors }),
|
|
22
|
+
],
|
|
23
|
+
series: [
|
|
24
|
+
{
|
|
25
|
+
label: 'bin',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
label: 'X1',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
label: 'Q1',
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
label: 'Median',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
label: 'Q3',
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
label: 'X2',
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
scales: {
|
|
44
|
+
x: {
|
|
45
|
+
distr: 2,
|
|
46
|
+
time: false,
|
|
47
|
+
range: (self, fromMin, fromMax) => [fromMin - 1, fromMax + 1],
|
|
48
|
+
},
|
|
49
|
+
y: {
|
|
50
|
+
time: false,
|
|
51
|
+
auto: true,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
axes: [
|
|
55
|
+
{
|
|
56
|
+
label: 'Bin Number',
|
|
57
|
+
labelSize: 30,
|
|
58
|
+
stroke: '#808080',
|
|
59
|
+
grid: {
|
|
60
|
+
stroke: 'rgba(128, 128, 128, 0.15)',
|
|
61
|
+
width: 1 / devicePixelRatio,
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
label: 'Prediction',
|
|
66
|
+
labelSize: 30,
|
|
67
|
+
stroke: '#808080',
|
|
68
|
+
grid: {
|
|
69
|
+
stroke: 'rgba(128, 128, 128, 0.15)',
|
|
70
|
+
width: 1 / devicePixelRatio,
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
});
|
|
75
|
+
exports.getBoxPlotOptions = getBoxPlotOptions;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getDefaultPlotOptions = void 0;
|
|
7
|
+
const color_1 = __importDefault(require("color"));
|
|
8
|
+
const colors_1 = require("../../../constants/colors");
|
|
9
|
+
const wheelZoomPlugin_1 = require("../plugins/wheelZoomPlugin");
|
|
10
|
+
const getDefaultPlotOptions = ({ computedColors }) => {
|
|
11
|
+
const axisColor = new color_1.default(computedColors[colors_1.OTHER_COLORS.AxisColor]).alpha(0.8).rgb().string();
|
|
12
|
+
const labelColor = computedColors[colors_1.OTHER_COLORS.LabelColor];
|
|
13
|
+
return {
|
|
14
|
+
id: 'defaultPlot',
|
|
15
|
+
title: 'Title',
|
|
16
|
+
width: 800,
|
|
17
|
+
height: 600,
|
|
18
|
+
cursor: {
|
|
19
|
+
drag: {
|
|
20
|
+
x: true,
|
|
21
|
+
y: true,
|
|
22
|
+
dist: 10,
|
|
23
|
+
uni: 10,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
plugins: [(0, wheelZoomPlugin_1.wheelZoomPlugin)({ factor: 0.75 })],
|
|
27
|
+
series: [
|
|
28
|
+
{
|
|
29
|
+
label: 'x',
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
scales: {
|
|
33
|
+
x: {
|
|
34
|
+
time: false,
|
|
35
|
+
auto: true,
|
|
36
|
+
},
|
|
37
|
+
y: {
|
|
38
|
+
time: false,
|
|
39
|
+
auto: true,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
axes: [
|
|
43
|
+
{
|
|
44
|
+
show: true,
|
|
45
|
+
label: 'x',
|
|
46
|
+
labelSize: 30,
|
|
47
|
+
stroke: labelColor,
|
|
48
|
+
grid: {
|
|
49
|
+
stroke: axisColor,
|
|
50
|
+
width: 1 / devicePixelRatio,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
show: true,
|
|
55
|
+
label: 'y',
|
|
56
|
+
labelSize: 30,
|
|
57
|
+
stroke: labelColor,
|
|
58
|
+
grid: {
|
|
59
|
+
stroke: axisColor,
|
|
60
|
+
width: 1 / devicePixelRatio,
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
exports.getDefaultPlotOptions = getDefaultPlotOptions;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./boxPlot"), exports);
|
|
18
|
+
__exportStar(require("./defaultPlot"), exports);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const PLOT_TYPES: {
|
|
2
|
+
readonly BoxPlot: "boxPlot";
|
|
3
|
+
readonly Default: "default";
|
|
4
|
+
};
|
|
5
|
+
export declare const LINE_INTERPOLATIONS: {
|
|
6
|
+
readonly Linear: "linear";
|
|
7
|
+
readonly StepAfter: "stepAfter";
|
|
8
|
+
readonly StepBefore: "stepBefore";
|
|
9
|
+
readonly Spline: "spline";
|
|
10
|
+
};
|
|
11
|
+
export declare const DRAW_STYLES: {
|
|
12
|
+
readonly Line: "line";
|
|
13
|
+
readonly Bars: "bars";
|
|
14
|
+
readonly Points: "points";
|
|
15
|
+
readonly BarsLeft: "barsLeft";
|
|
16
|
+
readonly BarsRight: "barsRight";
|
|
17
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DRAW_STYLES = exports.LINE_INTERPOLATIONS = exports.PLOT_TYPES = void 0;
|
|
4
|
+
exports.PLOT_TYPES = {
|
|
5
|
+
BoxPlot: 'boxPlot',
|
|
6
|
+
Default: 'default',
|
|
7
|
+
};
|
|
8
|
+
exports.LINE_INTERPOLATIONS = {
|
|
9
|
+
Linear: 'linear',
|
|
10
|
+
StepAfter: 'stepAfter',
|
|
11
|
+
StepBefore: 'stepBefore',
|
|
12
|
+
Spline: 'spline',
|
|
13
|
+
};
|
|
14
|
+
exports.DRAW_STYLES = {
|
|
15
|
+
Line: 'line',
|
|
16
|
+
Bars: 'bars',
|
|
17
|
+
Points: 'points',
|
|
18
|
+
BarsLeft: 'barsLeft',
|
|
19
|
+
BarsRight: 'barsRight',
|
|
20
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import uPlot from 'uplot';
|
|
2
|
+
import { DrawStyle, LineInterpolation } from '../types';
|
|
3
|
+
export declare function getPathRenderer(drawStyle: DrawStyle, lineInterpolation?: LineInterpolation): (self: uPlot, seriesIdx: number, idx0: number, idx1: number) => uPlot.Series.Paths | null;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3
|
+
// @ts-nocheck
|
|
4
|
+
/* eslint-disable */
|
|
5
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
6
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.getPathRenderer = getPathRenderer;
|
|
10
|
+
const uplot_1 = __importDefault(require("uplot"));
|
|
11
|
+
const constants_1 = require("../constants");
|
|
12
|
+
const { linear, stepped, bars, spline } = uplot_1.default.paths;
|
|
13
|
+
const _bars60_100 = bars({ size: [0.6, 100] });
|
|
14
|
+
const _bars100Left = bars({ size: [1], align: 1 });
|
|
15
|
+
const _bars100Right = bars({ size: [1], align: -1 });
|
|
16
|
+
const _stepBefore = stepped({ align: -1 });
|
|
17
|
+
const _stepAfter = stepped({ align: 1 });
|
|
18
|
+
const _linear = linear();
|
|
19
|
+
const _spline = spline();
|
|
20
|
+
function getPathRenderer(drawStyle, lineInterpolation) {
|
|
21
|
+
return function pathRenderer(self, seriesIdx, idx0, idx1) {
|
|
22
|
+
const style = drawStyle;
|
|
23
|
+
const interp = lineInterpolation;
|
|
24
|
+
const renderer = style === constants_1.DRAW_STYLES.Line
|
|
25
|
+
? interp === constants_1.LINE_INTERPOLATIONS.Linear
|
|
26
|
+
? _linear
|
|
27
|
+
: interp === constants_1.LINE_INTERPOLATIONS.StepAfter
|
|
28
|
+
? _stepAfter
|
|
29
|
+
: interp === constants_1.LINE_INTERPOLATIONS.StepBefore
|
|
30
|
+
? _stepBefore
|
|
31
|
+
: interp === constants_1.LINE_INTERPOLATIONS.Spline
|
|
32
|
+
? _spline
|
|
33
|
+
: null
|
|
34
|
+
: style === constants_1.DRAW_STYLES.Bars
|
|
35
|
+
? _bars60_100
|
|
36
|
+
: style === constants_1.DRAW_STYLES.BarsLeft
|
|
37
|
+
? _bars100Left
|
|
38
|
+
: style === constants_1.DRAW_STYLES.BarsRight
|
|
39
|
+
? _bars100Right
|
|
40
|
+
: style === constants_1.DRAW_STYLES.Points
|
|
41
|
+
? () => null
|
|
42
|
+
: () => null;
|
|
43
|
+
return renderer(self, seriesIdx, idx0, idx1);
|
|
44
|
+
};
|
|
45
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useComputedColors = useComputedColors;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const uikit_product_utils_1 = require("@sbercloud/uikit-product-utils");
|
|
6
|
+
const utils_1 = require("@snack-uikit/utils");
|
|
7
|
+
const colors_1 = require("../../../constants/colors");
|
|
8
|
+
const EMPTY_COLORS = {};
|
|
9
|
+
function useComputedColors() {
|
|
10
|
+
const { theme } = (0, uikit_product_utils_1.useTheme)();
|
|
11
|
+
const [computedColors, setComputedColors] = (0, react_1.useState)(EMPTY_COLORS);
|
|
12
|
+
(0, utils_1.useLayoutEffect)(() => {
|
|
13
|
+
const colorContainer = document.querySelector('.' + colors_1.COLOR_CONTAINER_CLASSNAME);
|
|
14
|
+
if (!colorContainer) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const styles = getComputedStyle(colorContainer);
|
|
18
|
+
setComputedColors(Object.values(Object.assign(Object.assign({}, colors_1.SERIES_COLORS), colors_1.OTHER_COLORS)).reduce((colors, color) => {
|
|
19
|
+
colors[color] = styles.getPropertyValue(`--${color}`);
|
|
20
|
+
return colors;
|
|
21
|
+
}, {}));
|
|
22
|
+
}, [theme]);
|
|
23
|
+
return computedColors;
|
|
24
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Series } from 'uplot';
|
|
2
|
+
import { SeriesColor } from '../../../constants/colors';
|
|
3
|
+
import { DrawStyle, LineInterpolation } from '../types';
|
|
4
|
+
type Layer = Partial<Series>;
|
|
5
|
+
type UseLayerProps = {
|
|
6
|
+
label: string;
|
|
7
|
+
color: SeriesColor;
|
|
8
|
+
drawStyle: DrawStyle;
|
|
9
|
+
lineInterpolation?: LineInterpolation;
|
|
10
|
+
};
|
|
11
|
+
export declare function useLayer({ label, color, drawStyle, lineInterpolation }: UseLayerProps): Layer;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.useLayer = useLayer;
|
|
7
|
+
const color_1 = __importDefault(require("color"));
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const pathRenderer_1 = require("../helpers/pathRenderer");
|
|
10
|
+
const useComputedColors_1 = require("./useComputedColors");
|
|
11
|
+
function useLayer({ label, color, drawStyle, lineInterpolation }) {
|
|
12
|
+
const computedColors = (0, useComputedColors_1.useComputedColors)();
|
|
13
|
+
const stroke = computedColors[color];
|
|
14
|
+
const fill = new color_1.default(stroke).alpha(0.1).rgb().string();
|
|
15
|
+
return (0, react_1.useMemo)(() => ({
|
|
16
|
+
label,
|
|
17
|
+
stroke,
|
|
18
|
+
fill,
|
|
19
|
+
width: 2,
|
|
20
|
+
paths: (0, pathRenderer_1.getPathRenderer)(drawStyle, lineInterpolation),
|
|
21
|
+
}), [drawStyle, label, stroke, fill, lineInterpolation]);
|
|
22
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./InteractiveChart"), exports);
|
|
18
|
+
__exportStar(require("./hooks/useLayer"), exports);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ColorMap } from '../../../constants/colors';
|
|
2
|
+
export declare function boxPlotPlugin({ gap, bodyMaxWidth, shadowWidth, computedColors, }: {
|
|
3
|
+
gap?: number;
|
|
4
|
+
bodyMaxWidth?: number;
|
|
5
|
+
shadowWidth?: number;
|
|
6
|
+
computedColors: ColorMap;
|
|
7
|
+
}): {
|
|
8
|
+
opts: (u: any, opts: any) => void;
|
|
9
|
+
hooks: {
|
|
10
|
+
draw: (u: any) => void;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.boxPlotPlugin = boxPlotPlugin;
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
8
|
+
// @ts-nocheck
|
|
9
|
+
/* eslint-disable */
|
|
10
|
+
const color_1 = __importDefault(require("color"));
|
|
11
|
+
const uplot_1 = __importDefault(require("uplot"));
|
|
12
|
+
const colors_1 = require("../../../constants/colors");
|
|
13
|
+
function boxPlotPlugin({ gap = 5, bodyMaxWidth = 60, shadowWidth = 3, computedColors, }) {
|
|
14
|
+
const shadowColor = computedColors[colors_1.OTHER_COLORS.ShadowColor];
|
|
15
|
+
const lineColor = new color_1.default(computedColors[colors_1.OTHER_COLORS.LineColor]).alpha(0.5).rgb().string();
|
|
16
|
+
function roundRect(ctx, x, y, width, height, radius) {
|
|
17
|
+
ctx.beginPath();
|
|
18
|
+
ctx.moveTo(x + radius, y);
|
|
19
|
+
ctx.lineTo(x + width - radius, y);
|
|
20
|
+
ctx.quadraticCurveTo(x + width, y, x + width, y - radius);
|
|
21
|
+
ctx.lineTo(x + width, y + height + radius);
|
|
22
|
+
ctx.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
|
|
23
|
+
ctx.lineTo(x + radius, y + height);
|
|
24
|
+
ctx.quadraticCurveTo(x, y + height, x, y + height + radius);
|
|
25
|
+
ctx.lineTo(x, y - radius);
|
|
26
|
+
ctx.quadraticCurveTo(x, y, x + radius, y);
|
|
27
|
+
ctx.closePath();
|
|
28
|
+
ctx.fill();
|
|
29
|
+
}
|
|
30
|
+
function drawBoxes(u) {
|
|
31
|
+
u.ctx.save();
|
|
32
|
+
const offset = (shadowWidth % 2) / 2;
|
|
33
|
+
u.ctx.translate(offset, offset);
|
|
34
|
+
const [iMin, iMax] = u.series[0].idxs;
|
|
35
|
+
for (let i = iMin; i <= iMax; i++) {
|
|
36
|
+
const xVal = u.scales.x.distr === 2 ? i : u.data[0][i];
|
|
37
|
+
const open = u.data[1][i];
|
|
38
|
+
const low = u.data[2][i];
|
|
39
|
+
const median = u.data[3][i];
|
|
40
|
+
const high = u.data[4][i];
|
|
41
|
+
const close = u.data[5][i];
|
|
42
|
+
const timeAsX = u.valToPos(xVal, 'x', true);
|
|
43
|
+
const openAsY = u.valToPos(open, 'y', true);
|
|
44
|
+
const lowAsY = u.valToPos(low, 'y', true);
|
|
45
|
+
const medianAsY = u.valToPos(median, 'y', true);
|
|
46
|
+
const highAsY = u.valToPos(high, 'y', true);
|
|
47
|
+
const closeAsY = u.valToPos(close, 'y', true);
|
|
48
|
+
// moustache
|
|
49
|
+
const shadowHeight = closeAsY - openAsY;
|
|
50
|
+
const shadowX = timeAsX - shadowWidth / 2;
|
|
51
|
+
const shadowY = openAsY;
|
|
52
|
+
const columnWidth = u.bbox.width / (iMax - iMin + 2);
|
|
53
|
+
const bodyWidth = Math.min(bodyMaxWidth, columnWidth - gap);
|
|
54
|
+
u.ctx.fillStyle = shadowColor;
|
|
55
|
+
u.ctx.fillRect(Math.round(shadowX), Math.round(shadowY), Math.round(shadowWidth), Math.round(shadowHeight));
|
|
56
|
+
u.ctx.fillRect(Math.round(timeAsX - bodyWidth / 4), Math.round(shadowY - shadowWidth / 2), Math.round(bodyWidth / 2), Math.round(shadowWidth));
|
|
57
|
+
u.ctx.fillRect(Math.round(timeAsX - bodyWidth / 4), Math.round(shadowY + shadowHeight - shadowWidth / 2), Math.round(bodyWidth / 2), Math.round(shadowWidth));
|
|
58
|
+
// body rect
|
|
59
|
+
const bodyHeight = highAsY - lowAsY;
|
|
60
|
+
const bodyX = timeAsX - bodyWidth / 2;
|
|
61
|
+
const bodyY = lowAsY;
|
|
62
|
+
if (Math.abs(bodyHeight) > 8) {
|
|
63
|
+
u.ctx.fillStyle = computedColors === null || computedColors === void 0 ? void 0 : computedColors[Object.values(colors_1.SERIES_COLORS)[i % Object.keys(colors_1.SERIES_COLORS).length]];
|
|
64
|
+
roundRect(u.ctx, Math.round(bodyX), Math.round(bodyY), Math.round(bodyWidth), Math.round(bodyHeight), 8, true, true);
|
|
65
|
+
u.ctx.fillStyle = lineColor;
|
|
66
|
+
u.ctx.fillRect(Math.round(bodyX), medianAsY - shadowWidth / 2, Math.round(bodyWidth), Math.round(shadowWidth));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
u.ctx.translate(-offset, -offset);
|
|
70
|
+
u.ctx.restore();
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
opts: (u, opts) => {
|
|
74
|
+
uplot_1.default.assign(opts, {
|
|
75
|
+
cursor: {
|
|
76
|
+
points: {
|
|
77
|
+
show: false,
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
opts.series.forEach(series => {
|
|
82
|
+
series.paths = () => null;
|
|
83
|
+
series.points = { show: false };
|
|
84
|
+
});
|
|
85
|
+
},
|
|
86
|
+
hooks: {
|
|
87
|
+
draw: drawBoxes,
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import uPlot from 'uplot';
|
|
2
|
+
import { ColorMap } from '../../../constants/colors';
|
|
3
|
+
export declare function columnHighlightPlugin({ className, computedColors, }: {
|
|
4
|
+
className?: string;
|
|
5
|
+
computedColors: ColorMap;
|
|
6
|
+
}): {
|
|
7
|
+
opts: (u: any, opts: any) => void;
|
|
8
|
+
hooks: {
|
|
9
|
+
init: (u: uPlot) => void;
|
|
10
|
+
setCursor: (u: any) => void;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.columnHighlightPlugin = columnHighlightPlugin;
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
8
|
+
// @ts-nocheck
|
|
9
|
+
/* eslint-disable */
|
|
10
|
+
const color_1 = __importDefault(require("color"));
|
|
11
|
+
const uplot_1 = __importDefault(require("uplot"));
|
|
12
|
+
const colors_1 = require("../../../constants/colors");
|
|
13
|
+
function columnHighlightPlugin({ className = '', computedColors, }) {
|
|
14
|
+
const backgroundColor = new color_1.default(computedColors[colors_1.OTHER_COLORS.ColumnHighlightColor]).alpha(0.5).rgb().string();
|
|
15
|
+
let underEl, overEl, currIdx;
|
|
16
|
+
function init(u) {
|
|
17
|
+
underEl = u.under;
|
|
18
|
+
overEl = u.over;
|
|
19
|
+
const highlightEl = document.createElement('div');
|
|
20
|
+
className && highlightEl.classList.add(className);
|
|
21
|
+
uplot_1.default.assign(highlightEl.style, {
|
|
22
|
+
pointerEvents: 'none',
|
|
23
|
+
display: 'none',
|
|
24
|
+
position: 'absolute',
|
|
25
|
+
left: 0,
|
|
26
|
+
top: 0,
|
|
27
|
+
height: '100%',
|
|
28
|
+
backgroundColor,
|
|
29
|
+
});
|
|
30
|
+
underEl.appendChild(highlightEl);
|
|
31
|
+
u._highlightEl = highlightEl;
|
|
32
|
+
// show/hide highlight on enter/exit
|
|
33
|
+
overEl.addEventListener('mouseenter', () => {
|
|
34
|
+
highlightEl.style.display = null;
|
|
35
|
+
});
|
|
36
|
+
overEl.addEventListener('mouseleave', () => {
|
|
37
|
+
highlightEl.style.display = 'none';
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
function update(u) {
|
|
41
|
+
if (currIdx !== u.cursor.idx) {
|
|
42
|
+
currIdx = u.cursor.idx;
|
|
43
|
+
const highlightEl = u._highlightEl;
|
|
44
|
+
const dx = u.scales.x.max - u.scales.x.min;
|
|
45
|
+
const width = u.bbox.width / dx / devicePixelRatio;
|
|
46
|
+
const left = u.valToPos(currIdx, 'x') - width / 2;
|
|
47
|
+
highlightEl.style.transform = 'translateX(' + Math.round(left) + 'px)';
|
|
48
|
+
highlightEl.style.width = Math.round(width) + 'px';
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
opts: (u, opts) => {
|
|
53
|
+
uplot_1.default.assign(opts, {
|
|
54
|
+
cursor: {
|
|
55
|
+
x: false,
|
|
56
|
+
y: false,
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
hooks: {
|
|
61
|
+
init: init,
|
|
62
|
+
setCursor: update,
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import uPlot from 'uplot';
|
|
2
|
+
import { ColorMap } from '../../../constants/colors';
|
|
3
|
+
export declare function legendAsTooltipPlugin({ className, computedColors, }: {
|
|
4
|
+
className?: string;
|
|
5
|
+
computedColors: ColorMap;
|
|
6
|
+
}): {
|
|
7
|
+
hooks: {
|
|
8
|
+
init: (u: uPlot, opts: any) => void;
|
|
9
|
+
setCursor: (u: any) => void;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3
|
+
// @ts-nocheck
|
|
4
|
+
/* eslint-disable */
|
|
5
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
6
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.legendAsTooltipPlugin = legendAsTooltipPlugin;
|
|
10
|
+
const uplot_1 = __importDefault(require("uplot"));
|
|
11
|
+
const colors_1 = require("../../../constants/colors");
|
|
12
|
+
function legendAsTooltipPlugin({ className = '', computedColors, }) {
|
|
13
|
+
const backgroundColor = computedColors[colors_1.OTHER_COLORS.TooltipBackgroundColor];
|
|
14
|
+
const color = computedColors[colors_1.OTHER_COLORS.TooltipColor];
|
|
15
|
+
function init(u, opts) {
|
|
16
|
+
const legendEl = u.root.querySelector(`.u-legend`);
|
|
17
|
+
legendEl.classList.remove('u-inline');
|
|
18
|
+
className && legendEl.classList.add(className);
|
|
19
|
+
uplot_1.default.assign(legendEl.style, {
|
|
20
|
+
borderRadius: '4px',
|
|
21
|
+
textAlign: 'left',
|
|
22
|
+
pointerEvents: 'none',
|
|
23
|
+
display: 'none',
|
|
24
|
+
position: 'absolute',
|
|
25
|
+
left: 0,
|
|
26
|
+
top: 0,
|
|
27
|
+
zIndex: 100,
|
|
28
|
+
backgroundColor,
|
|
29
|
+
color,
|
|
30
|
+
});
|
|
31
|
+
// hide series color markers
|
|
32
|
+
const idents = legendEl.querySelectorAll('.u-marker');
|
|
33
|
+
for (let i = 0; i < idents.length; i++)
|
|
34
|
+
idents[i].style.display = 'none';
|
|
35
|
+
const overEl = u.over;
|
|
36
|
+
overEl.style.overflow = 'visible';
|
|
37
|
+
// move legend into plot bounds
|
|
38
|
+
overEl.appendChild(legendEl);
|
|
39
|
+
// show/hide tooltip on enter/exit
|
|
40
|
+
overEl.addEventListener('mouseenter', () => {
|
|
41
|
+
legendEl.style.display = null;
|
|
42
|
+
});
|
|
43
|
+
overEl.addEventListener('mouseleave', () => {
|
|
44
|
+
legendEl.style.display = 'none';
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function update(u) {
|
|
48
|
+
const { left, top } = u.cursor;
|
|
49
|
+
const legendEl = u.root.querySelector(`.u-legend`);
|
|
50
|
+
legendEl.style.transform = 'translate(' + (left + 15) + 'px, ' + top + 'px)';
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
hooks: {
|
|
54
|
+
init: init,
|
|
55
|
+
setCursor: update,
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|