@elliemae/ds-dataviz 3.13.0-next.3 → 3.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/graphs/Chart/ChartContext.js.map +2 -2
- package/dist/cjs/graphs/Chart/config/useChart.js +55 -10
- package/dist/cjs/graphs/Chart/config/useChart.js.map +2 -2
- package/dist/cjs/graphs/Chart/config/useInternalMargins.js +48 -19
- package/dist/cjs/graphs/Chart/config/useInternalMargins.js.map +3 -3
- package/dist/cjs/graphs/Chart/config/useKeyboardNavigation.js +89 -7
- package/dist/cjs/graphs/Chart/config/useKeyboardNavigation.js.map +2 -2
- package/dist/cjs/graphs/Chart/config/useScales.js +25 -12
- package/dist/cjs/graphs/Chart/config/useScales.js.map +2 -2
- package/dist/cjs/graphs/Chart/config/useValidateProps.js +37 -0
- package/dist/cjs/graphs/Chart/config/useValidateProps.js.map +7 -0
- package/dist/cjs/graphs/Chart/parts/Axis/AxisBottom.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/ChartContainer.js +28 -10
- package/dist/cjs/graphs/Chart/parts/ChartContainer.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Labels/LeftLabel.js +5 -5
- package/dist/cjs/graphs/Chart/parts/Labels/LeftLabel.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Legend/BottomLegend.js +43 -43
- package/dist/cjs/graphs/Chart/parts/Legend/BottomLegend.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Legend/LeftLegend.js +12 -8
- package/dist/cjs/graphs/Chart/parts/Legend/LeftLegend.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Legend/LegendItem.js +4 -10
- package/dist/cjs/graphs/Chart/parts/Legend/LegendItem.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Legend/RightLegend.js +5 -9
- package/dist/cjs/graphs/Chart/parts/Legend/RightLegend.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Legend/TopLegend.js +21 -18
- package/dist/cjs/graphs/Chart/parts/Legend/TopLegend.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Scroller/Controllers.js +42 -19
- package/dist/cjs/graphs/Chart/parts/Scroller/Controllers.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Scroller/ScrollableContainerX.js +28 -18
- package/dist/cjs/graphs/Chart/parts/Scroller/ScrollableContainerX.js.map +2 -2
- package/dist/cjs/graphs/Chart/react-desc-prop-types.js +14 -1
- package/dist/cjs/graphs/Chart/react-desc-prop-types.js.map +2 -2
- package/dist/cjs/graphs/Chart/series/Bars.js +2 -2
- package/dist/cjs/graphs/Chart/series/Bars.js.map +2 -2
- package/dist/cjs/graphs/Chart/series/Point.js +1 -2
- package/dist/cjs/graphs/Chart/series/Point.js.map +2 -2
- package/dist/cjs/graphs/Chart/series/Rect.js +2 -2
- package/dist/cjs/graphs/Chart/series/Rect.js.map +1 -1
- package/dist/cjs/graphs/Chart/series/StackedBar.js +1 -1
- package/dist/cjs/graphs/Chart/series/StackedBar.js.map +1 -1
- package/dist/cjs/graphs/constants.js +7 -0
- package/dist/cjs/graphs/constants.js.map +2 -2
- package/dist/esm/graphs/Chart/ChartContext.js.map +2 -2
- package/dist/esm/graphs/Chart/config/useChart.js +55 -10
- package/dist/esm/graphs/Chart/config/useChart.js.map +2 -2
- package/dist/esm/graphs/Chart/config/useInternalMargins.js +49 -20
- package/dist/esm/graphs/Chart/config/useInternalMargins.js.map +2 -2
- package/dist/esm/graphs/Chart/config/useKeyboardNavigation.js +90 -8
- package/dist/esm/graphs/Chart/config/useKeyboardNavigation.js.map +2 -2
- package/dist/esm/graphs/Chart/config/useScales.js +25 -12
- package/dist/esm/graphs/Chart/config/useScales.js.map +2 -2
- package/dist/esm/graphs/Chart/config/useValidateProps.js +11 -0
- package/dist/esm/graphs/Chart/config/useValidateProps.js.map +7 -0
- package/dist/esm/graphs/Chart/parts/Axis/AxisBottom.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/ChartContainer.js +28 -10
- package/dist/esm/graphs/Chart/parts/ChartContainer.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Labels/LeftLabel.js +5 -5
- package/dist/esm/graphs/Chart/parts/Labels/LeftLabel.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Legend/BottomLegend.js +44 -44
- package/dist/esm/graphs/Chart/parts/Legend/BottomLegend.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Legend/LeftLegend.js +13 -9
- package/dist/esm/graphs/Chart/parts/Legend/LeftLegend.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Legend/LegendItem.js +4 -10
- package/dist/esm/graphs/Chart/parts/Legend/LegendItem.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Legend/RightLegend.js +6 -10
- package/dist/esm/graphs/Chart/parts/Legend/RightLegend.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Legend/TopLegend.js +23 -20
- package/dist/esm/graphs/Chart/parts/Legend/TopLegend.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Scroller/Controllers.js +44 -21
- package/dist/esm/graphs/Chart/parts/Scroller/Controllers.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Scroller/ScrollableContainerX.js +29 -19
- package/dist/esm/graphs/Chart/parts/Scroller/ScrollableContainerX.js.map +2 -2
- package/dist/esm/graphs/Chart/react-desc-prop-types.js +14 -1
- package/dist/esm/graphs/Chart/react-desc-prop-types.js.map +2 -2
- package/dist/esm/graphs/Chart/series/Bars.js +2 -2
- package/dist/esm/graphs/Chart/series/Bars.js.map +2 -2
- package/dist/esm/graphs/Chart/series/Point.js +1 -2
- package/dist/esm/graphs/Chart/series/Point.js.map +2 -2
- package/dist/esm/graphs/Chart/series/Rect.js +2 -2
- package/dist/esm/graphs/Chart/series/Rect.js.map +1 -1
- package/dist/esm/graphs/Chart/series/StackedBar.js +1 -1
- package/dist/esm/graphs/Chart/series/StackedBar.js.map +1 -1
- package/dist/esm/graphs/constants.js +7 -0
- package/dist/esm/graphs/constants.js.map +2 -2
- package/package.json +4 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useContext,
|
|
3
|
+
import { useContext, useCallback, useMemo } from "react";
|
|
4
4
|
import { ChartContext } from "../../ChartContext";
|
|
5
5
|
import { AxisBottom } from "../Axis/AxisBottom";
|
|
6
6
|
import { SeriesFactory } from "../SeriesFactory";
|
|
@@ -15,13 +15,24 @@ const ScrollableContainerX = () => {
|
|
|
15
15
|
containerRatio,
|
|
16
16
|
innerWidth,
|
|
17
17
|
isGrabbed,
|
|
18
|
+
containerRef,
|
|
18
19
|
setXScrollbarPosition,
|
|
19
20
|
setContainerRatio,
|
|
20
21
|
lastPosition,
|
|
21
22
|
innerHeight,
|
|
22
23
|
internalMargin,
|
|
23
|
-
chartId
|
|
24
|
+
chartId,
|
|
25
|
+
isZooming,
|
|
26
|
+
setIsZooming,
|
|
27
|
+
zoomStartingPosition,
|
|
28
|
+
setZoomStartingPosition,
|
|
29
|
+
movingPosition,
|
|
30
|
+
setMovingPosition
|
|
24
31
|
} = useContext(ChartContext);
|
|
32
|
+
const getRealClientX = useCallback(
|
|
33
|
+
(clientX) => clientX - internalMargin.left - containerRef.getBoundingClientRect().left,
|
|
34
|
+
[internalMargin.left]
|
|
35
|
+
);
|
|
25
36
|
const Scrappers = useMemo(() => {
|
|
26
37
|
if (scrapper?.type === "horizontal")
|
|
27
38
|
return /* @__PURE__ */ jsx(Scrapper, {});
|
|
@@ -29,14 +40,11 @@ const ScrollableContainerX = () => {
|
|
|
29
40
|
return /* @__PURE__ */ jsx(VerticalScrapper, {});
|
|
30
41
|
return null;
|
|
31
42
|
}, [scrapper?.type]);
|
|
32
|
-
const [isZooming, setIsZooming] = useState(false);
|
|
33
|
-
const [startingPosition, setStartingPosition] = useState(0);
|
|
34
|
-
const [movingPosition, setMovingPosition] = useState(0);
|
|
35
43
|
const handleOnMouseDown = useCallback(
|
|
36
|
-
(
|
|
44
|
+
({ clientX }) => {
|
|
37
45
|
if (!isGrabbed && !xScale.bandwidth) {
|
|
38
46
|
setIsZooming(true);
|
|
39
|
-
|
|
47
|
+
setZoomStartingPosition(getRealClientX(clientX));
|
|
40
48
|
setMovingPosition(0);
|
|
41
49
|
}
|
|
42
50
|
},
|
|
@@ -45,22 +53,22 @@ const ScrollableContainerX = () => {
|
|
|
45
53
|
const handleOnMouseMove = useCallback(
|
|
46
54
|
({ clientX }) => {
|
|
47
55
|
if (isZooming)
|
|
48
|
-
setMovingPosition(clientX);
|
|
56
|
+
setMovingPosition(getRealClientX(clientX));
|
|
49
57
|
},
|
|
50
58
|
[isZooming]
|
|
51
59
|
);
|
|
52
60
|
const handleOnMouseUp = useCallback(
|
|
53
61
|
(e) => {
|
|
54
|
-
const bounds = e.currentTarget.closest("div").getBoundingClientRect();
|
|
55
62
|
if (!isZooming)
|
|
56
63
|
return;
|
|
57
64
|
setIsZooming(false);
|
|
58
|
-
|
|
59
|
-
const
|
|
65
|
+
setMovingPosition(0);
|
|
66
|
+
const endingPosition = getRealClientX(e.clientX);
|
|
67
|
+
const diff = Math.abs(zoomStartingPosition - endingPosition);
|
|
60
68
|
if (diff <= 0)
|
|
61
69
|
return;
|
|
62
70
|
const newRatio = innerWidth / (innerWidth * containerRatio / diff) < 40 ? innerWidth / 40 : innerWidth * containerRatio / diff;
|
|
63
|
-
const newPosition = lastPosition?.current + (
|
|
71
|
+
const newPosition = lastPosition?.current + (zoomStartingPosition > endingPosition ? endingPosition : zoomStartingPosition) / containerRatio;
|
|
64
72
|
if (newPosition > innerWidth - innerWidth / newRatio)
|
|
65
73
|
setXScrollbarPosition(innerWidth - innerWidth / newRatio);
|
|
66
74
|
else
|
|
@@ -70,14 +78,16 @@ const ScrollableContainerX = () => {
|
|
|
70
78
|
e.stopPropagation();
|
|
71
79
|
},
|
|
72
80
|
[
|
|
73
|
-
containerRatio,
|
|
74
|
-
innerWidth,
|
|
75
81
|
isZooming,
|
|
76
|
-
|
|
82
|
+
setIsZooming,
|
|
83
|
+
setMovingPosition,
|
|
84
|
+
getRealClientX,
|
|
85
|
+
zoomStartingPosition,
|
|
86
|
+
innerWidth,
|
|
87
|
+
containerRatio,
|
|
77
88
|
lastPosition,
|
|
78
|
-
setContainerRatio,
|
|
79
89
|
setXScrollbarPosition,
|
|
80
|
-
|
|
90
|
+
setContainerRatio
|
|
81
91
|
]
|
|
82
92
|
);
|
|
83
93
|
return /* @__PURE__ */ jsxs(
|
|
@@ -97,8 +107,8 @@ const ScrollableContainerX = () => {
|
|
|
97
107
|
isZooming && movingPosition !== 0 ? /* @__PURE__ */ jsx(
|
|
98
108
|
"rect",
|
|
99
109
|
{
|
|
100
|
-
x:
|
|
101
|
-
width: Math.abs(movingPosition -
|
|
110
|
+
x: movingPosition < zoomStartingPosition ? movingPosition : zoomStartingPosition,
|
|
111
|
+
width: Math.abs(movingPosition - zoomStartingPosition),
|
|
102
112
|
height: innerHeight,
|
|
103
113
|
fill: "orange",
|
|
104
114
|
style: { opacity: 0.2 }
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../../src/graphs/Chart/parts/Scroller/ScrollableContainerX.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable arrow-body-style */\n/* eslint-disable indent */\nimport React, { useContext,
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable arrow-body-style */\n/* eslint-disable indent */\nimport React, { useContext, useCallback, useMemo } from 'react';\nimport { ChartContext } from '../../ChartContext';\nimport { AxisBottom } from '../Axis/AxisBottom';\nimport { SeriesFactory } from '../SeriesFactory';\nimport { ScrollBarX } from './ScrollBarX';\nimport { Scrapper } from '../Scrapper/Scrapper';\nimport { VerticalScrapper } from '../Scrapper/VerticalScrapper';\nexport const ScrollableContainerX = () => {\n const {\n props: { scrapper },\n xScrollbarPosition,\n xScale,\n containerRatio,\n innerWidth,\n isGrabbed,\n containerRef,\n setXScrollbarPosition,\n setContainerRatio,\n lastPosition,\n innerHeight,\n internalMargin,\n chartId,\n isZooming,\n setIsZooming,\n zoomStartingPosition,\n setZoomStartingPosition,\n movingPosition,\n setMovingPosition,\n } = useContext(ChartContext);\n\n const getRealClientX = useCallback(\n (clientX: number) => clientX - internalMargin.left - containerRef.getBoundingClientRect().left,\n [internalMargin.left],\n );\n\n const Scrappers = useMemo(() => {\n if (scrapper?.type === 'horizontal') return <Scrapper />;\n if (scrapper?.type === 'vertical') return <VerticalScrapper />;\n return null;\n }, [scrapper?.type]);\n\n //mouse\n const handleOnMouseDown: React.MouseEventHandler = useCallback(\n ({ clientX }) => {\n if (!isGrabbed && !xScale.bandwidth) {\n setIsZooming(true);\n setZoomStartingPosition(getRealClientX(clientX));\n setMovingPosition(0);\n }\n },\n [isGrabbed, xScale],\n );\n\n const handleOnMouseMove: React.MouseEventHandler = useCallback(\n ({ clientX }) => {\n if (isZooming) setMovingPosition(getRealClientX(clientX));\n },\n [isZooming],\n );\n const handleOnMouseUp: React.MouseEventHandler = useCallback(\n (e) => {\n if (!isZooming) return;\n setIsZooming(false);\n setMovingPosition(0);\n const endingPosition = getRealClientX(e.clientX);\n\n const diff = Math.abs(zoomStartingPosition - endingPosition);\n if (diff <= 0) return;\n const newRatio =\n innerWidth / ((innerWidth * containerRatio) / diff) < 40\n ? innerWidth / 40\n : (innerWidth * containerRatio) / diff;\n const newPosition =\n lastPosition?.current +\n (zoomStartingPosition > endingPosition ? endingPosition : zoomStartingPosition) / containerRatio;\n\n // if (newPosition < 0) setXScrollbarPosition(0);\n // if is bigger thant innerwidth possible we force the end\n if (newPosition > innerWidth - innerWidth / newRatio) setXScrollbarPosition(innerWidth - innerWidth / newRatio);\n else setXScrollbarPosition(newPosition);\n\n setContainerRatio(newRatio);\n lastPosition.current = newPosition;\n e.stopPropagation();\n },\n [\n isZooming,\n setIsZooming,\n setMovingPosition,\n getRealClientX,\n zoomStartingPosition,\n innerWidth,\n containerRatio,\n lastPosition,\n setXScrollbarPosition,\n setContainerRatio,\n ],\n );\n return (\n <g\n className=\"scrollable-container-x\"\n onMouseDown={handleOnMouseDown}\n onMouseMove={handleOnMouseMove}\n onMouseUp={handleOnMouseUp}\n >\n <g mask={`url(#mask-${chartId})`}>\n <g transform={`translate(${-xScrollbarPosition * containerRatio},0)`}>\n <AxisBottom />\n <SeriesFactory />\n {Scrappers}\n </g>\n {isZooming && movingPosition !== 0 ? (\n <rect\n x={movingPosition < zoomStartingPosition ? movingPosition : zoomStartingPosition}\n width={Math.abs(movingPosition - zoomStartingPosition)}\n height={innerHeight}\n fill=\"orange\"\n style={{ opacity: 0.2 }}\n />\n ) : null}\n </g>\n <ScrollBarX />\n </g>\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACsCyB,cAsExC,YAtEwC;AApChD,SAAgB,YAAY,aAAa,eAAe;AACxD,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB;AAC9B,SAAS,kBAAkB;AAC3B,SAAS,gBAAgB;AACzB,SAAS,wBAAwB;AAC1B,MAAM,uBAAuB,MAAM;AACxC,QAAM;AAAA,IACJ,OAAO,EAAE,SAAS;AAAA,IAClB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,WAAW,YAAY;AAE3B,QAAM,iBAAiB;AAAA,IACrB,CAAC,YAAoB,UAAU,eAAe,OAAO,aAAa,sBAAsB,EAAE;AAAA,IAC1F,CAAC,eAAe,IAAI;AAAA,EACtB;AAE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ACF;AACA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAU;AAAA,MACV,aAAa;AAAA,MACb,aAAa;AAAA,MACb,WAAW;AAAA,MAEX;AAAA,6BAAC,OAAE,MAAM,aAAa,YACpB;AAAA,+BAAC,OAAE,WAAW,aAAa,CAAC,qBAAqB,qBAC/C;AAAA,gCAAC,cAAW;AAAA,YACZ,oBAAC,iBAAc;AAAA,YACd;AAAA,aACH;AAAA,UACC,aAAa,mBAAmB,IAC/B;AAAA,YAAC;AAAA;AAAA,cACC,GAAG,iBAAiB,uBAAuB,iBAAiB;AAAA,cAC5D,OAAO,KAAK,IAAI,iBAAiB,oBAAoB;AAAA,cACrD,QAAQ;AAAA,cACR,MAAK;AAAA,cACL,OAAO,EAAE,SAAS,IAAI;AAAA;AAAA,UACxB,IACE;AAAA,WACN;AAAA,QACA,oBAAC,cAAW;AAAA;AAAA;AAAA,EACd;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { globalAttributesPropTypes, PropTypes } from "@elliemae/ds-utilities";
|
|
3
|
-
const defaultProps = {
|
|
3
|
+
const defaultProps = {
|
|
4
|
+
series: [
|
|
5
|
+
{
|
|
6
|
+
name: "1",
|
|
7
|
+
data: [0],
|
|
8
|
+
color: "grey-100",
|
|
9
|
+
type: "bar"
|
|
10
|
+
}
|
|
11
|
+
],
|
|
12
|
+
xAxis: {
|
|
13
|
+
cols: ["0"]
|
|
14
|
+
},
|
|
15
|
+
yAxis: {}
|
|
16
|
+
};
|
|
4
17
|
const propTypes = {
|
|
5
18
|
...globalAttributesPropTypes,
|
|
6
19
|
height: PropTypes.number.isRequired.description("height").defaultValue(""),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/graphs/Chart/react-desc-prop-types.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { globalAttributesPropTypes, PropTypes } from '@elliemae/ds-utilities';\nimport type { Series, ScaleLinear, ScaleBand } from 'd3';\nexport declare namespace DSChartT {\n export type SerieTypeT = 'line' | 'bar' | 'area' | 'point';\n export type AxisTypeT = 'log' | 'band' | 'time' | 'linear';\n\n export type LinearScale = ScaleLinear<number, number, never>;\n export type BandScale = ScaleBand<string>;\n\n export type Scales = LinearScale | BandScale;\n export interface SeriesT {\n name: string;\n data: Array<number | null | { x: number; y: number }>;\n type: SerieTypeT;\n scale?: string;\n color?: string;\n // line\n dashStyle?: string;\n pointRadius?: number;\n }\n\n export interface ScrapperT {\n type: 'horizontal' | 'vertical';\n color: string;\n tooltipPreference: string;\n }\n\n export interface SerieComponentT {\n serie: InternalSerie;\n }\n\n export interface AxisTickT {\n tickValues: number[] | Date[];\n tickFormat: () => void | string;\n tickCount: number;\n tickRotation: number;\n overwriteTicks: boolean;\n color: string;\n }\n\n export interface AxisT {\n showGrid: boolean;\n color: string;\n label: string;\n type: AxisTypeT;\n cols?: string[];\n domainPadding: number;\n hideAxis: boolean;\n beginAtZero?: boolean;\n advanced: {\n pointSpacing: {\n type: 'string';\n value: number;\n };\n };\n tick: AxisTickT;\n }\n\n export interface InternalDatum {\n key: string;\n value: number | { x: number; y: number };\n position: number;\n serie: string;\n }\n\n export interface InternalSerie {\n key: string;\n data: InternalDatum[];\n name: string;\n type: DSChartT.SerieTypeT;\n scale?: string | undefined;\n color?: string;\n dashStyle?: string;\n pointRadius?: number;\n }\n\n export type InternalData = InternalSerie[];\n\n export interface OptionalProps {\n y2Axis?: AxisT;\n groups?: string[][];\n types?: 'scatter';\n scrapper: ScrapperT;\n withTrendHighlight: boolean;\n TooltipRenderer: () => JSX.Element;\n
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,2BAA2B,iBAAiB;AA2G9C,MAAM,eAAsC,CAAC;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { globalAttributesPropTypes, PropTypes } from '@elliemae/ds-utilities';\nimport type { Series, ScaleLinear, ScaleBand } from 'd3';\nexport declare namespace DSChartT {\n export type SerieTypeT = 'line' | 'bar' | 'area' | 'point';\n export type AxisTypeT = 'log' | 'band' | 'time' | 'linear';\n\n export type LinearScale = ScaleLinear<number, number, never>;\n export type BandScale = ScaleBand<string>;\n\n export type Scales = LinearScale | BandScale;\n export interface SeriesT {\n name: string;\n data: Array<number | null | { x: number; y: number }>;\n type: SerieTypeT;\n scale?: string;\n color?: string;\n // line\n dashStyle?: string;\n pointRadius?: number;\n }\n\n export interface ScrapperT {\n type: 'horizontal' | 'vertical';\n color: string;\n tooltipPreference: string;\n }\n\n export interface SerieComponentT {\n serie: InternalSerie;\n }\n\n export interface AxisTickT {\n tickValues: number[] | Date[];\n tickFormat: () => void | string;\n tickCount: number;\n tickRotation: number;\n overwriteTicks: boolean;\n color: string;\n }\n\n export interface AxisT {\n showGrid: boolean;\n color: string;\n label: string;\n type: AxisTypeT;\n cols?: string[];\n domainPadding: number;\n hideAxis: boolean;\n beginAtZero?: boolean;\n advanced: {\n pointSpacing: {\n type: 'string';\n value: number;\n };\n };\n tick: AxisTickT;\n }\n\n export interface InternalDatum {\n key: string;\n value: number | { x: number; y: number };\n position: number;\n serie: string;\n }\n\n export interface InternalSerie {\n key: string;\n data: InternalDatum[];\n name: string;\n type: DSChartT.SerieTypeT;\n scale?: string | undefined;\n color?: string;\n dashStyle?: string;\n pointRadius?: number;\n }\n\n export type InternalData = InternalSerie[];\n\n export interface OptionalProps {\n y2Axis?: AxisT;\n groups?: string[][];\n types?: 'scatter';\n scrapper: ScrapperT;\n withTrendHighlight: boolean;\n TooltipRenderer: () => JSX.Element;\n height: number;\n width: number;\n }\n\n export interface DefaultProps {\n yAxis: AxisT;\n xAxis: AxisT;\n series: SeriesT[];\n }\n\n export interface RequiredProps {}\n\n export interface Props extends OptionalProps, DefaultProps, RequiredProps {}\n\n export type StackedSeriesByGroupT = Series<\n {\n [key: string]: number;\n },\n string\n >[][];\n}\n\nexport const defaultProps: DSChartT.DefaultProps = {\n series: [\n {\n name: '1',\n data: [0],\n color: 'grey-100',\n type: 'bar',\n },\n ],\n xAxis: {\n cols: ['0'],\n },\n yAxis: {},\n};\n\nexport const propTypes = {\n ...globalAttributesPropTypes,\n height: PropTypes.number.isRequired.description('height').defaultValue(''),\n width: PropTypes.number.isRequired.description('height').defaultValue(''),\n margin: PropTypes.shape({\n top: PropTypes.number,\n bottom: PropTypes.number,\n left: PropTypes.number,\n right: PropTypes.number,\n })\n .isRequired.description('margin')\n .defaultValue(''),\n series: PropTypes.arrayOf(PropTypes.object).description('yValue').defaultValue(''),\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,2BAA2B,iBAAiB;AA2G9C,MAAM,eAAsC;AAAA,EACjD,QAAQ;AAAA,IACN;AAAA,MACE,MAAM;AAAA,MACN,MAAM,CAAC,CAAC;AAAA,MACR,OAAO;AAAA,MACP,MAAM;AAAA,IACR;AAAA,EACF;AAAA,EACA,OAAO;AAAA,IACL,MAAM,CAAC,GAAG;AAAA,EACZ;AAAA,EACA,OAAO,CAAC;AACV;AAEO,MAAM,YAAY;AAAA,EACvB,GAAG;AAAA,EACH,QAAQ,UAAU,OAAO,WAAW,YAAY,QAAQ,EAAE,aAAa,EAAE;AAAA,EACzE,OAAO,UAAU,OAAO,WAAW,YAAY,QAAQ,EAAE,aAAa,EAAE;AAAA,EACxE,QAAQ,UAAU,MAAM;AAAA,IACtB,KAAK,UAAU;AAAA,IACf,QAAQ,UAAU;AAAA,IAClB,MAAM,UAAU;AAAA,IAChB,OAAO,UAAU;AAAA,EACnB,CAAC,EACE,WAAW,YAAY,QAAQ,EAC/B,aAAa,EAAE;AAAA,EAClB,QAAQ,UAAU,QAAQ,UAAU,MAAM,EAAE,YAAY,QAAQ,EAAE,aAAa,EAAE;AACnF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -5,7 +5,6 @@ import { Rect } from "./Rect";
|
|
|
5
5
|
import { ChartContext } from "../ChartContext";
|
|
6
6
|
const Bars = ({ serie }) => {
|
|
7
7
|
const {
|
|
8
|
-
props: { yAxis, TooltipRenderer },
|
|
9
8
|
innerHeight,
|
|
10
9
|
xScale,
|
|
11
10
|
yScale,
|
|
@@ -14,6 +13,7 @@ const Bars = ({ serie }) => {
|
|
|
14
13
|
colorScale,
|
|
15
14
|
getXValue,
|
|
16
15
|
getYValue,
|
|
16
|
+
isHorizontal,
|
|
17
17
|
chartId
|
|
18
18
|
} = useContext(ChartContext);
|
|
19
19
|
const finalYScale = serie.scale === "y2" ? y2Scale : yScale;
|
|
@@ -24,7 +24,7 @@ const Bars = ({ serie }) => {
|
|
|
24
24
|
const y = getYValue(bar);
|
|
25
25
|
const width = subGroupScale?.bandwidth();
|
|
26
26
|
const height = y > 0 ? positiveSize - finalYScale(y) : finalYScale(y) - finalYScale(0);
|
|
27
|
-
const transformX = subGroupScale(serie.name) + xScale(x);
|
|
27
|
+
const transformX = isHorizontal ? 0 : subGroupScale(serie.name) + xScale(x) - (bar.value.x ? width / 2 * subGroupScale.domain().length : 0);
|
|
28
28
|
const transformY = y > 0 ? finalYScale(0) - height : finalYScale(0);
|
|
29
29
|
return /* @__PURE__ */ jsx("g", { id: `${serie.name}-rects`, transform: `translate(${transformX},0)`, children: /* @__PURE__ */ jsx(
|
|
30
30
|
Rect,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/graphs/Chart/series/Bars.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable complexity */\nimport React, { useContext } from 'react';\nimport {
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable complexity */\nimport React, { useContext } from 'react';\nimport { Rect } from './Rect';\nimport { ChartContext } from '../ChartContext';\n\nexport const Bars = ({ serie }) => {\n const {\n innerHeight,\n xScale,\n yScale,\n y2Scale,\n subGroupScale,\n colorScale,\n getXValue,\n getYValue,\n isHorizontal,\n chartId,\n } = useContext(ChartContext);\n const finalYScale = serie.scale === 'y2' ? y2Scale : yScale;\n\n const negativeSize = innerHeight - finalYScale(0);\n const positiveSize = innerHeight - negativeSize;\n\n return (\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 = subGroupScale?.bandwidth();\n const height = y > 0 ? positiveSize - finalYScale(y) : finalYScale(y) - finalYScale(0);\n\n // const transformX = subGroupScale(serie.name) + xScale(x);\n\n // @todo find a way to create bars with linear\n // scale here is something but conflict with bars like {x: 'Monday', y: 10}\n const transformX = isHorizontal\n ? 0\n : subGroupScale(serie.name) + xScale(x) - (bar.value.x ? (width / 2) * subGroupScale.domain().length : 0);\n\n const transformY = y > 0 ? finalYScale(0) - height : finalYScale(0);\n\n return (\n <g id={`${serie.name}-rects`} key={bar.key} transform={`translate(${transformX},0)`}>\n <Rect\n name={serie.name}\n xValue={x}\n yValue={y}\n width={width}\n height={height}\n id={bar.key}\n y={transformY}\n isNegative={y < 0}\n datum={bar}\n />\n </g>\n );\n })}\n </g>\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;AC4CX;AA3CZ,SAAgB,kBAAkB;AAClC,SAAS,YAAY;AACrB,SAAS,oBAAoB;AAEtB,MAAM,OAAO,CAAC,EAAE,MAAM,MAAM;AACjC,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,WAAW,YAAY;AAC3B,QAAM,cAAc,MAAM,UAAU,OAAO,UAAU;AAErD,QAAM,eAAe,cAAc,YAAY,CAAC;AAChD,QAAM,eAAe,cAAc;AAEnC,SACE,oBAAC,OAAE,MAAM,WAAW,MAAM,IAAI,GAAG,UAAU,wBAAwB,YAChE,gBAAM,KAAK,IAAI,CAAC,KAAK,MAAM;AAC1B,UAAM,IAAI,UAAU,GAAG;AACvB,UAAM,IAAI,UAAU,GAAG;AAEvB,UAAM,QAAQ,eAAe,UAAU;AACvC,UAAM,SAAS,IAAI,IAAI,eAAe,YAAY,CAAC,IAAI,YAAY,CAAC,IAAI,YAAY,CAAC;AAMrF,UAAM,aAAa,eACf,IACA,cAAc,MAAM,IAAI,IAAI,OAAO,CAAC,KAAK,IAAI,MAAM,IAAK,QAAQ,IAAK,cAAc,OAAO,EAAE,SAAS;AAEzG,UAAM,aAAa,IAAI,IAAI,YAAY,CAAC,IAAI,SAAS,YAAY,CAAC;AAElE,WACE,oBAAC,OAAE,IAAI,GAAG,MAAM,cAA4B,WAAW,aAAa,iBAClE;AAAA,MAAC;AAAA;AAAA,QACC,MAAM,MAAM;AAAA,QACZ,QAAQ;AAAA,QACR,QAAQ;AAAA,QACR;AAAA,QACA;AAAA,QACA,IAAI,IAAI;AAAA,QACR,GAAG;AAAA,QACH,YAAY,IAAI;AAAA,QAChB,OAAO;AAAA;AAAA,IACT,KAXiC,IAAI,GAYvC;AAAA,EAEJ,CAAC,GACH;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -107,8 +107,7 @@ const Point = ({ x, y, xValue, yValue, name, pointStyle, pointRadius, id, opacit
|
|
|
107
107
|
id,
|
|
108
108
|
width: (pointRadius ?? 3) * 4,
|
|
109
109
|
height: (pointRadius ?? 3) * 4,
|
|
110
|
-
pointRadius,
|
|
111
|
-
style: { transform: `translate(-${pointRadius}px, -${pointRadius}px)` },
|
|
110
|
+
style: { transform: `translate(-${pointRadius ?? 3}px, -${pointRadius ?? 3}px)` },
|
|
112
111
|
content: /* @__PURE__ */ jsx(TooltipRenderer, { data: [{ name, yValue, xValue }] })
|
|
113
112
|
}
|
|
114
113
|
) : null
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/graphs/Chart/series/Point.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext, useCallback, useMemo } from 'react';\nimport { ChartContext } from '../ChartContext';\nimport { FOCUS_RING, SCRAPPER, LINE } from '../../constants';\nimport { FocusableRegion } from '../parts/FocusableRegion';\nimport { TrendHighlight } from '../parts/TrendHighlight';\nimport { DataVizDataTestIds } from '../DataTestIds';\nexport const Point = ({ x, y, xValue, yValue, name, pointStyle, pointRadius, id, opacity, datum }) => {\n const {\n activePoint,\n scrapperPosY,\n scrapperPosX,\n setActivePoint,\n props: { scrapper, TooltipRenderer, withTrendHighlight },\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 const handleMouseEnter = useCallback(() => {\n if (!scrapper) setActivePoint(datum);\n }, [datum, scrapper, setActivePoint]);\n\n const handleOnMouseLeave = useCallback(() => {\n if (!scrapper) setActivePoint(null);\n }, [scrapper, setActivePoint]);\n return (\n <>\n <g\n data-testid={DataVizDataTestIds.POINT}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleOnMouseLeave}\n transform={`translate(${x},${y})`}\n >\n {point}\n {activePoint?.key === id && TooltipRenderer ? (\n <FocusableRegion\n id={id}\n width={(pointRadius ?? 3) * 4}\n height={(pointRadius ?? 3) * 4}\n
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACgCf,SAmEJ,UAjE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W,aAAa,KAAK;AAAA,QAE5B;AAAA;AAAA,UACA,aAAa,QAAQ,MAAM,kBAC1B;AAAA,YAAC;AAAA;AAAA,cACC;AAAA,cACA,QAAQ,eAAe,KAAK;AAAA,cAC5B,SAAS,eAAe,KAAK;AAAA,cAC7B
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext, useCallback, useMemo } from 'react';\nimport { ChartContext } from '../ChartContext';\nimport { FOCUS_RING, SCRAPPER, LINE } from '../../constants';\nimport { FocusableRegion } from '../parts/FocusableRegion';\nimport { TrendHighlight } from '../parts/TrendHighlight';\nimport { DataVizDataTestIds } from '../DataTestIds';\nexport const Point = ({ x, y, xValue, yValue, name, pointStyle, pointRadius, id, opacity, datum }) => {\n const {\n activePoint,\n scrapperPosY,\n scrapperPosX,\n setActivePoint,\n props: { scrapper, TooltipRenderer, withTrendHighlight },\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 const handleMouseEnter = useCallback(() => {\n if (!scrapper) setActivePoint(datum);\n }, [datum, scrapper, setActivePoint]);\n\n const handleOnMouseLeave = useCallback(() => {\n if (!scrapper) setActivePoint(null);\n }, [scrapper, setActivePoint]);\n return (\n <>\n <g\n data-testid={DataVizDataTestIds.POINT}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleOnMouseLeave}\n transform={`translate(${x},${y})`}\n >\n {point}\n {activePoint?.key === id && TooltipRenderer ? (\n <FocusableRegion\n id={id}\n width={(pointRadius ?? 3) * 4}\n height={(pointRadius ?? 3) * 4}\n style={{ transform: `translate(-${pointRadius ?? 3}px, -${pointRadius ?? 3}px)` }}\n content={<TooltipRenderer data={[{ name, yValue, xValue }]} />}\n />\n ) : null}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,cAAc,CAAC;AAC7B,SACE,iCACE;AAAA;AAAA,MAAC;AAAA;AAAA,QACC,eAAa,mBAAmB;AAAA,QAChC,cAAc;AAAA,QACd,cAAc;AAAA,QACd,WAAW,aAAa,KAAK;AAAA,QAE5B;AAAA;AAAA,UACA,aAAa,QAAQ,MAAM,kBAC1B;AAAA,YAAC;AAAA;AAAA,cACC;AAAA,cACA,QAAQ,eAAe,KAAK;AAAA,cAC5B,SAAS,eAAe,KAAK;AAAA,cAC7B,OAAO,EAAE,WAAW,cAAc,eAAe,SAAS,eAAe,OAAO;AAAA,cAChF,SAAS,oBAAC,mBAAgB,MAAM,CAAC,EAAE,MAAM,QAAQ,OAAO,CAAC,GAAG;AAAA;AAAA,UAC9D,IACE;AAAA;AAAA;AAAA,IACN;AAAA,IACC,aAAa,qBAAqB,oBAAC,kBAAe,cAAc,OAAO,IAAK;AAAA,KAC/E;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -92,13 +92,13 @@ const Rect = ({ name, width, height, isNegative = false, x = null, y = null, id,
|
|
|
92
92
|
isFocused,
|
|
93
93
|
chartId,
|
|
94
94
|
transform,
|
|
95
|
+
handleMouseEnter,
|
|
96
|
+
handleOnMouseLeave,
|
|
95
97
|
isHorizontal,
|
|
96
98
|
x,
|
|
97
99
|
y,
|
|
98
100
|
width,
|
|
99
101
|
height,
|
|
100
|
-
handleMouseEnter,
|
|
101
|
-
handleOnMouseLeave,
|
|
102
102
|
activePoint?.key,
|
|
103
103
|
id,
|
|
104
104
|
TooltipRenderer,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/graphs/Chart/series/Rect.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useMemo, useContext, useCallback } from 'react';\n\nimport { ChartContext } from '../ChartContext';\nimport { FOCUS_RING } from '../../constants';\nimport { FocusableRegion } from '../parts/FocusableRegion';\nimport { DataVizDataTestIds } from '../DataTestIds';\n\nexport const Rect = ({ name, width, height, isNegative = false, x = null, y = null, id, xValue, yValue, datum }) => {\n const {\n activePoint,\n isGrabbed,\n chartId,\n isHorizontal,\n innerWidth,\n yScale,\n innerHeight,\n setActivePoint,\n props: { TooltipRenderer, scrapper },\n } = useContext(ChartContext);\n const isFocused = activePoint?.key === id;\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\n const handleMouseEnter = useCallback(() => {\n if (!scrapper) setActivePoint(datum);\n }, [datum, scrapper, setActivePoint]);\n\n const handleOnMouseLeave = useCallback(() => {\n if (!scrapper) setActivePoint(null);\n }, [scrapper, setActivePoint]);\n\n return useMemo(\n () => (\n <g clipPath={clipPathSign}>\n <g\n id={isFocused ? `data-focused-${chartId}` : ''}\n transform={transform}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleOnMouseLeave}\n data-testid={DataVizDataTestIds.BAR}\n >\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
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useMemo, useContext, useCallback } from 'react';\n\nimport { ChartContext } from '../ChartContext';\nimport { FOCUS_RING } from '../../constants';\nimport { FocusableRegion } from '../parts/FocusableRegion';\nimport { DataVizDataTestIds } from '../DataTestIds';\n\nexport const Rect = ({ name, width, height, isNegative = false, x = null, y = null, id, xValue, yValue, datum }) => {\n const {\n activePoint,\n isGrabbed,\n chartId,\n isHorizontal,\n innerWidth,\n yScale,\n innerHeight,\n setActivePoint,\n props: { TooltipRenderer, scrapper },\n } = useContext(ChartContext);\n const isFocused = activePoint?.key === id;\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\n const handleMouseEnter = useCallback(() => {\n if (!scrapper) setActivePoint(datum);\n }, [datum, scrapper, setActivePoint]);\n\n const handleOnMouseLeave = useCallback(() => {\n if (!scrapper) setActivePoint(null);\n }, [scrapper, setActivePoint]);\n\n return useMemo(\n () => (\n <g clipPath={clipPathSign}>\n <g\n id={isFocused ? `data-focused-${chartId}` : ''}\n transform={transform}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleOnMouseLeave}\n data-testid={DataVizDataTestIds.BAR}\n >\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 handleMouseEnter,\n handleOnMouseLeave,\n isHorizontal,\n x,\n y,\n width,\n height,\n activePoint?.key,\n id,\n TooltipRenderer,\n name,\n yValue,\n xValue,\n ],\n );\n};\n"],
|
|
5
5
|
"mappings": "AAAA,YAAY,WAAW;ACsBM,cA4BrB,YA5BqB;AAtB7B,SAAgB,SAAS,YAAY,mBAAmB;AAExD,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AAC3B,SAAS,uBAAuB;AAChC,SAAS,0BAA0B;AAE5B,MAAM,OAAO,C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const yValue = sequence[1] - sequence[0];
|
|
25
25
|
const width = subGroupScale?.bandwidth();
|
|
26
|
-
const height = yScale(sequence[0]) - yScale(sequence[1]) - (!isFloorStack ?
|
|
26
|
+
const height = yScale(sequence[0]) - yScale(sequence[1]) - (!isFloorStack ? 1 : 0);
|
|
27
27
|
const transformX = xScale(xValue) + subGroupScale(`stacked-data-${stackIndex}`);
|
|
28
28
|
const transformY = yScale(sequence[1]) + (sequence[0] < 0 ? 2 : 0);
|
|
29
29
|
return /* @__PURE__ */ jsx("g", { fill: colorScale(serie.name), transform: `translate(${transformX},0)`, children: /* @__PURE__ */ jsx(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/graphs/Chart/series/StackedBar.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* 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 {serie.data.map((bar, i) => {\n const sequence = serieWithStackedValues[bar.position];\n const isFloorStack = sequence[0] === 0;\n\n const xValue = getXValue(bar);\n\n const yValue = sequence[1] - sequence[0];\n const width = subGroupScale?.bandwidth();\n const height = yScale(sequence[0]) - yScale(sequence[1]) - (!isFloorStack ?
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* 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 {serie.data.map((bar, i) => {\n const sequence = serieWithStackedValues[bar.position];\n const isFloorStack = sequence[0] === 0;\n\n const xValue = getXValue(bar);\n\n const yValue = sequence[1] - sequence[0];\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]) + (sequence[0] < 0 ? 2 : 0);\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 datum={bar}\n />\n </g>\n );\n })}\n </g>\n );\n};\n"],
|
|
5
5
|
"mappings": "AAAA,YAAY,WAAW;ACqCX;AApCZ,SAAgB,kBAAkB;AAElC,SAAS,YAAY;AACrB,SAAS,oBAAoB;AAC7B,SAAS,gBAAgB,uBAAuB;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,IAAI,WAAW,YAAY;AAE3B,QAAM,yBAAyB,eAAe,aAAa,KAAK;AAChE,QAAM,aAAa,gBAAgB,QAAQ,MAAM,IAAI;AACrD,SACE,oBAAC,OAAE,UAAU,wBAAwB,YAClC,gBAAM,KAAK,IAAI,CAAC,KAAK,MAAM;AAC1B,UAAM,WAAW,uBAAuB,IAAI;AAC5C,UAAM,eAAe,SAAS,OAAO;AAErC,UAAM,SAAS,UAAU,GAAG;AAE5B,UAAM,SAAS,SAAS,KAAK,SAAS;AACtC,UAAM,QAAQ,eAAe,UAAU;AACvC,UAAM,SAAS,OAAO,SAAS,EAAE,IAAI,OAAO,SAAS,EAAE,KAAK,CAAC,eAAe,IAAI;AAChF,UAAM,aAAa,OAAO,MAAM,IAAI,cAAc,gBAAgB,YAAY;AAC9E,UAAM,aAAa,OAAO,SAAS,EAAE,KAAK,SAAS,KAAK,IAAI,IAAI;AAEhE,WACE,oBAAC,OAA0B,MAAM,WAAW,MAAM,IAAI,GAAG,WAAW,aAAa,iBAC/E;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,GAAG;AAAA,QACH,IAAI,MAAM,KAAK,GAAG;AAAA,QAClB,MAAM,MAAM;AAAA,QACZ,OAAO;AAAA;AAAA,IACT,KAVM,MAAM,KAAK,GAAG,GAWtB;AAAA,EAEJ,CAAC,GACH;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -43,11 +43,18 @@ const curveStyleMap = {
|
|
|
43
43
|
[LINE.CURVE_STYLE.LINEAR]: curveLinear,
|
|
44
44
|
[LINE.CURVE_STYLE.SPLINE]: curveMonotoneX
|
|
45
45
|
};
|
|
46
|
+
const TOOLBAR = {
|
|
47
|
+
RESET: {
|
|
48
|
+
HEIGHT: 21,
|
|
49
|
+
WIDTH: 21
|
|
50
|
+
}
|
|
51
|
+
};
|
|
46
52
|
export {
|
|
47
53
|
FOCUS_RING,
|
|
48
54
|
LINE,
|
|
49
55
|
SCALE_TYPES,
|
|
50
56
|
SCRAPPER,
|
|
57
|
+
TOOLBAR,
|
|
51
58
|
curveStyleMap
|
|
52
59
|
};
|
|
53
60
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/graphs/constants.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { curveLinear, curveMonotoneX } from 'd3';\n\nexport const SCALE_TYPES = {\n LINEAR: 'linear',\n BAND: 'band',\n LOG: 'log',\n TIME: 'time',\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 DASH_STYLE: {\n SHORTDOT: 'SHORTDOT',\n SHORTDASHDOT: 'SHORTDASHDOT',\n DASH: 'DASH',\n SHORTDASH: 'SHORTDASH',\n },\n DASH_STYLE_VALUES: {\n SHORTDOT: [2, 2],\n SHORTDASHDOT: [6, 2, 2, 2],\n DASH: [8, 6],\n SHORTDASH: [6, 2],\n },\n CURVE_STYLE: {\n LINEAR: 'LINEAR',\n SPLINE: 'SPLINE',\n },\n};\n\nexport const curveStyleMap = {\n [LINE.CURVE_STYLE.LINEAR]: curveLinear,\n [LINE.CURVE_STYLE.SPLINE]: curveMonotoneX,\n};\n"],
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,aAAa,sBAAsB;AAErC,MAAM,cAAc;AAAA,EACzB,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,KAAK;AAAA,EACL,MAAM;AACR;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;AAAA,EACtB,YAAY;AAAA,IACV,UAAU;AAAA,IACV,cAAc;AAAA,IACd,MAAM;AAAA,IACN,WAAW;AAAA,EACb;AAAA,EACA,mBAAmB;AAAA,IACjB,UAAU,CAAC,GAAG,CAAC;AAAA,IACf,cAAc,CAAC,GAAG,GAAG,GAAG,CAAC;AAAA,IACzB,MAAM,CAAC,GAAG,CAAC;AAAA,IACX,WAAW,CAAC,GAAG,CAAC;AAAA,EAClB;AAAA,EACA,aAAa;AAAA,IACX,QAAQ;AAAA,IACR,QAAQ;AAAA,EACV;AACF;AAEO,MAAM,gBAAgB;AAAA,EAC3B,CAAC,KAAK,YAAY,SAAS;AAAA,EAC3B,CAAC,KAAK,YAAY,SAAS;AAC7B;",
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { curveLinear, curveMonotoneX } from 'd3';\n\nexport const SCALE_TYPES = {\n LINEAR: 'linear',\n BAND: 'band',\n LOG: 'log',\n TIME: 'time',\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 DASH_STYLE: {\n SHORTDOT: 'SHORTDOT',\n SHORTDASHDOT: 'SHORTDASHDOT',\n DASH: 'DASH',\n SHORTDASH: 'SHORTDASH',\n },\n DASH_STYLE_VALUES: {\n SHORTDOT: [2, 2],\n SHORTDASHDOT: [6, 2, 2, 2],\n DASH: [8, 6],\n SHORTDASH: [6, 2],\n },\n CURVE_STYLE: {\n LINEAR: 'LINEAR',\n SPLINE: 'SPLINE',\n },\n};\n\nexport const curveStyleMap = {\n [LINE.CURVE_STYLE.LINEAR]: curveLinear,\n [LINE.CURVE_STYLE.SPLINE]: curveMonotoneX,\n};\n\nexport const TOOLBAR = {\n RESET: {\n HEIGHT: 21,\n WIDTH: 21,\n },\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,aAAa,sBAAsB;AAErC,MAAM,cAAc;AAAA,EACzB,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,KAAK;AAAA,EACL,MAAM;AACR;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;AAAA,EACtB,YAAY;AAAA,IACV,UAAU;AAAA,IACV,cAAc;AAAA,IACd,MAAM;AAAA,IACN,WAAW;AAAA,EACb;AAAA,EACA,mBAAmB;AAAA,IACjB,UAAU,CAAC,GAAG,CAAC;AAAA,IACf,cAAc,CAAC,GAAG,GAAG,GAAG,CAAC;AAAA,IACzB,MAAM,CAAC,GAAG,CAAC;AAAA,IACX,WAAW,CAAC,GAAG,CAAC;AAAA,EAClB;AAAA,EACA,aAAa;AAAA,IACX,QAAQ;AAAA,IACR,QAAQ;AAAA,EACV;AACF;AAEO,MAAM,gBAAgB;AAAA,EAC3B,CAAC,KAAK,YAAY,SAAS;AAAA,EAC3B,CAAC,KAAK,YAAY,SAAS;AAC7B;AAEO,MAAM,UAAU;AAAA,EACrB,OAAO;AAAA,IACL,QAAQ;AAAA,IACR,OAAO;AAAA,EACT;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-dataviz",
|
|
3
|
-
"version": "3.13.0
|
|
3
|
+
"version": "3.13.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - DataViz",
|
|
6
6
|
"files": [
|
|
@@ -40,9 +40,9 @@
|
|
|
40
40
|
"d3-shape": "~3.1.0",
|
|
41
41
|
"resize-observer-polyfill": "~1.5.1",
|
|
42
42
|
"uid": "~2.0.0",
|
|
43
|
-
"@elliemae/ds-popperjs": "3.13.0
|
|
44
|
-
"@elliemae/ds-system": "3.13.0
|
|
45
|
-
"@elliemae/ds-utilities": "3.13.0
|
|
43
|
+
"@elliemae/ds-popperjs": "3.13.0",
|
|
44
|
+
"@elliemae/ds-system": "3.13.0",
|
|
45
|
+
"@elliemae/ds-utilities": "3.13.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@elliemae/pui-theme": "~2.6.0",
|