@elliemae/ds-dataviz 3.8.1 → 3.9.0-next.1
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/cjs/graphs/Chart/Chart.js.map +2 -2
- package/dist/cjs/graphs/Chart/ChartContext.js +3 -1
- package/dist/cjs/graphs/Chart/ChartContext.js.map +2 -2
- package/dist/cjs/graphs/Chart/config/useChart.js +86 -33
- package/dist/cjs/graphs/Chart/config/useChart.js.map +3 -3
- package/dist/cjs/graphs/Chart/config/useInternalMargins.js +103 -0
- package/dist/cjs/graphs/Chart/config/useInternalMargins.js.map +7 -0
- package/dist/cjs/graphs/Chart/config/useKeyboardNavigation.js +25 -15
- package/dist/cjs/graphs/Chart/config/useKeyboardNavigation.js.map +2 -2
- package/dist/cjs/graphs/Chart/config/useScales.js +43 -17
- package/dist/cjs/graphs/Chart/config/useScales.js.map +2 -2
- package/dist/cjs/graphs/Chart/helpers/index.js +9 -13
- package/dist/cjs/graphs/Chart/helpers/index.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/ActivePoint.js +1 -1
- package/dist/cjs/graphs/Chart/parts/ActivePoint.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Axis/AxisBottom.js +17 -25
- package/dist/cjs/graphs/Chart/parts/Axis/AxisBottom.js.map +3 -3
- package/dist/cjs/graphs/Chart/parts/Axis/AxisLeft.js +33 -38
- package/dist/cjs/graphs/Chart/parts/Axis/AxisLeft.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Axis/AxisRight.js +6 -11
- package/dist/cjs/graphs/Chart/parts/Axis/AxisRight.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/ChartContainer.js +65 -16
- package/dist/cjs/graphs/Chart/parts/ChartContainer.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/FocusableRegion.js +17 -68
- package/dist/cjs/graphs/Chart/parts/FocusableRegion.js.map +2 -2
- package/dist/cjs/graphs/Chart/{series/Pie.js → parts/Labels/BottomLabel.js} +20 -12
- package/dist/cjs/graphs/Chart/parts/Labels/BottomLabel.js.map +7 -0
- package/dist/cjs/graphs/Chart/parts/Labels/Label.js +52 -0
- package/dist/cjs/graphs/Chart/parts/Labels/Label.js.map +7 -0
- package/dist/cjs/graphs/Chart/parts/Labels/LeftLabel.js +61 -0
- package/dist/cjs/graphs/Chart/parts/Labels/LeftLabel.js.map +7 -0
- package/dist/cjs/graphs/Chart/parts/Labels/RightLabel.js +65 -0
- package/dist/cjs/graphs/Chart/parts/Labels/RightLabel.js.map +7 -0
- package/dist/cjs/graphs/Chart/parts/Legend/BottomLegend.js +28 -30
- package/dist/cjs/graphs/Chart/parts/Legend/BottomLegend.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Legend/LeftLegend.js +14 -19
- package/dist/cjs/graphs/Chart/parts/Legend/LeftLegend.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Legend/LegendItem.js +100 -0
- package/dist/cjs/graphs/Chart/parts/Legend/LegendItem.js.map +7 -0
- package/dist/cjs/graphs/Chart/parts/Legend/RightLegend.js +31 -25
- package/dist/cjs/graphs/Chart/parts/Legend/RightLegend.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Legend/TopLegend.js +3 -13
- package/dist/cjs/graphs/Chart/parts/Legend/TopLegend.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Scrapper/Scrapper.js +50 -16
- package/dist/cjs/graphs/Chart/parts/Scrapper/Scrapper.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Scrapper/ScrapperLine.js +3 -1
- package/dist/cjs/graphs/Chart/parts/Scrapper/ScrapperLine.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Scrapper/VerticalScrapper.js +39 -17
- package/dist/cjs/graphs/Chart/parts/Scrapper/VerticalScrapper.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Scrapper/VerticalScrapperLine.js +29 -28
- package/dist/cjs/graphs/Chart/parts/Scrapper/VerticalScrapperLine.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Scroller/ScrollBarX.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Scroller/ScrollableContainerX.js +2 -2
- package/dist/cjs/graphs/Chart/parts/Scroller/ScrollableContainerX.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/SeriesFactory.js +57 -41
- package/dist/cjs/graphs/Chart/parts/SeriesFactory.js.map +2 -2
- package/dist/cjs/graphs/Chart/react-desc-prop-types.js +1 -12
- package/dist/cjs/graphs/Chart/react-desc-prop-types.js.map +2 -2
- package/dist/cjs/graphs/Chart/series/Bars.js +29 -27
- package/dist/cjs/graphs/Chart/series/Bars.js.map +2 -2
- package/dist/cjs/graphs/Chart/series/HorizontalBars.js +85 -0
- package/dist/cjs/graphs/Chart/series/HorizontalBars.js.map +7 -0
- package/dist/cjs/graphs/Chart/series/HorizontalStackedBars.js +77 -0
- package/dist/cjs/graphs/Chart/series/HorizontalStackedBars.js.map +7 -0
- package/dist/cjs/graphs/Chart/series/Line.js +23 -19
- package/dist/cjs/graphs/Chart/series/Line.js.map +2 -2
- package/dist/cjs/graphs/Chart/series/Point.js +88 -18
- package/dist/cjs/graphs/Chart/series/Point.js.map +2 -2
- package/dist/cjs/graphs/Chart/series/Points.js +23 -27
- package/dist/cjs/graphs/Chart/series/Points.js.map +2 -2
- package/dist/cjs/graphs/Chart/series/Rect.js +105 -8
- package/dist/cjs/graphs/Chart/series/Rect.js.map +2 -2
- package/dist/cjs/graphs/Chart/series/StackedBar.js +23 -30
- package/dist/cjs/graphs/Chart/series/StackedBar.js.map +2 -2
- package/dist/cjs/graphs/Chart/series/index.js +0 -1
- package/dist/cjs/graphs/Chart/series/index.js.map +2 -2
- package/dist/cjs/graphs/Chart/styles.js +5 -20
- package/dist/cjs/graphs/Chart/styles.js.map +2 -2
- package/dist/cjs/graphs/constants.js +20 -0
- package/dist/cjs/graphs/constants.js.map +2 -2
- package/dist/esm/graphs/Chart/Chart.js.map +2 -2
- package/dist/esm/graphs/Chart/ChartContext.js +3 -1
- package/dist/esm/graphs/Chart/ChartContext.js.map +2 -2
- package/dist/esm/graphs/Chart/config/useChart.js +87 -34
- package/dist/esm/graphs/Chart/config/useChart.js.map +2 -2
- package/dist/esm/graphs/Chart/config/useInternalMargins.js +77 -0
- package/dist/esm/graphs/Chart/config/useInternalMargins.js.map +7 -0
- package/dist/esm/graphs/Chart/config/useKeyboardNavigation.js +26 -16
- package/dist/esm/graphs/Chart/config/useKeyboardNavigation.js.map +2 -2
- package/dist/esm/graphs/Chart/config/useScales.js +44 -18
- package/dist/esm/graphs/Chart/config/useScales.js.map +2 -2
- package/dist/esm/graphs/Chart/helpers/index.js +10 -14
- package/dist/esm/graphs/Chart/helpers/index.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/ActivePoint.js +1 -1
- package/dist/esm/graphs/Chart/parts/ActivePoint.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Axis/AxisBottom.js +18 -26
- package/dist/esm/graphs/Chart/parts/Axis/AxisBottom.js.map +3 -3
- package/dist/esm/graphs/Chart/parts/Axis/AxisLeft.js +34 -39
- package/dist/esm/graphs/Chart/parts/Axis/AxisLeft.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Axis/AxisRight.js +6 -11
- package/dist/esm/graphs/Chart/parts/Axis/AxisRight.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/ChartContainer.js +66 -17
- package/dist/esm/graphs/Chart/parts/ChartContainer.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/FocusableRegion.js +18 -69
- package/dist/esm/graphs/Chart/parts/FocusableRegion.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Labels/BottomLabel.js +28 -0
- package/dist/esm/graphs/Chart/parts/Labels/BottomLabel.js.map +7 -0
- package/dist/esm/graphs/Chart/parts/Labels/Label.js +26 -0
- package/dist/esm/graphs/Chart/parts/Labels/Label.js.map +7 -0
- package/dist/esm/graphs/Chart/parts/Labels/LeftLabel.js +35 -0
- package/dist/esm/graphs/Chart/parts/Labels/LeftLabel.js.map +7 -0
- package/dist/esm/graphs/Chart/parts/Labels/RightLabel.js +39 -0
- package/dist/esm/graphs/Chart/parts/Labels/RightLabel.js.map +7 -0
- package/dist/esm/graphs/Chart/parts/Legend/BottomLegend.js +28 -30
- package/dist/esm/graphs/Chart/parts/Legend/BottomLegend.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Legend/LeftLegend.js +16 -21
- package/dist/esm/graphs/Chart/parts/Legend/LeftLegend.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Legend/LegendItem.js +74 -0
- package/dist/esm/graphs/Chart/parts/Legend/LegendItem.js.map +7 -0
- package/dist/esm/graphs/Chart/parts/Legend/RightLegend.js +32 -26
- package/dist/esm/graphs/Chart/parts/Legend/RightLegend.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Legend/TopLegend.js +3 -13
- package/dist/esm/graphs/Chart/parts/Legend/TopLegend.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Scrapper/Scrapper.js +51 -17
- package/dist/esm/graphs/Chart/parts/Scrapper/Scrapper.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Scrapper/ScrapperLine.js +3 -1
- package/dist/esm/graphs/Chart/parts/Scrapper/ScrapperLine.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Scrapper/VerticalScrapper.js +39 -17
- package/dist/esm/graphs/Chart/parts/Scrapper/VerticalScrapper.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Scrapper/VerticalScrapperLine.js +29 -28
- package/dist/esm/graphs/Chart/parts/Scrapper/VerticalScrapperLine.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Scroller/ScrollBarX.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Scroller/ScrollableContainerX.js +2 -2
- package/dist/esm/graphs/Chart/parts/Scroller/ScrollableContainerX.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/SeriesFactory.js +58 -42
- package/dist/esm/graphs/Chart/parts/SeriesFactory.js.map +2 -2
- package/dist/esm/graphs/Chart/react-desc-prop-types.js +1 -12
- package/dist/esm/graphs/Chart/react-desc-prop-types.js.map +2 -2
- package/dist/esm/graphs/Chart/series/Bars.js +30 -28
- package/dist/esm/graphs/Chart/series/Bars.js.map +2 -2
- package/dist/esm/graphs/Chart/series/HorizontalBars.js +59 -0
- package/dist/esm/graphs/Chart/series/HorizontalBars.js.map +7 -0
- package/dist/esm/graphs/Chart/series/HorizontalStackedBars.js +51 -0
- package/dist/esm/graphs/Chart/series/HorizontalStackedBars.js.map +7 -0
- package/dist/esm/graphs/Chart/series/Line.js +25 -21
- package/dist/esm/graphs/Chart/series/Line.js.map +2 -2
- package/dist/esm/graphs/Chart/series/Point.js +89 -19
- package/dist/esm/graphs/Chart/series/Point.js.map +2 -2
- package/dist/esm/graphs/Chart/series/Points.js +24 -28
- package/dist/esm/graphs/Chart/series/Points.js.map +2 -2
- package/dist/esm/graphs/Chart/series/Rect.js +106 -9
- package/dist/esm/graphs/Chart/series/Rect.js.map +2 -2
- package/dist/esm/graphs/Chart/series/StackedBar.js +24 -31
- package/dist/esm/graphs/Chart/series/StackedBar.js.map +2 -2
- package/dist/esm/graphs/Chart/series/index.js +0 -1
- package/dist/esm/graphs/Chart/series/index.js.map +2 -2
- package/dist/esm/graphs/Chart/styles.js +5 -20
- package/dist/esm/graphs/Chart/styles.js.map +2 -2
- package/dist/esm/graphs/constants.js +20 -0
- package/dist/esm/graphs/constants.js.map +2 -2
- package/package.json +8 -8
- package/dist/cjs/graphs/Chart/series/Pie.js.map +0 -7
- package/dist/esm/graphs/Chart/series/Pie.js +0 -20
- package/dist/esm/graphs/Chart/series/Pie.js.map +0 -7
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var HorizontalBars_exports = {};
|
|
26
|
+
__export(HorizontalBars_exports, {
|
|
27
|
+
HorizontalBars: () => HorizontalBars
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(HorizontalBars_exports);
|
|
30
|
+
var React = __toESM(require("react"));
|
|
31
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
32
|
+
var import_react = require("react");
|
|
33
|
+
var import_Rect = require("./Rect");
|
|
34
|
+
var import_ChartContext = require("../ChartContext");
|
|
35
|
+
const HorizontalBars = ({ serie }) => {
|
|
36
|
+
const {
|
|
37
|
+
props: { yAxis },
|
|
38
|
+
xScale,
|
|
39
|
+
yScale,
|
|
40
|
+
y2Scale,
|
|
41
|
+
subGroupScale,
|
|
42
|
+
colorScale,
|
|
43
|
+
getXValue,
|
|
44
|
+
getYValue,
|
|
45
|
+
chartId
|
|
46
|
+
} = (0, import_react.useContext)(import_ChartContext.ChartContext);
|
|
47
|
+
const finalYScale = serie.scale === "y2" ? y2Scale : yScale;
|
|
48
|
+
return (0, import_react.useMemo)(
|
|
49
|
+
() => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("g", {
|
|
50
|
+
fill: colorScale(serie.name),
|
|
51
|
+
clipPath: `url(#rect-focus-ring-${chartId})`,
|
|
52
|
+
children: serie.data.map((bar, i) => {
|
|
53
|
+
const x = getXValue(bar);
|
|
54
|
+
const y = getYValue(bar);
|
|
55
|
+
const width = xScale(x);
|
|
56
|
+
const height = subGroupScale?.bandwidth();
|
|
57
|
+
const transformY = subGroupScale(serie.name) + finalYScale(yAxis?.cols?.[i] ?? i);
|
|
58
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("g", {
|
|
59
|
+
transform: `translate(0,${transformY})`,
|
|
60
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Rect.Rect, {
|
|
61
|
+
width,
|
|
62
|
+
height,
|
|
63
|
+
id: bar.key,
|
|
64
|
+
x: 0,
|
|
65
|
+
xValue: x,
|
|
66
|
+
yValue: y
|
|
67
|
+
})
|
|
68
|
+
}, bar.key);
|
|
69
|
+
})
|
|
70
|
+
}),
|
|
71
|
+
[
|
|
72
|
+
chartId,
|
|
73
|
+
colorScale,
|
|
74
|
+
finalYScale,
|
|
75
|
+
getXValue,
|
|
76
|
+
getYValue,
|
|
77
|
+
serie.data,
|
|
78
|
+
serie.name,
|
|
79
|
+
subGroupScale,
|
|
80
|
+
xScale,
|
|
81
|
+
yAxis?.cols
|
|
82
|
+
]
|
|
83
|
+
);
|
|
84
|
+
};
|
|
85
|
+
//# sourceMappingURL=HorizontalBars.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/graphs/Chart/series/HorizontalBars.tsx", "../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["/* eslint-disable complexity */\nimport React, { useContext, useMemo } from 'react';\nimport { Rect } from './Rect';\nimport { ChartContext } from '../ChartContext';\nimport { DSChartT } from '../react-desc-prop-types';\ninterface BarsT {\n serie: DSChartT.InternalData;\n}\nexport const HorizontalBars = ({ serie }: BarsT) => {\n const {\n props: { yAxis },\n xScale,\n yScale,\n y2Scale,\n subGroupScale,\n colorScale,\n getXValue,\n getYValue,\n chartId,\n } = useContext(ChartContext);\n const finalYScale = serie.scale === 'y2' ? y2Scale : yScale;\n\n return useMemo(\n () => (\n <g fill={colorScale(serie.name)} clipPath={`url(#rect-focus-ring-${chartId})`}>\n {serie.data.map((bar, i) => {\n const x = getXValue(bar);\n const y = getYValue(bar);\n\n const width = xScale(x);\n const height = subGroupScale?.bandwidth();\n\n const transformY = subGroupScale(serie.name) + finalYScale(yAxis?.cols?.[i] ?? i);\n\n return (\n <g key={bar.key} transform={`translate(0,${transformY})`}>\n <Rect width={width} height={height} id={bar.key} x={0} xValue={x} yValue={y} />\n </g>\n );\n })}\n </g>\n ),\n [\n chartId,\n colorScale,\n finalYScale,\n getXValue,\n getYValue,\n serie.data,\n serie.name,\n subGroupScale,\n xScale,\n yAxis?.cols,\n ],\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB;AACA,mBAA2C;AAC3C,kBAAqB;AACrB,0BAA6B;AAKtB,MAAM,iBAAiB,CAAC,EAAE,MAAM,MAAa;AAClD,QAAM;AAAA,IACJ,OAAO,EAAE,MAAM;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,QAAI,yBAAW,gCAAY;AAC3B,QAAM,cAAc,MAAM,UAAU,OAAO,UAAU;AAErD,aAAO;AAAA,IACL,MACE,4CAAC;AAAA,MAAE,MAAM,WAAW,MAAM,IAAI;AAAA,MAAG,UAAU,wBAAwB;AAAA,MAChE,gBAAM,KAAK,IAAI,CAAC,KAAK,MAAM;AAC1B,cAAM,IAAI,UAAU,GAAG;AACvB,cAAM,IAAI,UAAU,GAAG;AAEvB,cAAM,QAAQ,OAAO,CAAC;AACtB,cAAM,SAAS,eAAe,UAAU;AAExC,cAAM,aAAa,cAAc,MAAM,IAAI,IAAI,YAAY,OAAO,OAAO,MAAM,CAAC;AAEhF,eACE,4CAAC;AAAA,UAAgB,WAAW,eAAe;AAAA,UACzC,sDAAC;AAAA,YAAK;AAAA,YAAc;AAAA,YAAgB,IAAI,IAAI;AAAA,YAAK,GAAG;AAAA,YAAG,QAAQ;AAAA,YAAG,QAAQ;AAAA,WAAG;AAAA,WADvE,IAAI,GAEZ;AAAA,MAEJ,CAAC;AAAA,KACH;AAAA,IAEF;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,MAAM;AAAA,MACN,MAAM;AAAA,MACN;AAAA,MACA;AAAA,MACA,OAAO;AAAA,IACT;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var HorizontalStackedBars_exports = {};
|
|
26
|
+
__export(HorizontalStackedBars_exports, {
|
|
27
|
+
HorizontalStackedBars: () => HorizontalStackedBars
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(HorizontalStackedBars_exports);
|
|
30
|
+
var React = __toESM(require("react"));
|
|
31
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
32
|
+
var import_react = require("react");
|
|
33
|
+
var import_Rect = require("./Rect");
|
|
34
|
+
var import_ChartContext = require("../ChartContext");
|
|
35
|
+
var import_helpers = require("../helpers");
|
|
36
|
+
const HorizontalStackedBars = ({ serie }) => {
|
|
37
|
+
const {
|
|
38
|
+
props: { yAxis, groups },
|
|
39
|
+
xScale,
|
|
40
|
+
yScale,
|
|
41
|
+
stackedData,
|
|
42
|
+
subGroupScale,
|
|
43
|
+
colorScale,
|
|
44
|
+
chartId,
|
|
45
|
+
getYValue
|
|
46
|
+
} = (0, import_react.useContext)(import_ChartContext.ChartContext);
|
|
47
|
+
const serieWithStackedValues = (0, import_helpers.getStackedData)(stackedData, serie);
|
|
48
|
+
const stackIndex = (0, import_helpers.getStackedIndex)(groups, serie.name);
|
|
49
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("g", {
|
|
50
|
+
children: serieWithStackedValues.map((sequence, i) => {
|
|
51
|
+
const isFloorStack = sequence[0] === 0;
|
|
52
|
+
const xValue = sequence[1] - sequence[0];
|
|
53
|
+
const yValue = getYValue(serie.data[i]);
|
|
54
|
+
const width = xScale(sequence[1]) - xScale(sequence[0]) - (!isFloorStack ? 1 : 0);
|
|
55
|
+
const height = subGroupScale?.bandwidth();
|
|
56
|
+
const transformX = xScale(sequence[0]) + (!isFloorStack ? 1 : 0);
|
|
57
|
+
const transformY = subGroupScale(`stacked-data-${stackIndex}`) + yScale(yAxis?.cols?.[i]);
|
|
58
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("g", {
|
|
59
|
+
clipPath: `url(#rect-focus-ring-${chartId})`,
|
|
60
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("g", {
|
|
61
|
+
fill: colorScale(serie.name),
|
|
62
|
+
transform: `translate(0, ${transformY})`,
|
|
63
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Rect.Rect, {
|
|
64
|
+
width,
|
|
65
|
+
height,
|
|
66
|
+
x: transformX,
|
|
67
|
+
xValue,
|
|
68
|
+
yValue,
|
|
69
|
+
id: serie.data[i].key,
|
|
70
|
+
name: serie.name
|
|
71
|
+
})
|
|
72
|
+
})
|
|
73
|
+
}, serie.data[i].key);
|
|
74
|
+
})
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
//# sourceMappingURL=HorizontalStackedBars.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/graphs/Chart/series/HorizontalStackedBars.tsx", "../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["/* eslint-disable complexity */\nimport React, { useContext } from 'react';\n\nimport { Rect } from './Rect';\nimport { ChartContext } from '../ChartContext';\nimport { getStackedData, getStackedIndex } from '../helpers';\n\nexport const HorizontalStackedBars = ({ serie }) => {\n const {\n props: { yAxis, groups },\n xScale,\n yScale,\n stackedData,\n subGroupScale,\n colorScale,\n chartId,\n getYValue,\n } = useContext(ChartContext);\n\n const serieWithStackedValues = getStackedData(stackedData, serie);\n const stackIndex = getStackedIndex(groups, serie.name);\n return (\n <g>\n {serieWithStackedValues.map((sequence, i) => {\n const isFloorStack = sequence[0] === 0;\n const xValue = sequence[1] - sequence[0];\n const yValue = getYValue(serie.data[i]);\n\n const width = xScale(sequence[1]) - xScale(sequence[0]) - (!isFloorStack ? 1 : 0);\n\n const height = subGroupScale?.bandwidth();\n\n const transformX = xScale(sequence[0]) + (!isFloorStack ? 1 : 0);\n const transformY = subGroupScale(`stacked-data-${stackIndex}`) + yScale(yAxis?.cols?.[i]);\n\n return (\n <g key={serie.data[i].key} clipPath={`url(#rect-focus-ring-${chartId})`}>\n <g fill={colorScale(serie.name)} transform={`translate(0, ${transformY})`}>\n <Rect\n width={width}\n height={height}\n x={transformX}\n xValue={xValue}\n yValue={yValue}\n id={serie.data[i].key}\n name={serie.name}\n />\n </g>\n </g>\n );\n })}\n </g>\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB;AACA,mBAAkC;AAElC,kBAAqB;AACrB,0BAA6B;AAC7B,qBAAgD;AAEzC,MAAM,wBAAwB,CAAC,EAAE,MAAM,MAAM;AAClD,QAAM;AAAA,IACJ,OAAO,EAAE,OAAO,OAAO;AAAA,IACvB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,QAAI,yBAAW,gCAAY;AAE3B,QAAM,6BAAyB,+BAAe,aAAa,KAAK;AAChE,QAAM,iBAAa,gCAAgB,QAAQ,MAAM,IAAI;AACrD,SACE,4CAAC;AAAA,IACE,iCAAuB,IAAI,CAAC,UAAU,MAAM;AAC3C,YAAM,eAAe,SAAS,OAAO;AACrC,YAAM,SAAS,SAAS,KAAK,SAAS;AACtC,YAAM,SAAS,UAAU,MAAM,KAAK,EAAE;AAEtC,YAAM,QAAQ,OAAO,SAAS,EAAE,IAAI,OAAO,SAAS,EAAE,KAAK,CAAC,eAAe,IAAI;AAE/E,YAAM,SAAS,eAAe,UAAU;AAExC,YAAM,aAAa,OAAO,SAAS,EAAE,KAAK,CAAC,eAAe,IAAI;AAC9D,YAAM,aAAa,cAAc,gBAAgB,YAAY,IAAI,OAAO,OAAO,OAAO,EAAE;AAExF,aACE,4CAAC;AAAA,QAA0B,UAAU,wBAAwB;AAAA,QAC3D,sDAAC;AAAA,UAAE,MAAM,WAAW,MAAM,IAAI;AAAA,UAAG,WAAW,gBAAgB;AAAA,UAC1D,sDAAC;AAAA,YACC;AAAA,YACA;AAAA,YACA,GAAG;AAAA,YACH;AAAA,YACA;AAAA,YACA,IAAI,MAAM,KAAK,GAAG;AAAA,YAClB,MAAM,MAAM;AAAA,WACd;AAAA,SACF;AAAA,SAXM,MAAM,KAAK,GAAG,GAYtB;AAAA,IAEJ,CAAC;AAAA,GACH;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -31,33 +31,37 @@ var React = __toESM(require("react"));
|
|
|
31
31
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
32
32
|
var import_react = require("react");
|
|
33
33
|
var import_d3 = require("d3");
|
|
34
|
-
var import_styles = require("../styles");
|
|
35
34
|
var import_Points = require("./Points");
|
|
36
35
|
var import_ChartContext = require("../ChartContext");
|
|
37
36
|
const Line = ({ serie }) => {
|
|
38
|
-
const {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
};
|
|
37
|
+
const { xScale, yScale, y2Scale, colorScale, getXValue, getYValue } = (0, import_react.useContext)(import_ChartContext.ChartContext);
|
|
38
|
+
const ref = (0, import_react.useRef)(null);
|
|
39
|
+
const firstRender = (0, import_react.useRef)(true);
|
|
40
|
+
const finalYScale = (0, import_react.useMemo)(() => serie.scale === "y2" ? y2Scale : yScale, [serie.scale, y2Scale, yScale]);
|
|
41
|
+
const lineTypeMap = (0, import_react.useMemo)(
|
|
42
|
+
() => ({
|
|
43
|
+
line: import_d3.curveLinear,
|
|
44
|
+
spline: import_d3.curveNatural
|
|
45
|
+
}),
|
|
46
|
+
[]
|
|
47
|
+
);
|
|
50
48
|
const lineD3 = (0, import_react.useMemo)(
|
|
51
|
-
() => (0, import_d3.line)().x((d) => xScale(d
|
|
52
|
-
[
|
|
49
|
+
() => (0, import_d3.line)().x((d) => xScale(getXValue(d))).y((d) => finalYScale(getYValue(d))).curve(lineTypeMap[serie.type] ?? import_d3.curveLinear),
|
|
50
|
+
[finalYScale, getXValue, getYValue, lineTypeMap, serie.type, xScale]
|
|
53
51
|
);
|
|
54
|
-
|
|
52
|
+
(0, import_react.useEffect)(() => {
|
|
53
|
+
if (!ref.current)
|
|
54
|
+
return;
|
|
55
|
+
const groupContent = (0, import_d3.select)(ref?.current);
|
|
56
|
+
groupContent.selectAll("*").remove();
|
|
57
|
+
const path = groupContent.append("path").datum(serie.data).attr("fill", "none").attr("stroke", colorScale(serie.name)).attr("stroke-linejoin", "round").attr("stroke-linecap", "round").attr("stroke-width", 2).attr("d", lineD3);
|
|
58
|
+
}, [colorScale, finalYScale, getXValue, getYValue, lineD3, lineTypeMap, serie, xScale]);
|
|
59
|
+
const xTranslate = (0, import_react.useMemo)(() => (xScale?.bandwidth?.() ?? 0) / 2, [xScale]);
|
|
55
60
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("g", {
|
|
56
61
|
transform: `translate(${xTranslate}, 0)`,
|
|
57
62
|
children: [
|
|
58
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
59
|
-
|
|
60
|
-
stroke: colorScale(serie.name)
|
|
63
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("g", {
|
|
64
|
+
ref
|
|
61
65
|
}),
|
|
62
66
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Points.Points, {
|
|
63
67
|
serie
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/graphs/Chart/series/Line.tsx", "../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import React, { useContext, useMemo,
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB;AAAA,
|
|
4
|
+
"sourcesContent": ["import React, { useContext, useEffect, useMemo, useRef } from 'react';\nimport { line, curveNatural, easeLinear, transition, curveLinear, select } from 'd3';\nimport { Points } from './Points';\nimport { ChartContext } from '../ChartContext';\n\nexport const Line = ({ serie }) => {\n const { xScale, yScale, y2Scale, colorScale, getXValue, getYValue } = useContext(ChartContext);\n\n const ref = useRef<React.SVGProps<SVGGElement> | SVGGElement>(null);\n const firstRender = useRef(true);\n\n const finalYScale = useMemo(() => (serie.scale === 'y2' ? y2Scale : yScale), [serie.scale, y2Scale, yScale]);\n const lineTypeMap = useMemo(\n () => ({\n line: curveLinear,\n spline: curveNatural,\n }),\n [],\n );\n\n const lineD3 = useMemo(\n () =>\n line()\n .x((d) => xScale(getXValue(d)))\n .y((d) => finalYScale(getYValue(d)))\n .curve(lineTypeMap[serie.type] ?? curveLinear),\n [finalYScale, getXValue, getYValue, lineTypeMap, serie.type, xScale],\n );\n\n useEffect(() => {\n if (!ref.current) return;\n\n const groupContent = select(ref?.current);\n\n groupContent.selectAll('*').remove();\n const path = groupContent\n .append('path')\n .datum(serie.data)\n .attr('fill', 'none')\n .attr('stroke', colorScale(serie.name))\n .attr('stroke-linejoin', 'round')\n .attr('stroke-linecap', 'round')\n .attr('stroke-width', 2)\n .attr('d', lineD3);\n\n // const pathLength = path.node()?.getTotalLength();\n\n // if (firstRender?.current) {\n // const transitionPath = transition().ease(easeLinear).duration(800);\n\n // path\n // .attr('stroke-dashoffset', pathLength)\n // .attr('stroke-dasharray', pathLength)\n // .transition(transitionPath)\n // .attr('stroke-dashoffset', 0);\n\n // firstRender.current = false;\n // }\n }, [colorScale, finalYScale, getXValue, getYValue, lineD3, lineTypeMap, serie, xScale]);\n\n // we need to center the points and lines when\n // using them in a band axis context\n const xTranslate = useMemo(() => (xScale?.bandwidth?.() ?? 0) / 2, [xScale]);\n\n return (\n <g transform={`translate(${xTranslate}, 0)`}>\n <g ref={ref}></g>\n\n <Points serie={serie} />\n </g>\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB;AAAA,mBAA8D;AAC9D,gBAAgF;AAChF,oBAAuB;AACvB,0BAA6B;AAEtB,MAAM,OAAO,CAAC,EAAE,MAAM,MAAM;AACjC,QAAM,EAAE,QAAQ,QAAQ,SAAS,YAAY,WAAW,UAAU,QAAI,yBAAW,gCAAY;AAE7F,QAAM,UAAM,qBAAkD,IAAI;AAClE,QAAM,kBAAc,qBAAO,IAAI;AAE/B,QAAM,kBAAc,sBAAQ,MAAO,MAAM,UAAU,OAAO,UAAU,QAAS,CAAC,MAAM,OAAO,SAAS,MAAM,CAAC;AAC3G,QAAM,kBAAc;AAAA,IAClB,OAAO;AAAA,MACL,MAAM;AAAA,MACN,QAAQ;AAAA,IACV;AAAA,IACA,CAAC;AAAA,EACH;AAEA,QAAM,aAAS;AAAA,IACb,UACE,gBAAK,EACF,EAAE,CAAC,MAAM,OAAO,UAAU,CAAC,CAAC,CAAC,EAC7B,EAAE,CAAC,MAAM,YAAY,UAAU,CAAC,CAAC,CAAC,EAClC,MAAM,YAAY,MAAM,SAAS,qBAAW;AAAA,IACjD,CAAC,aAAa,WAAW,WAAW,aAAa,MAAM,MAAM,MAAM;AAAA,EACrE;AAEA,8BAAU,MAAM;AACd,QAAI,CAAC,IAAI;AAAS;AAElB,UAAM,mBAAe,kBAAO,KAAK,OAAO;AAExC,iBAAa,UAAU,GAAG,EAAE,OAAO;AACnC,UAAM,OAAO,aACV,OAAO,MAAM,EACb,MAAM,MAAM,IAAI,EAChB,KAAK,QAAQ,MAAM,EACnB,KAAK,UAAU,WAAW,MAAM,IAAI,CAAC,EACrC,KAAK,mBAAmB,OAAO,EAC/B,KAAK,kBAAkB,OAAO,EAC9B,KAAK,gBAAgB,CAAC,EACtB,KAAK,KAAK,MAAM;AAAA,EAerB,GAAG,CAAC,YAAY,aAAa,WAAW,WAAW,QAAQ,aAAa,OAAO,MAAM,CAAC;AAItF,QAAM,iBAAa,sBAAQ,OAAO,QAAQ,YAAY,KAAK,KAAK,GAAG,CAAC,MAAM,CAAC;AAE3E,SACE,6CAAC;AAAA,IAAE,WAAW,aAAa;AAAA,IACzB;AAAA,kDAAC;AAAA,QAAE;AAAA,OAAU;AAAA,MAEb,4CAAC;AAAA,QAAO;AAAA,OAAc;AAAA;AAAA,GACxB;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -30,38 +30,108 @@ module.exports = __toCommonJS(Point_exports);
|
|
|
30
30
|
var React = __toESM(require("react"));
|
|
31
31
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
32
32
|
var import_react = require("react");
|
|
33
|
-
var import_styles = require("../styles");
|
|
34
33
|
var import_ChartContext = require("../ChartContext");
|
|
35
|
-
|
|
34
|
+
var import_constants = require("../../constants");
|
|
35
|
+
var import_FocusableRegion = require("../parts/FocusableRegion");
|
|
36
|
+
const Point = ({ x, y, xValue, yValue, name, pointStyle, pointRadius, id, opacity }) => {
|
|
36
37
|
const {
|
|
37
38
|
activePoint,
|
|
38
|
-
setActivePoint,
|
|
39
39
|
scrapperPosY,
|
|
40
40
|
scrapperPosX,
|
|
41
|
-
props: {
|
|
41
|
+
props: { scrapper, TooltipRenderer }
|
|
42
42
|
} = (0, import_react.useContext)(import_ChartContext.ChartContext);
|
|
43
43
|
const isFocused = (0, import_react.useMemo)(() => {
|
|
44
|
-
if (activePoint === id) {
|
|
44
|
+
if (activePoint?.key === id) {
|
|
45
45
|
return true;
|
|
46
46
|
}
|
|
47
|
-
if (scrapper?.type ===
|
|
47
|
+
if (scrapper?.type === import_constants.SCRAPPER.TYPE_HORIZONTAL) {
|
|
48
48
|
return y === scrapperPosY;
|
|
49
49
|
}
|
|
50
|
-
if (scrapper?.type ===
|
|
50
|
+
if (scrapper?.type === import_constants.SCRAPPER.TYPE_VERTICAL) {
|
|
51
51
|
return x === scrapperPosX;
|
|
52
52
|
}
|
|
53
53
|
return false;
|
|
54
54
|
}, [activePoint, id, scrapper, y, scrapperPosY, x, scrapperPosX]);
|
|
55
|
-
|
|
56
|
-
(
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
55
|
+
const point = (0, import_react.useMemo)(() => {
|
|
56
|
+
if (import_constants.LINE.POINT_STYLE.DIAMOND === pointStyle) {
|
|
57
|
+
const squareEdge = pointRadius * 2;
|
|
58
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("g", {
|
|
59
|
+
transform: "rotate(45)",
|
|
60
|
+
children: [
|
|
61
|
+
isFocused ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", {
|
|
62
|
+
x: -pointRadius - import_constants.FOCUS_RING.STROKE_WIDTH,
|
|
63
|
+
y: -pointRadius - import_constants.FOCUS_RING.STROKE_WIDTH,
|
|
64
|
+
width: squareEdge + import_constants.FOCUS_RING.STROKE_WIDTH * 2,
|
|
65
|
+
height: squareEdge + import_constants.FOCUS_RING.STROKE_WIDTH * 2,
|
|
66
|
+
fill: "none",
|
|
67
|
+
stroke: import_constants.FOCUS_RING.COLOR,
|
|
68
|
+
strokeWidth: import_constants.FOCUS_RING.STROKE_WIDTH
|
|
69
|
+
}) : null,
|
|
70
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", {
|
|
71
|
+
x: -pointRadius,
|
|
72
|
+
y: -pointRadius,
|
|
73
|
+
id: `${id}-mark`,
|
|
74
|
+
width: squareEdge,
|
|
75
|
+
height: squareEdge
|
|
76
|
+
})
|
|
77
|
+
]
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
if (import_constants.LINE.POINT_STYLE.SQUARE === pointStyle) {
|
|
81
|
+
const squareEdge = pointRadius * 2;
|
|
82
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("g", {
|
|
83
|
+
children: [
|
|
84
|
+
isFocused ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", {
|
|
85
|
+
x: -pointRadius - import_constants.FOCUS_RING.STROKE_WIDTH,
|
|
86
|
+
y: -pointRadius - import_constants.FOCUS_RING.STROKE_WIDTH,
|
|
87
|
+
width: squareEdge + import_constants.FOCUS_RING.STROKE_WIDTH * 2,
|
|
88
|
+
height: squareEdge + import_constants.FOCUS_RING.STROKE_WIDTH * 2,
|
|
89
|
+
fill: "none",
|
|
90
|
+
stroke: import_constants.FOCUS_RING.COLOR,
|
|
91
|
+
strokeWidth: import_constants.FOCUS_RING.STROKE_WIDTH
|
|
92
|
+
}) : null,
|
|
93
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", {
|
|
94
|
+
x: -pointRadius,
|
|
95
|
+
y: -pointRadius,
|
|
96
|
+
id: `${id}-mark`,
|
|
97
|
+
width: squareEdge,
|
|
98
|
+
height: squareEdge
|
|
99
|
+
})
|
|
100
|
+
]
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("g", {
|
|
104
|
+
children: [
|
|
105
|
+
isFocused ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("g", {
|
|
106
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", {
|
|
107
|
+
r: (pointRadius ?? import_constants.LINE.DEFAULT_POINT_RADIUS) + import_constants.FOCUS_RING.STROKE_WIDTH,
|
|
108
|
+
fill: "none",
|
|
109
|
+
stroke: import_constants.FOCUS_RING.COLOR,
|
|
110
|
+
strokeWidth: import_constants.FOCUS_RING.STROKE_WIDTH
|
|
111
|
+
})
|
|
112
|
+
}) : null,
|
|
113
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", {
|
|
114
|
+
id: `${id}-mark`,
|
|
115
|
+
r: pointRadius ?? (isFocused ? import_constants.LINE.DEFAULT_POINT_RADIUS : 0),
|
|
116
|
+
opacity
|
|
117
|
+
})
|
|
118
|
+
]
|
|
119
|
+
});
|
|
120
|
+
}, [id, isFocused, opacity, pointRadius, pointStyle]);
|
|
121
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("g", {
|
|
122
|
+
children: [
|
|
123
|
+
point,
|
|
124
|
+
activePoint?.key === id && TooltipRenderer ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_FocusableRegion.FocusableRegion, {
|
|
125
|
+
id,
|
|
126
|
+
width: pointRadius * 2,
|
|
127
|
+
height: pointRadius * 2,
|
|
128
|
+
pointRadius,
|
|
129
|
+
style: { transform: `translate(-${pointRadius}px, -${pointRadius}px)` },
|
|
130
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TooltipRenderer, {
|
|
131
|
+
data: [{ name, yValue, xValue }]
|
|
132
|
+
})
|
|
133
|
+
}) : ""
|
|
134
|
+
]
|
|
135
|
+
});
|
|
66
136
|
};
|
|
67
137
|
//# sourceMappingURL=Point.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/graphs/Chart/series/Point.tsx", "../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import React, { useContext, useMemo } from 'react';\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB;AAAA,mBAA2C;AAC3C,
|
|
4
|
+
"sourcesContent": ["import React, { useContext, useMemo } from 'react';\nimport { ChartContext } from '../ChartContext';\nimport { FOCUS_RING, SCRAPPER, LINE } from '../../constants';\nimport { FocusableRegion } from '../parts/FocusableRegion';\nexport const Point = ({ x, y, xValue, yValue, name, pointStyle, pointRadius, id, opacity }) => {\n const {\n activePoint,\n scrapperPosY,\n scrapperPosX,\n props: { scrapper, TooltipRenderer },\n } = useContext(ChartContext);\n const isFocused = useMemo(() => {\n if (activePoint?.key === id) {\n return true;\n }\n if (scrapper?.type === SCRAPPER.TYPE_HORIZONTAL) {\n return y === scrapperPosY;\n }\n if (scrapper?.type === SCRAPPER.TYPE_VERTICAL) {\n return x === scrapperPosX;\n }\n return false;\n }, [activePoint, id, scrapper, y, scrapperPosY, x, scrapperPosX]);\n\n const point = useMemo(() => {\n if (LINE.POINT_STYLE.DIAMOND === pointStyle) {\n const squareEdge = pointRadius * 2;\n\n return (\n <g transform=\"rotate(45)\">\n {isFocused ? (\n <rect\n x={-pointRadius - FOCUS_RING.STROKE_WIDTH}\n y={-pointRadius - FOCUS_RING.STROKE_WIDTH}\n width={squareEdge + FOCUS_RING.STROKE_WIDTH * 2}\n height={squareEdge + FOCUS_RING.STROKE_WIDTH * 2}\n fill=\"none\"\n stroke={FOCUS_RING.COLOR}\n strokeWidth={FOCUS_RING.STROKE_WIDTH}\n ></rect>\n ) : null}\n <rect x={-pointRadius} y={-pointRadius} id={`${id}-mark`} width={squareEdge} height={squareEdge}></rect>\n </g>\n );\n }\n if (LINE.POINT_STYLE.SQUARE === pointStyle) {\n const squareEdge = pointRadius * 2;\n\n return (\n <g>\n {isFocused ? (\n <rect\n x={-pointRadius - FOCUS_RING.STROKE_WIDTH}\n y={-pointRadius - FOCUS_RING.STROKE_WIDTH}\n width={squareEdge + FOCUS_RING.STROKE_WIDTH * 2}\n height={squareEdge + FOCUS_RING.STROKE_WIDTH * 2}\n fill=\"none\"\n stroke={FOCUS_RING.COLOR}\n strokeWidth={FOCUS_RING.STROKE_WIDTH}\n ></rect>\n ) : null}\n <rect x={-pointRadius} y={-pointRadius} id={`${id}-mark`} width={squareEdge} height={squareEdge}></rect>\n </g>\n );\n }\n\n return (\n <g>\n {isFocused ? (\n <g>\n <circle\n r={(pointRadius ?? LINE.DEFAULT_POINT_RADIUS) + FOCUS_RING.STROKE_WIDTH}\n fill=\"none\"\n // data-z-index=\"99\"\n stroke={FOCUS_RING.COLOR}\n strokeWidth={FOCUS_RING.STROKE_WIDTH}\n ></circle>\n </g>\n ) : null}\n <circle\n id={`${id}-mark`}\n r={pointRadius ?? (isFocused ? LINE.DEFAULT_POINT_RADIUS : 0)}\n opacity={opacity}\n ></circle>\n </g>\n );\n }, [id, isFocused, opacity, pointRadius, pointStyle]);\n\n return (\n <g>\n {point}\n {activePoint?.key === id && TooltipRenderer ? (\n <FocusableRegion\n id={id}\n width={pointRadius * 2}\n height={pointRadius * 2}\n pointRadius={pointRadius}\n style={{ transform: `translate(-${pointRadius}px, -${pointRadius}px)` }}\n content={<TooltipRenderer data={[{ name, yValue, xValue }]} />}\n />\n ) : (\n ''\n )}\n </g>\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB;AAAA,mBAA2C;AAC3C,0BAA6B;AAC7B,uBAA2C;AAC3C,6BAAgC;AACzB,MAAM,QAAQ,CAAC,EAAE,GAAG,GAAG,QAAQ,QAAQ,MAAM,YAAY,aAAa,IAAI,QAAQ,MAAM;AAC7F,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO,EAAE,UAAU,gBAAgB;AAAA,EACrC,QAAI,yBAAW,gCAAY;AAC3B,QAAM,gBAAY,sBAAQ,MAAM;AAC9B,QAAI,aAAa,QAAQ,IAAI;AAC3B,aAAO;AAAA,IACT;AACA,QAAI,UAAU,SAAS,0BAAS,iBAAiB;AAC/C,aAAO,MAAM;AAAA,IACf;AACA,QAAI,UAAU,SAAS,0BAAS,eAAe;AAC7C,aAAO,MAAM;AAAA,IACf;AACA,WAAO;AAAA,EACT,GAAG,CAAC,aAAa,IAAI,UAAU,GAAG,cAAc,GAAG,YAAY,CAAC;AAEhE,QAAM,YAAQ,sBAAQ,MAAM;AAC1B,QAAI,sBAAK,YAAY,YAAY,YAAY;AAC3C,YAAM,aAAa,cAAc;AAEjC,aACE,6CAAC;AAAA,QAAE,WAAU;AAAA,QACV;AAAA,sBACC,4CAAC;AAAA,YACC,GAAG,CAAC,cAAc,4BAAW;AAAA,YAC7B,GAAG,CAAC,cAAc,4BAAW;AAAA,YAC7B,OAAO,aAAa,4BAAW,eAAe;AAAA,YAC9C,QAAQ,aAAa,4BAAW,eAAe;AAAA,YAC/C,MAAK;AAAA,YACL,QAAQ,4BAAW;AAAA,YACnB,aAAa,4BAAW;AAAA,WACzB,IACC;AAAA,UACJ,4CAAC;AAAA,YAAK,GAAG,CAAC;AAAA,YAAa,GAAG,CAAC;AAAA,YAAa,IAAI,GAAG;AAAA,YAAW,OAAO;AAAA,YAAY,QAAQ;AAAA,WAAY;AAAA;AAAA,OACnG;AAAA,IAEJ;AACA,QAAI,sBAAK,YAAY,WAAW,YAAY;AAC1C,YAAM,aAAa,cAAc;AAEjC,aACE,6CAAC;AAAA,QACE;AAAA,sBACC,4CAAC;AAAA,YACC,GAAG,CAAC,cAAc,4BAAW;AAAA,YAC7B,GAAG,CAAC,cAAc,4BAAW;AAAA,YAC7B,OAAO,aAAa,4BAAW,eAAe;AAAA,YAC9C,QAAQ,aAAa,4BAAW,eAAe;AAAA,YAC/C,MAAK;AAAA,YACL,QAAQ,4BAAW;AAAA,YACnB,aAAa,4BAAW;AAAA,WACzB,IACC;AAAA,UACJ,4CAAC;AAAA,YAAK,GAAG,CAAC;AAAA,YAAa,GAAG,CAAC;AAAA,YAAa,IAAI,GAAG;AAAA,YAAW,OAAO;AAAA,YAAY,QAAQ;AAAA,WAAY;AAAA;AAAA,OACnG;AAAA,IAEJ;AAEA,WACE,6CAAC;AAAA,MACE;AAAA,oBACC,4CAAC;AAAA,UACC,sDAAC;AAAA,YACC,IAAI,eAAe,sBAAK,wBAAwB,4BAAW;AAAA,YAC3D,MAAK;AAAA,YAEL,QAAQ,4BAAW;AAAA,YACnB,aAAa,4BAAW;AAAA,WACzB;AAAA,SACH,IACE;AAAA,QACJ,4CAAC;AAAA,UACC,IAAI,GAAG;AAAA,UACP,GAAG,gBAAgB,YAAY,sBAAK,uBAAuB;AAAA,UAC3D;AAAA,SACD;AAAA;AAAA,KACH;AAAA,EAEJ,GAAG,CAAC,IAAI,WAAW,SAAS,aAAa,UAAU,CAAC;AAEpD,SACE,6CAAC;AAAA,IACE;AAAA;AAAA,MACA,aAAa,QAAQ,MAAM,kBAC1B,4CAAC;AAAA,QACC;AAAA,QACA,OAAO,cAAc;AAAA,QACrB,QAAQ,cAAc;AAAA,QACtB;AAAA,QACA,OAAO,EAAE,WAAW,cAAc,mBAAmB,iBAAiB;AAAA,QACtE,SAAS,4CAAC;AAAA,UAAgB,MAAM,CAAC,EAAE,MAAM,QAAQ,OAAO,CAAC;AAAA,SAAG;AAAA,OAC9D,IAEA;AAAA;AAAA,GAEJ;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -32,15 +32,17 @@ var import_jsx_runtime = require("react/jsx-runtime");
|
|
|
32
32
|
var import_react = require("react");
|
|
33
33
|
var import_Point = require("./Point");
|
|
34
34
|
var import_ChartContext = require("../ChartContext");
|
|
35
|
-
var
|
|
35
|
+
var import_helpers = require("../helpers");
|
|
36
36
|
const Points = ({ serie }) => {
|
|
37
37
|
const {
|
|
38
38
|
colorScale,
|
|
39
39
|
xScale,
|
|
40
40
|
y2Scale,
|
|
41
41
|
yScale,
|
|
42
|
+
getXValue,
|
|
43
|
+
getYValue,
|
|
42
44
|
stackedData,
|
|
43
|
-
props: {
|
|
45
|
+
props: { types }
|
|
44
46
|
} = (0, import_react.useContext)(import_ChartContext.ChartContext);
|
|
45
47
|
const finalYScale = serie.scale === "y2" ? y2Scale : yScale;
|
|
46
48
|
const opacity = (0, import_react.useMemo)(() => types === "scatter" ? 0.8 : 1, [serie.type]);
|
|
@@ -48,36 +50,30 @@ const Points = ({ serie }) => {
|
|
|
48
50
|
() => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("g", {
|
|
49
51
|
fill: colorScale(serie.name),
|
|
50
52
|
children: serie.data.map((point, i) => {
|
|
51
|
-
const { pointRadius } = serie;
|
|
52
|
-
const
|
|
53
|
-
const
|
|
53
|
+
const { pointRadius, pointStyle } = serie;
|
|
54
|
+
const serieWithStackedValues = (0, import_helpers.getStackedData)(stackedData, serie);
|
|
55
|
+
const deltaY = serieWithStackedValues ? serieWithStackedValues[i][0] : 0;
|
|
56
|
+
const x = getXValue(point);
|
|
57
|
+
const y = getYValue(point);
|
|
54
58
|
const xPosition = xScale(x);
|
|
55
|
-
const yPosition = finalYScale(y);
|
|
56
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.
|
|
59
|
+
const yPosition = finalYScale(y + deltaY);
|
|
60
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("g", {
|
|
57
61
|
transform: `translate(${xPosition},${yPosition})`,
|
|
58
|
-
children:
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
height: pointRadius * 2,
|
|
70
|
-
pointRadius,
|
|
71
|
-
style: { transform: `translate(-${pointRadius}px, -${pointRadius}px)` },
|
|
72
|
-
content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TooltipRenderer, {
|
|
73
|
-
data: [{ name: serie.name, yValue: y, xValue: x }]
|
|
74
|
-
})
|
|
75
|
-
})
|
|
76
|
-
]
|
|
62
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Point.Point, {
|
|
63
|
+
pointRadius,
|
|
64
|
+
id: point.key,
|
|
65
|
+
opacity,
|
|
66
|
+
x: xPosition + (xScale.bandwidth?.() ?? 0) / 2,
|
|
67
|
+
y: yPosition,
|
|
68
|
+
xValue: x,
|
|
69
|
+
yValue: y,
|
|
70
|
+
pointStyle,
|
|
71
|
+
name: serie.name
|
|
72
|
+
})
|
|
77
73
|
}, `${point.key}-p`);
|
|
78
74
|
})
|
|
79
75
|
}),
|
|
80
|
-
[
|
|
76
|
+
[colorScale, finalYScale, getXValue, getYValue, opacity, serie, stackedData, xScale]
|
|
81
77
|
);
|
|
82
78
|
return render;
|
|
83
79
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/graphs/Chart/series/Points.tsx", "../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable complexity */\nimport React, { useMemo, useContext } from 'react';\nimport { Point } from './Point';\nimport { ChartContext } from '../ChartContext';\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB;AACA,mBAA2C;AAC3C,mBAAsB;AACtB,0BAA6B;
|
|
4
|
+
"sourcesContent": ["/* eslint-disable complexity */\nimport React, { useMemo, useContext } from 'react';\nimport { Point } from './Point';\nimport { ChartContext } from '../ChartContext';\nimport { getStackedData } from '../helpers';\n\nexport const Points = ({ serie }) => {\n const {\n colorScale,\n xScale,\n y2Scale,\n yScale,\n getXValue,\n getYValue,\n stackedData,\n props: { types },\n } = useContext(ChartContext);\n const finalYScale = serie.scale === 'y2' ? y2Scale : yScale;\n\n const opacity = useMemo(() => (types === 'scatter' ? 0.8 : 1), [serie.type]);\n const render = useMemo(\n () => (\n <g fill={colorScale(serie.name)}>\n {serie.data.map((point, i) => {\n const { pointRadius, pointStyle } = serie;\n // we need to recalculate the height with stacked data if is an AREA STACKED ELEMENT\n const serieWithStackedValues = getStackedData(stackedData, serie);\n const deltaY = serieWithStackedValues ? serieWithStackedValues[i][0] : 0;\n const x = getXValue(point);\n const y = getYValue(point);\n const xPosition = xScale(x);\n const yPosition = finalYScale(y + deltaY);\n\n return (\n <g key={`${point.key}-p`} transform={`translate(${xPosition},${yPosition})`}>\n <Point\n pointRadius={pointRadius}\n id={point.key}\n opacity={opacity}\n x={xPosition + (xScale.bandwidth?.() ?? 0) / 2}\n y={yPosition}\n xValue={x}\n yValue={y}\n pointStyle={pointStyle}\n name={serie.name}\n />\n </g>\n );\n })}\n </g>\n ),\n [colorScale, finalYScale, getXValue, getYValue, opacity, serie, stackedData, xScale],\n );\n return render;\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB;AACA,mBAA2C;AAC3C,mBAAsB;AACtB,0BAA6B;AAC7B,qBAA+B;AAExB,MAAM,SAAS,CAAC,EAAE,MAAM,MAAM;AACnC,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO,EAAE,MAAM;AAAA,EACjB,QAAI,yBAAW,gCAAY;AAC3B,QAAM,cAAc,MAAM,UAAU,OAAO,UAAU;AAErD,QAAM,cAAU,sBAAQ,MAAO,UAAU,YAAY,MAAM,GAAI,CAAC,MAAM,IAAI,CAAC;AAC3E,QAAM,aAAS;AAAA,IACb,MACE,4CAAC;AAAA,MAAE,MAAM,WAAW,MAAM,IAAI;AAAA,MAC3B,gBAAM,KAAK,IAAI,CAAC,OAAO,MAAM;AAC5B,cAAM,EAAE,aAAa,WAAW,IAAI;AAEpC,cAAM,6BAAyB,+BAAe,aAAa,KAAK;AAChE,cAAM,SAAS,yBAAyB,uBAAuB,GAAG,KAAK;AACvE,cAAM,IAAI,UAAU,KAAK;AACzB,cAAM,IAAI,UAAU,KAAK;AACzB,cAAM,YAAY,OAAO,CAAC;AAC1B,cAAM,YAAY,YAAY,IAAI,MAAM;AAExC,eACE,4CAAC;AAAA,UAAyB,WAAW,aAAa,aAAa;AAAA,UAC7D,sDAAC;AAAA,YACC;AAAA,YACA,IAAI,MAAM;AAAA,YACV;AAAA,YACA,GAAG,aAAa,OAAO,YAAY,KAAK,KAAK;AAAA,YAC7C,GAAG;AAAA,YACH,QAAQ;AAAA,YACR,QAAQ;AAAA,YACR;AAAA,YACA,MAAM,MAAM;AAAA,WACd;AAAA,WAXM,GAAG,MAAM,OAYjB;AAAA,MAEJ,CAAC;AAAA,KACH;AAAA,IAEF,CAAC,YAAY,aAAa,WAAW,WAAW,SAAS,OAAO,aAAa,MAAM;AAAA,EACrF;AACA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|