@cloudscape-design/components-themeable 3.0.430 → 3.0.432
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/lib/internal/manifest.json +1 -1
- package/lib/internal/scss/table/styles.scss +2 -1
- package/lib/internal/template/area-chart/chart-container.d.ts.map +1 -1
- package/lib/internal/template/area-chart/chart-container.js +3 -2
- package/lib/internal/template/area-chart/chart-container.js.map +1 -1
- package/lib/internal/template/internal/components/cartesian-chart/label-utils.d.ts +4 -0
- package/lib/internal/template/internal/components/cartesian-chart/label-utils.d.ts.map +1 -1
- package/lib/internal/template/internal/components/cartesian-chart/label-utils.js +8 -0
- package/lib/internal/template/internal/components/cartesian-chart/label-utils.js.map +1 -1
- package/lib/internal/template/internal/components/cartesian-chart/labels-measure.d.ts +2 -1
- package/lib/internal/template/internal/components/cartesian-chart/labels-measure.d.ts.map +1 -1
- package/lib/internal/template/internal/components/cartesian-chart/labels-measure.js +6 -4
- package/lib/internal/template/internal/components/cartesian-chart/labels-measure.js.map +1 -1
- package/lib/internal/template/internal/components/cartesian-chart/left-labels.d.ts +4 -3
- package/lib/internal/template/internal/components/cartesian-chart/left-labels.d.ts.map +1 -1
- package/lib/internal/template/internal/components/cartesian-chart/left-labels.js +23 -13
- package/lib/internal/template/internal/components/cartesian-chart/left-labels.js.map +1 -1
- package/lib/internal/template/internal/components/responsive-text/index.d.ts +13 -0
- package/lib/internal/template/internal/components/responsive-text/index.d.ts.map +1 -0
- package/lib/internal/template/internal/components/responsive-text/index.js +32 -0
- package/lib/internal/template/internal/components/responsive-text/index.js.map +1 -0
- package/lib/internal/template/internal/components/responsive-text/responsive-text-utils.d.ts +2 -0
- package/lib/internal/template/internal/components/responsive-text/responsive-text-utils.d.ts.map +1 -0
- package/lib/internal/template/internal/components/responsive-text/responsive-text-utils.js +11 -0
- package/lib/internal/template/internal/components/responsive-text/responsive-text-utils.js.map +1 -0
- package/lib/internal/template/internal/environment.js +1 -1
- package/lib/internal/template/internal/environment.json +1 -1
- package/lib/internal/template/mixed-line-bar-chart/chart-container.d.ts.map +1 -1
- package/lib/internal/template/mixed-line-bar-chart/chart-container.js +3 -2
- package/lib/internal/template/mixed-line-bar-chart/chart-container.js.map +1 -1
- package/lib/internal/template/pie-chart/responsive-text.d.ts.map +1 -1
- package/lib/internal/template/pie-chart/responsive-text.js +1 -18
- package/lib/internal/template/pie-chart/responsive-text.js.map +1 -1
- package/lib/internal/template/table/internal.d.ts.map +1 -1
- package/lib/internal/template/table/internal.js +4 -7
- package/lib/internal/template/table/internal.js.map +1 -1
- package/lib/internal/template/table/node-data-cell.d.ts +15 -0
- package/lib/internal/template/table/node-data-cell.d.ts.map +1 -0
- package/lib/internal/template/table/node-data-cell.js +25 -0
- package/lib/internal/template/table/node-data-cell.js.map +1 -0
- package/lib/internal/template/table/styles.css.js +35 -34
- package/lib/internal/template/table/styles.scoped.css +40 -40
- package/lib/internal/template/table/styles.selectors.js +35 -34
- package/lib/internal/template/table/thead.d.ts +1 -1
- package/lib/internal/template/table/thead.d.ts.map +1 -1
- package/lib/internal/template/table/thead.js.map +1 -1
- package/package.json +1 -1
|
@@ -68,7 +68,8 @@
|
|
|
68
68
|
scrollbar-width: none; /* Hide scrollbar in Firefox */
|
|
69
69
|
&.variant-stacked,
|
|
70
70
|
&.variant-container {
|
|
71
|
-
& > .table
|
|
71
|
+
& > .table,
|
|
72
|
+
& > .wrapper-content-measure {
|
|
72
73
|
padding-left: awsui.$space-table-horizontal;
|
|
73
74
|
padding-right: awsui.$space-table-horizontal;
|
|
74
75
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chart-container.d.ts","sourceRoot":"lib/default/","sources":["area-chart/chart-container.tsx"],"names":[],"mappings":";AAWA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAiBrC,UAAU,mBAAmB,CAAC,CAAC,SAAS,cAAc,CAAC,SAAS,CAC9D,SAAQ,IAAI,CACV,cAAc,CAAC,CAAC,CAAC,EACf,QAAQ,GACR,QAAQ,GACR,gBAAgB,GAChB,gBAAgB,GAChB,sBAAsB,GACtB,mBAAmB,GACnB,qBAAqB,GACrB,WAAW,GACX,gBAAgB,GAChB,iBAAiB,GACjB,aAAa,CAChB;IACD,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IACrB,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB;;AAED,wBAA6D;AAE7D,iBAAS,cAAc,CAAC,CAAC,SAAS,cAAc,CAAC,SAAS,EAAE,EAC1D,KAAK,EACL,SAAS,EACT,MAAM,EACN,MAAM,EACN,iBAAiB,EACjB,mBAAmB,EACnB,SAAS,EACT,cAAc,EACd,eAAe,EACf,WAAW,EAAE,EACX,cAAc,EAAE,wBAAwB,EACxC,cAAc,EAAE,wBAAwB,EACxC,oBAAoB,EAAE,8BAA8B,EACpD,gBAAgB,EAChB,wBAAwB,EACxB,wBAAwB,EACxB,wBAAwB,EACxB,6BAA6B,GACzB,EACN,SAAS,EACT,SAAS,EACT,cAAyC,EACzC,cAAyC,EACzC,oBAAqD,GACtD,EAAE,mBAAmB,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"chart-container.d.ts","sourceRoot":"lib/default/","sources":["area-chart/chart-container.tsx"],"names":[],"mappings":";AAWA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAiBrC,UAAU,mBAAmB,CAAC,CAAC,SAAS,cAAc,CAAC,SAAS,CAC9D,SAAQ,IAAI,CACV,cAAc,CAAC,CAAC,CAAC,EACf,QAAQ,GACR,QAAQ,GACR,gBAAgB,GAChB,gBAAgB,GAChB,sBAAsB,GACtB,mBAAmB,GACnB,qBAAqB,GACrB,WAAW,GACX,gBAAgB,GAChB,iBAAiB,GACjB,aAAa,CAChB;IACD,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IACrB,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB;;AAED,wBAA6D;AAE7D,iBAAS,cAAc,CAAC,CAAC,SAAS,cAAc,CAAC,SAAS,EAAE,EAC1D,KAAK,EACL,SAAS,EACT,MAAM,EACN,MAAM,EACN,iBAAiB,EACjB,mBAAmB,EACnB,SAAS,EACT,cAAc,EACd,eAAe,EACf,WAAW,EAAE,EACX,cAAc,EAAE,wBAAwB,EACxC,cAAc,EAAE,wBAAwB,EACxC,oBAAoB,EAAE,8BAA8B,EACpD,gBAAgB,EAChB,wBAAwB,EACxB,wBAAwB,EACxB,wBAAwB,EACxB,6BAA6B,GACzB,EACN,SAAS,EACT,SAAS,EACT,cAAyC,EACzC,cAAyC,EACzC,oBAAqD,GACtD,EAAE,mBAAmB,CAAC,CAAC,CAAC,eAgIxB"}
|
|
@@ -23,6 +23,7 @@ export default memo(ChartContainer);
|
|
|
23
23
|
function ChartContainer({ model, autoWidth, xTitle, yTitle, detailPopoverSize, detailPopoverFooter, ariaLabel, ariaLabelledby, ariaDescription, i18nStrings: { xTickFormatter: deprecatedXTickFormatter, yTickFormatter: deprecatedYTickFormatter, detailTotalFormatter: deprecatedDetailTotalFormatter, detailTotalLabel, chartAriaRoleDescription, xAxisAriaRoleDescription, yAxisAriaRoleDescription, detailPopoverDismissAriaLabel, } = {}, fitHeight, minHeight, xTickFormatter = deprecatedXTickFormatter, yTickFormatter = deprecatedYTickFormatter, detailTotalFormatter = deprecatedDetailTotalFormatter, }) {
|
|
24
24
|
const [leftLabelsWidth, setLeftLabelsWidth] = useState(0);
|
|
25
25
|
const [containerWidth, containerWidthRef] = useContainerWidth(DEFAULT_CHART_WIDTH);
|
|
26
|
+
const maxLeftLabelsWidth = Math.round(containerWidth / 2);
|
|
26
27
|
const bottomLabelsProps = useBottomLabels({
|
|
27
28
|
ticks: model.computed.xTicks,
|
|
28
29
|
scale: model.computed.xScale,
|
|
@@ -45,9 +46,9 @@ function ChartContainer({ model, autoWidth, xTitle, yTitle, detailPopoverSize, d
|
|
|
45
46
|
const isPointHighlighted = model.interactions.get().highlightedPoint !== null;
|
|
46
47
|
const highlightedX = useSelector(model.interactions, state => state.highlightedX);
|
|
47
48
|
const detailPopoverFooterContent = useMemo(() => (detailPopoverFooter && highlightedX ? detailPopoverFooter(highlightedX[0].x) : null), [detailPopoverFooter, highlightedX]);
|
|
48
|
-
return (React.createElement(CartesianChartContainer, { ref: mergedRef, minHeight: minHeight + bottomLabelsProps.height, fitHeight: !!fitHeight, leftAxisLabel: React.createElement(AxisLabel, { axis: "y", position: "left", title: yTitle }), leftAxisLabelMeasure: React.createElement(LabelsMeasure, { scale: model.computed.yScale, ticks: model.computed.yTicks, tickFormatter: yTickFormatter, autoWidth: setLeftLabelsWidth }), bottomAxisLabel: React.createElement(AxisLabel, { axis: "x", position: "bottom", title: xTitle }), chartPlot: React.createElement(ChartPlot, { ref: model.refs.plot, width: "100%", height: fitHeight ? `calc(100% - ${bottomLabelsProps.height}px)` : model.height, offsetBottom: bottomLabelsProps.height, ariaLabel: ariaLabel, ariaLabelledby: ariaLabelledby, ariaDescription: ariaDescription, ariaRoleDescription: chartAriaRoleDescription, activeElementKey: !(highlightDetails === null || highlightDetails === void 0 ? void 0 : highlightDetails.isPopoverPinned) && (highlightDetails === null || highlightDetails === void 0 ? void 0 : highlightDetails.activeLabel), activeElementRef: isPointHighlighted ? highlightedPointRef : model.refs.verticalMarker, activeElementFocusOffset: isPointHighlighted ? 3 : { x: 8, y: 0 }, isClickable: !(highlightDetails === null || highlightDetails === void 0 ? void 0 : highlightDetails.isPopoverPinned), onMouseMove: model.handlers.onSVGMouseMove, onMouseOut: model.handlers.onSVGMouseOut, onMouseDown: model.handlers.onSVGMouseDown, onKeyDown: model.handlers.onSVGKeyDown, onFocus: model.handlers.onSVGFocus, onBlur: model.handlers.onSVGBlur },
|
|
49
|
+
return (React.createElement(CartesianChartContainer, { ref: mergedRef, minHeight: minHeight + bottomLabelsProps.height, fitHeight: !!fitHeight, leftAxisLabel: React.createElement(AxisLabel, { axis: "y", position: "left", title: yTitle }), leftAxisLabelMeasure: React.createElement(LabelsMeasure, { scale: model.computed.yScale, ticks: model.computed.yTicks, tickFormatter: yTickFormatter, autoWidth: setLeftLabelsWidth, maxLabelsWidth: maxLeftLabelsWidth }), bottomAxisLabel: React.createElement(AxisLabel, { axis: "x", position: "bottom", title: xTitle }), chartPlot: React.createElement(ChartPlot, { ref: model.refs.plot, width: "100%", height: fitHeight ? `calc(100% - ${bottomLabelsProps.height}px)` : model.height, offsetBottom: bottomLabelsProps.height, ariaLabel: ariaLabel, ariaLabelledby: ariaLabelledby, ariaDescription: ariaDescription, ariaRoleDescription: chartAriaRoleDescription, activeElementKey: !(highlightDetails === null || highlightDetails === void 0 ? void 0 : highlightDetails.isPopoverPinned) && (highlightDetails === null || highlightDetails === void 0 ? void 0 : highlightDetails.activeLabel), activeElementRef: isPointHighlighted ? highlightedPointRef : model.refs.verticalMarker, activeElementFocusOffset: isPointHighlighted ? 3 : { x: 8, y: 0 }, isClickable: !(highlightDetails === null || highlightDetails === void 0 ? void 0 : highlightDetails.isPopoverPinned), onMouseMove: model.handlers.onSVGMouseMove, onMouseOut: model.handlers.onSVGMouseOut, onMouseDown: model.handlers.onSVGMouseDown, onKeyDown: model.handlers.onSVGKeyDown, onFocus: model.handlers.onSVGFocus, onBlur: model.handlers.onSVGBlur },
|
|
49
50
|
React.createElement("line", { ref: model.refs.plotMeasure, x1: "0", x2: "0", y1: "0", y2: "100%", stroke: "transparent", strokeWidth: 1, style: { pointerEvents: 'none' } }),
|
|
50
|
-
React.createElement(LeftLabels, {
|
|
51
|
+
React.createElement(LeftLabels, { plotWidth: model.width, plotHeight: model.height, scale: model.computed.yScale, ticks: model.computed.yTicks, tickFormatter: yTickFormatter, title: yTitle, ariaRoleDescription: yAxisAriaRoleDescription, maxLabelsWidth: maxLeftLabelsWidth }),
|
|
51
52
|
React.createElement(AreaDataSeries, { model: model }),
|
|
52
53
|
React.createElement(BottomLabels, Object.assign({}, bottomLabelsProps, { width: model.width, height: model.height, scale: model.computed.xScale, title: xTitle, ariaRoleDescription: xAxisAriaRoleDescription, offsetLeft: leftLabelsWidth + BOTTOM_LABELS_OFFSET, offsetRight: BOTTOM_LABELS_OFFSET })),
|
|
53
54
|
React.createElement(EmphasizedBaseline, { width: model.width, height: model.height, scale: model.computed.yScale }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chart-container.js","sourceRoot":"lib/default/","sources":["area-chart/chart-container.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAEhE,OAAO,SAAS,MAAM,mCAAmC,CAAC;AAC1D,OAAO,SAAS,MAAM,mDAAmD,CAAC;AAC1E,OAAO,aAAa,MAAM,uDAAuD,CAAC;AAClF,OAAO,UAAU,MAAM,oDAAoD,CAAC;AAC5E,OAAO,YAAY,EAAE,EAAE,eAAe,EAAE,MAAM,sDAAsD,CAAC;AACrG,OAAO,kBAAkB,MAAM,4DAA4D,CAAC;AAG5F,OAAO,cAAc,MAAM,wBAAwB,CAAC;AACpD,OAAO,gBAAgB,MAAM,0BAA0B,CAAC;AACxD,OAAO,oBAAoB,MAAM,8BAA8B,CAAC;AAChE,OAAO,kBAAkB,MAAM,4BAA4B,CAAC;AAE5D,OAAO,mBAAmB,MAAM,kCAAkC,CAAC;AACnE,OAAO,iBAAiB,MAAM,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AI,CAChG,EAEd,OAAO,EACL,oBAAC,gBAAgB,IACf,KAAK,EAAE,KAAK,EACZ,gBAAgB,EAAE,gBAAgB,EAClC,gBAAgB,EAAE,6BAA6B,EAC/C,IAAI,EAAE,iBAAiB,EACvB,MAAM,EAAE,0BAA0B,GAClC,GAEJ,CACH,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useState, useEffect, memo, useRef, useMemo } from 'react';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\n\nimport ChartPlot from '../internal/components/chart-plot';\nimport AxisLabel from '../internal/components/cartesian-chart/axis-label';\nimport LabelsMeasure from '../internal/components/cartesian-chart/labels-measure';\nimport LeftLabels from '../internal/components/cartesian-chart/left-labels';\nimport BottomLabels, { useBottomLabels } from '../internal/components/cartesian-chart/bottom-labels';\nimport EmphasizedBaseline from '../internal/components/cartesian-chart/emphasized-baseline';\nimport { AreaChartProps } from './interfaces';\nimport { ChartModel } from './model';\nimport AreaDataSeries from './elements/data-series';\nimport AreaChartPopover from './elements/chart-popover';\nimport AreaHighlightedPoint from './elements/highlighted-point';\nimport AreaVerticalMarker from './elements/vertical-marker';\n\nimport useHighlightDetails from './elements/use-highlight-details';\nimport useContainerWidth from '../internal/utils/use-container-width';\nimport { useSelector } from './async-store';\nimport { CartesianChartContainer } from '../internal/components/cartesian-chart/chart-container';\n\nconst DEFAULT_CHART_WIDTH = 500;\nconst LEFT_LABELS_MARGIN = 16;\nconst BOTTOM_LABELS_OFFSET = 12;\n\ntype TickFormatter = undefined | ((value: AreaChartProps.DataTypes) => string);\n\ninterface ChartContainerProps<T extends AreaChartProps.DataTypes>\n extends Pick<\n AreaChartProps<T>,\n | 'xTitle'\n | 'yTitle'\n | 'xTickFormatter'\n | 'yTickFormatter'\n | 'detailTotalFormatter'\n | 'detailPopoverSize'\n | 'detailPopoverFooter'\n | 'ariaLabel'\n | 'ariaLabelledby'\n | 'ariaDescription'\n | 'i18nStrings'\n > {\n model: ChartModel<T>;\n autoWidth: (value: number) => void;\n fitHeight?: boolean;\n minHeight: number;\n}\n\nexport default memo(ChartContainer) as typeof ChartContainer;\n\nfunction ChartContainer<T extends AreaChartProps.DataTypes>({\n model,\n autoWidth,\n xTitle,\n yTitle,\n detailPopoverSize,\n detailPopoverFooter,\n ariaLabel,\n ariaLabelledby,\n ariaDescription,\n i18nStrings: {\n xTickFormatter: deprecatedXTickFormatter,\n yTickFormatter: deprecatedYTickFormatter,\n detailTotalFormatter: deprecatedDetailTotalFormatter,\n detailTotalLabel,\n chartAriaRoleDescription,\n xAxisAriaRoleDescription,\n yAxisAriaRoleDescription,\n detailPopoverDismissAriaLabel,\n } = {},\n fitHeight,\n minHeight,\n xTickFormatter = deprecatedXTickFormatter,\n yTickFormatter = deprecatedYTickFormatter,\n detailTotalFormatter = deprecatedDetailTotalFormatter,\n}: ChartContainerProps<T>) {\n const [leftLabelsWidth, setLeftLabelsWidth] = useState(0);\n const [containerWidth, containerWidthRef] = useContainerWidth(DEFAULT_CHART_WIDTH);\n\n const bottomLabelsProps = useBottomLabels({\n ticks: model.computed.xTicks,\n scale: model.computed.xScale,\n tickFormatter: xTickFormatter as TickFormatter,\n });\n\n // Calculate the width of the plot area and tell it to the parent.\n const plotWidth = Math.max(0, containerWidth - leftLabelsWidth - LEFT_LABELS_MARGIN);\n useEffect(() => {\n autoWidth(plotWidth);\n }, [autoWidth, plotWidth]);\n\n const highlightDetails = useHighlightDetails({\n model,\n xTickFormatter,\n yTickFormatter,\n detailTotalFormatter,\n detailTotalLabel,\n });\n\n const highlightedPointRef = useRef<SVGGElement>(null);\n\n const mergedRef = useMergeRefs(containerWidthRef, model.refs.container);\n\n const isPointHighlighted = model.interactions.get().highlightedPoint !== null;\n\n const highlightedX = useSelector(model.interactions, state => state.highlightedX);\n\n const detailPopoverFooterContent = useMemo(\n () => (detailPopoverFooter && highlightedX ? detailPopoverFooter(highlightedX[0].x) : null),\n [detailPopoverFooter, highlightedX]\n );\n\n return (\n <CartesianChartContainer\n ref={mergedRef}\n minHeight={minHeight + bottomLabelsProps.height}\n fitHeight={!!fitHeight}\n leftAxisLabel={<AxisLabel axis=\"y\" position=\"left\" title={yTitle} />}\n leftAxisLabelMeasure={\n <LabelsMeasure\n scale={model.computed.yScale}\n ticks={model.computed.yTicks}\n tickFormatter={yTickFormatter as TickFormatter}\n autoWidth={setLeftLabelsWidth}\n />\n }\n bottomAxisLabel={<AxisLabel axis=\"x\" position=\"bottom\" title={xTitle} />}\n chartPlot={\n <ChartPlot\n ref={model.refs.plot}\n width=\"100%\"\n height={fitHeight ? `calc(100% - ${bottomLabelsProps.height}px)` : model.height}\n offsetBottom={bottomLabelsProps.height}\n ariaLabel={ariaLabel}\n ariaLabelledby={ariaLabelledby}\n ariaDescription={ariaDescription}\n ariaRoleDescription={chartAriaRoleDescription}\n activeElementKey={!highlightDetails?.isPopoverPinned && highlightDetails?.activeLabel}\n activeElementRef={isPointHighlighted ? highlightedPointRef : model.refs.verticalMarker}\n activeElementFocusOffset={isPointHighlighted ? 3 : { x: 8, y: 0 }}\n isClickable={!highlightDetails?.isPopoverPinned}\n onMouseMove={model.handlers.onSVGMouseMove}\n onMouseOut={model.handlers.onSVGMouseOut}\n onMouseDown={model.handlers.onSVGMouseDown}\n onKeyDown={model.handlers.onSVGKeyDown}\n onFocus={model.handlers.onSVGFocus}\n onBlur={model.handlers.onSVGBlur}\n >\n <line\n ref={model.refs.plotMeasure}\n x1=\"0\"\n x2=\"0\"\n y1=\"0\"\n y2=\"100%\"\n stroke=\"transparent\"\n strokeWidth={1}\n style={{ pointerEvents: 'none' }}\n />\n\n <LeftLabels\n width={model.width}\n height={model.height}\n scale={model.computed.yScale}\n ticks={model.computed.yTicks}\n tickFormatter={yTickFormatter}\n title={yTitle}\n ariaRoleDescription={yAxisAriaRoleDescription}\n />\n\n <AreaDataSeries model={model} />\n\n <BottomLabels\n {...bottomLabelsProps}\n width={model.width}\n height={model.height}\n scale={model.computed.xScale}\n title={xTitle}\n ariaRoleDescription={xAxisAriaRoleDescription}\n offsetLeft={leftLabelsWidth + BOTTOM_LABELS_OFFSET}\n offsetRight={BOTTOM_LABELS_OFFSET}\n />\n\n <EmphasizedBaseline width={model.width} height={model.height} scale={model.computed.yScale} />\n\n <AreaVerticalMarker model={model} />\n\n <AreaHighlightedPoint ref={highlightedPointRef} model={model} ariaLabel={highlightDetails?.activeLabel} />\n </ChartPlot>\n }\n popover={\n <AreaChartPopover\n model={model}\n highlightDetails={highlightDetails}\n dismissAriaLabel={detailPopoverDismissAriaLabel}\n size={detailPopoverSize}\n footer={detailPopoverFooterContent}\n />\n }\n />\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"chart-container.js","sourceRoot":"lib/default/","sources":["area-chart/chart-container.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAEhE,OAAO,SAAS,MAAM,mCAAmC,CAAC;AAC1D,OAAO,SAAS,MAAM,mDAAmD,CAAC;AAC1E,OAAO,aAAa,MAAM,uDAAuD,CAAC;AAClF,OAAO,UAAU,MAAM,oDAAoD,CAAC;AAC5E,OAAO,YAAY,EAAE,EAAE,eAAe,EAAE,MAAM,sDAAsD,CAAC;AACrG,OAAO,kBAAkB,MAAM,4DAA4D,CAAC;AAG5F,OAAO,cAAc,MAAM,wBAAwB,CAAC;AACpD,OAAO,gBAAgB,MAAM,0BAA0B,CAAC;AACxD,OAAO,oBAAoB,MAAM,8BAA8B,CAAC;AAChE,OAAO,kBAAkB,MAAM,4BAA4B,CAAC;AAE5D,OAAO,mBAAmB,MAAM,kCAAkC,CAAC;AACnE,OAAO,iBAAiB,MAAM,uCAAuC,CAAC;AACt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AG,EAAE,mBAAmB,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,WAAW,GAAI,CAChG,EAEd,OAAO,EACL,oBAAC,gBAAgB,IACf,KAAK,EAAE,KAAK,EACZ,gBAAgB,EAAE,gBAAgB,EAClC,gBAAgB,EAAE,6BAA6B,EAC/C,IAAI,EAAE,iBAAiB,EACvB,MAAM,EAAE,0BAA0B,GAClC,GAEJ,CACH,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useState, useEffect, memo, useRef, useMemo } from 'react';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\n\nimport ChartPlot from '../internal/components/chart-plot';\nimport AxisLabel from '../internal/components/cartesian-chart/axis-label';\nimport LabelsMeasure from '../internal/components/cartesian-chart/labels-measure';\nimport LeftLabels from '../internal/components/cartesian-chart/left-labels';\nimport BottomLabels, { useBottomLabels } from '../internal/components/cartesian-chart/bottom-labels';\nimport EmphasizedBaseline from '../internal/components/cartesian-chart/emphasized-baseline';\nimport { AreaChartProps } from './interfaces';\nimport { ChartModel } from './model';\nimport AreaDataSeries from './elements/data-series';\nimport AreaChartPopover from './elements/chart-popover';\nimport AreaHighlightedPoint from './elements/highlighted-point';\nimport AreaVerticalMarker from './elements/vertical-marker';\n\nimport useHighlightDetails from './elements/use-highlight-details';\nimport useContainerWidth from '../internal/utils/use-container-width';\nimport { useSelector } from './async-store';\nimport { CartesianChartContainer } from '../internal/components/cartesian-chart/chart-container';\n\nconst DEFAULT_CHART_WIDTH = 500;\nconst LEFT_LABELS_MARGIN = 16;\nconst BOTTOM_LABELS_OFFSET = 12;\n\ntype TickFormatter = undefined | ((value: AreaChartProps.DataTypes) => string);\n\ninterface ChartContainerProps<T extends AreaChartProps.DataTypes>\n extends Pick<\n AreaChartProps<T>,\n | 'xTitle'\n | 'yTitle'\n | 'xTickFormatter'\n | 'yTickFormatter'\n | 'detailTotalFormatter'\n | 'detailPopoverSize'\n | 'detailPopoverFooter'\n | 'ariaLabel'\n | 'ariaLabelledby'\n | 'ariaDescription'\n | 'i18nStrings'\n > {\n model: ChartModel<T>;\n autoWidth: (value: number) => void;\n fitHeight?: boolean;\n minHeight: number;\n}\n\nexport default memo(ChartContainer) as typeof ChartContainer;\n\nfunction ChartContainer<T extends AreaChartProps.DataTypes>({\n model,\n autoWidth,\n xTitle,\n yTitle,\n detailPopoverSize,\n detailPopoverFooter,\n ariaLabel,\n ariaLabelledby,\n ariaDescription,\n i18nStrings: {\n xTickFormatter: deprecatedXTickFormatter,\n yTickFormatter: deprecatedYTickFormatter,\n detailTotalFormatter: deprecatedDetailTotalFormatter,\n detailTotalLabel,\n chartAriaRoleDescription,\n xAxisAriaRoleDescription,\n yAxisAriaRoleDescription,\n detailPopoverDismissAriaLabel,\n } = {},\n fitHeight,\n minHeight,\n xTickFormatter = deprecatedXTickFormatter,\n yTickFormatter = deprecatedYTickFormatter,\n detailTotalFormatter = deprecatedDetailTotalFormatter,\n}: ChartContainerProps<T>) {\n const [leftLabelsWidth, setLeftLabelsWidth] = useState(0);\n const [containerWidth, containerWidthRef] = useContainerWidth(DEFAULT_CHART_WIDTH);\n const maxLeftLabelsWidth = Math.round(containerWidth / 2);\n\n const bottomLabelsProps = useBottomLabels({\n ticks: model.computed.xTicks,\n scale: model.computed.xScale,\n tickFormatter: xTickFormatter as TickFormatter,\n });\n\n // Calculate the width of the plot area and tell it to the parent.\n const plotWidth = Math.max(0, containerWidth - leftLabelsWidth - LEFT_LABELS_MARGIN);\n useEffect(() => {\n autoWidth(plotWidth);\n }, [autoWidth, plotWidth]);\n\n const highlightDetails = useHighlightDetails({\n model,\n xTickFormatter,\n yTickFormatter,\n detailTotalFormatter,\n detailTotalLabel,\n });\n\n const highlightedPointRef = useRef<SVGGElement>(null);\n\n const mergedRef = useMergeRefs(containerWidthRef, model.refs.container);\n\n const isPointHighlighted = model.interactions.get().highlightedPoint !== null;\n\n const highlightedX = useSelector(model.interactions, state => state.highlightedX);\n\n const detailPopoverFooterContent = useMemo(\n () => (detailPopoverFooter && highlightedX ? detailPopoverFooter(highlightedX[0].x) : null),\n [detailPopoverFooter, highlightedX]\n );\n\n return (\n <CartesianChartContainer\n ref={mergedRef}\n minHeight={minHeight + bottomLabelsProps.height}\n fitHeight={!!fitHeight}\n leftAxisLabel={<AxisLabel axis=\"y\" position=\"left\" title={yTitle} />}\n leftAxisLabelMeasure={\n <LabelsMeasure\n scale={model.computed.yScale}\n ticks={model.computed.yTicks}\n tickFormatter={yTickFormatter as TickFormatter}\n autoWidth={setLeftLabelsWidth}\n maxLabelsWidth={maxLeftLabelsWidth}\n />\n }\n bottomAxisLabel={<AxisLabel axis=\"x\" position=\"bottom\" title={xTitle} />}\n chartPlot={\n <ChartPlot\n ref={model.refs.plot}\n width=\"100%\"\n height={fitHeight ? `calc(100% - ${bottomLabelsProps.height}px)` : model.height}\n offsetBottom={bottomLabelsProps.height}\n ariaLabel={ariaLabel}\n ariaLabelledby={ariaLabelledby}\n ariaDescription={ariaDescription}\n ariaRoleDescription={chartAriaRoleDescription}\n activeElementKey={!highlightDetails?.isPopoverPinned && highlightDetails?.activeLabel}\n activeElementRef={isPointHighlighted ? highlightedPointRef : model.refs.verticalMarker}\n activeElementFocusOffset={isPointHighlighted ? 3 : { x: 8, y: 0 }}\n isClickable={!highlightDetails?.isPopoverPinned}\n onMouseMove={model.handlers.onSVGMouseMove}\n onMouseOut={model.handlers.onSVGMouseOut}\n onMouseDown={model.handlers.onSVGMouseDown}\n onKeyDown={model.handlers.onSVGKeyDown}\n onFocus={model.handlers.onSVGFocus}\n onBlur={model.handlers.onSVGBlur}\n >\n <line\n ref={model.refs.plotMeasure}\n x1=\"0\"\n x2=\"0\"\n y1=\"0\"\n y2=\"100%\"\n stroke=\"transparent\"\n strokeWidth={1}\n style={{ pointerEvents: 'none' }}\n />\n\n <LeftLabels\n plotWidth={model.width}\n plotHeight={model.height}\n scale={model.computed.yScale}\n ticks={model.computed.yTicks}\n tickFormatter={yTickFormatter}\n title={yTitle}\n ariaRoleDescription={yAxisAriaRoleDescription}\n maxLabelsWidth={maxLeftLabelsWidth}\n />\n\n <AreaDataSeries model={model} />\n\n <BottomLabels\n {...bottomLabelsProps}\n width={model.width}\n height={model.height}\n scale={model.computed.xScale}\n title={xTitle}\n ariaRoleDescription={xAxisAriaRoleDescription}\n offsetLeft={leftLabelsWidth + BOTTOM_LABELS_OFFSET}\n offsetRight={BOTTOM_LABELS_OFFSET}\n />\n\n <EmphasizedBaseline width={model.width} height={model.height} scale={model.computed.yScale} />\n\n <AreaVerticalMarker model={model} />\n\n <AreaHighlightedPoint ref={highlightedPointRef} model={model} ariaLabel={highlightDetails?.activeLabel} />\n </ChartPlot>\n }\n popover={\n <AreaChartPopover\n model={model}\n highlightDetails={highlightDetails}\n dismissAriaLabel={detailPopoverDismissAriaLabel}\n size={detailPopoverSize}\n footer={detailPopoverFooterContent}\n />\n }\n />\n );\n}\n"]}
|
|
@@ -12,4 +12,8 @@ export declare function formatTicks({ ticks, scale, getLabelSpace, tickFormatter
|
|
|
12
12
|
tickFormatter?: (value: any) => string;
|
|
13
13
|
}): FormattedTick[];
|
|
14
14
|
export declare function getVisibleTicks(ticks: readonly FormattedTick[], from: number, until: number, balanceTicks?: boolean): readonly FormattedTick[];
|
|
15
|
+
export declare function getSVGTextSize(element: null | SVGTextElement): undefined | {
|
|
16
|
+
width: number;
|
|
17
|
+
height: number;
|
|
18
|
+
};
|
|
15
19
|
//# sourceMappingURL=label-utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"label-utils.d.ts","sourceRoot":"lib/default/","sources":["internal/components/cartesian-chart/label-utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAIzD,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,KAAK,EACL,aAAa,EACb,aAAa,GACd,EAAE;IACD,KAAK,EAAE,SAAS,cAAc,EAAE,CAAC;IACjC,KAAK,EAAE,UAAU,GAAG,iBAAiB,CAAC;IACtC,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IACzC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,MAAM,CAAC;CACxC,GAAG,aAAa,EAAE,CAOlB;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,SAAS,aAAa,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,UAAQ,4BAGjH"}
|
|
1
|
+
{"version":3,"file":"label-utils.d.ts","sourceRoot":"lib/default/","sources":["internal/components/cartesian-chart/label-utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAIzD,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,KAAK,EACL,aAAa,EACb,aAAa,GACd,EAAE;IACD,KAAK,EAAE,SAAS,cAAc,EAAE,CAAC;IACjC,KAAK,EAAE,UAAU,GAAG,iBAAiB,CAAC;IACtC,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IACzC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,MAAM,CAAC;CACxC,GAAG,aAAa,EAAE,CAOlB;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,SAAS,aAAa,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,UAAQ,4BAGjH;AAkDD,wBAAgB,cAAc,CAAC,OAAO,EAAE,IAAI,GAAG,cAAc,GAAG,SAAS,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAK5G"}
|
|
@@ -52,4 +52,12 @@ function hasIntersection(a, b) {
|
|
|
52
52
|
const rightEdge = right.position - right.space / 2;
|
|
53
53
|
return leftEdge > rightEdge;
|
|
54
54
|
}
|
|
55
|
+
// Ignoring as unsupported in JSDom.
|
|
56
|
+
/* istanbul ignore next */
|
|
57
|
+
export function getSVGTextSize(element) {
|
|
58
|
+
if (element && element.getBBox) {
|
|
59
|
+
return element.getBBox();
|
|
60
|
+
}
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
55
63
|
//# sourceMappingURL=label-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"label-utils.js","sourceRoot":"lib/default/","sources":["internal/components/cartesian-chart/label-utils.ts"],"names":[],"mappings":"AAKA,MAAM,aAAa,GAAG,CAAC,CAAC;AAQxB,MAAM,UAAU,WAAW,CAAC,EAC1B,KAAK,EACL,KAAK,EACL,aAAa,EACb,aAAa,GAMd;IACC,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;;QACtB,MAAM,QAAQ,GAAG,MAAA,KAAK,CAAC,OAAO,CAAC,IAAW,CAAC,mCAAI,GAAG,CAAC;QACnD,MAAM,KAAK,GAAG,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC,IAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC3E,MAAM,KAAK,GAAG,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,I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{ ChartDataTypes } from './interfaces';\nimport { ChartScale, NumericChartScale } from './scales';\n\nconst SPACE_BETWEEN = 4;\n\nexport interface FormattedTick {\n position: number;\n space: number;\n lines: string[];\n}\n\nexport function formatTicks({\n ticks,\n scale,\n getLabelSpace,\n tickFormatter,\n}: {\n ticks: readonly ChartDataTypes[];\n scale: ChartScale | NumericChartScale;\n getLabelSpace: (label: string) => number;\n tickFormatter?: (value: any) => string;\n}): FormattedTick[] {\n return ticks.map(tick => {\n const position = scale.d3Scale(tick as any) ?? NaN;\n const label = tickFormatter ? tickFormatter(tick as any) : tick.toString();\n const lines = (label + '').split('\\n');\n return { position, lines, space: Math.max(...lines.map(getLabelSpace)) };\n });\n}\n\nexport function getVisibleTicks(ticks: readonly FormattedTick[], from: number, until: number, balanceTicks = false) {\n ticks = getTicksInRange(ticks, from, until);\n return balanceTicks ? getReducedTicks(ticks) : removeIntersections(ticks);\n}\n\nfunction getTicksInRange(ticks: readonly FormattedTick[], from: number, until: number) {\n return ticks.filter(tick => from <= tick.position - tick.space / 2 && tick.position + tick.space / 2 <= until);\n}\n\nfunction getReducedTicks(ticks: readonly FormattedTick[]): readonly FormattedTick[] {\n const reduceLabelRatio = findReduceLabelRatio(ticks);\n\n const reducedTicks = [];\n for (let index = 0; index < ticks.length; index += reduceLabelRatio) {\n reducedTicks.push(ticks[index]);\n }\n return reducedTicks;\n}\n\n// Returns a ratio such that all elements can be displayed with no intersections.\nfunction findReduceLabelRatio(ticks: readonly FormattedTick[], ratio = 1): number {\n if (ratio >= ticks.length) {\n return ratio;\n }\n for (let i = ratio; i < ticks.length; i += ratio) {\n if (hasIntersection(ticks[i - ratio], ticks[i])) {\n return findReduceLabelRatio(ticks, ratio + 1);\n }\n }\n return ratio;\n}\n\nfunction removeIntersections(ticks: readonly FormattedTick[]) {\n const visibleTicks = [];\n let prevTick = null;\n for (const tick of ticks) {\n if (!prevTick || !hasIntersection(prevTick, tick)) {\n visibleTicks.push(tick);\n prevTick = tick;\n }\n }\n return visibleTicks;\n}\n\nfunction hasIntersection(a: FormattedTick, b: FormattedTick) {\n const [left, right] = a.position < b.position ? [a, b] : [b, a];\n const leftEdge = left.position + left.space / 2 + SPACE_BETWEEN;\n const rightEdge = right.position - right.space / 2;\n return leftEdge > rightEdge;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"label-utils.js","sourceRoot":"lib/default/","sources":["internal/components/cartesian-chart/label-utils.ts"],"names":[],"mappings":"AAKA,MAAM,aAAa,GAAG,CAAC,CAAC;AAQxB,MAAM,UAAU,WAAW,CAAC,EAC1B,KAAK,EACL,KAAK,EACL,aAAa,EACb,aAAa,GAMd;IACC,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;;QACtB,MAAM,QAAQ,GAAG,MAAA,KAAK,CAAC,OAAO,CAAC,IAAW,CAAC,mCAAI,GAAG,CAAC;QACnD,MAAM,KAAK,GAAG,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC,IAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC3E,MAAM,KAAK,GAAG,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACvC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC;IAC3E,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,KAA+B,EAAE,IAAY,EAAE,KAAa,EAAE,YAAY,GAAG,KAAK;IAChH,KAAK,GAAG,eAAe,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IAC5C,OAAO,YAAY,CAAC,CAAC,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC;AAC5E,CAAC;AAED,SAAS,eAAe,CAAC,KAA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AAI,CAAC,eAAe,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE;YACjD,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACxB,QAAQ,GAAG,IAAI,CAAC;SACjB;KACF;IACD,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,SAAS,eAAe,CAAC,CAAgB,EAAE,CAAgB;IACzD,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAChE,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,KAAK,GAAG,CAAC,GAAG,aAAa,CAAC;IAChE,MAAM,SAAS,GAAG,KAAK,CAAC,QAAQ,GAAG,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC;IACnD,OAAO,QAAQ,GAAG,SAAS,CAAC;AAC9B,CAAC;AAED,oCAAoC;AACpC,0BAA0B;AAC1B,MAAM,UAAU,cAAc,CAAC,OAA8B;IAC3D,IAAI,OAAO,IAAI,OAAO,CAAC,OAAO,EAAE;QAC9B,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;KAC1B;IACD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ChartDataTypes } from './interfaces';\nimport { ChartScale, NumericChartScale } from './scales';\n\nconst SPACE_BETWEEN = 4;\n\nexport interface FormattedTick {\n position: number;\n space: number;\n lines: string[];\n}\n\nexport function formatTicks({\n ticks,\n scale,\n getLabelSpace,\n tickFormatter,\n}: {\n ticks: readonly ChartDataTypes[];\n scale: ChartScale | NumericChartScale;\n getLabelSpace: (label: string) => number;\n tickFormatter?: (value: any) => string;\n}): FormattedTick[] {\n return ticks.map(tick => {\n const position = scale.d3Scale(tick as any) ?? NaN;\n const label = tickFormatter ? tickFormatter(tick as any) : tick.toString();\n const lines = (label + '').split('\\n');\n return { position, lines, space: Math.max(...lines.map(getLabelSpace)) };\n });\n}\n\nexport function getVisibleTicks(ticks: readonly FormattedTick[], from: number, until: number, balanceTicks = false) {\n ticks = getTicksInRange(ticks, from, until);\n return balanceTicks ? getReducedTicks(ticks) : removeIntersections(ticks);\n}\n\nfunction getTicksInRange(ticks: readonly FormattedTick[], from: number, until: number) {\n return ticks.filter(tick => from <= tick.position - tick.space / 2 && tick.position + tick.space / 2 <= until);\n}\n\nfunction getReducedTicks(ticks: readonly FormattedTick[]): readonly FormattedTick[] {\n const reduceLabelRatio = findReduceLabelRatio(ticks);\n\n const reducedTicks = [];\n for (let index = 0; index < ticks.length; index += reduceLabelRatio) {\n reducedTicks.push(ticks[index]);\n }\n return reducedTicks;\n}\n\n// Returns a ratio such that all elements can be displayed with no intersections.\nfunction findReduceLabelRatio(ticks: readonly FormattedTick[], ratio = 1): number {\n if (ratio >= ticks.length) {\n return ratio;\n }\n for (let i = ratio; i < ticks.length; i += ratio) {\n if (hasIntersection(ticks[i - ratio], ticks[i])) {\n return findReduceLabelRatio(ticks, ratio + 1);\n }\n }\n return ratio;\n}\n\nfunction removeIntersections(ticks: readonly FormattedTick[]) {\n const visibleTicks = [];\n let prevTick = null;\n for (const tick of ticks) {\n if (!prevTick || !hasIntersection(prevTick, tick)) {\n visibleTicks.push(tick);\n prevTick = tick;\n }\n }\n return visibleTicks;\n}\n\nfunction hasIntersection(a: FormattedTick, b: FormattedTick) {\n const [left, right] = a.position < b.position ? [a, b] : [b, a];\n const leftEdge = left.position + left.space / 2 + SPACE_BETWEEN;\n const rightEdge = right.position - right.space / 2;\n return leftEdge > rightEdge;\n}\n\n// Ignoring as unsupported in JSDom.\n/* istanbul ignore next */\nexport function getSVGTextSize(element: null | SVGTextElement): undefined | { width: number; height: number } {\n if (element && element.getBBox) {\n return element.getBBox();\n }\n return undefined;\n}\n"]}
|
|
@@ -6,8 +6,9 @@ interface LabelsMeasureProps {
|
|
|
6
6
|
ticks: readonly ChartDataTypes[];
|
|
7
7
|
tickFormatter?: (value: ChartDataTypes) => string;
|
|
8
8
|
autoWidth: (value: number) => void;
|
|
9
|
+
maxLabelsWidth?: number;
|
|
9
10
|
}
|
|
10
11
|
declare const _default: typeof LabelsMeasure;
|
|
11
12
|
export default _default;
|
|
12
|
-
declare function LabelsMeasure({ scale, ticks, tickFormatter, autoWidth }: LabelsMeasureProps): JSX.Element;
|
|
13
|
+
declare function LabelsMeasure({ scale, ticks, tickFormatter, autoWidth, maxLabelsWidth }: LabelsMeasureProps): JSX.Element;
|
|
13
14
|
//# sourceMappingURL=labels-measure.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"labels-measure.d.ts","sourceRoot":"lib/default/","sources":["internal/components/cartesian-chart/labels-measure.tsx"],"names":[],"mappings":";AAKA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAGzD,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAG1E,UAAU,kBAAkB;IAC1B,KAAK,EAAE,UAAU,GAAG,iBAAiB,CAAC;IACtC,KAAK,EAAE,SAAS,cAAc,EAAE,CAAC;IACjC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,MAAM,CAAC;IAClD,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"labels-measure.d.ts","sourceRoot":"lib/default/","sources":["internal/components/cartesian-chart/labels-measure.tsx"],"names":[],"mappings":";AAKA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAGzD,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAG1E,UAAU,kBAAkB;IAC1B,KAAK,EAAE,UAAU,GAAG,iBAAiB,CAAC;IACtC,KAAK,EAAE,SAAS,cAAc,EAAE,CAAC;IACjC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,MAAM,CAAC;IAClD,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;;AAED,wBAA2D;AAG3D,iBAAS,aAAa,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,cAAc,EAAE,EAAE,kBAAkB,eAqCpG"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
import React, { memo, useEffect } from 'react';
|
|
3
|
+
import React, { memo, useEffect, Fragment } from 'react';
|
|
4
4
|
import clsx from 'clsx';
|
|
5
5
|
import styles from './styles.css.js';
|
|
6
6
|
import { useContainerQuery } from '@cloudscape-design/component-toolkit';
|
|
7
7
|
export default memo(LabelsMeasure);
|
|
8
8
|
// Places the invisible left-hand side labels to calculate their maximum width.
|
|
9
|
-
function LabelsMeasure({ scale, ticks, tickFormatter, autoWidth }) {
|
|
9
|
+
function LabelsMeasure({ scale, ticks, tickFormatter, autoWidth, maxLabelsWidth }) {
|
|
10
10
|
const [width, ref] = useContainerQuery(rect => rect.contentBoxWidth);
|
|
11
11
|
// Tell elements's width to the parent.
|
|
12
12
|
useEffect(() => {
|
|
@@ -17,8 +17,10 @@ function LabelsMeasure({ scale, ticks, tickFormatter, autoWidth }) {
|
|
|
17
17
|
if (scaledValue === undefined || !isFinite(scaledValue)) {
|
|
18
18
|
return null;
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
const formattedValue = tickFormatter ? tickFormatter(value) : value.toString();
|
|
21
|
+
const lines = (formattedValue + '').split('\n');
|
|
22
|
+
return (React.createElement(Fragment, { key: `${value}` }, lines.map((line, lineIndex) => (React.createElement("div", { key: lineIndex, className: styles['labels-left__label'], "aria-hidden": "true" }, line)))));
|
|
21
23
|
};
|
|
22
|
-
return (React.createElement("div", { ref: ref, className: clsx(styles['labels-left'], styles['labels-left--hidden']) }, ticks.map(labelMapper)));
|
|
24
|
+
return (React.createElement("div", { ref: ref, className: clsx(styles['labels-left'], styles['labels-left--hidden']), style: { maxWidth: maxLabelsWidth } }, ticks.map(labelMapper)));
|
|
23
25
|
}
|
|
24
26
|
//# sourceMappingURL=labels-measure.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"labels-measure.js","sourceRoot":"lib/default/","sources":["internal/components/cartesian-chart/labels-measure.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"labels-measure.js","sourceRoot":"lib/default/","sources":["internal/components/cartesian-chart/labels-measure.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,IAAI,MAAM,MAAM,CAAC;AAIxB,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAUzE,eAAe,IAAI,CAAC,aAAa,CAAyB,CAAC;AAE3D,+EAA+E;AAC/E,SAAS,aAAa,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,cAAc,EAAsB;IACnG,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,GAAG,iBAAiB,CAAS,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAE7E,uCAAuC;IACvC,SAAS,CAAC,GAAG,EAAE;QACb,SAAS,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC;IACxB,CAAC,EAAE,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;IAEvB,MAAM,WAAW,GAAG,CAAC,KAAqB,EAAE,EAAE;QAC5C,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC,KAAY,CAAC,CAAC;QAChD,IAAI,WAAW,KAAK,SAAS,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;YACvD,OAAO,IAAI,CAAC;SACb;QAED,MAAM,cAAc,GAAG,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC,KAAY,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QACtF,MAAM,KAAK,GAAG,CAAC,cAAc,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAEhD,OAAO,CACL,oBAAC,QAAQ,IAAC,GAAG,EAAE,GAAG,KAAK,EAAE,IACtB,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC,CAC9B,6BAAK,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,CAAC,oBAAoB,CAAC,iBAAc,MAAM,IAC7E,IAAI,CACD,CACP,CAAC,CACO,CACZ,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,CACL,6BACE,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC,qBAAqB,CAAC,CAAC,EACrE,KAAK,EAAE,EAAE,QAAQ,EAAE,cAAc,EAAE,IAElC,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CACnB,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { memo, useEffect, Fragment } from 'react';\nimport clsx from 'clsx';\n\nimport { ChartScale, NumericChartScale } from './scales';\n\nimport styles from './styles.css.js';\nimport { ChartDataTypes } from '../../../mixed-line-bar-chart/interfaces';\nimport { useContainerQuery } from '@cloudscape-design/component-toolkit';\n\ninterface LabelsMeasureProps {\n scale: ChartScale | NumericChartScale;\n ticks: readonly ChartDataTypes[];\n tickFormatter?: (value: ChartDataTypes) => string;\n autoWidth: (value: number) => void;\n maxLabelsWidth?: number;\n}\n\nexport default memo(LabelsMeasure) as typeof LabelsMeasure;\n\n// Places the invisible left-hand side labels to calculate their maximum width.\nfunction LabelsMeasure({ scale, ticks, tickFormatter, autoWidth, maxLabelsWidth }: LabelsMeasureProps) {\n const [width, ref] = useContainerQuery<number>(rect => rect.contentBoxWidth);\n\n // Tell elements's width to the parent.\n useEffect(() => {\n autoWidth(width || 0);\n }, [autoWidth, width]);\n\n const labelMapper = (value: ChartDataTypes) => {\n const scaledValue = scale.d3Scale(value as any);\n if (scaledValue === undefined || !isFinite(scaledValue)) {\n return null;\n }\n\n const formattedValue = tickFormatter ? tickFormatter(value as any) : value.toString();\n const lines = (formattedValue + '').split('\\n');\n\n return (\n <Fragment key={`${value}`}>\n {lines.map((line, lineIndex) => (\n <div key={lineIndex} className={styles['labels-left__label']} aria-hidden=\"true\">\n {line}\n </div>\n ))}\n </Fragment>\n );\n };\n\n return (\n <div\n ref={ref}\n className={clsx(styles['labels-left'], styles['labels-left--hidden'])}\n style={{ maxWidth: maxLabelsWidth }}\n >\n {ticks.map(labelMapper)}\n </div>\n );\n}\n"]}
|
|
@@ -3,8 +3,9 @@ import { ChartScale, NumericChartScale } from './scales';
|
|
|
3
3
|
import { ChartDataTypes } from '../../../mixed-line-bar-chart/interfaces';
|
|
4
4
|
interface LeftLabelsProps {
|
|
5
5
|
axis?: 'x' | 'y';
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
plotWidth: number;
|
|
7
|
+
plotHeight: number;
|
|
8
|
+
maxLabelsWidth?: number;
|
|
8
9
|
scale: ChartScale | NumericChartScale;
|
|
9
10
|
ticks: readonly ChartDataTypes[];
|
|
10
11
|
tickFormatter?: (value: number) => string;
|
|
@@ -13,5 +14,5 @@ interface LeftLabelsProps {
|
|
|
13
14
|
}
|
|
14
15
|
declare const _default: typeof LeftLabels;
|
|
15
16
|
export default _default;
|
|
16
|
-
declare function LeftLabels({ axis,
|
|
17
|
+
declare function LeftLabels({ axis, plotWidth, plotHeight, maxLabelsWidth, scale, ticks, tickFormatter, title, ariaRoleDescription, }: LeftLabelsProps): JSX.Element;
|
|
17
18
|
//# sourceMappingURL=left-labels.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"left-labels.d.ts","sourceRoot":"lib/default/","sources":["internal/components/cartesian-chart/left-labels.tsx"],"names":[],"mappings":";AAKA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAKzD,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"left-labels.d.ts","sourceRoot":"lib/default/","sources":["internal/components/cartesian-chart/left-labels.tsx"],"names":[],"mappings":";AAKA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAKzD,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAM1E,UAAU,eAAe;IACvB,IAAI,CAAC,EAAE,GAAG,GAAG,GAAG,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,UAAU,GAAG,iBAAiB,CAAC;IACtC,KAAK,EAAE,SAAS,cAAc,EAAE,CAAC;IACjC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;;AAED,wBAAqD;AAGrD,iBAAS,UAAU,CAAC,EAClB,IAAU,EACV,SAAS,EACT,UAAU,EACV,cAAyC,EACzC,KAAK,EACL,KAAK,EACL,aAAa,EACb,KAAK,EACL,mBAAmB,GACpB,EAAE,eAAe,eA4EjB"}
|
|
@@ -2,40 +2,50 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import React, { memo, useRef } from 'react';
|
|
4
4
|
import clsx from 'clsx';
|
|
5
|
-
import { TICK_LENGTH, TICK_MARGIN } from './constants';
|
|
5
|
+
import { TICK_LENGTH, TICK_LINE_HEIGHT, TICK_MARGIN } from './constants';
|
|
6
6
|
import styles from './styles.css.js';
|
|
7
|
-
import { formatTicks, getVisibleTicks } from './label-utils';
|
|
7
|
+
import { formatTicks, getSVGTextSize, getVisibleTicks } from './label-utils';
|
|
8
8
|
import { useInternalI18n } from '../../../i18n/context';
|
|
9
|
+
import ResponsiveText from '../responsive-text';
|
|
9
10
|
const OFFSET_PX = 12;
|
|
10
11
|
export default memo(LeftLabels);
|
|
11
12
|
// Renders the visible tick labels on the left axis, as well as their grid lines.
|
|
12
|
-
function LeftLabels({ axis = 'y',
|
|
13
|
+
function LeftLabels({ axis = 'y', plotWidth, plotHeight, maxLabelsWidth = Number.POSITIVE_INFINITY, scale, ticks, tickFormatter, title, ariaRoleDescription, }) {
|
|
13
14
|
const i18n = useInternalI18n('[charts]');
|
|
14
15
|
const virtualTextRef = useRef(null);
|
|
15
16
|
const yOffset = axis === 'x' && scale.isCategorical() ? Math.max(0, scale.d3Scale.bandwidth() - 1) / 2 : 0;
|
|
16
|
-
const
|
|
17
|
+
const labelToBoxCache = useRef({});
|
|
17
18
|
const getLabelSpace = (label) => {
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
var _a, _b, _c, _d;
|
|
20
|
+
if (labelToBoxCache.current[label] !== undefined) {
|
|
21
|
+
return (_b = (_a = labelToBoxCache.current[label]) === null || _a === void 0 ? void 0 : _a.height) !== null && _b !== void 0 ? _b : 0;
|
|
20
22
|
}
|
|
21
|
-
if (virtualTextRef.current
|
|
23
|
+
if (virtualTextRef.current) {
|
|
22
24
|
virtualTextRef.current.textContent = label;
|
|
23
|
-
cacheRef.current[label] = virtualTextRef.current.getBBox().height;
|
|
24
|
-
return cacheRef.current[label];
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
labelToBoxCache.current[label] = getSVGTextSize(virtualTextRef.current);
|
|
27
|
+
return (_d = (_c = labelToBoxCache.current[label]) === null || _c === void 0 ? void 0 : _c.height) !== null && _d !== void 0 ? _d : 0;
|
|
27
28
|
};
|
|
28
29
|
const formattedTicks = formatTicks({ ticks, scale, getLabelSpace, tickFormatter });
|
|
29
30
|
if (virtualTextRef.current) {
|
|
30
31
|
virtualTextRef.current.textContent = '';
|
|
31
32
|
}
|
|
32
33
|
const from = 0 - OFFSET_PX - yOffset;
|
|
33
|
-
const until =
|
|
34
|
+
const until = plotHeight + OFFSET_PX - yOffset;
|
|
34
35
|
const visibleTicks = getVisibleTicks(formattedTicks, from, until);
|
|
35
36
|
return (React.createElement("g", { className: clsx(styles['labels-left']), "aria-label": title, role: "list", "aria-roledescription": i18n('i18nStrings.chartAriaRoleDescription', ariaRoleDescription), "aria-hidden": true },
|
|
36
37
|
visibleTicks.map(({ position, lines }, index) => isFinite(position) && (React.createElement("g", { key: index, role: "listitem", transform: `translate(0,${position + yOffset})`, className: clsx(styles.ticks, axis === 'x' ? styles['ticks--x'] : styles['ticks--y']) },
|
|
37
|
-
axis === 'y' && (React.createElement("line", { className: clsx(styles.grid, styles.ticks_line), x1: -TICK_LENGTH, y1: 0, x2:
|
|
38
|
-
|
|
38
|
+
axis === 'y' && (React.createElement("line", { className: clsx(styles.grid, styles.ticks_line), x1: -TICK_LENGTH, y1: 0, x2: plotWidth, y2: 0, "aria-hidden": "true" })),
|
|
39
|
+
lines.map((line, lineIndex) => {
|
|
40
|
+
var _a, _b;
|
|
41
|
+
const lineTextProps = {
|
|
42
|
+
x: -(TICK_LENGTH + TICK_MARGIN),
|
|
43
|
+
y: (lineIndex - (lines.length - 1) * 0.5) * TICK_LINE_HEIGHT,
|
|
44
|
+
className: styles.ticks__text,
|
|
45
|
+
children: line,
|
|
46
|
+
};
|
|
47
|
+
return ((_b = (_a = labelToBoxCache.current[lines[0]]) === null || _a === void 0 ? void 0 : _a.width) !== null && _b !== void 0 ? _b : 0) > maxLabelsWidth ? (React.createElement(ResponsiveText, Object.assign({ key: lineIndex }, lineTextProps, { maxWidth: maxLabelsWidth }))) : (React.createElement("text", Object.assign({ key: lineIndex }, lineTextProps)));
|
|
48
|
+
})))),
|
|
39
49
|
React.createElement("text", { ref: virtualTextRef, x: 0, y: 0, style: { visibility: 'hidden' }, "aria-hidden": "true" })));
|
|
40
50
|
}
|
|
41
51
|
//# sourceMappingURL=left-labels.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"left-labels.js","sourceRoot":"lib/default/","sources":["internal/components/cartesian-chart/left-labels.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"left-labels.js","sourceRoot":"lib/default/","sources":["internal/components/cartesian-chart/left-labels.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEzE,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAE7E,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,c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AAE;;gBAC7B,MAAM,aAAa,GAAG;oBACpB,CAAC,EAAE,CAAC,CAAC,WAAW,GAAG,WAAW,CAAC;oBAC/B,CAAC,EAAE,CAAC,SAAS,GAAG,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,gBAAgB;oBAC5D,SAAS,EAAE,MAAM,CAAC,WAAW;oBAC7B,QAAQ,EAAE,IAAI;iBACf,CAAC;gBACF,OAAO,CAAC,MAAA,MAAA,eAAe,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,0CAAE,KAAK,mCAAI,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CACxE,oBAAC,cAAc,kBAAC,GAAG,EAAE,SAAS,IAAM,aAAa,IAAE,QAAQ,EAAE,cAAc,IAAI,CAChF,CAAC,CAAC,CAAC,CACF,4CAAM,GAAG,EAAE,SAAS,IAAM,aAAa,EAAI,CAC5C,CAAC;YACJ,CAAC,CAAC,CACA,CACL,CACJ;QAED,8BAAM,GAAG,EAAE,cAAc,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,iBAAc,MAAM,GAAQ,CAChG,CACL,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { memo, useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { ChartScale, NumericChartScale } from './scales';\nimport { TICK_LENGTH, TICK_LINE_HEIGHT, TICK_MARGIN } from './constants';\n\nimport styles from './styles.css.js';\nimport { formatTicks, getSVGTextSize, getVisibleTicks } from './label-utils';\nimport { ChartDataTypes } from '../../../mixed-line-bar-chart/interfaces';\nimport { useInternalI18n } from '../../../i18n/context';\nimport ResponsiveText from '../responsive-text';\n\nconst OFFSET_PX = 12;\n\ninterface LeftLabelsProps {\n axis?: 'x' | 'y';\n plotWidth: number;\n plotHeight: number;\n maxLabelsWidth?: number;\n scale: ChartScale | NumericChartScale;\n ticks: readonly ChartDataTypes[];\n tickFormatter?: (value: number) => string;\n title?: string;\n ariaRoleDescription?: string;\n}\n\nexport default memo(LeftLabels) as typeof LeftLabels;\n\n// Renders the visible tick labels on the left axis, as well as their grid lines.\nfunction LeftLabels({\n axis = 'y',\n plotWidth,\n plotHeight,\n maxLabelsWidth = Number.POSITIVE_INFINITY,\n scale,\n ticks,\n tickFormatter,\n title,\n ariaRoleDescription,\n}: LeftLabelsProps) {\n const i18n = useInternalI18n('[charts]');\n const virtualTextRef = useRef<SVGTextElement>(null);\n\n const yOffset = axis === 'x' && scale.isCategorical() ? Math.max(0, scale.d3Scale.bandwidth() - 1) / 2 : 0;\n\n const labelToBoxCache = useRef<{ [label: string]: undefined | { width: number; height: number } }>({});\n const getLabelSpace = (label: string) => {\n if (labelToBoxCache.current[label] !== undefined) {\n return labelToBoxCache.current[label]?.height ?? 0;\n }\n if (virtualTextRef.current) {\n virtualTextRef.current.textContent = label;\n }\n labelToBoxCache.current[label] = getSVGTextSize(virtualTextRef.current);\n return labelToBoxCache.current[label]?.height ?? 0;\n };\n\n const formattedTicks = formatTicks({ ticks, scale, getLabelSpace, tickFormatter });\n\n if (virtualTextRef.current) {\n virtualTextRef.current.textContent = '';\n }\n\n const from = 0 - OFFSET_PX - yOffset;\n const until = plotHeight + OFFSET_PX - yOffset;\n const visibleTicks = getVisibleTicks(formattedTicks, from, until);\n\n return (\n <g\n className={clsx(styles['labels-left'])}\n aria-label={title}\n role=\"list\"\n aria-roledescription={i18n('i18nStrings.chartAriaRoleDescription', ariaRoleDescription)}\n aria-hidden={true}\n >\n {visibleTicks.map(\n ({ position, lines }, index) =>\n isFinite(position) && (\n <g\n key={index}\n role=\"listitem\"\n transform={`translate(0,${position + yOffset})`}\n className={clsx(styles.ticks, axis === 'x' ? styles['ticks--x'] : styles['ticks--y'])}\n >\n {axis === 'y' && (\n <line\n className={clsx(styles.grid, styles.ticks_line)}\n x1={-TICK_LENGTH}\n y1={0}\n x2={plotWidth}\n y2={0}\n aria-hidden=\"true\"\n />\n )}\n\n {lines.map((line, lineIndex) => {\n const lineTextProps = {\n x: -(TICK_LENGTH + TICK_MARGIN),\n y: (lineIndex - (lines.length - 1) * 0.5) * TICK_LINE_HEIGHT,\n className: styles.ticks__text,\n children: line,\n };\n return (labelToBoxCache.current[lines[0]]?.width ?? 0) > maxLabelsWidth ? (\n <ResponsiveText key={lineIndex} {...lineTextProps} maxWidth={maxLabelsWidth} />\n ) : (\n <text key={lineIndex} {...lineTextProps} />\n );\n })}\n </g>\n )\n )}\n\n <text ref={virtualTextRef} x={0} y={0} style={{ visibility: 'hidden' }} aria-hidden=\"true\"></text>\n </g>\n );\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface ResponsiveTextProps {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
className?: string;
|
|
6
|
+
children: string;
|
|
7
|
+
maxWidth: number;
|
|
8
|
+
}
|
|
9
|
+
declare const _default: React.MemoExoticComponent<typeof ResponsiveText>;
|
|
10
|
+
export default _default;
|
|
11
|
+
declare function ResponsiveText({ x, y, className, children, maxWidth }: ResponsiveTextProps): JSX.Element;
|
|
12
|
+
export declare function renderTextContent(textNode: SVGTextElement, text: string, maxWidth: number): void;
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"lib/default/","sources":["internal/components/responsive-text/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAkC,MAAM,OAAO,CAAC;AAGvD,UAAU,mBAAmB;IAC3B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;;AAED,wBAAoC;AAEpC,iBAAS,cAAc,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,mBAAmB,eAanF;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,QAWzF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import React, { memo, useEffect, useRef } from 'react';
|
|
4
|
+
import { getTextWidth } from './responsive-text-utils';
|
|
5
|
+
export default memo(ResponsiveText);
|
|
6
|
+
function ResponsiveText({ x, y, className, children, maxWidth }) {
|
|
7
|
+
const textRef = useRef(null);
|
|
8
|
+
// Determine the visible width of the text and if necessary truncate it until it fits.
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
renderTextContent(textRef.current, children, maxWidth);
|
|
11
|
+
}, [maxWidth, children]);
|
|
12
|
+
return (React.createElement("text", { ref: textRef, x: x, y: y, style: { textAnchor: 'end' }, className: className }, children));
|
|
13
|
+
}
|
|
14
|
+
export function renderTextContent(textNode, text, maxWidth) {
|
|
15
|
+
let visibleLength = text.length;
|
|
16
|
+
while (visibleLength >= 0) {
|
|
17
|
+
textNode.textContent = truncateText(text, visibleLength);
|
|
18
|
+
if (getTextWidth(textNode) <= maxWidth) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
visibleLength--;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function truncateText(text, maxLength) {
|
|
27
|
+
if (text.length === maxLength) {
|
|
28
|
+
return text;
|
|
29
|
+
}
|
|
30
|
+
return text.slice(0, maxLength) + '…';
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|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IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE;QAC7B,OAAO,IAAI,CAAC;KACb;IACD,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,GAAG,GAAG,CAAC;AACxC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { memo, useEffect, useRef } from 'react';\nimport { getTextWidth } from './responsive-text-utils';\n\ninterface ResponsiveTextProps {\n x: number;\n y: number;\n className?: string;\n children: string;\n maxWidth: number;\n}\n\nexport default memo(ResponsiveText);\n\nfunction ResponsiveText({ x, y, className, children, maxWidth }: ResponsiveTextProps) {\n const textRef = useRef<SVGTextElement>(null);\n\n // Determine the visible width of the text and if necessary truncate it until it fits.\n useEffect(() => {\n renderTextContent(textRef.current!, children, maxWidth);\n }, [maxWidth, children]);\n\n return (\n <text ref={textRef} x={x} y={y} style={{ textAnchor: 'end' }} className={className}>\n {children}\n </text>\n );\n}\n\nexport function renderTextContent(textNode: SVGTextElement, text: string, maxWidth: number) {\n let visibleLength = text.length;\n while (visibleLength >= 0) {\n textNode.textContent = truncateText(text, visibleLength);\n\n if (getTextWidth(textNode) <= maxWidth) {\n return;\n } else {\n visibleLength--;\n }\n }\n}\n\nfunction truncateText(text: string, maxLength: number) {\n if (text.length === maxLength) {\n return text;\n }\n return text.slice(0, maxLength) + '…';\n}\n"]}
|
package/lib/internal/template/internal/components/responsive-text/responsive-text-utils.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"responsive-text-utils.d.ts","sourceRoot":"lib/default/","sources":["internal/components/responsive-text/responsive-text-utils.ts"],"names":[],"mappings":"AAKA,wBAAgB,YAAY,CAAC,QAAQ,EAAE,cAAc,UAKpD"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
// Ignoring as unsupported in JSDom.
|
|
4
|
+
/* istanbul ignore next */
|
|
5
|
+
export function getTextWidth(textNode) {
|
|
6
|
+
if (textNode.getComputedTextLength) {
|
|
7
|
+
return textNode.getComputedTextLength();
|
|
8
|
+
}
|
|
9
|
+
return -1;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=responsive-text-utils.js.map
|
package/lib/internal/template/internal/components/responsive-text/responsive-text-utils.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"responsive-text-utils.js","sourceRoot":"lib/default/","sources":["internal/components/responsive-text/responsive-text-utils.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,oCAAoC;AACpC,0BAA0B;AAC1B,MAAM,UAAU,YAAY,CAAC,QAAwB;IACnD,IAAI,QAAQ,CAAC,qBAAqB,EAAE;QAClC,OAAO,QAAQ,CAAC,qBAAqB,EAAE,CAAC;KACzC;IACD,OAAO,CAAC,CAAC,CAAC;AACZ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\n// Ignoring as unsupported in JSDom.\n/* istanbul ignore next */\nexport function getTextWidth(textNode: SVGTextElement) {\n if (textNode.getComputedTextLength) {\n return textNode.getComputedTextLength();\n }\n return -1;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chart-container.d.ts","sourceRoot":"lib/default/","sources":["mixed-line-bar-chart/chart-container.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA6E,MAAM,OAAO,CAAC;AAgBlG,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,SAAS,EAAmB,MAAM,cAAc,CAAC;AAGvH,OAAyB,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AASrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mDAAmD,CAAC;AAYxF,MAAM,WAAW,m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AAC,GAAG,IAAI,KAAK,IAAI,CAAC;IAC5D,qBAAqB,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,wBAAwB,EAAE,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAE9D,SAAS,EAAE,sBAAsB,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;IAClD,cAAc,EAAE,sBAAsB,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC;IAC5D,eAAe,EAAE,sBAAsB,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC;IAC9D,WAAW,EAAE,sBAAsB,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC;IAEtD,gBAAgB,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;CACnD;AAqBD,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,CAAC,SAAS,cAAc,EAAE,EAC/D,SAAS,EACT,MAAM,EAAE,kBAAkB,EAC1B,MAAM,EACN,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,EACxB,mBAAmB,EACnB,iBAA4B,EAC5B,WAAmB,EACnB,cAAsB,EACtB,UAAU,EACV,UAAU,EACV,cAAc,EACd,cAAc,EACd,qBAAqB,EACrB,MAAM,EACN,MAAM,EACN,SAAS,EACT,cAAc,EACd,eAAe,EACf,WAAgB,EAChB,gBAAgB,EAChB,GAAG,KAAK,EACT,EAAE,mBAAmB,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"chart-container.d.ts","sourceRoot":"lib/default/","sources":["mixed-line-bar-chart/chart-container.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA6E,MAAM,OAAO,CAAC;AAgBlG,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,SAAS,EAAmB,MAAM,cAAc,CAAC;AAGvH,OAAyB,EAAE,WAAW,EA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AW,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IACxC,mBAAmB,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,IAAI,KAAK,IAAI,CAAC;IAC5D,qBAAqB,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,wBAAwB,EAAE,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAE9D,SAAS,EAAE,sBAAsB,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;IAClD,cAAc,EAAE,sBAAsB,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC;IAC5D,eAAe,EAAE,sBAAsB,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC;IAC9D,WAAW,EAAE,sBAAsB,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC;IAEtD,gBAAgB,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;CACnD;AAqBD,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,CAAC,SAAS,cAAc,EAAE,EAC/D,SAAS,EACT,MAAM,EAAE,kBAAkB,EAC1B,MAAM,EACN,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,EACxB,mBAAmB,EACnB,iBAA4B,EAC5B,WAAmB,EACnB,cAAsB,EACtB,UAAU,EACV,UAAU,EACV,cAAc,EACd,cAAc,EACd,qBAAqB,EACrB,MAAM,EACN,MAAM,EACN,SAAS,EACT,cAAc,EACd,eAAe,EACf,WAAgB,EAChB,gBAAgB,EAChB,GAAG,KAAK,EACT,EAAE,mBAAmB,CAAC,CAAC,CAAC,eAkgBxB"}
|
|
@@ -40,6 +40,7 @@ export default function ChartContainer(_a) {
|
|
|
40
40
|
const [leftLabelsWidth, setLeftLabelsWidth] = useState(0);
|
|
41
41
|
const [verticalMarkerX, setVerticalMarkerX] = useState(null);
|
|
42
42
|
const [containerWidth, containerMeasureRef] = useContainerWidth(500);
|
|
43
|
+
const maxLeftLabelsWidth = Math.round(containerWidth / 2);
|
|
43
44
|
const plotWidth = containerWidth ? containerWidth - leftLabelsWidth - LEFT_LABELS_MARGIN : 500;
|
|
44
45
|
const containerRefObject = useRef(null);
|
|
45
46
|
const containerRef = useMergeRefs(containerMeasureRef, containerRefObject);
|
|
@@ -325,10 +326,10 @@ export default function ChartContainer(_a) {
|
|
|
325
326
|
const activeLiveRegion = activeAriaLabel && !highlightedPoint && highlightedGroupIndex === null ? activeAriaLabel : '';
|
|
326
327
|
const isLineXKeyboardFocused = isPlotFocused && !highlightedPoint && verticalMarkerX;
|
|
327
328
|
const isRefresh = useVisualRefresh();
|
|
328
|
-
return (React.createElement(CartesianChartContainer, { ref: containerRef, minHeight: explicitPlotHeight + bottomLabelsProps.height, fitHeight: !!fitHeight, leftAxisLabel: React.createElement(AxisLabel, { axis: y, position: "left", title: leftAxisProps.title }), leftAxisLabelMeasure: React.createElement(LabelsMeasure, { ticks: leftAxisProps.ticks, scale: leftAxisProps.scale, tickFormatter: leftAxisProps.tickFormatter, autoWidth: setLeftLabelsWidth }), bottomAxisLabel: React.createElement(AxisLabel, { axis: x, position: "bottom", title: bottomAxisProps.title }), chartPlot: React.createElement(ChartPlot, { ref: plotRef, width: "100%", height: fitHeight ? `calc(100% - ${bottomLabelsProps.height}px)` : plotHeight, offsetBottom: bottomLabelsProps.height, isClickable: isPopoverOpen && !isPopoverPinned, ariaLabel: ariaLabel, ariaLabelledby: ariaLabelledby, ariaDescription: ariaDescription, ariaRoleDescription: i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.chartAriaRoleDescription, ariaLiveRegion: activeLiveRegion, activeElementRef: highlightedElementRef, activeElementKey: isPlotFocused &&
|
|
329
|
+
return (React.createElement(CartesianChartContainer, { ref: containerRef, minHeight: explicitPlotHeight + bottomLabelsProps.height, fitHeight: !!fitHeight, leftAxisLabel: React.createElement(AxisLabel, { axis: y, position: "left", title: leftAxisProps.title }), leftAxisLabelMeasure: React.createElement(LabelsMeasure, { ticks: leftAxisProps.ticks, scale: leftAxisProps.scale, tickFormatter: leftAxisProps.tickFormatter, autoWidth: setLeftLabelsWidth, maxLabelsWidth: maxLeftLabelsWidth }), bottomAxisLabel: React.createElement(AxisLabel, { axis: x, position: "bottom", title: bottomAxisProps.title }), chartPlot: React.createElement(ChartPlot, { ref: plotRef, width: "100%", height: fitHeight ? `calc(100% - ${bottomLabelsProps.height}px)` : plotHeight, offsetBottom: bottomLabelsProps.height, isClickable: isPopoverOpen && !isPopoverPinned, ariaLabel: ariaLabel, ariaLabelledby: ariaLabelledby, ariaDescription: ariaDescription, ariaRoleDescription: i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.chartAriaRoleDescription, ariaLiveRegion: activeLiveRegion, activeElementRef: highlightedElementRef, activeElementKey: isPlotFocused &&
|
|
329
330
|
((_c = highlightedGroupIndex === null || highlightedGroupIndex === void 0 ? void 0 : highlightedGroupIndex.toString()) !== null && _c !== void 0 ? _c : (isLineXKeyboardFocused ? `point-index-${handlers.xIndex}` : point === null || point === void 0 ? void 0 : point.key)), activeElementFocusOffset: isGroupNavigation ? 0 : isLineXKeyboardFocused ? { x: 8, y: 0 } : 3, onMouseMove: onSVGMouseMove, onMouseOut: onSVGMouseOut, onMouseDown: onSVGMouseDown, onFocus: onSVGFocus, onBlur: onSVGBlur, onKeyDown: onSVGKeyDown },
|
|
330
331
|
React.createElement("line", { ref: plotMeasureRef, x1: "0", x2: "0", y1: "0", y2: "100%", stroke: "transparent", strokeWidth: 1, style: { pointerEvents: 'none' } }),
|
|
331
|
-
React.createElement(LeftLabels, { axis: y, ticks: leftAxisProps.ticks, scale: leftAxisProps.scale, tickFormatter: leftAxisProps.tickFormatter, title: leftAxisProps.title, ariaRoleDescription: leftAxisProps.ariaRoleDescription,
|
|
332
|
+
React.createElement(LeftLabels, { axis: y, ticks: leftAxisProps.ticks, scale: leftAxisProps.scale, tickFormatter: leftAxisProps.tickFormatter, title: leftAxisProps.title, ariaRoleDescription: leftAxisProps.ariaRoleDescription, maxLabelsWidth: maxLeftLabelsWidth, plotWidth: plotWidth, plotHeight: plotHeight }),
|
|
332
333
|
horizontalBars && (React.createElement(VerticalGridLines, { scale: yAxisProps.scale, ticks: yAxisProps.ticks, height: plotHeight })),
|
|
333
334
|
emphasizeBaselineAxis && linesOnly && (React.createElement(EmphasizedBaseline, { axis: x, scale: yAxisProps.scale, width: plotWidth, height: plotHeight })),
|
|
334
335
|
React.createElement(DataSeries, { axis: x, plotWidth: plotWidth, plotHeight: plotHeight, highlightedSeries: highlightedSeries !== null && highlightedSeries !== void 0 ? highlightedSeries : null, highlightedGroupIndex: highlightedGroupIndex, stackedBars: stackedBars, isGroupNavigation: isGroupNavigation, visibleSeries: visibleSeries, xScale: xAxisProps.scale, yScale: yAxisProps.scale }),
|