@cloudscape-design/components 3.0.23 → 3.0.26

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.
Files changed (163) hide show
  1. package/alert/styles.scoped.css +0 -34
  2. package/annotation-context/annotation/styles.scoped.css +0 -18
  3. package/app-layout/content-wrapper/styles.scoped.css +0 -4
  4. package/app-layout/mobile-toolbar/styles.scoped.css +0 -9
  5. package/app-layout/styles.scoped.css +0 -20
  6. package/app-layout/toggles/styles.scoped.css +0 -16
  7. package/app-layout/visual-refresh/styles.scoped.css +0 -71
  8. package/area-chart/styles.scoped.css +0 -13
  9. package/attribute-editor/styles.scoped.css +0 -23
  10. package/badge/styles.scoped.css +0 -15
  11. package/bar-chart/interfaces.d.ts +1 -1
  12. package/bar-chart/interfaces.d.ts.map +1 -1
  13. package/bar-chart/interfaces.js.map +1 -1
  14. package/box/styles.scoped.css +0 -171
  15. package/breadcrumb-group/item/styles.scoped.css +0 -11
  16. package/breadcrumb-group/styles.scoped.css +0 -10
  17. package/button/styles.scoped.css +0 -264
  18. package/button-dropdown/category-elements/styles.scoped.css +0 -26
  19. package/button-dropdown/item-element/styles.scoped.css +0 -22
  20. package/button-dropdown/mobile-expandable-group/styles.scoped.css +0 -5
  21. package/button-dropdown/styles.scoped.css +0 -7
  22. package/cards/styles.scoped.css +0 -45
  23. package/checkbox/styles.scoped.css +0 -11
  24. package/code-editor/styles.scoped.css +0 -87
  25. package/collection-preferences/styles.scoped.css +0 -12
  26. package/column-layout/styles.scoped.css +0 -12
  27. package/container/styles.scoped.css +0 -27
  28. package/date-picker/styles.scoped.css +0 -45
  29. package/date-range-picker/calendar/grids/day/styles.scoped.css +0 -45
  30. package/date-range-picker/index.d.ts.map +1 -1
  31. package/date-range-picker/index.js +13 -15
  32. package/date-range-picker/index.js.map +1 -1
  33. package/date-range-picker/relative-range/styles.scoped.css +0 -3
  34. package/date-range-picker/styles.css.js +41 -42
  35. package/date-range-picker/styles.scoped.css +49 -92
  36. package/date-range-picker/styles.selectors.js +41 -42
  37. package/expandable-section/styles.scoped.css +0 -33
  38. package/flashbar/styles.scoped.css +0 -36
  39. package/form/styles.scoped.css +0 -12
  40. package/form-field/styles.scoped.css +0 -26
  41. package/grid/styles.scoped.css +0 -6
  42. package/header/styles.scoped.css +0 -51
  43. package/help-panel/styles.scoped.css +0 -73
  44. package/hotspot/styles.scoped.css +0 -3
  45. package/icon/styles.scoped.css +0 -33
  46. package/input/styles.scoped.css +0 -49
  47. package/internal/base-component/styles.scoped.css +0 -1
  48. package/internal/components/abstract-switch/styles.scoped.css +0 -7
  49. package/internal/components/button-trigger/styles.scoped.css +0 -42
  50. package/internal/components/cartesian-chart/styles.scoped.css +0 -10
  51. package/internal/components/chart-filter/styles.scoped.css +0 -4
  52. package/internal/components/chart-legend/styles.scoped.css +0 -8
  53. package/internal/components/chart-plot/styles.scoped.css +0 -1
  54. package/internal/components/chart-popover/styles.scoped.css +0 -4
  55. package/internal/components/chart-series-details/styles.scoped.css +0 -12
  56. package/internal/components/chart-series-marker/styles.scoped.css +0 -7
  57. package/internal/components/chart-status-container/styles.scoped.css +0 -1
  58. package/internal/components/checkbox-icon/styles.scoped.css +0 -10
  59. package/internal/components/content-layout/styles.scoped.css +0 -5
  60. package/internal/components/dark-ribbon/styles.scoped.css +0 -1
  61. package/internal/components/dropdown/styles.scoped.css +0 -17
  62. package/internal/components/dropdown-footer/styles.scoped.css +0 -6
  63. package/internal/components/dropdown-status/styles.scoped.css +0 -6
  64. package/internal/components/filtering-token/styles.scoped.css +0 -21
  65. package/internal/components/menu-dropdown/styles.scoped.css +0 -17
  66. package/internal/components/option/styles.scoped.css +0 -16
  67. package/internal/components/options-list/styles.scoped.css +0 -5
  68. package/internal/components/selectable-item/styles.scoped.css +0 -44
  69. package/internal/environment.js +1 -1
  70. package/line-chart/interfaces.d.ts +1 -1
  71. package/line-chart/interfaces.d.ts.map +1 -1
  72. package/line-chart/interfaces.js.map +1 -1
  73. package/link/styles.scoped.css +0 -77
  74. package/mixed-line-bar-chart/bar-series.d.ts +1 -1
  75. package/mixed-line-bar-chart/bar-series.d.ts.map +1 -1
  76. package/mixed-line-bar-chart/bar-series.js.map +1 -1
  77. package/mixed-line-bar-chart/chart-container.d.ts.map +1 -1
  78. package/mixed-line-bar-chart/chart-container.js +9 -10
  79. package/mixed-line-bar-chart/chart-container.js.map +1 -1
  80. package/mixed-line-bar-chart/chart-filters.d.ts +2 -2
  81. package/mixed-line-bar-chart/chart-filters.d.ts.map +1 -1
  82. package/mixed-line-bar-chart/chart-filters.js +1 -2
  83. package/mixed-line-bar-chart/chart-filters.js.map +1 -1
  84. package/mixed-line-bar-chart/chart-legend.d.ts +2 -2
  85. package/mixed-line-bar-chart/chart-legend.d.ts.map +1 -1
  86. package/mixed-line-bar-chart/chart-legend.js +1 -2
  87. package/mixed-line-bar-chart/chart-legend.js.map +1 -1
  88. package/mixed-line-bar-chart/domain.d.ts +4 -0
  89. package/mixed-line-bar-chart/domain.d.ts.map +1 -0
  90. package/mixed-line-bar-chart/domain.js +138 -0
  91. package/mixed-line-bar-chart/domain.js.map +1 -0
  92. package/mixed-line-bar-chart/format-highlighted.d.ts +2 -4
  93. package/mixed-line-bar-chart/format-highlighted.d.ts.map +1 -1
  94. package/mixed-line-bar-chart/format-highlighted.js +26 -15
  95. package/mixed-line-bar-chart/format-highlighted.js.map +1 -1
  96. package/mixed-line-bar-chart/hooks/use-mouse-hover.d.ts.map +1 -1
  97. package/mixed-line-bar-chart/hooks/use-mouse-hover.js +3 -2
  98. package/mixed-line-bar-chart/hooks/use-mouse-hover.js.map +1 -1
  99. package/mixed-line-bar-chart/hooks/use-navigation.d.ts.map +1 -1
  100. package/mixed-line-bar-chart/hooks/use-navigation.js +23 -35
  101. package/mixed-line-bar-chart/hooks/use-navigation.js.map +1 -1
  102. package/mixed-line-bar-chart/interfaces.d.ts +12 -2
  103. package/mixed-line-bar-chart/interfaces.d.ts.map +1 -1
  104. package/mixed-line-bar-chart/interfaces.js.map +1 -1
  105. package/mixed-line-bar-chart/internal.d.ts.map +1 -1
  106. package/mixed-line-bar-chart/internal.js +14 -6
  107. package/mixed-line-bar-chart/internal.js.map +1 -1
  108. package/mixed-line-bar-chart/line-series.d.ts +2 -2
  109. package/mixed-line-bar-chart/line-series.d.ts.map +1 -1
  110. package/mixed-line-bar-chart/line-series.js +21 -9
  111. package/mixed-line-bar-chart/line-series.js.map +1 -1
  112. package/mixed-line-bar-chart/make-scaled-bar-groups.d.ts.map +1 -1
  113. package/mixed-line-bar-chart/make-scaled-bar-groups.js +11 -4
  114. package/mixed-line-bar-chart/make-scaled-bar-groups.js.map +1 -1
  115. package/mixed-line-bar-chart/make-scaled-series.d.ts +2 -4
  116. package/mixed-line-bar-chart/make-scaled-series.d.ts.map +1 -1
  117. package/mixed-line-bar-chart/make-scaled-series.js +89 -25
  118. package/mixed-line-bar-chart/make-scaled-series.js.map +1 -1
  119. package/mixed-line-bar-chart/styles.scoped.css +0 -13
  120. package/mixed-line-bar-chart/utils.d.ts +5 -6
  121. package/mixed-line-bar-chart/utils.d.ts.map +1 -1
  122. package/mixed-line-bar-chart/utils.js +11 -112
  123. package/mixed-line-bar-chart/utils.js.map +1 -1
  124. package/modal/styles.scoped.css +0 -31
  125. package/multiselect/styles.scoped.css +0 -4
  126. package/package.json +1 -1
  127. package/pagination/styles.scoped.css +0 -22
  128. package/pie-chart/styles.scoped.css +0 -25
  129. package/popover/styles.scoped.css +0 -35
  130. package/progress-bar/styles.scoped.css +0 -25
  131. package/property-filter/styles.scoped.css +0 -22
  132. package/radio-group/styles.scoped.css +0 -22
  133. package/s3-resource-selector/s3-in-context/styles.scoped.css +0 -6
  134. package/segmented-control/styles.scoped.css +0 -36
  135. package/select/parts/styles.scoped.css +0 -6
  136. package/select/styles.scoped.css +0 -4
  137. package/side-navigation/styles.scoped.css +0 -38
  138. package/space-between/styles.scoped.css +0 -40
  139. package/spinner/styles.scoped.css +0 -17
  140. package/split-panel/styles.scoped.css +0 -65
  141. package/status-indicator/styles.scoped.css +0 -20
  142. package/table/body-cell/styles.scoped.css +0 -29
  143. package/table/header-cell/styles.scoped.css +0 -32
  144. package/table/resizer/styles.scoped.css +0 -6
  145. package/table/selection-control/styles.scoped.css +0 -3
  146. package/table/styles.scoped.css +0 -39
  147. package/table/use-selection.d.ts.map +1 -1
  148. package/table/use-selection.js +5 -5
  149. package/table/use-selection.js.map +1 -1
  150. package/tabs/styles.scoped.css +0 -41
  151. package/tag-editor/styles.scoped.css +0 -12
  152. package/text-content/styles.scoped.css +0 -54
  153. package/text-filter/styles.scoped.css +0 -7
  154. package/textarea/styles.scoped.css +0 -30
  155. package/tiles/styles.scoped.css +0 -55
  156. package/toggle/styles.scoped.css +0 -14
  157. package/token-group/styles.scoped.css +0 -35
  158. package/top-navigation/1.0-beta/styles.scoped.css +0 -40
  159. package/top-navigation/styles.scoped.css +0 -75
  160. package/tutorial-panel/components/tutorial-detail-view/styles.scoped.css +0 -22
  161. package/tutorial-panel/components/tutorial-list/styles.scoped.css +0 -24
  162. package/tutorial-panel/styles.scoped.css +0 -5
  163. package/wizard/styles.scoped.css +0 -54
