@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
|
@@ -30,18 +30,115 @@ module.exports = __toCommonJS(Rect_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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
var import_constants = require("../../constants");
|
|
35
|
+
var import_FocusableRegion = require("../parts/FocusableRegion");
|
|
36
|
+
const Rect = ({ name, width, height, isNegative = false, x = null, y = null, id, xValue, yValue }) => {
|
|
37
|
+
const {
|
|
38
|
+
activePoint,
|
|
39
|
+
isGrabbed,
|
|
40
|
+
chartId,
|
|
41
|
+
isHorizontal,
|
|
42
|
+
innerWidth,
|
|
43
|
+
yScale,
|
|
44
|
+
innerHeight,
|
|
45
|
+
props: { TooltipRenderer }
|
|
46
|
+
} = (0, import_react.useContext)(import_ChartContext.ChartContext);
|
|
47
|
+
const isFocused = activePoint?.key === id;
|
|
48
|
+
const animation = (0, import_react.useMemo)(() => {
|
|
49
|
+
if (isGrabbed)
|
|
50
|
+
return null;
|
|
51
|
+
if (isHorizontal)
|
|
52
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("animate", {
|
|
53
|
+
attributeName: "x",
|
|
54
|
+
from: -innerWidth,
|
|
55
|
+
to: x,
|
|
56
|
+
dur: "0.4s",
|
|
57
|
+
fill: "both"
|
|
58
|
+
});
|
|
59
|
+
if (isNegative)
|
|
60
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("animate", {
|
|
61
|
+
attributeName: "y",
|
|
62
|
+
from: yScale(0),
|
|
63
|
+
to: -y,
|
|
64
|
+
dur: "0.40s",
|
|
65
|
+
fill: "both"
|
|
66
|
+
});
|
|
67
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("animate", {
|
|
68
|
+
attributeName: "y",
|
|
69
|
+
from: -innerHeight - y,
|
|
70
|
+
to: -y,
|
|
71
|
+
dur: "0.40s",
|
|
72
|
+
fill: "both"
|
|
73
|
+
});
|
|
74
|
+
}, [innerHeight, innerWidth, isGrabbed, isHorizontal, isNegative, x, y, yScale]);
|
|
75
|
+
const clipPathSign = (0, import_react.useMemo)(() => {
|
|
76
|
+
if (isHorizontal)
|
|
77
|
+
return "";
|
|
78
|
+
if (isNegative)
|
|
79
|
+
return `url(#rects-negative-${chartId})`;
|
|
80
|
+
return `url(#rects-positive-${chartId})`;
|
|
81
|
+
}, [chartId, isHorizontal, isNegative]);
|
|
82
|
+
const transform = (0, import_react.useMemo)(() => {
|
|
83
|
+
if (isHorizontal)
|
|
84
|
+
return ``;
|
|
85
|
+
return `scale(1,-1) translate(0,${-height})`;
|
|
86
|
+
}, [height, isHorizontal]);
|
|
38
87
|
return (0, import_react.useMemo)(
|
|
39
|
-
() => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
88
|
+
() => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("g", {
|
|
89
|
+
clipPath: clipPathSign,
|
|
90
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("g", {
|
|
91
|
+
id: isFocused ? `data-focused-${chartId}` : "",
|
|
92
|
+
transform,
|
|
93
|
+
children: [
|
|
94
|
+
isFocused ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", {
|
|
95
|
+
x: (isHorizontal ? x : 0) - import_constants.FOCUS_RING.STROKE_WIDTH,
|
|
96
|
+
y: (!isHorizontal ? -y : 0) - import_constants.FOCUS_RING.STROKE_WIDTH,
|
|
97
|
+
width: width + import_constants.FOCUS_RING.OFFSET,
|
|
98
|
+
height: height + import_constants.FOCUS_RING.OFFSET,
|
|
99
|
+
fill: "none",
|
|
100
|
+
rx: "1",
|
|
101
|
+
ry: "1",
|
|
102
|
+
stroke: import_constants.FOCUS_RING.COLOR,
|
|
103
|
+
strokeWidth: import_constants.FOCUS_RING.STROKE_WIDTH
|
|
104
|
+
}) : null,
|
|
105
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", {
|
|
106
|
+
width,
|
|
107
|
+
height,
|
|
108
|
+
y: -y,
|
|
109
|
+
x
|
|
110
|
+
}),
|
|
111
|
+
activePoint?.key === id && TooltipRenderer ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_FocusableRegion.FocusableRegion, {
|
|
112
|
+
id,
|
|
113
|
+
y,
|
|
114
|
+
x,
|
|
115
|
+
width,
|
|
116
|
+
height,
|
|
117
|
+
transform,
|
|
118
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TooltipRenderer, {
|
|
119
|
+
data: [{ name, yValue, xValue }]
|
|
120
|
+
})
|
|
121
|
+
}) : ""
|
|
122
|
+
]
|
|
123
|
+
})
|
|
124
|
+
}),
|
|
125
|
+
[
|
|
126
|
+
clipPathSign,
|
|
127
|
+
isFocused,
|
|
128
|
+
chartId,
|
|
129
|
+
transform,
|
|
130
|
+
isHorizontal,
|
|
131
|
+
x,
|
|
132
|
+
y,
|
|
40
133
|
width,
|
|
41
134
|
height,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
135
|
+
activePoint?.key,
|
|
136
|
+
id,
|
|
137
|
+
TooltipRenderer,
|
|
138
|
+
name,
|
|
139
|
+
yValue,
|
|
140
|
+
xValue
|
|
141
|
+
]
|
|
45
142
|
);
|
|
46
143
|
};
|
|
47
144
|
//# sourceMappingURL=Rect.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/graphs/Chart/series/Rect.tsx", "../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import React, { useMemo, useContext } from 'react';\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB;AAAA,mBAA2C;AAC3C,
|
|
4
|
+
"sourcesContent": ["import React, { useMemo, useContext } from 'react';\nimport { ChartContext } from '../ChartContext';\nimport { FOCUS_RING } from '../../constants';\nimport { FocusableRegion } from '../parts/FocusableRegion';\nexport const Rect = ({ name, width, height, isNegative = false, x = null, y = null, id, xValue, yValue }) => {\n const {\n activePoint,\n isGrabbed,\n chartId,\n isHorizontal,\n innerWidth,\n yScale,\n innerHeight,\n props: { TooltipRenderer },\n } = useContext(ChartContext);\n\n const isFocused = activePoint?.key === id;\n\n const animation = useMemo(() => {\n if (isGrabbed) return null;\n if (isHorizontal) return <animate attributeName=\"x\" from={-innerWidth} to={x} dur=\"0.4s\" fill=\"both\" />;\n if (isNegative) return <animate attributeName=\"y\" from={yScale(0)} to={-y} dur=\"0.40s\" fill=\"both\" />;\n return <animate attributeName=\"y\" from={-innerHeight - y} to={-y} dur=\"0.40s\" fill=\"both\" />;\n }, [innerHeight, innerWidth, isGrabbed, isHorizontal, isNegative, x, y, yScale]);\n\n const clipPathSign = useMemo(() => {\n // @todo horizontal clip paths\n if (isHorizontal) return '';\n if (isNegative) return `url(#rects-negative-${chartId})`;\n return `url(#rects-positive-${chartId})`;\n }, [chartId, isHorizontal, isNegative]);\n\n const transform = useMemo(() => {\n if (isHorizontal) return ``;\n return `scale(1,-1) translate(0,${-height})`;\n }, [height, isHorizontal]);\n return useMemo(\n () => (\n <g clipPath={clipPathSign}>\n <g id={isFocused ? `data-focused-${chartId}` : ''} transform={transform}>\n {isFocused ? (\n <rect\n x={(isHorizontal ? x : 0) - FOCUS_RING.STROKE_WIDTH}\n y={(!isHorizontal ? -y : 0) - FOCUS_RING.STROKE_WIDTH}\n width={width + FOCUS_RING.OFFSET}\n height={height + FOCUS_RING.OFFSET}\n fill=\"none\"\n rx=\"1\"\n ry=\"1\"\n stroke={FOCUS_RING.COLOR}\n strokeWidth={FOCUS_RING.STROKE_WIDTH}\n ></rect>\n ) : null}\n <rect width={width} height={height} y={-y} x={x}>\n {/* {animation} */}\n </rect>\n {activePoint?.key === id && TooltipRenderer ? (\n <FocusableRegion\n id={id}\n y={y}\n x={x}\n width={width}\n height={height}\n transform={transform}\n content={<TooltipRenderer data={[{ name, yValue, xValue }]} />}\n />\n ) : (\n ''\n )}\n </g>\n </g>\n ),\n [\n clipPathSign,\n isFocused,\n chartId,\n transform,\n isHorizontal,\n x,\n y,\n width,\n height,\n // animation,\n activePoint?.key,\n id,\n TooltipRenderer,\n name,\n yValue,\n xValue,\n ],\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,uBAA2B;AAC3B,6BAAgC;AACzB,MAAM,OAAO,CAAC,EAAE,MAAM,OAAO,QAAQ,aAAa,OAAO,IAAI,MAAM,IAAI,MAAM,IAAI,QAAQ,OAAO,MAAM;AAC3G,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO,EAAE,gBAAgB;AAAA,EAC3B,QAAI,yBAAW,gCAAY;AAE3B,QAAM,YAAY,aAAa,QAAQ;AAEvC,QAAM,gBAAY,sBAAQ,MAAM;AAC9B,QAAI;AAAW,aAAO;AACtB,QAAI;AAAc,aAAO,4CAAC;AAAA,QAAQ,eAAc;AAAA,QAAI,MAAM,CAAC;AAAA,QAAY,IAAI;AAAA,QAAG,KAAI;AAAA,QAAO,MAAK;AAAA,OAAO;AACrG,QAAI;AAAY,aAAO,4CAAC;AAAA,QAAQ,eAAc;AAAA,QAAI,MAAM,OAAO,CAAC;AAAA,QAAG,IAAI,CAAC;AAAA,QAAG,KAAI;AAAA,QAAQ,MAAK;AAAA,OAAO;AACnG,WAAO,4CAAC;AAAA,MAAQ,eAAc;AAAA,MAAI,MAAM,CAAC,cAAc;AAAA,MAAG,IAAI,CAAC;AAAA,MAAG,KAAI;AAAA,MAAQ,MAAK;AAAA,KAAO;AAAA,EAC5F,GAAG,CAAC,aAAa,YAAY,WAAW,cAAc,YAAY,GAAG,GAAG,MAAM,CAAC;AAE/E,QAAM,mBAAe,sBAAQ,MAAM;AAEjC,QAAI;AAAc,aAAO;AACzB,QAAI;AAAY,aAAO,uBAAuB;AAC9C,WAAO,uBAAuB;AAAA,EAChC,GAAG,CAAC,SAAS,cAAc,UAAU,CAAC;AAEtC,QAAM,gBAAY,sBAAQ,MAAM;AAC9B,QAAI;AAAc,aAAO;AACzB,WAAO,2BAA2B,CAAC;AAAA,EACrC,GAAG,CAAC,QAAQ,YAAY,CAAC;AACzB,aAAO;AAAA,IACL,MACE,4CAAC;AAAA,MAAE,UAAU;AAAA,MACX,uDAAC;AAAA,QAAE,IAAI,YAAY,gBAAgB,YAAY;AAAA,QAAI;AAAA,QAChD;AAAA,sBACC,4CAAC;AAAA,YACC,IAAI,eAAe,IAAI,KAAK,4BAAW;AAAA,YACvC,IAAI,CAAC,eAAe,CAAC,IAAI,KAAK,4BAAW;AAAA,YACzC,OAAO,QAAQ,4BAAW;AAAA,YAC1B,QAAQ,SAAS,4BAAW;AAAA,YAC5B,MAAK;AAAA,YACL,IAAG;AAAA,YACH,IAAG;AAAA,YACH,QAAQ,4BAAW;AAAA,YACnB,aAAa,4BAAW;AAAA,WACzB,IACC;AAAA,UACJ,4CAAC;AAAA,YAAK;AAAA,YAAc;AAAA,YAAgB,GAAG,CAAC;AAAA,YAAG;AAAA,WAE3C;AAAA,UACC,aAAa,QAAQ,MAAM,kBAC1B,4CAAC;AAAA,YACC;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA,SAAS,4CAAC;AAAA,cAAgB,MAAM,CAAC,EAAE,MAAM,QAAQ,OAAO,CAAC;AAAA,aAAG;AAAA,WAC9D,IAEA;AAAA;AAAA,OAEJ;AAAA,KACF;AAAA,IAEF;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MAEA,aAAa;AAAA,MACb;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -33,48 +33,41 @@ var import_react = require("react");
|
|
|
33
33
|
var import_Rect = require("./Rect");
|
|
34
34
|
var import_ChartContext = require("../ChartContext");
|
|
35
35
|
var import_helpers = require("../helpers");
|
|
36
|
-
var import_FocusableRegion = require("../parts/FocusableRegion");
|
|
37
36
|
const StackedBar = ({ serie }) => {
|
|
38
37
|
const {
|
|
39
|
-
props: {
|
|
38
|
+
props: { groups },
|
|
40
39
|
xScale,
|
|
41
40
|
yScale,
|
|
42
41
|
stackedData,
|
|
43
42
|
subGroupScale,
|
|
44
|
-
colorScale
|
|
43
|
+
colorScale,
|
|
44
|
+
chartId,
|
|
45
|
+
getXValue
|
|
45
46
|
} = (0, import_react.useContext)(import_ChartContext.ChartContext);
|
|
46
|
-
const isHorizontal = !!yScale.bandwidth;
|
|
47
47
|
const serieWithStackedValues = (0, import_helpers.getStackedData)(stackedData, serie);
|
|
48
48
|
const stackIndex = (0, import_helpers.getStackedIndex)(groups, serie.name);
|
|
49
49
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("g", {
|
|
50
|
+
clipPath: `url(#rect-focus-ring-${chartId})`,
|
|
50
51
|
children: serieWithStackedValues.map((sequence, i) => {
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
const
|
|
56
|
-
const
|
|
57
|
-
|
|
52
|
+
const isFloorStack = sequence[0] === 0;
|
|
53
|
+
const xValue = getXValue(serie.data[i]);
|
|
54
|
+
const yValue = sequence[0] - sequence[1];
|
|
55
|
+
const width = subGroupScale?.bandwidth();
|
|
56
|
+
const height = yScale(sequence[0]) - yScale(sequence[1]) - (!isFloorStack ? 1 : 0);
|
|
57
|
+
const transformX = xScale(xValue) + subGroupScale(`stacked-data-${stackIndex}`);
|
|
58
|
+
const transformY = yScale(sequence[1]);
|
|
59
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("g", {
|
|
58
60
|
fill: colorScale(serie.name),
|
|
59
|
-
transform: `translate(${transformX},
|
|
60
|
-
children:
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
TooltipRenderer && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_FocusableRegion.FocusableRegion, {
|
|
70
|
-
id: serie.data[i].key,
|
|
71
|
-
width,
|
|
72
|
-
height,
|
|
73
|
-
content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TooltipRenderer, {
|
|
74
|
-
data: [{ name: serie.name, yValue, xValue }]
|
|
75
|
-
})
|
|
76
|
-
})
|
|
77
|
-
]
|
|
61
|
+
transform: `translate(${transformX},0)`,
|
|
62
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Rect.Rect, {
|
|
63
|
+
width,
|
|
64
|
+
height,
|
|
65
|
+
xValue,
|
|
66
|
+
yValue,
|
|
67
|
+
y: transformY,
|
|
68
|
+
id: serie.data[i].key,
|
|
69
|
+
name: serie.name
|
|
70
|
+
})
|
|
78
71
|
}, serie.data[i].key);
|
|
79
72
|
})
|
|
80
73
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/graphs/Chart/series/StackedBar.tsx", "../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB;
|
|
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 StackedBar = ({ serie }) => {\n const {\n props: { groups },\n xScale,\n yScale,\n stackedData,\n subGroupScale,\n colorScale,\n chartId,\n getXValue,\n } = useContext(ChartContext);\n\n const serieWithStackedValues = getStackedData(stackedData, serie);\n const stackIndex = getStackedIndex(groups, serie.name);\n return (\n <g clipPath={`url(#rect-focus-ring-${chartId})`}>\n {serieWithStackedValues.map((sequence, i) => {\n const isFloorStack = sequence[0] === 0;\n\n const xValue = getXValue(serie.data[i]);\n const yValue = sequence[0] - sequence[1];\n const width = subGroupScale?.bandwidth();\n const height = yScale(sequence[0]) - yScale(sequence[1]) - (!isFloorStack ? 1 : 0);\n const transformX = xScale(xValue) + subGroupScale(`stacked-data-${stackIndex}`);\n const transformY = yScale(sequence[1]);\n\n return (\n <g key={serie.data[i].key} fill={colorScale(serie.name)} transform={`translate(${transformX},0)`}>\n <Rect\n width={width}\n height={height}\n xValue={xValue}\n yValue={yValue}\n y={transformY}\n id={serie.data[i].key}\n name={serie.name}\n />\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,aAAa,CAAC,EAAE,MAAM,MAAM;AACvC,QAAM;AAAA,IACJ,OAAO,EAAE,OAAO;AAAA,IAChB;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,IAAE,UAAU,wBAAwB;AAAA,IAClC,iCAAuB,IAAI,CAAC,UAAU,MAAM;AAC3C,YAAM,eAAe,SAAS,OAAO;AAErC,YAAM,SAAS,UAAU,MAAM,KAAK,EAAE;AACtC,YAAM,SAAS,SAAS,KAAK,SAAS;AACtC,YAAM,QAAQ,eAAe,UAAU;AACvC,YAAM,SAAS,OAAO,SAAS,EAAE,IAAI,OAAO,SAAS,EAAE,KAAK,CAAC,eAAe,IAAI;AAChF,YAAM,aAAa,OAAO,MAAM,IAAI,cAAc,gBAAgB,YAAY;AAC9E,YAAM,aAAa,OAAO,SAAS,EAAE;AAErC,aACE,4CAAC;AAAA,QAA0B,MAAM,WAAW,MAAM,IAAI;AAAA,QAAG,WAAW,aAAa;AAAA,QAC/E,sDAAC;AAAA,UACC;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA,GAAG;AAAA,UACH,IAAI,MAAM,KAAK,GAAG;AAAA,UAClB,MAAM,MAAM;AAAA,SACd;AAAA,SATM,MAAM,KAAK,GAAG,GAUtB;AAAA,IAEJ,CAAC;AAAA,GACH;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -28,5 +28,4 @@ __reExport(series_exports, require("./StackedBar"), module.exports);
|
|
|
28
28
|
__reExport(series_exports, require("./Points"), module.exports);
|
|
29
29
|
__reExport(series_exports, require("./Line"), module.exports);
|
|
30
30
|
__reExport(series_exports, require("./Area"), module.exports);
|
|
31
|
-
__reExport(series_exports, require("./Pie"), module.exports);
|
|
32
31
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/graphs/Chart/series/index.tsx", "../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["export * from './Rect';\nexport * from './Bars';\nexport * from './StackedBar';\nexport * from './Points';\nexport * from './Line';\nexport * from './Area';\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;ACAA,YAAuB;ADAvB,2BAAc,mBAAd;AACA,2BAAc,mBADd;AAEA,2BAAc,yBAFd;AAGA,2BAAc,qBAHd;AAIA,2BAAc,mBAJd;AAKA,2BAAc,mBALd;
|
|
4
|
+
"sourcesContent": ["export * from './Rect';\nexport * from './Bars';\nexport * from './StackedBar';\nexport * from './Points';\nexport * from './Line';\nexport * from './Area';\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;ACAA,YAAuB;ADAvB,2BAAc,mBAAd;AACA,2BAAc,mBADd;AAEA,2BAAc,yBAFd;AAGA,2BAAc,qBAHd;AAIA,2BAAc,mBAJd;AAKA,2BAAc,mBALd;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -30,9 +30,7 @@ __export(styles_exports, {
|
|
|
30
30
|
StyledAxisLabel: () => StyledAxisLabel,
|
|
31
31
|
StyledGrid: () => StyledGrid,
|
|
32
32
|
StyledLine: () => StyledLine,
|
|
33
|
-
StyledMark: () => StyledMark,
|
|
34
33
|
StyledMouseOverDetectionBox: () => StyledMouseOverDetectionBox,
|
|
35
|
-
StyledPoint: () => StyledPoint,
|
|
36
34
|
StyledSVGWrapper: () => StyledSVGWrapper,
|
|
37
35
|
StyledTooltipContainer: () => StyledTooltipContainer
|
|
38
36
|
});
|
|
@@ -49,6 +47,10 @@ const StyledSVGWrapper = import_ds_system.styled.div`
|
|
|
49
47
|
}
|
|
50
48
|
|
|
51
49
|
cursor: ${({ isGrabbed }) => isGrabbed ? "grabbing" : "default"};
|
|
50
|
+
|
|
51
|
+
.domain {
|
|
52
|
+
stroke-width: 2px;
|
|
53
|
+
}
|
|
52
54
|
`;
|
|
53
55
|
const StyledAxis = (0, import_ds_system.styled)("g")`
|
|
54
56
|
text {
|
|
@@ -82,9 +84,6 @@ const borderCircle = import_ds_system.css`
|
|
|
82
84
|
stroke: #c64252;
|
|
83
85
|
stroke-width: 2;
|
|
84
86
|
`;
|
|
85
|
-
const StyledMark = (0, import_ds_system.styled)("rect")`
|
|
86
|
-
${({ isFocused }) => isFocused ? borderCircle : ""};
|
|
87
|
-
`;
|
|
88
87
|
const StyleFocusableRegion = (0, import_ds_system.styled)("div")`
|
|
89
88
|
width: ${({ s }) => s * 2}px;
|
|
90
89
|
height: ${({ s }) => s * 2}px;
|
|
@@ -102,23 +101,9 @@ const StyledArea = (0, import_ds_system.styled)("path")`
|
|
|
102
101
|
stroke-linejoin: round;
|
|
103
102
|
opacity: 0.8;
|
|
104
103
|
`;
|
|
105
|
-
const StyledPoint = (0, import_ds_system.styled)("circle")`
|
|
106
|
-
//opacity: ${({ isFocused }) => isFocused ? 1 : 0};
|
|
107
|
-
${({ isFocused }) => isFocused ? borderCircle : ""};
|
|
108
|
-
`;
|
|
109
104
|
const StyledTooltipContainer = import_ds_system.styled.div`
|
|
110
|
-
|
|
111
|
-
min-width: ${({ theme }) => theme.space.l};
|
|
112
|
-
max-width: 250px;
|
|
113
|
-
min-height: 30px;
|
|
114
|
-
display: grid;
|
|
115
|
-
align-items: center;
|
|
116
|
-
padding: ${({ theme }) => `${theme.space.xxxs} ${theme.space.xs}`};
|
|
117
|
-
position: relative;
|
|
105
|
+
max-width: 350px;
|
|
118
106
|
background-color: white;
|
|
119
|
-
border-radius: 2px;
|
|
120
|
-
font-size: 13px;
|
|
121
|
-
color: ${({ theme }) => theme.colors.neutral[600]};
|
|
122
107
|
`;
|
|
123
108
|
const StyledMouseOverDetectionBox = import_ds_system.styled.div`
|
|
124
109
|
position: absolute;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/graphs/Chart/styles.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import { styled, css } from '@elliemae/ds-system';\nimport { COLOR_PALLET } from './helpers/colorPallet';\nexport const StyledSVGWrapper = styled.div`\n :focus {\n outline: none;\n }\n :focus-within {\n outline: none;\n }\n\n cursor: ${({ isGrabbed }) => (isGrabbed ? 'grabbing' : 'default')};\n`;\n\nexport const StyledAxis = styled('g')`\n text {\n fill: #635f5d;\n }\n\n text.axis-label {\n /* font-size: 2.5em; */\n }\n\n .tick text {\n ${({ color }) => (color ? `fill: ${COLOR_PALLET[color] ?? color}` : '')}\n }\n .tick line {\n ${({ color }) => (color ? `stroke: ${COLOR_PALLET[color] ?? color}` : '')}\n }\n line {\n stroke: #c0c0bb;\n }\n`;\n\nexport const StyledAxisLabel = styled('text')`\n font-size: 13px;\n font-weight: 600;\n`;\n\nexport const StyledGrid = styled('g')`\n line {\n stroke: #c0c0bb;\n }\n`;\n\nconst borderCircle = css`\n stroke: #c64252;\n stroke-width: 2;\n`;\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["import { styled, css } from '@elliemae/ds-system';\nimport { COLOR_PALLET } from './helpers/colorPallet';\nexport const StyledSVGWrapper = styled.div`\n :focus {\n outline: none;\n }\n :focus-within {\n outline: none;\n }\n\n cursor: ${({ isGrabbed }) => (isGrabbed ? 'grabbing' : 'default')};\n\n .domain {\n stroke-width: 2px;\n }\n`;\n\nexport const StyledAxis = styled('g')`\n text {\n fill: #635f5d;\n }\n\n text.axis-label {\n /* font-size: 2.5em; */\n }\n\n .tick text {\n ${({ color }) => (color ? `fill: ${COLOR_PALLET[color] ?? color}` : '')}\n }\n .tick line {\n ${({ color }) => (color ? `stroke: ${COLOR_PALLET[color] ?? color}` : '')}\n }\n line {\n stroke: #c0c0bb;\n }\n`;\n\nexport const StyledAxisLabel = styled('text')`\n font-size: 13px;\n font-weight: 600;\n`;\n\nexport const StyledGrid = styled('g')`\n line {\n stroke: #c0c0bb;\n }\n`;\n\nconst borderCircle = css`\n stroke: #c64252;\n stroke-width: 2;\n`;\n\nexport const StyleFocusableRegion = styled('div')<{ s: number }>`\n width: ${({ s }) => s * 2 ?? '1'}px;\n height: ${({ s }) => s * 2 ?? '1'}px;\n :focus {\n outline: none;\n }\n`;\n\nexport const StyledLine = styled('path')`\n fill: none;\n stroke-width: ${({ isActiveLine }) => (isActiveLine ? 5 : 3)};\n stroke-linejoin: round;\n`;\nexport const StyledArea = styled('path')`\n stroke-width: ${({ isActiveLine }) => (isActiveLine ? 5 : 3)};\n stroke-linejoin: round;\n opacity: 0.8;\n`;\n\nexport const StyledTooltipContainer = styled.div`\n max-width: 350px;\n background-color: white;\n`;\n\nexport const StyledMouseOverDetectionBox = styled.div`\n position: absolute;\n top: -15px;\n right: -15px;\n width: calc(100% + 30px);\n height: calc(100% + 30px);\n z-index: -1;\n`;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,uBAA4B;AAC5B,yBAA6B;AACtB,MAAM,mBAAmB,wBAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAQ3B,CAAC,EAAE,UAAU,MAAO,YAAY,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAOlD,MAAM,iBAAa,yBAAO,GAAG;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAU9B,CAAC,EAAE,MAAM,MAAO,QAAQ,SAAS,gCAAa,UAAU,UAAU;AAAA;AAAA;AAAA,MAGlE,CAAC,EAAE,MAAM,MAAO,QAAQ,WAAW,gCAAa,UAAU,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAOnE,MAAM,sBAAkB,yBAAO,MAAM;AAAA;AAAA;AAAA;AAKrC,MAAM,iBAAa,yBAAO,GAAG;AAAA;AAAA;AAAA;AAAA;AAMpC,MAAM,eAAe;AAAA;AAAA;AAAA;AAKd,MAAM,2BAAuB,yBAAO,KAAK;AAAA,WACrC,CAAC,EAAE,EAAE,MAAM,IAAI;AAAA,YACd,CAAC,EAAE,EAAE,MAAM,IAAI;AAAA;AAAA;AAAA;AAAA;AAMpB,MAAM,iBAAa,yBAAO,MAAM;AAAA;AAAA,kBAErB,CAAC,EAAE,aAAa,MAAO,eAAe,IAAI;AAAA;AAAA;AAGrD,MAAM,iBAAa,yBAAO,MAAM;AAAA,kBACrB,CAAC,EAAE,aAAa,MAAO,eAAe,IAAI;AAAA;AAAA;AAAA;AAKrD,MAAM,yBAAyB,wBAAO;AAAA;AAAA;AAAA;AAKtC,MAAM,8BAA8B,wBAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -24,6 +24,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
24
24
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
25
|
var constants_exports = {};
|
|
26
26
|
__export(constants_exports, {
|
|
27
|
+
FOCUS_RING: () => FOCUS_RING,
|
|
28
|
+
LINE: () => LINE,
|
|
29
|
+
SCRAPPER: () => SCRAPPER,
|
|
27
30
|
TICK_FORMATS: () => TICK_FORMATS
|
|
28
31
|
});
|
|
29
32
|
module.exports = __toCommonJS(constants_exports);
|
|
@@ -34,4 +37,21 @@ const TICK_FORMATS = {
|
|
|
34
37
|
KSEPARATOR: (v) => (0, import_d3.format)(",")(v),
|
|
35
38
|
TIME: (userFormat) => (v) => (0, import_d3.timeFormat)(userFormat)(v)
|
|
36
39
|
};
|
|
40
|
+
const FOCUS_RING = {
|
|
41
|
+
COLOR: "#335cad",
|
|
42
|
+
STROKE_WIDTH: 2,
|
|
43
|
+
OFFSET: 4
|
|
44
|
+
};
|
|
45
|
+
const SCRAPPER = {
|
|
46
|
+
TYPE_HORIZONTAL: "horizontal",
|
|
47
|
+
TYPE_VERTICAL: "vertical"
|
|
48
|
+
};
|
|
49
|
+
const LINE = {
|
|
50
|
+
POINT_STYLE: {
|
|
51
|
+
CIRCLE: "CIRCLE",
|
|
52
|
+
SQUARE: "SQUARE",
|
|
53
|
+
DIAMOND: "DIAMOND"
|
|
54
|
+
},
|
|
55
|
+
DEFAULT_POINT_RADIUS: 4
|
|
56
|
+
};
|
|
37
57
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/graphs/constants.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import { format, timeFormat } from 'd3';\n\nexport const TICK_FORMATS = {\n MILLIONS: (v) => format('.2s')(v).replace('G', 'B'),\n KSEPARATOR: (v) => format(',')(v),\n TIME: (userFormat: string) => (v) => timeFormat(userFormat)(v),\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,gBAAmC;AAE5B,MAAM,eAAe;AAAA,EAC1B,UAAU,CAAC,UAAM,kBAAO,KAAK,EAAE,CAAC,EAAE,QAAQ,KAAK,GAAG;AAAA,EAClD,YAAY,CAAC,UAAM,kBAAO,GAAG,EAAE,CAAC;AAAA,EAChC,MAAM,CAAC,eAAuB,CAAC,UAAM,sBAAW,UAAU,EAAE,CAAC;AAC/D;",
|
|
4
|
+
"sourcesContent": ["import { format, timeFormat } from 'd3';\n\nexport const TICK_FORMATS = {\n MILLIONS: (v) => format('.2s')(v).replace('G', 'B'),\n KSEPARATOR: (v) => format(',')(v),\n TIME: (userFormat: string) => (v) => timeFormat(userFormat)(v),\n};\n\nexport const FOCUS_RING = {\n COLOR: '#335cad',\n STROKE_WIDTH: 2,\n OFFSET: 4,\n};\n\nexport const SCRAPPER = {\n TYPE_HORIZONTAL: 'horizontal',\n TYPE_VERTICAL: 'vertical',\n};\n\nexport const LINE = {\n POINT_STYLE: {\n CIRCLE: 'CIRCLE',\n SQUARE: 'SQUARE',\n DIAMOND: 'DIAMOND',\n },\n DEFAULT_POINT_RADIUS: 4,\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,gBAAmC;AAE5B,MAAM,eAAe;AAAA,EAC1B,UAAU,CAAC,UAAM,kBAAO,KAAK,EAAE,CAAC,EAAE,QAAQ,KAAK,GAAG;AAAA,EAClD,YAAY,CAAC,UAAM,kBAAO,GAAG,EAAE,CAAC;AAAA,EAChC,MAAM,CAAC,eAAuB,CAAC,UAAM,sBAAW,UAAU,EAAE,CAAC;AAC/D;AAEO,MAAM,aAAa;AAAA,EACxB,OAAO;AAAA,EACP,cAAc;AAAA,EACd,QAAQ;AACV;AAEO,MAAM,WAAW;AAAA,EACtB,iBAAiB;AAAA,EACjB,eAAe;AACjB;AAEO,MAAM,OAAO;AAAA,EAClB,aAAa;AAAA,IACX,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,SAAS;AAAA,EACX;AAAA,EACA,sBAAsB;AACxB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/graphs/Chart/Chart.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\n\nimport { ChartContainer } from './parts/ChartContainer';\n// import { SeriesFactory } from './parts/SeriesFactory';\n// import { ActivePoint } from './parts/ActivePoint';\n\nimport { ChartContext } from './ChartContext';\nimport { useChart } from './config/useChart';\nimport type { DSChartT } from './react-desc-prop-types';\n\nimport { Axes } from './parts/Axis/Axes';\nexport const Chart: React.ComponentType<DSChartT.Props> = (props) => {\n const ctx = useChart(props);\n
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACAvB;AAEA,SAAS,sBAAsB;AAI/B,SAAS,oBAAoB;AAC7B,SAAS,gBAAgB;AAGzB,SAAS,YAAY;AACd,MAAM,QAA6C,CAAC,UAAU;AACnE,QAAM,MAAM,SAAS,KAAK;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\n\nimport { ChartContainer } from './parts/ChartContainer';\n// import { SeriesFactory } from './parts/SeriesFactory';\n// import { ActivePoint } from './parts/ActivePoint';\n\nimport { ChartContext } from './ChartContext';\nimport { useChart } from './config/useChart';\nimport type { DSChartT } from './react-desc-prop-types';\n\nimport { Axes } from './parts/Axis/Axes';\nexport const Chart: React.ComponentType<DSChartT.Props> = (props) => {\n const ctx = useChart(props);\n return (\n <ChartContext.Provider value={ctx}>\n <ChartContainer>\n <Axes />\n </ChartContainer>\n </ChartContext.Provider>\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AAEA,SAAS,sBAAsB;AAI/B,SAAS,oBAAoB;AAC7B,SAAS,gBAAgB;AAGzB,SAAS,YAAY;AACd,MAAM,QAA6C,CAAC,UAAU;AACnE,QAAM,MAAM,SAAS,KAAK;AAC1B,SACE,oBAAC,aAAa,UAAb;AAAA,IAAsB,OAAO;AAAA,IAC5B,8BAAC;AAAA,MACC,8BAAC,QAAK;AAAA,KACR;AAAA,GACF;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/graphs/Chart/ChartContext.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { createContext, createRef } from 'react';\nimport { ScaleLinear, ScaleBand, scaleLinear, scaleBand, scaleOrdinal, ScaleOrdinal } from 'd3';\nimport { defaultProps, DSChartT } from './react-desc-prop-types';\n\ninterface ContextT {\n props:
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,eAAe,iBAAiB;AACzC,SAAiC,aAAa,WAAW,oBAAkC;AAC3F,SAAS,oBAA8B;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { createContext, createRef } from 'react';\nimport { ScaleLinear, ScaleBand, scaleLinear, scaleBand, scaleOrdinal, ScaleOrdinal } from 'd3';\nimport { defaultProps, DSChartT } from './react-desc-prop-types';\n\ninterface ContextT {\n props: DSChartT.Props;\n xScale: ScaleLinear<number, number, never> | ScaleBand<string>;\n yScale: ScaleLinear<number, number, never> | ScaleBand<string>;\n innerHeight: number;\n innerWidth: number;\n activePoint: string;\n setActivePoint: React.Dispatch<React.SetStateAction<string>>;\n activeSerie: string;\n setActiveSerie: React.Dispatch<React.SetStateAction<string>>;\n containerRef: React.RefObject<HTMLDivElement>;\n groups: string[];\n subGroupScale?: ScaleBand<string> | null;\n colorScale: ScaleOrdinal<string, unknown, never>;\n setLeftAxisRef: React.Dispatch<React.SetStateAction<Element | undefined>>;\n axisLeftRef: Element;\n}\n\nconst defaultContext: ContextT = {\n props: defaultProps,\n xScale: scaleBand(),\n yScale: scaleLinear(),\n innerHeight: 0,\n innerWidth: 0,\n activePoint: '',\n setActivePoint: () => {},\n activeSerie: '',\n setActiveSerie: () => {},\n scrapperPosY: '',\n setScrapperPosY: () => {},\n containerRef: createRef<HTMLDivElement>(),\n groups: [],\n colorScale: scaleOrdinal(),\n setLeftAxisRef: () => {},\n};\n\nexport const ChartContext = createContext(defaultContext);\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,eAAe,iBAAiB;AACzC,SAAiC,aAAa,WAAW,oBAAkC;AAC3F,SAAS,oBAA8B;AAoBvC,MAAM,iBAA2B;AAAA,EAC/B,OAAO;AAAA,EACP,QAAQ,UAAU;AAAA,EAClB,QAAQ,YAAY;AAAA,EACpB,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,gBAAgB,MAAM;AAAA,EAAC;AAAA,EACvB,aAAa;AAAA,EACb,gBAAgB,MAAM;AAAA,EAAC;AAAA,EACvB,cAAc;AAAA,EACd,iBAAiB,MAAM;AAAA,EAAC;AAAA,EACxB,cAAc,UAA0B;AAAA,EACxC,QAAQ,CAAC;AAAA,EACT,YAAY,aAAa;AAAA,EACzB,gBAAgB,MAAM;AAAA,EAAC;AACzB;AAEO,MAAM,eAAe,cAAc,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,36 +1,44 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { useMemo, useState, useRef } from "react";
|
|
2
|
+
import { useMemo, useState, useRef, useCallback } from "react";
|
|
3
|
+
import { v4 as uuidv4 } from "uuid";
|
|
3
4
|
import { useScales } from "./useScales";
|
|
4
5
|
import { stackData } from "../helpers";
|
|
6
|
+
import { useInternalMargins } from "./useInternalMargins";
|
|
5
7
|
const useChart = (props) => {
|
|
6
|
-
const { series, yAxis, width, height, groups: groupsStacked } = props;
|
|
8
|
+
const { series, yAxis, xAxis, width, height, groups: groupsStacked } = props;
|
|
7
9
|
const containerRef = useRef(null);
|
|
8
10
|
const svgRef = useRef(null);
|
|
9
11
|
const [isGrabbed, setIsGrabbed] = useState(false);
|
|
10
12
|
const [startPosition, setStartPosition] = useState(0);
|
|
11
|
-
const [activePoint, setActivePoint] = useState(
|
|
13
|
+
const [activePoint, setActivePoint] = useState(null);
|
|
12
14
|
const [activeSerie, setActiveSerie] = useState("");
|
|
13
15
|
const [scrapperPosY, setScrapperPosY] = useState("");
|
|
14
16
|
const [scrapperPosX, setScrapperPosX] = useState("");
|
|
15
17
|
const [xScrollbarPosition, setXScrollbarPosition] = useState(0);
|
|
16
18
|
const [isScrollbarVisible, setIsScrollbarVisible] = useState(false);
|
|
17
19
|
const oldLastPosition = useRef(0);
|
|
18
|
-
const [
|
|
19
|
-
const [
|
|
20
|
-
const [
|
|
21
|
-
const [leftLegend, setLeftLegend] = useState(
|
|
22
|
-
const [rightLegend, setRightLegend] = useState(
|
|
23
|
-
const [topLegend, setTopLegend] = useState(
|
|
24
|
-
const [bottomLegend, setBottomLegend] = useState(
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
20
|
+
const [axisLeftRef, setAxisLeftRef] = useState();
|
|
21
|
+
const [axisBottomRef, setAxisBottomRef] = useState();
|
|
22
|
+
const [axisRightRef, setAxisRightRef] = useState();
|
|
23
|
+
const [leftLegend, setLeftLegend] = useState();
|
|
24
|
+
const [rightLegend, setRightLegend] = useState();
|
|
25
|
+
const [topLegend, setTopLegend] = useState();
|
|
26
|
+
const [bottomLegend, setBottomLegend] = useState();
|
|
27
|
+
const [rightLabel, setRightLabel] = useState();
|
|
28
|
+
const [leftLabel, setLeftLabel] = useState();
|
|
29
|
+
const [bottomLabel, setBottomLabel] = useState();
|
|
30
|
+
const { axisBottomHeight, axisRightWidth, bottomLabelHeight, internalMargin, leftLegendWidth, rightLabelWidth } = useInternalMargins({
|
|
31
|
+
axisLeftRef,
|
|
32
|
+
axisBottomRef,
|
|
33
|
+
axisRightRef,
|
|
34
|
+
leftLabel,
|
|
35
|
+
leftLegend,
|
|
36
|
+
rightLegend,
|
|
37
|
+
topLegend,
|
|
38
|
+
bottomLegend,
|
|
39
|
+
rightLabel,
|
|
40
|
+
bottomLabel
|
|
41
|
+
});
|
|
34
42
|
const innerWidth = useMemo(
|
|
35
43
|
() => width - internalMargin.left - internalMargin.right,
|
|
36
44
|
[internalMargin.left, internalMargin.right, width]
|
|
@@ -39,10 +47,7 @@ const useChart = (props) => {
|
|
|
39
47
|
() => height - internalMargin.top - internalMargin.bottom,
|
|
40
48
|
[internalMargin.top, internalMargin.bottom, height]
|
|
41
49
|
);
|
|
42
|
-
const
|
|
43
|
-
const stackedData = useMemo(() => stackData(groupsStacked, series), [groupsStacked, series]);
|
|
44
|
-
const containerRatio = props?.xAxis.advanced?.pointSpacing?.value ?? 1;
|
|
45
|
-
const currentData = useMemo(
|
|
50
|
+
const [currentData, setCurrentData] = useState(
|
|
46
51
|
() => series.map((d, i) => ({
|
|
47
52
|
...d,
|
|
48
53
|
originalData: d,
|
|
@@ -51,9 +56,15 @@ const useChart = (props) => {
|
|
|
51
56
|
key: `${d.name}-${i}-${index}`,
|
|
52
57
|
value,
|
|
53
58
|
position: index
|
|
54
|
-
}))
|
|
55
|
-
}))
|
|
56
|
-
|
|
59
|
+
})).filter((datum) => datum.value !== null)
|
|
60
|
+
}))
|
|
61
|
+
);
|
|
62
|
+
const stackedData = useMemo(() => stackData(groupsStacked, currentData), [groupsStacked, currentData]);
|
|
63
|
+
const containerRatio = props?.xAxis.advanced?.pointSpacing?.value ?? 1;
|
|
64
|
+
const groups = useMemo(() => currentData.map((serie) => serie.name), [currentData]);
|
|
65
|
+
const visibleGroups = useMemo(
|
|
66
|
+
() => currentData.filter((serie) => !serie.isHidden).map((serie) => serie.name),
|
|
67
|
+
[currentData]
|
|
57
68
|
);
|
|
58
69
|
const { xScale, yScale, y2Scale, subGroupScale, colorScale, getBandwidth } = useScales({
|
|
59
70
|
props,
|
|
@@ -64,12 +75,23 @@ const useChart = (props) => {
|
|
|
64
75
|
currentData,
|
|
65
76
|
containerRatio
|
|
66
77
|
});
|
|
78
|
+
const isHorizontal = useMemo(() => !!yScale.bandwidth, [yScale]);
|
|
79
|
+
const getXValue = useCallback(
|
|
80
|
+
(datum) => !isHorizontal ? xAxis?.cols?.[datum.position] ?? datum.value.x ?? datum.position : datum.value.x ?? datum.value,
|
|
81
|
+
[isHorizontal, xAxis?.cols]
|
|
82
|
+
);
|
|
83
|
+
const getYValue = useCallback(
|
|
84
|
+
(datum) => !isHorizontal ? datum.value?.y ?? datum.value : yAxis?.cols?.[datum.position] ?? datum.value.x ?? datum.position,
|
|
85
|
+
[isHorizontal, yAxis?.cols]
|
|
86
|
+
);
|
|
87
|
+
const chartId = useMemo(() => uuidv4(), []);
|
|
67
88
|
return useMemo(
|
|
68
89
|
() => ({
|
|
69
90
|
props: { ...props, data: currentData },
|
|
70
91
|
innerHeight,
|
|
71
92
|
innerWidth,
|
|
72
93
|
groups,
|
|
94
|
+
visibleGroups,
|
|
73
95
|
colorScale,
|
|
74
96
|
stackedData,
|
|
75
97
|
subGroupScale,
|
|
@@ -98,15 +120,30 @@ const useChart = (props) => {
|
|
|
98
120
|
oldLastPosition,
|
|
99
121
|
containerRatio,
|
|
100
122
|
internalMargin,
|
|
101
|
-
|
|
123
|
+
axisLeftRef,
|
|
124
|
+
leftLegendWidth,
|
|
102
125
|
leftLegend,
|
|
103
|
-
|
|
126
|
+
setAxisLeftRef,
|
|
104
127
|
setLeftLegend,
|
|
105
128
|
setRightLegend,
|
|
129
|
+
rightLegend,
|
|
106
130
|
setTopLegend,
|
|
107
131
|
setBottomLegend,
|
|
108
|
-
|
|
109
|
-
|
|
132
|
+
setAxisBottomRef,
|
|
133
|
+
axisBottomHeight,
|
|
134
|
+
setAxisRightRef,
|
|
135
|
+
setRightLabel,
|
|
136
|
+
setBottomLabel,
|
|
137
|
+
bottomLabelHeight,
|
|
138
|
+
rightLabelWidth,
|
|
139
|
+
axisRightWidth,
|
|
140
|
+
getXValue,
|
|
141
|
+
getYValue,
|
|
142
|
+
isHorizontal,
|
|
143
|
+
setCurrentData,
|
|
144
|
+
setLeftLabel,
|
|
145
|
+
leftLabel,
|
|
146
|
+
chartId
|
|
110
147
|
}),
|
|
111
148
|
[
|
|
112
149
|
props,
|
|
@@ -114,6 +151,7 @@ const useChart = (props) => {
|
|
|
114
151
|
innerHeight,
|
|
115
152
|
innerWidth,
|
|
116
153
|
groups,
|
|
154
|
+
visibleGroups,
|
|
117
155
|
colorScale,
|
|
118
156
|
stackedData,
|
|
119
157
|
subGroupScale,
|
|
@@ -132,20 +170,35 @@ const useChart = (props) => {
|
|
|
132
170
|
setIsGrabbed,
|
|
133
171
|
startPosition,
|
|
134
172
|
setStartPosition,
|
|
173
|
+
rightLabelWidth,
|
|
174
|
+
rightLegend,
|
|
175
|
+
bottomLabelHeight,
|
|
135
176
|
isScrollbarVisible,
|
|
136
177
|
setIsScrollbarVisible,
|
|
137
178
|
oldLastPosition,
|
|
138
179
|
containerRatio,
|
|
139
180
|
internalMargin,
|
|
140
|
-
|
|
181
|
+
axisBottomHeight,
|
|
182
|
+
axisLeftRef,
|
|
183
|
+
leftLegendWidth,
|
|
141
184
|
leftLegend,
|
|
142
|
-
|
|
185
|
+
setAxisLeftRef,
|
|
143
186
|
setLeftLegend,
|
|
144
187
|
setRightLegend,
|
|
145
188
|
setTopLegend,
|
|
146
189
|
setBottomLegend,
|
|
147
|
-
|
|
148
|
-
|
|
190
|
+
setAxisBottomRef,
|
|
191
|
+
setAxisRightRef,
|
|
192
|
+
setRightLabel,
|
|
193
|
+
setBottomLabel,
|
|
194
|
+
getXValue,
|
|
195
|
+
getYValue,
|
|
196
|
+
isHorizontal,
|
|
197
|
+
setCurrentData,
|
|
198
|
+
axisRightWidth,
|
|
199
|
+
setLeftLabel,
|
|
200
|
+
leftLabel,
|
|
201
|
+
chartId
|
|
149
202
|
]
|
|
150
203
|
);
|
|
151
204
|
};
|