@@ -1 +1 @@
1
- {"version":3,"file":"use-navigation.js","sourceRoot":"","sources":["../../../../src/mixed-line-bar-chart/hooks/use-navigation.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAIjD,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAyBrE,MAAM,UAAU,aAAa,CAA2B,EAgBhC;QAftB,MAAM,YAAA,EACN,aAAa,mBAAA,EACb,YAAY,kBAAA,EACZ,SAAS,eAAA,EACT,MAAM,YAAA,EACN,MAAM,YAAA,EACN,gBAAgB,sBAAA,EAChB,qBAAqB,2BAAA,EACrB,iB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E,CAAC;QAEvB,IAAI,kBAAkB,EAAE;YACtB,OAAO;SACR;QAED,IAAI,OAAO,KAAK,OAAO,CAAC,IAAI,IAAI,OAAO,KAAK,OAAO,CAAC,EAAE,EAAE;YACtD,iBAAiB,CAAC,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;SACtD;aAAM,IAAI,OAAO,KAAK,OAAO,CAAC,IAAI,IAAI,OAAO,KAAK,OAAO,CAAC,KAAK,EAAE;YAChE,gBAAgB,CAAC,OAAO,KAAK,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;SACtD;aAAM,IAAI,OAAO,KAAK,OAAO,CAAC,KAAK,IAAI,OAAO,KAAK,OAAO,CAAC,KAAK,EAAE;YACjE,UAAU,EAAE,CAAC;SACd;IACH,CAAC,EACD,CAAC,gBAAgB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,UAAU,CAAC,CACtE,CAAC;IAEF,OAAO,EAAE,iBAAiB,mBAAA,EAAE,OAAO,SAAA,EAAE,SAAS,WAAA,EAAE,CAAC;AACnD,CAAC;AAED,kFAAkF;AAClF,SAAS,WAAW,CAAC,KAAa,EAAE,EAA4B;QAA3B,IAAI,QAAA,EAAE,EAAE,QAAA;IAC3C,IAAI,KAAK,GAAG,IAAI,EAAE;QAChB,OAAO,EAAE,CAAC;KACX;IACD,IAAI,KAAK,GAAG,EAAE,EAAE;QACd,OAAO,IAAI,CAAC;KACb;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { useCallback, useMemo, useState } from 'react';\nimport { KeyCode } from '../../internal/keycode';\nimport { ChartContainerProps } from '../chart-container';\nimport { ChartDataTypes, MixedLineBarChartProps } from '../interfaces';\nimport { ChartScale, NumericChartScale } from '../../internal/components/cartesian-chart/scales';\nimport { findNavigableSeries, nextValidDomainIndex } from '../utils';\nimport { ScaledPoint } from '../make-scaled-series';\nimport { ScaledBarGroup } from '../make-scaled-bar-groups';\n\nexport type UseNavigationProps<T extends ChartDataTypes> = Pick<\n ChartContainerProps<T>,\n 'highlightedSeries' | 'series' | 'visibleSeries'\n> & {\n xScale: ChartScale;\n yScale: NumericChartScale;\n barGroups: ScaledBarGroup<T>[];\n scaledSeries: ReadonlyArray<ScaledPoint<T>>;\n\n highlightedPoint: ScaledPoint<T> | null;\n highlightedGroupIndex: number | null;\n legendSeries: null | MixedLineBarChartProps.ChartSeries<T>;\n isHandlersDisabled: boolean;\n\n pinPopover(pinned?: boolean): void;\n highlightSeries(series: MixedLineBarChartProps.ChartSeries<T> | null): void;\n highlightGroup(groupIndex: number): void;\n highlightPoint(point: ScaledPoint<T> | null): void;\n clearHighlightedSeries(): void;\n};\n\nexport function useNavigation<T extends ChartDataTypes>({\n series,\n visibleSeries,\n scaledSeries,\n barGroups,\n xScale,\n yScale,\n highlightedPoint,\n highlightedGroupIndex,\n highlightedSeries,\n legendSeries,\n isHandlersDisabled,\n pinPopover,\n highlightSeries,\n highlightGroup,\n highlightPoint,\n}: UseNavigationProps<T>) {\n const [targetX, setTargetX] = useState<T | null>(null);\n\n // There are two different types of navigation:\n // 1) Group navigation for any chart that contains a bar series\n // 2) Line navigation for any chart that only contains lines and thresholds\n const isGroupNavigation = visibleSeries.some(({ series }) => series.type === 'bar');\n\n // Make a list of series that can be navigated between. Bar series are treated as one.\n const { navigableSeries } = useMemo(() => findNavigableSeries(visibleSeries), [visibleSeries]);\n\n const onBarGroupFocus = () => {\n const groupIndex = highlightedGroupIndex ?? 0;\n setTargetX((xScale.domain as T[])[groupIndex]);\n highlightGroup(groupIndex);\n };\n\n const onLineGroupFocus = () => {\n if (!highlightedSeries || !highlightedPoint) {\n const targetSeries = highlightedSeries ?? legendSeries ?? series[0]?.series ?? null;\n highlightSeries(targetSeries);\n for (const scaledS of scaledSeries) {\n if (scaledS.series === targetSeries) {\n highlightPoint(scaledS);\n return;\n }\n }\n }\n };\n\n const onFocus = () => {\n if (isGroupNavigation) {\n onBarGroupFocus();\n } else {\n onLineGroupFocus();\n }\n };\n\n const moveBetweenSeries = useCallback(\n (direction: number) => {\n if (isGroupNavigation) {\n return;\n }\n\n const xOffset = xScale.isCategorical() ? Math.max(0, xScale.d3Scale.bandwidth() - 1) / 2 : 0;\n const MAX_SERIES_INDEX = navigableSeries.length - 1;\n\n // Find the index of the currently highlighted series (if any)\n let previousSeriesIndex = -1;\n if (highlightedSeries) {\n previousSeriesIndex = navigableSeries.indexOf(highlightedSeries);\n }\n\n // Move forwards or backwards to the new series\n let nextSeriesIndex = 0;\n if (previousSeriesIndex !== -1) {\n nextSeriesIndex = previousSeriesIndex + direction;\n if (nextSeriesIndex > MAX_SERIES_INDEX) {\n nextSeriesIndex = 0;\n } else if (nextSeriesIndex < 0) {\n nextSeriesIndex = MAX_SERIES_INDEX;\n }\n }\n\n const nextSeries = navigableSeries[nextSeriesIndex];\n const nextInternalSeries = series.filter(({ series }) => series === nextSeries)[0];\n\n // 2. Find point in the next series\n let targetXPoint = (xScale.d3Scale(targetX as any) ?? NaN) + xOffset;\n if (!isFinite(targetXPoint)) {\n targetXPoint = 0;\n }\n\n if (nextSeries.type === 'line') {\n const nextSeriesData = nextSeries.data as ReadonlyArray<MixedLineBarChartProps.Datum<T>>;\n const lookingForScaled = targetXPoint; // scaled X in previous series\n\n const nextPoint = nextSeriesData\n // scale all points in series\n .map(d => ({\n x: (xScale.d3Scale(d.x as any) || 0) + xOffset,\n y: yScale.d3Scale(d.y) || 0,\n datum: d,\n }))\n // find the closest point to previous X\n .reduce(\n (prev, curr) => (Math.abs(curr.x - lookingForScaled) < Math.abs(prev.x - lookingForScaled) ? curr : prev),\n { x: -Infinity, y: -Infinity }\n );\n\n highlightSeries(nextSeries);\n highlightPoint({ ...nextPoint, color: nextInternalSeries.color, series: nextSeries });\n } else if (nextSeries.type === 'threshold') {\n const scaledTargetIndex = scaledSeries.map(it => it.datum?.x || null).indexOf(targetX);\n highlightSeries(nextSeries);\n highlightPoint({\n x: targetXPoint,\n y: yScale.d3Scale(nextSeries.y) ?? NaN,\n color: nextInternalSeries.color,\n series: nextSeries,\n datum: scaledSeries[scaledTargetIndex]?.datum,\n });\n }\n },\n [\n isGroupNavigation,\n xScale,\n navigableSeries,\n highlightedSeries,\n scaledSeries,\n series,\n targetX,\n highlightSeries,\n highlightPoint,\n yScale,\n ]\n );\n\n const moveWithinSeries = useCallback(\n (direction: number) => {\n const series = highlightedSeries || visibleSeries[0].series;\n const previousPoint = highlightedPoint || scaledSeries[0];\n\n if (series.type === 'line') {\n // find previous point in series\n const indexOfPreviousPoint = previousPoint?.datum\n ? (series.data as ReadonlyArray<MixedLineBarChartProps.Datum<T>>).indexOf(previousPoint.datum)\n : 0;\n const nextPointIndex = circleIndex(indexOfPreviousPoint + direction, [0, series.data.length - 1]);\n const nextPoint = series.data[nextPointIndex];\n\n // find scaled next point\n const nextPointScaled = scaledSeries.filter(s => s.datum === nextPoint)[0] || null;\n\n setTargetX(nextPoint.x as T);\n highlightSeries(series);\n highlightPoint(nextPointScaled);\n } else if (series.type === 'threshold') {\n const [scaledThresholdSeries] = scaledSeries.filter(it => it.series === series);\n const scaledDataSeries = scaledSeries.filter(it => it.datum);\n const indexOfPreviousPoint = scaledDataSeries.map(it => it.x).indexOf(previousPoint.x);\n const nextPointIndex = circleIndex(indexOfPreviousPoint + direction, [0, scaledDataSeries.length - 1]);\n setTargetX(scaledDataSeries[nextPointIndex].datum?.x || null);\n highlightSeries(series);\n highlightPoint({\n ...scaledThresholdSeries,\n datum: scaledDataSeries[nextPointIndex].datum,\n x: scaledDataSeries[nextPointIndex].x,\n });\n } else if (series.type === 'bar') {\n const xDomain = xScale.domain as T[];\n const MAX_GROUP_INDEX = xDomain.length - 1;\n\n let nextGroupIndex = 0;\n if (highlightedGroupIndex !== null) {\n // find next group\n nextGroupIndex = highlightedGroupIndex + direction;\n if (nextGroupIndex > MAX_GROUP_INDEX) {\n nextGroupIndex = 0;\n } else if (nextGroupIndex < 0) {\n nextGroupIndex = MAX_GROUP_INDEX;\n }\n }\n\n const nextDomainIndex = nextValidDomainIndex(nextGroupIndex, barGroups, direction);\n setTargetX(xDomain[nextDomainIndex]);\n highlightGroup(nextDomainIndex);\n }\n },\n [\n highlightedSeries,\n visibleSeries,\n highlightedPoint,\n scaledSeries,\n highlightSeries,\n highlightPoint,\n xScale.domain,\n highlightedGroupIndex,\n barGroups,\n highlightGroup,\n ]\n );\n\n const onKeyDown = useCallback(\n (event: React.KeyboardEvent) => {\n const keyCode = event.keyCode;\n if (\n keyCode !== KeyCode.up &&\n keyCode !== KeyCode.right &&\n keyCode !== KeyCode.down &&\n keyCode !== KeyCode.left &&\n keyCode !== KeyCode.space &&\n keyCode !== KeyCode.enter\n ) {\n return;\n }\n\n event.preventDefault();\n\n if (isHandlersDisabled) {\n return;\n }\n\n if (keyCode === KeyCode.down || keyCode === KeyCode.up) {\n moveBetweenSeries(keyCode === KeyCode.down ? 1 : -1);\n } else if (keyCode === KeyCode.left || keyCode === KeyCode.right) {\n moveWithinSeries(keyCode === KeyCode.right ? 1 : -1);\n } else if (keyCode === KeyCode.enter || keyCode === KeyCode.space) {\n pinPopover();\n }\n },\n [moveWithinSeries, moveBetweenSeries, isHandlersDisabled, pinPopover]\n );\n\n return { isGroupNavigation, onFocus, onKeyDown };\n}\n\n// Returns given index if it is in range or the opposite range boundary otherwise.\nfunction circleIndex(index: number, [from, to]: [number, number]): number {\n if (index < from) {\n return to;\n }\n if (index > to) {\n return from;\n }\n return index;\n}\n"]}
1
+ {"version":3,"file":"use-navigation.js","sourceRoot":"","sources":["../../../../src/mixed-line-bar-chart/hooks/use-navigation.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,M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CAAC,CAAC;SACtD;aAAM,IAAI,OAAO,KAAK,OAAO,CAAC,KAAK,IAAI,OAAO,KAAK,OAAO,CAAC,KAAK,EAAE;YACjE,UAAU,EAAE,CAAC;SACd;IACH,CAAC,EACD,CAAC,gBAAgB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,UAAU,CAAC,CACtE,CAAC;IAEF,OAAO,EAAE,iBAAiB,mBAAA,EAAE,OAAO,SAAA,EAAE,SAAS,WAAA,EAAE,CAAC;AACnD,CAAC;AAED,kFAAkF;AAClF,SAAS,WAAW,CAAC,KAAa,EAAE,EAA4B;QAA3B,IAAI,QAAA,EAAE,EAAE,QAAA;IAC3C,IAAI,KAAK,GAAG,IAAI,EAAE;QAChB,OAAO,EAAE,CAAC;KACX;IACD,IAAI,KAAK,GAAG,EAAE,EAAE;QACd,OAAO,IAAI,CAAC;KACb;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { useCallback, useMemo, useState } from 'react';\nimport { KeyCode } from '../../internal/keycode';\nimport { ChartContainerProps } from '../chart-container';\nimport { ChartDataTypes, MixedLineBarChartProps } from '../interfaces';\nimport { ChartScale, NumericChartScale } from '../../internal/components/cartesian-chart/scales';\nimport { findNavigableSeries, isXThreshold, isYThreshold, nextValidDomainIndex } from '../utils';\nimport { ScaledPoint } from '../make-scaled-series';\nimport { ScaledBarGroup } from '../make-scaled-bar-groups';\n\nexport type UseNavigationProps<T extends ChartDataTypes> = Pick<\n ChartContainerProps<T>,\n 'highlightedSeries' | 'series' | 'visibleSeries'\n> & {\n xScale: ChartScale;\n yScale: NumericChartScale;\n barGroups: ScaledBarGroup<T>[];\n scaledSeries: ReadonlyArray<ScaledPoint<T>>;\n\n highlightedPoint: ScaledPoint<T> | null;\n highlightedGroupIndex: number | null;\n legendSeries: null | MixedLineBarChartProps.ChartSeries<T>;\n isHandlersDisabled: boolean;\n\n pinPopover(pinned?: boolean): void;\n highlightSeries(series: MixedLineBarChartProps.ChartSeries<T> | null): void;\n highlightGroup(groupIndex: number): void;\n highlightPoint(point: ScaledPoint<T> | null): void;\n clearHighlightedSeries(): void;\n};\n\nexport function useNavigation<T extends ChartDataTypes>({\n series,\n visibleSeries,\n scaledSeries,\n barGroups,\n xScale,\n yScale,\n highlightedPoint,\n highlightedGroupIndex,\n highlightedSeries,\n legendSeries,\n isHandlersDisabled,\n pinPopover,\n highlightSeries,\n highlightGroup,\n highlightPoint,\n}: UseNavigationProps<T>) {\n const [targetX, setTargetX] = useState<T | null>(null);\n\n // There are two different types of navigation:\n // 1) Group navigation for any chart that contains a bar series\n // 2) Line navigation for any chart that only contains lines and thresholds\n const isGroupNavigation = visibleSeries.some(({ series }) => series.type === 'bar');\n\n // Make a list of series that can be navigated between. Bar series are treated as one.\n const { navigableSeries } = useMemo(() => findNavigableSeries(visibleSeries), [visibleSeries]);\n\n const onBarGroupFocus = () => {\n const groupIndex = highlightedGroupIndex ?? 0;\n setTargetX((xScale.domain as T[])[groupIndex]);\n highlightGroup(groupIndex);\n };\n\n const onLineGroupFocus = () => {\n if (!highlightedSeries || !highlightedPoint) {\n const targetSeries = highlightedSeries ?? legendSeries ?? series[0]?.series ?? null;\n highlightSeries(targetSeries);\n for (const scaledS of scaledSeries) {\n if (scaledS.series === targetSeries) {\n highlightPoint(scaledS);\n return;\n }\n }\n }\n };\n\n const onFocus = () => {\n if (isGroupNavigation) {\n onBarGroupFocus();\n } else {\n onLineGroupFocus();\n }\n };\n\n const moveBetweenSeries = useCallback(\n (direction: number) => {\n if (isGroupNavigation) {\n return;\n }\n\n const xOffset = xScale.isCategorical() ? Math.max(0, xScale.d3Scale.bandwidth() - 1) / 2 : 0;\n const MAX_SERIES_INDEX = navigableSeries.length - 1;\n\n // Find the index of the currently highlighted series (if any)\n let previousSeriesIndex = -1;\n if (highlightedSeries) {\n previousSeriesIndex = navigableSeries.indexOf(highlightedSeries);\n }\n\n // Move forwards or backwards to the new series\n let nextSeriesIndex = 0;\n if (previousSeriesIndex !== -1) {\n nextSeriesIndex = previousSeriesIndex + direction;\n if (nextSeriesIndex > MAX_SERIES_INDEX) {\n nextSeriesIndex = 0;\n } else if (nextSeriesIndex < 0) {\n nextSeriesIndex = MAX_SERIES_INDEX;\n }\n }\n\n const nextSeries = navigableSeries[nextSeriesIndex];\n const nextInternalSeries = series.filter(({ series }) => series === nextSeries)[0];\n\n // 2. Find point in the next series\n let targetXPoint = (xScale.d3Scale(targetX as any) ?? NaN) + xOffset;\n if (!isFinite(targetXPoint)) {\n targetXPoint = 0;\n }\n\n if (nextSeries.type === 'line') {\n const nextScaledSeries = scaledSeries.filter(it => it.series === nextSeries);\n const closestNextSeriesPoint = nextScaledSeries.reduce(\n (prev, curr) => (Math.abs(curr.x - targetXPoint) < Math.abs(prev.x - targetXPoint) ? curr : prev),\n { x: -Infinity, y: -Infinity }\n );\n highlightSeries(nextSeries);\n highlightPoint({ ...closestNextSeriesPoint, color: nextInternalSeries.color, series: nextSeries });\n } else if (isYThreshold(nextSeries)) {\n const scaledTargetIndex = scaledSeries.map(it => it.datum?.x || null).indexOf(targetX);\n highlightSeries(nextSeries);\n highlightPoint({\n x: targetXPoint,\n y: yScale.d3Scale(nextSeries.y) ?? NaN,\n color: nextInternalSeries.color,\n series: nextSeries,\n datum: scaledSeries[scaledTargetIndex]?.datum,\n });\n } else if (isXThreshold(nextSeries)) {\n highlightSeries(nextSeries);\n highlightPoint({\n x: xScale.d3Scale(nextSeries.x as any) ?? NaN,\n y: yScale.d3Scale.range()[0],\n color: nextInternalSeries.color,\n series: nextSeries,\n datum: { x: nextSeries.x, y: NaN },\n });\n }\n },\n [\n isGroupNavigation,\n xScale,\n navigableSeries,\n highlightedSeries,\n scaledSeries,\n series,\n targetX,\n highlightSeries,\n highlightPoint,\n yScale,\n ]\n );\n\n const moveWithinSeries = useCallback(\n (direction: number) => {\n const series = highlightedSeries || visibleSeries[0].series;\n const previousPoint = highlightedPoint || scaledSeries[0];\n\n if (series.type === 'line' || isYThreshold(series)) {\n const targetScaledSeries = scaledSeries.filter(it => it.series === series);\n const indexOfPreviousPoint = targetScaledSeries.map(it => it.x).indexOf(previousPoint.x);\n const nextPointIndex = circleIndex(indexOfPreviousPoint + direction, [0, targetScaledSeries.length - 1]);\n const nextPoint = targetScaledSeries[nextPointIndex];\n\n setTargetX(nextPoint.datum?.x || null);\n highlightSeries(series);\n highlightPoint(nextPoint);\n } else if (series.type === 'bar') {\n const xDomain = xScale.domain as T[];\n const MAX_GROUP_INDEX = xDomain.length - 1;\n\n let nextGroupIndex = 0;\n if (highlightedGroupIndex !== null) {\n // find next group\n nextGroupIndex = highlightedGroupIndex + direction;\n if (nextGroupIndex > MAX_GROUP_INDEX) {\n nextGroupIndex = 0;\n } else if (nextGroupIndex < 0) {\n nextGroupIndex = MAX_GROUP_INDEX;\n }\n }\n\n const nextDomainIndex = nextValidDomainIndex(nextGroupIndex, barGroups, direction);\n setTargetX(xDomain[nextDomainIndex]);\n highlightGroup(nextDomainIndex);\n }\n },\n [\n highlightedSeries,\n visibleSeries,\n highlightedPoint,\n scaledSeries,\n highlightSeries,\n highlightPoint,\n xScale.domain,\n highlightedGroupIndex,\n barGroups,\n highlightGroup,\n ]\n );\n\n const onKeyDown = useCallback(\n (event: React.KeyboardEvent) => {\n const keyCode = event.keyCode;\n if (\n keyCode !== KeyCode.up &&\n keyCode !== KeyCode.right &&\n keyCode !== KeyCode.down &&\n keyCode !== KeyCode.left &&\n keyCode !== KeyCode.space &&\n keyCode !== KeyCode.enter\n ) {\n return;\n }\n\n event.preventDefault();\n\n if (isHandlersDisabled) {\n return;\n }\n\n if (keyCode === KeyCode.down || keyCode === KeyCode.up) {\n moveBetweenSeries(keyCode === KeyCode.down ? 1 : -1);\n } else if (keyCode === KeyCode.left || keyCode === KeyCode.right) {\n moveWithinSeries(keyCode === KeyCode.right ? 1 : -1);\n } else if (keyCode === KeyCode.enter || keyCode === KeyCode.space) {\n pinPopover();\n }\n },\n [moveWithinSeries, moveBetweenSeries, isHandlersDisabled, pinPopover]\n );\n\n return { isGroupNavigation, onFocus, onKeyDown };\n}\n\n// Returns given index if it is in range or the opposite range boundary otherwise.\nfunction circleIndex(index: number, [from, to]: [number, number]): number {\n if (index < from) {\n return to;\n }\n if (index > to) {\n return from;\n }\n return index;\n}\n"]}
@@ -53,13 +53,23 @@ export declare namespace MixedLineBarChartProps {
53
53
  export interface LineDataSeries<T> extends IDataSeries<T> {
54
54
  type: 'line';
55
55
  }
56
- export interface ThresholdSeries extends Omit<IDataSeries<never>, 'data' | 'valueFormatter'> {
56
+ export interface ThresholdSeries<T = any> extends Omit<IDataSeries<never>, 'data' | 'valueFormatter'> {
57
+ type: 'threshold';
58
+ y?: number;
59
+ x?: T;
60
+ valueFormatter?: CartesianChartProps.TickFormatter<number>;
61
+ }
62
+ export interface YThresholdSeries extends Omit<ThresholdSeries<never>, 'x'> {
57
63
  type: 'threshold';
58
64
  y: number;
59
65
  valueFormatter?: CartesianChartProps.TickFormatter<number>;
60
66
  }
67
+ export interface XThresholdSeries<T> extends Omit<ThresholdSeries<T>, 'y' | 'valueFormatter'> {
68
+ type: 'threshold';
69
+ x: T;
70
+ }
61
71
  export type DataSeries<T> = LineDataSeries<T> | BarDataSeries<T>;
62
- export type ChartSeries<T> = DataSeries<T> | ThresholdSeries;
72
+ export type ChartSeries<T> = DataSeries<T> | ThresholdSeries<T>;
63
73
  export type FilterChangeDetail<T> = CartesianChartProps.FilterChangeDetail<ChartSeries<T>>;
64
74
  export type HighlightChangeDetail<T> = CartesianChartProps.HighlightChangeDetail<ChartSeries<T>>;
65
75
  export type TickFormatter<T> = CartesianChartProps.TickFormatter<T>;
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/mixed-line-bar-chart/interfaces.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mDAAmD,CAAC;AAExF,oBA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G,gBAAgB,CAAC;QAC3F,IAAI,EAAE,WAAW,CAAC;QAClB,CAAC,EAAE,CAAC,CAAC;KACN;IAED,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,cAAc,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;IAEjE,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC;IAEhE,MAAM,MAAM,kBAAkB,CAAC,CAAC,IAAI,mBAAmB,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IAE3F,MAAM,MAAM,qBAAqB,CAAC,CAAC,IAAI,mBAAmB,CAAC,qBAAqB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IAEjG,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,mBAAmB,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAEpE,MAAM,MAAM,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,IAAI,mBAAmB,CAAC,cAAc,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAEnG,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,mBAAmB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;;CACjE"}
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/mixed-line-bar-chart/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { CartesianChartProps } from '../internal/components/cartesian-chart/interfaces';\n\nexport type ChartDataTypes = number | string | Date;\n\nexport type SeriesType = 'line' | 'bar';\nexport type ScaleType = 'linear' | 'log' | 'time' | 'categorical';\nexport type ScaleRange = [number, number];\n\nexport interface InternalChartSeries<T> {\n index: number;\n color: string;\n series: MixedLineBarChartProps.ChartSeries<T>;\n}\n\nexport interface MixedLineBarChartProps<T extends ChartDataTypes>\n extends CartesianChartProps<T, MixedLineBarChartProps.ChartSeries<T>> {\n /**\n * Array that represents the source of data for the displayed chart.\n * Each element can represent a line series, bar series, or a threshold, and can have the following properties:\n *\n * * `title` (string): A human-readable title for this series\n * * `type` (string): Series type (`\"line\"`, `\"bar\"`, or `\"threshold\"`)\n * * `data` (Array): An array of data points, represented as objects with `x` and `y` properties\n * * `color` (string): (Optional) A color hex value for this series. When assigned, it takes priority over the automatically assigned color\n * * `valueFormatter` (Function): (Optional) A function that formats data values before rendering in the UI, For example, in the details popover.\n */\n series: ReadonlyArray<MixedLineBarChartProps.ChartSeries<T>>;\n\n /**\n * When set to `true`, bars in the same data point are stacked instead of grouped next to each other.\n */\n stackedBars?: boolean;\n\n /**\n * When set to `true`, the x and y axes are flipped, which causes any bars to be rendered horizontally instead of vertically.\n * This can only be used when the chart consists exclusively of bar series.\n */\n horizontalBars?: boolean;\n\n /**\n * When set to `true`, adds a visual emphasis on the zero baseline axis.\n * See the usage guidelines for more details.\n */\n emphasizeBaselineAxis?: boolean;\n}\n\nexport namespace MixedLineBarChartProps {\n export interface Datum<T> {\n x: T;\n y: number;\n }\n\n interface IDataSeries<T> {\n type: 'line' | 'bar' | 'threshold';\n title: string;\n color?: string;\n\n // This makes sure that the element type of the array is reduced to just one type,\n // even if `T` is a union type, e.g. `number | string`.\n data: T extends unknown ? ReadonlyArray<Datum<T>> : ReadonlyArray<Datum<T>>;\n valueFormatter?: T extends unknown\n ? CartesianChartProps.ValueFormatter<number, T>\n : CartesianChartProps.ValueFormatter<number, T>;\n }\n\n export interface BarDataSeries<T> extends IDataSeries<T> {\n type: 'bar';\n }\n\n export interface LineDataSeries<T> extends IDataSeries<T> {\n type: 'line';\n }\n\n export interface ThresholdSeries extends Omit<IDataSeries<never>, 'data' | 'valueFormatter'> {\n type: 'threshold';\n y: number;\n valueFormatter?: CartesianChartProps.TickFormatter<number>;\n }\n\n export type DataSeries<T> = LineDataSeries<T> | BarDataSeries<T>;\n\n export type ChartSeries<T> = DataSeries<T> | ThresholdSeries;\n\n export type FilterChangeDetail<T> = CartesianChartProps.FilterChangeDetail<ChartSeries<T>>;\n\n export type HighlightChangeDetail<T> = CartesianChartProps.HighlightChangeDetail<ChartSeries<T>>;\n\n export type TickFormatter<T> = CartesianChartProps.TickFormatter<T>;\n\n export type ValueFormatter<YType, XType = null> = CartesianChartProps.ValueFormatter<YType, XType>;\n\n export type I18nStrings<T> = CartesianChartProps.I18nStrings<T>;\n}\n"]}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/mixed-line-bar-chart/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { CartesianChartProps } from '../internal/components/cartesian-chart/interfaces';\n\nexport type ChartDataTypes = number | string | Date;\n\nexport type SeriesType = 'line' | 'bar';\nexport type ScaleType = 'linear' | 'log' | 'time' | 'categorical';\nexport type ScaleRange = [number, number];\n\nexport interface InternalChartSeries<T> {\n index: number;\n color: string;\n series: MixedLineBarChartProps.ChartSeries<T>;\n}\n\nexport interface MixedLineBarChartProps<T extends ChartDataTypes>\n extends CartesianChartProps<T, MixedLineBarChartProps.ChartSeries<T>> {\n /**\n * Array that represents the source of data for the displayed chart.\n * Each element can represent a line series, bar series, or a threshold, and can have the following properties:\n *\n * * `title` (string): A human-readable title for this series\n * * `type` (string): Series type (`\"line\"`, `\"bar\"`, or `\"threshold\"`)\n * * `data` (Array): An array of data points, represented as objects with `x` and `y` properties\n * * `color` (string): (Optional) A color hex value for this series. When assigned, it takes priority over the automatically assigned color\n * * `valueFormatter` (Function): (Optional) A function that formats data values before rendering in the UI, For example, in the details popover.\n */\n series: ReadonlyArray<MixedLineBarChartProps.ChartSeries<T>>;\n\n /**\n * When set to `true`, bars in the same data point are stacked instead of grouped next to each other.\n */\n stackedBars?: boolean;\n\n /**\n * When set to `true`, the x and y axes are flipped, which causes any bars to be rendered horizontally instead of vertically.\n * This can only be used when the chart consists exclusively of bar series.\n */\n horizontalBars?: boolean;\n\n /**\n * When set to `true`, adds a visual emphasis on the zero baseline axis.\n * See the usage guidelines for more details.\n */\n emphasizeBaselineAxis?: boolean;\n}\n\nexport namespace MixedLineBarChartProps {\n export interface Datum<T> {\n x: T;\n y: number;\n }\n\n interface IDataSeries<T> {\n type: 'line' | 'bar' | 'threshold';\n title: string;\n color?: string;\n\n // This makes sure that the element type of the array is reduced to just one type,\n // even if `T` is a union type, e.g. `number | string`.\n data: T extends unknown ? ReadonlyArray<Datum<T>> : ReadonlyArray<Datum<T>>;\n valueFormatter?: T extends unknown\n ? CartesianChartProps.ValueFormatter<number, T>\n : CartesianChartProps.ValueFormatter<number, T>;\n }\n\n export interface BarDataSeries<T> extends IDataSeries<T> {\n type: 'bar';\n }\n\n export interface LineDataSeries<T> extends IDataSeries<T> {\n type: 'line';\n }\n\n export interface ThresholdSeries<T = any> extends Omit<IDataSeries<never>, 'data' | 'valueFormatter'> {\n type: 'threshold';\n y?: number;\n x?: T;\n valueFormatter?: CartesianChartProps.TickFormatter<number>;\n }\n\n export interface YThresholdSeries extends Omit<ThresholdSeries<never>, 'x'> {\n type: 'threshold';\n y: number;\n valueFormatter?: CartesianChartProps.TickFormatter<number>;\n }\n\n export interface XThresholdSeries<T> extends Omit<ThresholdSeries<T>, 'y' | 'valueFormatter'> {\n type: 'threshold';\n x: T;\n }\n\n export type DataSeries<T> = LineDataSeries<T> | BarDataSeries<T>;\n\n export type ChartSeries<T> = DataSeries<T> | ThresholdSeries<T>;\n\n export type FilterChangeDetail<T> = CartesianChartProps.FilterChangeDetail<ChartSeries<T>>;\n\n export type HighlightChangeDetail<T> = CartesianChartProps.HighlightChangeDetail<ChartSeries<T>>;\n\n export type TickFormatter<T> = CartesianChartProps.TickFormatter<T>;\n\n export type ValueFormatter<YType, XType = null> = CartesianChartProps.ValueFormatter<YType, XType>;\n\n export type I18nStrings<T> = CartesianChartProps.I18nStrings<T>;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/mixed-line-bar-chart/internal.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAMtE,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAMlF,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,aAAK,8BAA8B,CAAC,CAAC,SAAS,cAAc,IAAI,YAAY,CAC1E,sBAAsB,CAAC,CAAC,CAAC,EACvB,QAAQ,GACR,QAAQ,GACR,YAAY,GACZ,YAAY,GACZ,aAAa,GACb,gBAAgB,GAChB,YAAY,GACZ,mBAAmB,GACnB,uBAAuB,CAC1B,GACC,0BAA0B,CAAC;AAE7B,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,IAAI,EAAE,EAClF,MAAM,EACN,UAAU,EACV,UAAU,EACV,OAAO,EACP,OAAO,EACP,iBAAiB,EAAE,2BAA2B,EAC9C,aAAa,EAAE,uBAAuB,EACtC,MAAM,EAAE,cAAc,EACtB,cAAc,EACd,iBAAiB,EAAE,2BAA2B,EAC9C,WAAW,EACX,SAAS,EACT,cAAc,EACd,eAAe,EACf,MAAM,EACN,MAAM,EACN,WAAW,EACX,cAAc,EACd,UAAU,EACV,iBAAiB,EACjB,UAAU,EACV,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,qBAAqB,EACrB,KAAK,EACL,OAAO,EACP,SAAS,EACT,WAAW,EACX,YAAY,EACZ,eAAe,EACf,iBAAwB,EACxB,GAAG,KAAK,EACT,EAAE,8BAA8B,CAAC,CAAC,CAAC,eA4MnC"}
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/mixed-line-bar-chart/internal.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAMtE,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAMlF,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjD,aAAK,8BAA8B,CAAC,CAAC,SAAS,cAAc,IAAI,YAAY,CAC1E,sBAAsB,CAAC,CAAC,CAAC,EACvB,QAAQ,GACR,QAAQ,GACR,YAAY,GACZ,YAAY,GACZ,aAAa,GACb,gBAAgB,GAChB,YAAY,GACZ,mBAAmB,GACnB,uBAAuB,CAC1B,GACC,0BAA0B,CAAC;AAE7B,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,IAAI,EAAE,EAClF,MAAM,EACN,UAAU,EACV,UAAU,EACV,OAAO,EACP,OAAO,EACP,iBAAiB,EAAE,2BAA2B,EAC9C,aAAa,EAAE,uBAAuB,EACtC,MAAM,EAAE,cAAc,EACtB,cAAc,EACd,iBAAiB,EAAE,2BAA2B,EAC9C,WAAW,EACX,SAAS,EACT,cAAc,EACd,eAAe,EACf,MAAM,EACN,MAAM,EACN,WAAW,EACX,cAAc,EACd,UAAU,EACV,iBAAiB,EACjB,UAAU,EACV,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,qBAAqB,EACrB,KAAK,EACL,OAAO,EACP,SAAS,EACT,WAAW,EACX,YAAY,EACZ,eAAe,EACf,iBAAwB,EACxB,GAAG,KAAK,EACT,EAAE,8BAA8B,CAAC,CAAC,CAAC,eAmNnC"}
@@ -19,6 +19,7 @@ import { isDevelopment } from '../internal/is-development';
19
19
  import createCategoryColorScale from '../internal/utils/create-category-color-scale';
20
20
  import { useMergeRefs } from '../internal/hooks/use-merge-refs';
21
21
  import { nodeContains } from '../internal/utils/dom';
22
+ import { isXThreshold, isYThreshold } from './utils';
22
23
  export default function InternalMixedLineBarChart(_a) {
23
24
  var _b;
24
25
  var height = _a.height, xScaleType = _a.xScaleType, yScaleType = _a.yScaleType, xDomain = _a.xDomain, yDomain = _a.yDomain, controlledHighlightedSeries = _a.highlightedSeries, controlledVisibleSeries = _a.visibleSeries, externalSeries = _a.series, onFilterChange = _a.onFilterChange, controlledOnHighlightChange = _a.onHighlightChange, i18nStrings = _a.i18nStrings, ariaLabel = _a.ariaLabel, ariaLabelledby = _a.ariaLabelledby, ariaDescription = _a.ariaDescription, xTitle = _a.xTitle, yTitle = _a.yTitle, stackedBars = _a.stackedBars, horizontalBars = _a.horizontalBars, hideFilter = _a.hideFilter, additionalFilters = _a.additionalFilters, hideLegend = _a.hideLegend, legendTitle = _a.legendTitle, statusType = _a.statusType, detailPopoverSize = _a.detailPopoverSize, emphasizeBaselineAxis = _a.emphasizeBaselineAxis, empty = _a.empty, noMatch = _a.noMatch, errorText = _a.errorText, loadingText = _a.loadingText, recoveryText = _a.recoveryText, onRecoveryClick = _a.onRecoveryClick, _c = _a.__internalRootRef, __internalRootRef = _c === void 0 ? null : _c, props = __rest(_a, ["height", "xScaleType", "yScaleType", "xDomain", "yDomain", "highlightedSeries", "visibleSeries", "series", "onFilterChange", "onHighlightChange", "i18nStrings", "ariaLabel", "ariaLabelledby", "ariaDescription", "xTitle", "yTitle", "stackedBars", "horizontalBars", "hideFilter", "additionalFilters", "hideLegend", "legendTitle", "statusType", "detailPopoverSize", "emphasizeBaselineAxis", "empty", "noMatch", "errorText", "loadingText", "recoveryText", "onRecoveryClick", "__internalRootRef"]);
@@ -33,14 +34,21 @@ export default function InternalMixedLineBarChart(_a) {
33
34
  if (horizontalBars && gotLineSeries) {
34
35
  warnOnce('MixedLineBarChart', "Property horizontalBars can only be used with charts that contain only bar or threshold series.");
35
36
  }
37
+ for (var _i = 0, externalSeries_1 = externalSeries; _i < externalSeries_1.length; _i++) {
38
+ var s = externalSeries_1[_i];
39
+ if (s.type === 'threshold' && s.x !== undefined && s.y !== undefined) {
40
+ warnOnce('MixedLineBarChart', "Series of type \"threshold\" must contain either x or y property.");
41
+ }
42
+ if (s.type === 'threshold' && s.x === undefined && s.y === undefined) {
43
+ warnOnce('MixedLineBarChart', "Series of type \"threshold\" must contain either x or y property.");
44
+ }
45
+ }
36
46
  }, [xScaleType, horizontalBars, externalSeries]);
37
47
  var series = useMemo(function () {
38
- var colors = createCategoryColorScale(externalSeries, function (it) { return it.type === 'threshold'; }, function (it) { return it.color || null; });
39
- return externalSeries.map(function (s, i) { return ({
40
- index: i,
41
- color: colors[i],
42
- series: s
43
- }); });
48
+ // Generate series colors if not explicitly provided.
49
+ // The thresholds use a dedicated colour scale.
50
+ var colors = createCategoryColorScale(externalSeries, function (it) { return isYThreshold(it) || isXThreshold(it); }, function (it) { return it.color || null; });
51
+ return externalSeries.map(function (s, i) { return ({ index: i, color: colors[i], series: s }); });
44
52
  }, [externalSeries]);
45
53
  var _d = useState(null), highlightedPoint = _d[0], setHighlightedPoint = _d[1];
46
54
  var _e = useState(null), highlightedGroupIndex = _e[0], setHighlightedGroupIndex = _e[1];
@@ -1 +1 @@
1
- {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/mixed-line-bar-chart/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpE,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAC1C,OAAO,oBAAoB,EAAE,EAAE,cAAc,EAAE,MAAM,+CAA+C,CAAC;AACrG,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAG/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identifier: Apache-2.0\nimport React, { useEffect, useMemo, useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport { getBaseProps } from '../internal/base-component';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport InternalBox from '../box/internal';\nimport ChartStatusContainer, { getChartStatus } from '../internal/components/chart-status-container';\nimport { useControllable } from '../internal/hooks/use-controllable';\nimport { usePrevious } from '../internal/hooks/use-previous';\nimport { warnOnce } from '../internal/logging';\n\nimport { ChartDataTypes, MixedLineBarChartProps } from './interfaces';\nimport InternalChartFilters from './chart-filters';\nimport InternalChartLegend from './chart-legend';\nimport ChartContainer from './chart-container';\nimport cartesianStyles from '../internal/components/cartesian-chart/styles.css.js';\nimport styles from './styles.css.js';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { isDevelopment } from '../internal/is-development';\nimport createCategoryColorScale from '../internal/utils/create-category-color-scale';\nimport { ScaledPoint } from './make-scaled-series';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\nimport { nodeContains } from '../internal/utils/dom';\nimport { SomeRequired } from '../internal/types';\n\ntype InternalMixedLineBarChartProps<T extends ChartDataTypes> = SomeRequired<\n MixedLineBarChartProps<T>,\n | 'series'\n | 'height'\n | 'xScaleType'\n | 'yScaleType'\n | 'stackedBars'\n | 'horizontalBars'\n | 'statusType'\n | 'detailPopoverSize'\n | 'emphasizeBaselineAxis'\n> &\n InternalBaseComponentProps;\n\nexport default function InternalMixedLineBarChart<T extends number | string | Date>({\n height,\n xScaleType,\n yScaleType,\n xDomain,\n yDomain,\n highlightedSeries: controlledHighlightedSeries,\n visibleSeries: controlledVisibleSeries,\n series: externalSeries,\n onFilterChange,\n onHighlightChange: controlledOnHighlightChange,\n i18nStrings,\n ariaLabel,\n ariaLabelledby,\n ariaDescription,\n xTitle,\n yTitle,\n stackedBars,\n horizontalBars,\n hideFilter,\n additionalFilters,\n hideLegend,\n legendTitle,\n statusType,\n detailPopoverSize,\n emphasizeBaselineAxis,\n empty,\n noMatch,\n errorText,\n loadingText,\n recoveryText,\n onRecoveryClick,\n __internalRootRef = null,\n ...props\n}: InternalMixedLineBarChartProps<T>) {\n const baseProps = getBaseProps(props);\n const containerRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n const gotBarSeries = externalSeries.some(s => s.type === 'bar');\n const gotLineSeries = externalSeries.some(s => s.type === 'line');\n\n if (xScaleType !== 'categorical' && gotBarSeries) {\n warnOnce(\n 'MixedLineBarChart',\n `Bar series cannot be used with a ${xScaleType} scale. Use a categorical x axis instead.`\n );\n }\n\n if (horizontalBars && gotLineSeries) {\n warnOnce(\n 'MixedLineBarChart',\n `Property horizontalBars can only be used with charts that contain only bar or threshold series.`\n );\n }\n }, [xScaleType, horizontalBars, externalSeries]);\n\n const series = useMemo(() => {\n const colors = createCategoryColorScale(\n externalSeries,\n it => it.type === 'threshold',\n it => it.color || null\n );\n\n return externalSeries.map((s, i) => ({\n index: i,\n color: colors[i],\n series: s,\n }));\n }, [externalSeries]);\n\n const [highlightedPoint, setHighlightedPoint] = useState<ScaledPoint<T> | null>(null);\n const [highlightedGroupIndex, setHighlightedGroupIndex] = useState<number | null>(null);\n const [highlightedSeries = null, setHighlightedSeries] = useControllable(\n controlledHighlightedSeries,\n controlledOnHighlightChange,\n null,\n {\n componentName: 'MixedLineBarChart',\n controlledProp: 'highlightedSeries',\n changeHandler: 'onHighlightChange',\n }\n );\n const [legendSeries, setLegendSeries] = useState<MixedLineBarChartProps.ChartSeries<T> | null>(highlightedSeries);\n useEffect(() => {\n setLegendSeries(controlledHighlightedSeries || null);\n }, [controlledHighlightedSeries]);\n\n const [externalVisibleSeries, setExternalVisibleSeries] = useControllable(\n controlledVisibleSeries,\n onFilterChange,\n externalSeries,\n {\n componentName: 'MixedLineBarChart',\n controlledProp: 'visibleSeries',\n changeHandler: 'onFilterChange',\n }\n );\n\n if (isDevelopment) {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const previousSeries = usePrevious(externalSeries);\n\n const hasPrevious = !!(previousSeries && previousSeries.length);\n const hasCurrent = !!externalSeries.length;\n\n if (hasPrevious && hasCurrent && externalSeries !== previousSeries && !controlledVisibleSeries && !hideFilter) {\n warnOnce(\n 'MixedLineBarChart',\n 'The `series` value passed into the component changed. ' +\n 'This may cause problems with filtering - we recommend that you make the `series` value constant, ' +\n 'or provide a `visibleSeries` value that derives from the current `series` value.'\n );\n }\n }\n\n const visibleSeries = useMemo(\n () => series.filter(s => externalVisibleSeries?.indexOf(s.series) !== -1),\n [series, externalVisibleSeries]\n );\n\n const filterChange = (selectedSeries: ReadonlyArray<MixedLineBarChartProps.ChartSeries<T>>) => {\n setExternalVisibleSeries(selectedSeries);\n fireNonCancelableEvent(onFilterChange, {\n visibleSeries: selectedSeries,\n });\n };\n\n const onHighlightChange = (series: MixedLineBarChartProps.ChartSeries<T> | null) => {\n setHighlightedSeries(series);\n fireNonCancelableEvent(controlledOnHighlightChange, {\n highlightedSeries: series,\n });\n setLegendSeries(series);\n };\n\n const onBlur = (event: React.FocusEvent) => {\n if (event.relatedTarget && !nodeContains(containerRef.current, event.relatedTarget)) {\n highlightedSeries && onHighlightChange(highlightedSeries);\n setHighlightedPoint(null);\n setHighlightedGroupIndex(null);\n setLegendSeries(null);\n }\n };\n\n const { isEmpty, isNoMatch, showChart } = getChartStatus({\n externalData: externalSeries,\n visibleData: visibleSeries || [],\n statusType,\n });\n const showFilters = statusType === 'finished' && (!isEmpty || isNoMatch);\n const showLegend = !hideLegend && !isEmpty && statusType === 'finished';\n const reserveLegendSpace = !showChart && !hideLegend;\n const reserveFilterSpace = !showChart && !isNoMatch && (!hideFilter || additionalFilters);\n const mergedRef = useMergeRefs(containerRef, __internalRootRef);\n\n return (\n <div {...baseProps} className={clsx(baseProps.className, styles.root)} ref={mergedRef} onBlur={onBlur}>\n {showFilters && (\n <InternalBox className={cartesianStyles['filter-container']} margin={{ bottom: 'l' }}>\n <InternalChartFilters\n series={series}\n visibleSeries={externalVisibleSeries || []}\n onChange={filterChange}\n i18nStrings={i18nStrings}\n hideFilter={hideFilter}\n additionalFilters={additionalFilters}\n />\n </InternalBox>\n )}\n\n <div\n className={clsx(styles.content, {\n [styles['content--reserve-filter']]: reserveFilterSpace,\n [styles['content--reserve-legend']]: reserveLegendSpace,\n })}\n style={{ minHeight: height }}\n >\n <ChartStatusContainer\n isEmpty={isEmpty}\n isNoMatch={isNoMatch}\n showChart={showChart}\n statusType={statusType}\n empty={empty}\n noMatch={noMatch}\n loadingText={loadingText}\n errorText={errorText}\n recoveryText={recoveryText}\n onRecoveryClick={onRecoveryClick}\n />\n {showChart && (\n <ChartContainer\n height={height}\n xScaleType={xScaleType}\n yScaleType={yScaleType}\n xDomain={xDomain}\n yDomain={yDomain}\n xTickFormatter={i18nStrings?.xTickFormatter}\n yTickFormatter={i18nStrings?.yTickFormatter}\n emphasizeBaselineAxis={emphasizeBaselineAxis}\n stackedBars={stackedBars}\n horizontalBars={horizontalBars}\n series={series}\n visibleSeries={visibleSeries}\n highlightedSeries={highlightedSeries}\n onHighlightChange={onHighlightChange}\n highlightedPoint={highlightedPoint}\n setHighlightedPoint={setHighlightedPoint}\n highlightedGroupIndex={highlightedGroupIndex}\n setHighlightedGroupIndex={setHighlightedGroupIndex}\n legendSeries={legendSeries}\n detailPopoverSize={detailPopoverSize}\n xTitle={xTitle}\n yTitle={yTitle}\n ariaLabel={ariaLabel}\n ariaLabelledby={ariaLabelledby}\n ariaDescription={ariaDescription}\n i18nStrings={i18nStrings}\n plotContainerRef={containerRef}\n />\n )}\n </div>\n\n {showLegend && (\n <InternalBox margin={{ top: 'm' }}>\n <InternalChartLegend\n series={series}\n visibleSeries={externalVisibleSeries || []}\n highlightedSeries={legendSeries}\n onHighlightChange={onHighlightChange}\n legendTitle={legendTitle}\n ariaLabel={i18nStrings?.legendAriaLabel}\n plotContainerRef={containerRef}\n />\n </InternalBox>\n )}\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/mixed-line-bar-chart/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O,EAAE,OAAO,EAChB,cAAc,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,cAAc,EAC3C,cAAc,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,cAAc,EAC3C,qBAAqB,EAAE,qBAAqB,EAC5C,WAAW,EAAE,WAAW,EACxB,cAAc,EAAE,cAAc,EAC9B,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,aAAa,EAC5B,iBAAiB,EAAE,iBAAiB,EACpC,iBAAiB,EAAE,iBAAiB,EACpC,gBAAgB,EAAE,gBAAgB,EAClC,mBAAmB,EAAE,mBAAmB,EACxC,qBAAqB,EAAE,qBAAqB,EAC5C,wBAAwB,EAAE,wBAAwB,EAClD,YAAY,EAAE,YAAY,EAC1B,iBAAiB,EAAE,iBAAiB,EACpC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,cAAc,EAAE,cAAc,EAC9B,eAAe,EAAE,eAAe,EAChC,WAAW,EAAE,WAAW,EACxB,gBAAgB,EAAE,YAAY,GAC9B,CACH,CACG;QAEL,UAAU,IAAI,CACb,oBAAC,WAAW,IAAC,MAAM,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE;YAC/B,oBAAC,mBAAmB,IAClB,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,qBAAqB,IAAI,EAAE,EAC1C,iBAAiB,EAAE,YAAY,EAC/B,iBAAiB,EAAE,iBAAiB,EACpC,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,eAAe,EACvC,gBAAgB,EAAE,YAAY,GAC9B,CACU,CACf,CACG,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useMemo, useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport { getBaseProps } from '../internal/base-component';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport InternalBox from '../box/internal';\nimport ChartStatusContainer, { getChartStatus } from '../internal/components/chart-status-container';\nimport { useControllable } from '../internal/hooks/use-controllable';\nimport { usePrevious } from '../internal/hooks/use-previous';\nimport { warnOnce } from '../internal/logging';\n\nimport { ChartDataTypes, MixedLineBarChartProps } from './interfaces';\nimport InternalChartFilters from './chart-filters';\nimport InternalChartLegend from './chart-legend';\nimport ChartContainer from './chart-container';\nimport cartesianStyles from '../internal/components/cartesian-chart/styles.css.js';\nimport styles from './styles.css.js';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { isDevelopment } from '../internal/is-development';\nimport createCategoryColorScale from '../internal/utils/create-category-color-scale';\nimport { ScaledPoint } from './make-scaled-series';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\nimport { nodeContains } from '../internal/utils/dom';\nimport { SomeRequired } from '../internal/types';\nimport { isXThreshold, isYThreshold } from './utils';\n\ntype InternalMixedLineBarChartProps<T extends ChartDataTypes> = SomeRequired<\n MixedLineBarChartProps<T>,\n | 'series'\n | 'height'\n | 'xScaleType'\n | 'yScaleType'\n | 'stackedBars'\n | 'horizontalBars'\n | 'statusType'\n | 'detailPopoverSize'\n | 'emphasizeBaselineAxis'\n> &\n InternalBaseComponentProps;\n\nexport default function InternalMixedLineBarChart<T extends number | string | Date>({\n height,\n xScaleType,\n yScaleType,\n xDomain,\n yDomain,\n highlightedSeries: controlledHighlightedSeries,\n visibleSeries: controlledVisibleSeries,\n series: externalSeries,\n onFilterChange,\n onHighlightChange: controlledOnHighlightChange,\n i18nStrings,\n ariaLabel,\n ariaLabelledby,\n ariaDescription,\n xTitle,\n yTitle,\n stackedBars,\n horizontalBars,\n hideFilter,\n additionalFilters,\n hideLegend,\n legendTitle,\n statusType,\n detailPopoverSize,\n emphasizeBaselineAxis,\n empty,\n noMatch,\n errorText,\n loadingText,\n recoveryText,\n onRecoveryClick,\n __internalRootRef = null,\n ...props\n}: InternalMixedLineBarChartProps<T>) {\n const baseProps = getBaseProps(props);\n const containerRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n const gotBarSeries = externalSeries.some(s => s.type === 'bar');\n const gotLineSeries = externalSeries.some(s => s.type === 'line');\n\n if (xScaleType !== 'categorical' && gotBarSeries) {\n warnOnce(\n 'MixedLineBarChart',\n `Bar series cannot be used with a ${xScaleType} scale. Use a categorical x axis instead.`\n );\n }\n\n if (horizontalBars && gotLineSeries) {\n warnOnce(\n 'MixedLineBarChart',\n `Property horizontalBars can only be used with charts that contain only bar or threshold series.`\n );\n }\n\n for (const s of externalSeries) {\n if (s.type === 'threshold' && s.x !== undefined && s.y !== undefined) {\n warnOnce('MixedLineBarChart', `Series of type \"threshold\" must contain either x or y property.`);\n }\n if (s.type === 'threshold' && s.x === undefined && s.y === undefined) {\n warnOnce('MixedLineBarChart', `Series of type \"threshold\" must contain either x or y property.`);\n }\n }\n }, [xScaleType, horizontalBars, externalSeries]);\n\n const series = useMemo(() => {\n // Generate series colors if not explicitly provided.\n // The thresholds use a dedicated colour scale.\n const colors = createCategoryColorScale(\n externalSeries,\n it => isYThreshold(it) || isXThreshold(it),\n it => it.color || null\n );\n\n return externalSeries.map((s, i) => ({ index: i, color: colors[i], series: s }));\n }, [externalSeries]);\n\n const [highlightedPoint, setHighlightedPoint] = useState<ScaledPoint<T> | null>(null);\n const [highlightedGroupIndex, setHighlightedGroupIndex] = useState<number | null>(null);\n const [highlightedSeries = null, setHighlightedSeries] = useControllable(\n controlledHighlightedSeries,\n controlledOnHighlightChange,\n null,\n {\n componentName: 'MixedLineBarChart',\n controlledProp: 'highlightedSeries',\n changeHandler: 'onHighlightChange',\n }\n );\n const [legendSeries, setLegendSeries] = useState<MixedLineBarChartProps.ChartSeries<T> | null>(highlightedSeries);\n useEffect(() => {\n setLegendSeries(controlledHighlightedSeries || null);\n }, [controlledHighlightedSeries]);\n\n const [externalVisibleSeries, setExternalVisibleSeries] = useControllable(\n controlledVisibleSeries,\n onFilterChange,\n externalSeries,\n {\n componentName: 'MixedLineBarChart',\n controlledProp: 'visibleSeries',\n changeHandler: 'onFilterChange',\n }\n );\n\n if (isDevelopment) {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const previousSeries = usePrevious(externalSeries);\n\n const hasPrevious = !!(previousSeries && previousSeries.length);\n const hasCurrent = !!externalSeries.length;\n\n if (hasPrevious && hasCurrent && externalSeries !== previousSeries && !controlledVisibleSeries && !hideFilter) {\n warnOnce(\n 'MixedLineBarChart',\n 'The `series` value passed into the component changed. ' +\n 'This may cause problems with filtering - we recommend that you make the `series` value constant, ' +\n 'or provide a `visibleSeries` value that derives from the current `series` value.'\n );\n }\n }\n\n const visibleSeries = useMemo(\n () => series.filter(s => externalVisibleSeries?.indexOf(s.series) !== -1),\n [series, externalVisibleSeries]\n );\n\n const filterChange = (selectedSeries: ReadonlyArray<MixedLineBarChartProps.ChartSeries<T>>) => {\n setExternalVisibleSeries(selectedSeries);\n fireNonCancelableEvent(onFilterChange, {\n visibleSeries: selectedSeries,\n });\n };\n\n const onHighlightChange = (series: MixedLineBarChartProps.ChartSeries<T> | null) => {\n setHighlightedSeries(series);\n fireNonCancelableEvent(controlledOnHighlightChange, {\n highlightedSeries: series,\n });\n setLegendSeries(series);\n };\n\n const onBlur = (event: React.FocusEvent) => {\n if (event.relatedTarget && !nodeContains(containerRef.current, event.relatedTarget)) {\n highlightedSeries && onHighlightChange(highlightedSeries);\n setHighlightedPoint(null);\n setHighlightedGroupIndex(null);\n setLegendSeries(null);\n }\n };\n\n const { isEmpty, isNoMatch, showChart } = getChartStatus({\n externalData: externalSeries,\n visibleData: visibleSeries || [],\n statusType,\n });\n const showFilters = statusType === 'finished' && (!isEmpty || isNoMatch);\n const showLegend = !hideLegend && !isEmpty && statusType === 'finished';\n const reserveLegendSpace = !showChart && !hideLegend;\n const reserveFilterSpace = !showChart && !isNoMatch && (!hideFilter || additionalFilters);\n const mergedRef = useMergeRefs(containerRef, __internalRootRef);\n\n return (\n <div {...baseProps} className={clsx(baseProps.className, styles.root)} ref={mergedRef} onBlur={onBlur}>\n {showFilters && (\n <InternalBox className={cartesianStyles['filter-container']} margin={{ bottom: 'l' }}>\n <InternalChartFilters\n series={series}\n visibleSeries={externalVisibleSeries || []}\n onChange={filterChange}\n i18nStrings={i18nStrings}\n hideFilter={hideFilter}\n additionalFilters={additionalFilters}\n />\n </InternalBox>\n )}\n\n <div\n className={clsx(styles.content, {\n [styles['content--reserve-filter']]: reserveFilterSpace,\n [styles['content--reserve-legend']]: reserveLegendSpace,\n })}\n style={{ minHeight: height }}\n >\n <ChartStatusContainer\n isEmpty={isEmpty}\n isNoMatch={isNoMatch}\n showChart={showChart}\n statusType={statusType}\n empty={empty}\n noMatch={noMatch}\n loadingText={loadingText}\n errorText={errorText}\n recoveryText={recoveryText}\n onRecoveryClick={onRecoveryClick}\n />\n {showChart && (\n <ChartContainer\n height={height}\n xScaleType={xScaleType}\n yScaleType={yScaleType}\n xDomain={xDomain}\n yDomain={yDomain}\n xTickFormatter={i18nStrings?.xTickFormatter}\n yTickFormatter={i18nStrings?.yTickFormatter}\n emphasizeBaselineAxis={emphasizeBaselineAxis}\n stackedBars={stackedBars}\n horizontalBars={horizontalBars}\n series={series}\n visibleSeries={visibleSeries}\n highlightedSeries={highlightedSeries}\n onHighlightChange={onHighlightChange}\n highlightedPoint={highlightedPoint}\n setHighlightedPoint={setHighlightedPoint}\n highlightedGroupIndex={highlightedGroupIndex}\n setHighlightedGroupIndex={setHighlightedGroupIndex}\n legendSeries={legendSeries}\n detailPopoverSize={detailPopoverSize}\n xTitle={xTitle}\n yTitle={yTitle}\n ariaLabel={ariaLabel}\n ariaLabelledby={ariaLabelledby}\n ariaDescription={ariaDescription}\n i18nStrings={i18nStrings}\n plotContainerRef={containerRef}\n />\n )}\n </div>\n\n {showLegend && (\n <InternalBox margin={{ top: 'm' }}>\n <InternalChartLegend\n series={series}\n visibleSeries={externalVisibleSeries || []}\n highlightedSeries={legendSeries}\n onHighlightChange={onHighlightChange}\n legendTitle={legendTitle}\n ariaLabel={i18nStrings?.legendAriaLabel}\n plotContainerRef={containerRef}\n />\n </InternalBox>\n )}\n </div>\n );\n}\n"]}
@@ -2,11 +2,11 @@ import { ChartScale, NumericChartScale } from '../internal/components/cartesian-
2
2
  import { MixedLineBarChartProps } from './interfaces';
3
3
  export interface LineSeriesProps<T> {
4
4
  axis: 'x' | 'y';
5
- series: MixedLineBarChartProps.LineDataSeries<T> | MixedLineBarChartProps.ThresholdSeries;
5
+ series: MixedLineBarChartProps.LineDataSeries<T> | MixedLineBarChartProps.ThresholdSeries<T>;
6
6
  color: string;
7
7
  chartAreaClipPath: string;
8
8
  xScale: ChartScale;
9
9
  yScale: NumericChartScale;
10
10
  }
11
- export default function LineSeries<T>({ axis, series, color, xScale, yScale, chartAreaClipPath }: LineSeriesProps<T>): JSX.Element;
11
+ export default function LineSeries<T>({ axis, series, color, xScale, yScale, chartAreaClipPath }: LineSeriesProps<T>): JSX.Element | null;
12
12
  //# sourceMappingURL=line-series.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"line-series.d.ts","sourceRoot":"","sources":["../../../src/mixed-line-bar-chart/line-series.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAC9F,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAEtD,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,IAAI,EAAE,GAAG,GAAG,GAAG,CAAC;IAChB,MAAM,EAAE,sBAAsB,CAAC,cAAc,CAAC,CAAC,CAAC,GAAG,sBAAsB,CAAC,eAAe,CAAC;IAE1F,KAAK,EAAE,MAAM,CAAC;IACd,iBAAiB,EAAE,MAAM,CAAC;IAE1B,MAAM,EAAE,UAAU,CAAC;IACnB,MAAM,EAAE,iBAAiB,CAAC;CAC3B;AAED,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAE,EAAE,eAAe,CAAC,CAAC,CAAC,eAoCnH"}
1
+ {"version":3,"file":"line-series.d.ts","sourceRoot":"","sources":["../../../src/mixed-line-bar-chart/line-series.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAC9F,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAGtD,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,IAAI,EAAE,GAAG,GAAG,GAAG,CAAC;IAChB,MAAM,EAAE,sBAAsB,CAAC,cAAc,CAAC,CAAC,CAAC,GAAG,sBAAsB,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IAE7F,KAAK,EAAE,MAAM,CAAC;IACd,iBAAiB,EAAE,MAAM,CAAC;IAE1B,MAAM,EAAE,UAAU,CAAC;IACnB,MAAM,EAAE,iBAAiB,CAAC;CAC3B;AAED,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAE,EAAE,eAAe,CAAC,CAAC,CAAC,sBA8CnH"}
@@ -3,14 +3,12 @@ import { __assign } from "tslib";
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
  import React from 'react';
5
5
  import { line } from 'd3-shape';
6
+ import { isXThreshold, isYThreshold } from './utils';
6
7
  export default function LineSeries(_a) {
8
+ var _b;
7
9
  var axis = _a.axis, series = _a.series, color = _a.color, xScale = _a.xScale, yScale = _a.yScale, chartAreaClipPath = _a.chartAreaClipPath;
8
- var commonProps = {
9
- 'aria-hidden': true,
10
- stroke: color,
11
- clipPath: "url(#".concat(chartAreaClipPath, ")")
12
- };
13
- // Ignore axis for line series as we only support horizontally-oriented lines.
10
+ var commonProps = { 'aria-hidden': true, stroke: color, clipPath: "url(#".concat(chartAreaClipPath, ")") };
11
+ // Render data path. The chart orientation is ignored as only horizontally-oriented lines are supported.
14
12
  if (series.type === 'line') {
15
13
  var lineGenerator = line()
16
14
  .x(function (d) {
@@ -29,11 +27,25 @@ export default function LineSeries(_a) {
29
27
  });
30
28
  return (React.createElement("path", __assign({}, commonProps, { d: lineGenerator(visibleData) || '' })));
31
29
  }
32
- else {
33
- var range = xScale.d3Scale.range();
30
+ // Render a horizontal line (vertical if chart orientation is inverted).
31
+ else if (isYThreshold(series)) {
32
+ var _c = xScale.d3Scale.range(), x1 = _c[0], x2 = _c[1];
34
33
  var y = yScale.d3Scale(series.y);
35
- var coordinates = axis === 'x' ? { x1: range[0], x2: range[1], y1: y, y2: y } : { x1: y, x2: y, y1: range[0], y2: range[1] };
34
+ var coordinates = axis === 'x' ? { x1: x1, x2: x2, y1: y, y2: y } : { x1: y, x2: y, y1: x1, y2: x2 };
35
+ return React.createElement("line", __assign({}, commonProps, coordinates));
36
+ }
37
+ // Render a vertical line (horizontal if chart orientation is inverted).
38
+ // The offset is necessary for categorical scale to render the line in the middle of the category bar.
39
+ else if (isXThreshold(series)) {
40
+ var _d = yScale.d3Scale.range(), y1 = _d[0], y2 = _d[1];
41
+ var xOffset = xScale.isCategorical() ? Math.max(0, xScale.d3Scale.bandwidth() - 1) / 2 : 0;
42
+ var x = ((_b = xScale.d3Scale(series.x)) !== null && _b !== void 0 ? _b : NaN) + xOffset;
43
+ var coordinates = axis === 'x' ? { x1: x, x2: x, y1: y1, y2: y2 } : { x1: y1, x2: y2, y1: x, y2: x };
36
44
  return React.createElement("line", __assign({}, commonProps, coordinates));
37
45
  }
46
+ // Bar series are handled separately.
47
+ else {
48
+ return null;
49
+ }
38
50
  }
39
51
  //# sourceMappingURL=line-series.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"line-series.js","sourceRoot":"","sources":["../../../src/mixed-line-bar-chart/line-series.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,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WAAgE,CAAC,IAAI,EAAE,IACxF,CACH,CAAC;KACH;SAAM;QACL,IAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACrC,IAAM,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACnC,IAAM,WAAW,GACf,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7G,OAAO,yCAAU,WAAW,EAAM,WAAW,EAAI,CAAC;KACnD;AACH,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\n\nimport { line } from 'd3-shape';\n\nimport { ChartScale, NumericChartScale } from '../internal/components/cartesian-chart/scales';\nimport { MixedLineBarChartProps } from './interfaces';\n\nexport interface LineSeriesProps<T> {\n axis: 'x' | 'y';\n series: MixedLineBarChartProps.LineDataSeries<T> | MixedLineBarChartProps.ThresholdSeries;\n\n color: string;\n chartAreaClipPath: string;\n\n xScale: ChartScale;\n yScale: NumericChartScale;\n}\n\nexport default function LineSeries<T>({ axis, series, color, xScale, yScale, chartAreaClipPath }: LineSeriesProps<T>) {\n const commonProps = {\n 'aria-hidden': true,\n stroke: color,\n clipPath: `url(#${chartAreaClipPath})`,\n };\n\n // Ignore axis for line series as we only support horizontally-oriented lines.\n if (series.type === 'line') {\n const lineGenerator = line<MixedLineBarChartProps.Datum<T>>()\n .x((d: MixedLineBarChartProps.Datum<T>) => {\n let x = xScale.d3Scale(d.x as any) || 0;\n if (xScale.isCategorical()) {\n const offset = Math.max(0, xScale.d3Scale.bandwidth() - 1) / 2;\n x += offset;\n }\n return x;\n })\n .y((d: MixedLineBarChartProps.Datum<T>) => yScale.d3Scale(d.y) || 0);\n\n // Filter out any data that is not part of the xScale\n const visibleData = series.data.filter(({ x }) => xScale.d3Scale(x as any) !== undefined);\n\n return (\n <path\n {...commonProps}\n d={lineGenerator(visibleData as unknown as Array<MixedLineBarChartProps.Datum<T>>) || ''}\n />\n );\n } else {\n const range = xScale.d3Scale.range();\n const y = yScale.d3Scale(series.y);\n const coordinates =\n axis === 'x' ? { x1: range[0], x2: range[1], y1: y, y2: y } : { x1: y, x2: y, y1: range[0], y2: range[1] };\n return <line {...commonProps} {...coordinates} />;\n }\n}\n"]}
1
+ {"version":3,"file":"line-series.js","sourceRoot":"","sources":["../../../src/mixed-line-bar-chart/line-series.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAIhC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAarD,MAAM,CAAC,OAAO,UAAU,UAAU,CAAI,EAA8E;;QAA5E,IAAI,UAAA,EAAE,MAAM,YAAA,EAAE,KAAK,WAAA,EAAE,MAAM,YAAA,EAAE,MAAM,YAAA,EAAE,iBAAiB,uBAAA;IAC5F,IAAM,WAAW,GAAG,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,eAAQ,iBAAiB,MAAG,EAAE,CAAC;IAEnG,wGAAwG;IACxG,IAAI,MAAM,CAAC,IAAI,KAAK,MAAM,EAAE;QAC1B,IAAM,aAAa,GAAG,IAAI,EAAmC;aAC1D,CAAC,CAAC,UAAC,CAAkC;YACpC,IAAI,CAAC,GAAG,MAAM,CAAC,OAAO,CA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,CAAC;QAC/F,OAAO,yCAAU,WAAW,EAAM,WAAW,EAAI,CAAC;KACnD;IACD,wEAAwE;IACxE,sGAAsG;SACjG,IAAI,YAAY,CAAC,MAAM,CAAC,EAAE;QACvB,IAAA,KAAW,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,EAAhC,EAAE,QAAA,EAAE,EAAE,QAA0B,CAAC;QACxC,IAAM,OAAO,GAAG,MAAM,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC7F,IAAM,CAAC,GAAG,CAAC,MAAA,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAQ,CAAC,mCAAI,GAAG,CAAC,GAAG,OAAO,CAAC;QAC7D,IAAM,WAAW,GAAG,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,IAAA,EAAE,EAAE,IAAA,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC;QAC/F,OAAO,yCAAU,WAAW,EAAM,WAAW,EAAI,CAAC;KACnD;IACD,qCAAqC;SAChC;QACH,OAAO,IAAI,CAAC;KACb;AACH,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\n\nimport { line } from 'd3-shape';\n\nimport { ChartScale, NumericChartScale } from '../internal/components/cartesian-chart/scales';\nimport { MixedLineBarChartProps } from './interfaces';\nimport { isXThreshold, isYThreshold } from './utils';\n\nexport interface LineSeriesProps<T> {\n axis: 'x' | 'y';\n series: MixedLineBarChartProps.LineDataSeries<T> | MixedLineBarChartProps.ThresholdSeries<T>;\n\n color: string;\n chartAreaClipPath: string;\n\n xScale: ChartScale;\n yScale: NumericChartScale;\n}\n\nexport default function LineSeries<T>({ axis, series, color, xScale, yScale, chartAreaClipPath }: LineSeriesProps<T>) {\n const commonProps = { 'aria-hidden': true, stroke: color, clipPath: `url(#${chartAreaClipPath})` };\n\n // Render data path. The chart orientation is ignored as only horizontally-oriented lines are supported.\n if (series.type === 'line') {\n const lineGenerator = line<MixedLineBarChartProps.Datum<T>>()\n .x((d: MixedLineBarChartProps.Datum<T>) => {\n let x = xScale.d3Scale(d.x as any) || 0;\n if (xScale.isCategorical()) {\n const offset = Math.max(0, xScale.d3Scale.bandwidth() - 1) / 2;\n x += offset;\n }\n return x;\n })\n .y((d: MixedLineBarChartProps.Datum<T>) => yScale.d3Scale(d.y) || 0);\n\n // Filter out any data that is not part of the xScale\n const visibleData = series.data.filter(({ x }) => xScale.d3Scale(x as any) !== undefined);\n\n return (\n <path\n {...commonProps}\n d={lineGenerator(visibleData as unknown as Array<MixedLineBarChartProps.Datum<T>>) || ''}\n />\n );\n }\n // Render a horizontal line (vertical if chart orientation is inverted).\n else if (isYThreshold(series)) {\n const [x1, x2] = xScale.d3Scale.range();\n const y = yScale.d3Scale(series.y);\n const coordinates = axis === 'x' ? { x1, x2, y1: y, y2: y } : { x1: y, x2: y, y1: x1, y2: x2 };\n return <line {...commonProps} {...coordinates} />;\n }\n // Render a vertical line (horizontal if chart orientation is inverted).\n // The offset is necessary for categorical scale to render the line in the middle of the category bar.\n else if (isXThreshold(series)) {\n const [y1, y2] = yScale.d3Scale.range();\n const xOffset = xScale.isCategorical() ? Math.max(0, xScale.d3Scale.bandwidth() - 1) / 2 : 0;\n const x = (xScale.d3Scale(series.x as any) ?? NaN) + xOffset;\n const coordinates = axis === 'x' ? { x1: x, x2: x, y1, y2 } : { x1: y1, x2: y2, y1: x, y2: x };\n return <line {...commonProps} {...coordinates} />;\n }\n // Bar series are handled separately.\n else {\n return null;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"make-scaled-bar-groups.d.ts","sourceRoot":"","sources":["../../../src/mixed-line-bar-chart/make-scaled-bar-groups.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAA0B,MAAM,cAAc,CAAC;AAC3F,OAAO,EAAE,UAAU,EAAE,MAAM,+CAA+C,CAAC;AAG3E,MAAM,WAAW,cAAc,CAAC,CAAC;IAC/B,CAAC,EAAE,CAAC,CAAC;IACL,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE;QACR,CAAC,EAAE,MAAM,CAAC;QACV,CAAC,EAAE,MAAM,CAAC;QACV,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,CAAC,SAAS,cAAc,EAClE,MAAM,EAAE,aAAa,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,EAC7C,MAAM,EAAE,UAAU,EAClB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,GAAG,GAAG,GAAG,GACd,cAAc,CAAC,CAAC,CAAC,EAAE,CAmCrB"}
1
+ {"version":3,"file":"make-scaled-bar-groups.d.ts","sourceRoot":"","sources":["../../../src/mixed-line-bar-chart/make-scaled-bar-groups.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAA0B,MAAM,cAAc,CAAC;AAC3F,OAAO,EAAE,UAAU,EAAE,MAAM,+CAA+C,CAAC;AAG3E,MAAM,WAAW,cAAc,CAAC,CAAC;IAC/B,CAAC,EAAE,CAAC,CAAC;IACL,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE;QACR,CAAC,EAAE,MAAM,CAAC;QACV,CAAC,EAAE,MAAM,CAAC;QACV,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,CAAC,SAAS,cAAc,EAClE,MAAM,EAAE,aAAa,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,EAC7C,MAAM,EAAE,UAAU,EAClB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,GAAG,GAAG,GAAG,GACd,cAAc,CAAC,CAAC,CAAC,EAAE,CA0CrB"}
@@ -1,4 +1,4 @@
1
- import { matchesX } from './utils';
1
+ import { isDataSeries, isXThreshold, isYThreshold, matchesX } from './utils';
2
2
  /**
3
3
  * Creates a list of all bar (and mixed) groups in the series with their scaled positions.
4
4
  */
@@ -14,11 +14,18 @@ export default function makeScaledBarGroups(series, xScale, plotWidth, plotHeigh
14
14
  isValid: isValid,
15
15
  hasData: series.some(function (_a) {
16
16
  var series = _a.series;
17
- if (series.type === 'threshold') {
18
- // If there is a threshold series, every valid group will have a data point
17
+ // If there is a threshold series, every valid group will have a data point.
18
+ if (isYThreshold(series)) {
19
19
  return true;
20
20
  }
21
- return series.data.some(function (datum) { return matchesX(datum.x, x); });
21
+ // X-thresholds do not have associated value.
22
+ if (isXThreshold(series)) {
23
+ return false;
24
+ }
25
+ if (isDataSeries(series)) {
26
+ return series.data.some(function (datum) { return matchesX(datum.x, x); });
27
+ }
28
+ return false;
22
29
  }),
23
30
  position: axis === 'x'
24
31
  ? {
@@ -1 +1 @@
1
- {"version":3,"file":"make-scaled-bar-groups.js","sourceRoot":"","sources":["../../../src/mixed-line-bar-chart/make-scaled-bar-groups.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAcnC;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,mBAAmB,CACzC,MAA6C,EAC7C,MAAkB,EAClB,SAAi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Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ChartDataTypes, InternalChartSeries, MixedLineBarChartProps } from './interfaces';\nimport { ChartScale } from '../internal/components/cartesian-chart/scales';\nimport { matchesX } from './utils';\n\nexport interface ScaledBarGroup<T> {\n x: T;\n hasData: boolean;\n isValid: boolean;\n position: {\n x: number;\n y: number;\n width: number;\n height: number;\n };\n}\n\n/**\n * Creates a list of all bar (and mixed) groups in the series with their scaled positions.\n */\nexport default function makeScaledBarGroups<T extends ChartDataTypes>(\n series: ReadonlyArray<InternalChartSeries<T>>,\n xScale: ChartScale,\n plotWidth: number,\n plotHeight: number,\n axis: 'x' | 'y'\n): ScaledBarGroup<T>[] {\n if (!xScale.isCategorical()) {\n return [];\n }\n\n return (xScale.domain as ReadonlyArray<T>).map(x => {\n const scaledX = xScale.d3Scale(x);\n const isValid = typeof scaledX !== 'undefined' && isFinite(scaledX);\n\n return {\n x,\n isValid,\n hasData: series.some(({ series }) => {\n if (series.type === 'threshold') {\n // If there is a threshold series, every valid group will have a data point\n return true;\n }\n return (series.data as ReadonlyArray<MixedLineBarChartProps.Datum<T>>).some(datum => matchesX(datum.x, x));\n }),\n position:\n axis === 'x'\n ? {\n x: 0,\n y: isValid ? scaledX || 0 : 0,\n width: plotWidth,\n height: xScale.d3Scale.bandwidth(),\n }\n : {\n x: isValid ? scaledX || 0 : 0,\n y: 0,\n width: xScale.d3Scale.bandwidth(),\n height: plotHeight,\n },\n };\n });\n}\n"]}
1
+ {"version":3,"file":"make-scaled-bar-groups.js","sourceRoot":"","sources":["../../../src/mixed-line-bar-chart/make-scaled-bar-groups.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAc7E;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,mBAAmB,CACzC,MAA6C,EAC7C,MAAkB,EAClB,SAAiB,EACjB,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AC;oBACJ,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,SAAS,EAAE;oBACjC,MAAM,EAAE,UAAU;iBACnB;SACR,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ChartDataTypes, InternalChartSeries, MixedLineBarChartProps } from './interfaces';\nimport { ChartScale } from '../internal/components/cartesian-chart/scales';\nimport { isDataSeries, isXThreshold, isYThreshold, matchesX } from './utils';\n\nexport interface ScaledBarGroup<T> {\n x: T;\n hasData: boolean;\n isValid: boolean;\n position: {\n x: number;\n y: number;\n width: number;\n height: number;\n };\n}\n\n/**\n * Creates a list of all bar (and mixed) groups in the series with their scaled positions.\n */\nexport default function makeScaledBarGroups<T extends ChartDataTypes>(\n series: ReadonlyArray<InternalChartSeries<T>>,\n xScale: ChartScale,\n plotWidth: number,\n plotHeight: number,\n axis: 'x' | 'y'\n): ScaledBarGroup<T>[] {\n if (!xScale.isCategorical()) {\n return [];\n }\n\n return (xScale.domain as ReadonlyArray<T>).map(x => {\n const scaledX = xScale.d3Scale(x);\n const isValid = typeof scaledX !== 'undefined' && isFinite(scaledX);\n\n return {\n x,\n isValid,\n hasData: series.some(({ series }) => {\n // If there is a threshold series, every valid group will have a data point.\n if (isYThreshold(series)) {\n return true;\n }\n // X-thresholds do not have associated value.\n if (isXThreshold(series)) {\n return false;\n }\n if (isDataSeries(series)) {\n return (series.data as ReadonlyArray<MixedLineBarChartProps.Datum<T>>).some(datum => matchesX(datum.x, x));\n }\n return false;\n }),\n position:\n axis === 'x'\n ? {\n x: 0,\n y: isValid ? scaledX || 0 : 0,\n width: plotWidth,\n height: xScale.d3Scale.bandwidth(),\n }\n : {\n x: isValid ? scaledX || 0 : 0,\n y: 0,\n width: xScale.d3Scale.bandwidth(),\n height: plotHeight,\n },\n };\n });\n}\n"]}
@@ -7,8 +7,6 @@ export interface ScaledPoint<T> {
7
7
  datum?: MixedLineBarChartProps.Datum<T> | undefined;
8
8
  series: MixedLineBarChartProps.ChartSeries<T>;
9
9
  }
10
- /**
11
- * Combine all line series into an array of scaled data points with the given scales.
12
- */
13
- export default function makeScaledSeries<T extends ChartDataTypes>(series: ReadonlyArray<InternalChartSeries<T>>, xScale: ChartScale, yScale: NumericChartScale): readonly ScaledPoint<T>[];
10
+ /** Combine all line series into an array of scaled data points with the given scales. */
11
+ export default function makeScaledSeries<T extends ChartDataTypes>(allSeries: ReadonlyArray<InternalChartSeries<T>>, xScale: ChartScale, yScale: NumericChartScale): readonly ScaledPoint<T>[];
14
12
  //# sourceMappingURL=make-scaled-series.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"make-scaled-series.d.ts","sourceRoot":"","sources":["../../../src/mixed-line-bar-chart/make-scaled-series.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAC3F,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAE9F,MAAM,WAAW,WAAW,CAAC,CAAC;IAC5B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,sBAAsB,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;IACpD,MAAM,EAAE,sBAAsB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;CAC/C;AAED;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,CAAC,SAAS,cAAc,EAC/D,MAAM,EAAE,aAAa,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,EAC7C,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,iBAAiB,GACxB,SAAS,WAAW,CAAC,CAAC,CAAC,EAAE,CAuB3B"}
1
+ {"version":3,"file":"make-scaled-series.d.ts","sourceRoot":"","sources":["../../../src/mixed-line-bar-chart/make-scaled-series.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAC3F,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAG9F,MAAM,WAAW,WAAW,CAAC,CAAC;IAC5B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,sBAAsB,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;IACpD,MAAM,EAAE,sBAAsB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;CAC/C;AAED,yFAAyF;AACzF,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,CAAC,SAAS,cAAc,EAC/D,SAAS,EAAE,aAAa,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,EAChD,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,iBAAiB,GACxB,SAAS,WAAW,CAAC,CAAC,CAAC,EAAE,CA6E3B"}
@@ -1,48 +1,112 @@
1
- /**
2
- * Combine all line series into an array of scaled data points with the given scales.
3
- */
4
- export default function makeScaledSeries(series, xScale, yScale) {
1
+ import { isXThreshold, isYThreshold } from './utils';
2
+ /** Combine all line series into an array of scaled data points with the given scales. */
3
+ export default function makeScaledSeries(allSeries, xScale, yScale) {
5
4
  var xOffset = xScale.isCategorical() ? Math.max(0, xScale.d3Scale.bandwidth() - 1) / 2 : 0;
6
5
  var scaleX = function (x) { return (xScale.d3Scale(x) || 0) + xOffset; };
7
6
  var scaleY = function (y) { return yScale.d3Scale(y) || 0; };
8
- var allScaledX = getAllScaledX(series, scaleX);
9
- // Support threshold-only setup.
10
- if (allScaledX.length === 0) {
11
- allScaledX.push(NaN);
7
+ var allX = getAllX(allSeries);
8
+ function mergeLineSeriesPointsWithXThresholds(scaledPoints, xThresholdSeries, xThresholdSeriesColor) {
9
+ var _a, _b;
10
+ var x = scaleX(xThresholdSeries.x);
11
+ // Locate a point the x-threshold can be inserted after (if such exists).
12
+ var bisectIndex = -1;
13
+ for (var i = 0; i < scaledPoints.length - 1; i++) {
14
+ if (scaledPoints[i].x < x && x < scaledPoints[i + 1].x) {
15
+ bisectIndex = i;
16
+ break;
17
+ }
18
+ }
19
+ // Insert x-threshold point into the given series using extrapolated Y value.
20
+ // The extrapolated value is only used to render highlighted point on the chart plot.
21
+ if (bisectIndex !== -1) {
22
+ var prevY = ((_a = scaledPoints[bisectIndex].datum) === null || _a === void 0 ? void 0 : _a.y) || 0;
23
+ var nextY = ((_b = scaledPoints[bisectIndex + 1].datum) === null || _b === void 0 ? void 0 : _b.y) || 0;
24
+ var averageY = (prevY + nextY) / 2;
25
+ scaledPoints.push({
26
+ x: x,
27
+ y: scaleY(averageY),
28
+ datum: { x: xThresholdSeries.x, y: NaN },
29
+ series: scaledPoints[bisectIndex].series,
30
+ color: xThresholdSeriesColor
31
+ });
32
+ }
12
33
  }
13
- return series.reduce(function (acc, _a) {
34
+ var scaledSeriesX = allSeries.map(function (_a) {
14
35
  var series = _a.series, color = _a.color;
36
+ var scaledPoints = [];
37
+ // Scale and add all line series data points.
15
38
  if (series.type === 'line') {
16
39
  for (var _i = 0, _b = series.data; _i < _b.length; _i++) {
17
40
  var datum = _b[_i];
18
- acc.push({ x: scaleX(datum.x), y: scaleY(datum.y), datum: datum, series: series, color: color });
41
+ scaledPoints.push({ x: scaleX(datum.x), y: scaleY(datum.y), datum: datum, series: series, color: color });
42
+ }
43
+ // Sort scaled points to ensure correct x-thresholds insertion.
44
+ scaledPoints.sort(function (s1, s2) { return s1.x - s2.x; });
45
+ // Merge x-thresholds into series if they don't have a shared coordinate.
46
+ for (var _c = 0, allSeries_1 = allSeries; _c < allSeries_1.length; _c++) {
47
+ var otherSeries = allSeries_1[_c];
48
+ if (isXThreshold(otherSeries.series)) {
49
+ mergeLineSeriesPointsWithXThresholds(scaledPoints, otherSeries.series, otherSeries.color);
50
+ }
19
51
  }
20
52
  }
21
- else if (series.type === 'threshold') {
22
- for (var _c = 0, allScaledX_1 = allScaledX; _c < allScaledX_1.length; _c++) {
23
- var x = allScaledX_1[_c];
24
- acc.push({ x: x, y: scaleY(series.y), series: series, color: color });
53
+ // Y-thresholds only have Y. To make thresholds navigable they are mapped to all defined X values.
54
+ else if (isYThreshold(series)) {
55
+ for (var _d = 0, allX_1 = allX; _d < allX_1.length; _d++) {
56
+ var x = allX_1[_d];
57
+ scaledPoints.push({ x: scaleX(x), y: scaleY(series.y), datum: { x: x, y: series.y }, series: series, color: color });
58
+ }
59
+ // Support threshold-only setup.
60
+ if (allX.length === 0) {
61
+ scaledPoints.push({ x: NaN, y: scaleY(series.y), series: series, color: color });
25
62
  }
26
63
  }
27
- return acc;
28
- }, []);
64
+ // X-thresholds only have X. The y value is taken as NaN which means there is no associated point - only vertical marker.
65
+ else if (isXThreshold(series)) {
66
+ scaledPoints.push({ x: scaleX(series.x), y: NaN, datum: { x: series.x, y: NaN }, series: series, color: color });
67
+ }
68
+ // Bar series are handled separately.
69
+ return scaledPoints;
70
+ });
71
+ // Sort scaled points by x to ensure their order matches visual order in the chart to support navigation.
72
+ return flatten(scaledSeriesX).sort(function (s1, s2) { return s1.x - s2.x; });
29
73
  }
30
- /**
31
- * Collect unique x values from all data series.
32
- */
33
- function getAllScaledX(series, scaleX) {
74
+ /** Collect unique x values from all data series. */
75
+ function getAllX(series) {
34
76
  var addDataXSet = new Set();
35
77
  for (var _i = 0, series_1 = series; _i < series_1.length; _i++) {
36
78
  var s = series_1[_i].series;
37
- if (s.type !== 'threshold') {
38
- for (var _a = 0, _b = s.data; _a < _b.length; _a++) {
39
- var d = _b[_a];
40
- addDataXSet.add(scaleX(d.x));
41
- }
79
+ switch (s.type) {
80
+ // Add all X values from data series.
81
+ case 'bar':
82
+ case 'line':
83
+ for (var _a = 0, _b = s.data; _a < _b.length; _a++) {
84
+ var d = _b[_a];
85
+ addDataXSet.add(d.x);
86
+ }
87
+ break;
88
+ case 'threshold':
89
+ // X-thresholds have a single X value.
90
+ if (isXThreshold(s)) {
91
+ addDataXSet.add(s.x);
92
+ }
93
+ // Thresholds don't have X values.
94
+ break;
42
95
  }
43
96
  }
44
97
  var allDataX = [];
45
98
  addDataXSet.forEach(function (x) { return allDataX.push(x); });
46
99
  return allDataX;
47
100
  }
101
+ function flatten(arrays) {
102
+ var merged = [];
103
+ for (var _i = 0, arrays_1 = arrays; _i < arrays_1.length; _i++) {
104
+ var array = arrays_1[_i];
105
+ for (var _a = 0, array_1 = array; _a < array_1.length; _a++) {
106
+ var item = array_1[_a];
107
+ merged.push(item);
108
+ }
109
+ }
110
+ return merged;
111
+ }
48
112
  //# sourceMappingURL=make-scaled-series.js.map