@cloudscape-design/chart-components 1.0.89 → 1.0.90
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.
|
@@ -63,8 +63,8 @@ export class ChartExtraTooltip extends AsyncStore {
|
|
|
63
63
|
const pointRect = point ? getPointRect(point) : getGroupRect(group.slice(0, 1));
|
|
64
64
|
const groupRect = getGroupRect(group);
|
|
65
65
|
// The cursor is not shown when column series are present (a UX decision).
|
|
66
|
-
const
|
|
67
|
-
this.cursor.create(groupRect, point, group, !
|
|
66
|
+
const hideCursorLine = getChartSeries(this.context.chart()).some((s) => s.type === "column" || s.type === "heatmap");
|
|
67
|
+
this.cursor.create(groupRect, point, group, !hideCursorLine);
|
|
68
68
|
this.targetTrack.rect(this.context.chart().renderer, { ...pointRect, ...this.commonTrackAttrs });
|
|
69
69
|
this.groupTrack.rect(this.context.chart().renderer, { ...groupRect, ...this.commonTrackAttrs });
|
|
70
70
|
};
|
|
@@ -147,7 +147,8 @@ class HighlightCursorCartesian {
|
|
|
147
147
|
return (isPointVisible(point) &&
|
|
148
148
|
!isXThreshold(point.series) &&
|
|
149
149
|
point.series.type !== "column" &&
|
|
150
|
-
point.series.type !== "errorbar"
|
|
150
|
+
point.series.type !== "errorbar" &&
|
|
151
|
+
point.series.type !== "heatmap");
|
|
151
152
|
};
|
|
152
153
|
}
|
|
153
154
|
create(target, point, group, showLine) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chart-extra-tooltip.js","sourceRoot":"","sources":["../../../../src/core/chart-api/chart-extra-tooltip.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAEzE,OAAO,KAAK,MAAM,MAAM,6BAA6B,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,uDAAuD,CAAC;AACrF,OAAO,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sx from \"clsx\";\nimport type Highcharts from \"highcharts\";\n\nimport { getIsRtl } from \"@cloudscape-design/component-toolkit/internal\";\n\nimport * as Styles from \"../../internal/chart-styles\";\nimport { renderMarker } from \"../../internal/components/series-marker/render-marker\";\nimport AsyncStore from \"../../internal/utils/async-store\";\nimport { getChartSeries, isPointVisible } from \"../../internal/utils/highcharts\";\nimport { SVGRendererPool, SVGRendererSingle } from \"../../internal/utils/renderer-utils\";\nimport { DebouncedCall, isEqualArrays } from \"../../internal/utils/utils\";\nimport { Rect } from \"../interfaces\";\nimport { getGroupRect, getPointRect, getSeriesId, isXThreshold, safeRect } from \"../utils\";\nimport { ChartExtraContext } from \"./chart-extra-context\";\n\nimport testClasses from \"../test-classes/styles.css.js\";\n\nconst TOOLTIP_LAST_DISMISS_DELAY = 250;\n\n// The reactive state is used to propagate updates to the chart tooltip React component. The tooltip\n// content is to be derived from the target point and group.\nexport interface ReactiveTooltipState {\n visible: boolean;\n pinned: boolean;\n point: null | Highcharts.Point;\n group: readonly Highcharts.Point[];\n}\n\n// Chart helper that implements tooltip placement logic and cursors.\nexport class ChartExtraTooltip extends AsyncStore<ReactiveTooltipState> {\n private context: ChartExtraContext;\n\n // The tooltip lock is used to prevent tooltip position changes shortly after it was dismissed, to\n // deny its immediate re-appearance in the spot under where the dismiss button was.\n public tooltipLock = false;\n private tooltipLockCall = new DebouncedCall();\n private setTooltipLock = () => {\n if (this.get().pinned) {\n this.tooltipLock = true;\n this.tooltipLockCall.call(() => (this.tooltipLock = false), TOOLTIP_LAST_DISMISS_DELAY);\n }\n };\n\n // The cursor is a vertical or horizontal (in inverted charts) line and hollow or filled markers,\n // shown in cartesian charts on top of the matched group or point.\n private cursor = new HighlightCursorCartesian();\n // The track elements are invisible rectangles, compted for the given target point or group.\n // The target track is used for the \"target\" tooltip placement. The group track is used for\n // the \"middle\" and \"outside\" tooltip placement.\n private targetTrack = new SVGRendererSingle();\n private groupTrack = new SVGRendererSingle();\n\n // Cached coordinates to update cursor's position on re-render.\n private lastPoint: null | Highcharts.Point = null;\n private lastGroup: null | readonly Highcharts.Point[] = null;\n\n constructor(context: ChartExtraContext) {\n super({ visible: false, pinned: false, point: null, group: [] });\n this.context = context;\n }\n\n // The targetElement.element can get invalidated by Highcharts, so we cannot use\n // trackRef.current = targetElement.element as it might get invalidated unexpectedly.\n // The getTrack function ensures the latest element reference is given on each request.\n public getTargetTrack = () => (this.targetTrack.element?.element ?? null) as null | SVGElement;\n public getGroupTrack = () => {\n return (this.groupTrack.element?.element ?? null) as null | SVGElement;\n };\n\n public onChartRender() {\n if (this.lastGroup && this.get().visible) {\n this.updateTooltipCursor({ point: this.lastPoint, group: this.lastGroup });\n }\n }\n\n public onChartDestroy() {\n this.cursor.destroy();\n this.targetTrack.destroy();\n this.groupTrack.destroy();\n }\n\n public showTooltipOnPoint(point: Highcharts.Point, matchingGroup: readonly Highcharts.Point[], ignoreLock = false) {\n if (!this.tooltipLock || ignoreLock) {\n this.updateTooltipCursor({ point, group: matchingGroup });\n this.set(() => ({ visible: true, pinned: false, point, group: matchingGroup }));\n }\n }\n\n public showTooltipOnGroup(group: readonly Highcharts.Point[], ignoreLock = false) {\n if (!this.tooltipLock || ignoreLock) {\n this.updateTooltipCursor({ point: null, group });\n this.setGroupIfDifferent(group);\n }\n }\n\n public hideTooltip() {\n this.cursor.hide();\n this.targetTrack.hide();\n this.groupTrack.hide();\n this.setTooltipLock();\n this.set((prev) => ({ ...prev, visible: false, pinned: false }));\n }\n\n public pinTooltip() {\n if (this.context.settings.tooltipEnabled) {\n this.set((prev) => ({ ...prev, visible: true, pinned: true }));\n }\n }\n\n // Avoid re-rendering the tooltip on every cursor position change when hovering over the graph.\n // Just re-render when the groups are different.\n private setGroupIfDifferent(group: readonly Highcharts.Point[]) {\n function isGroupEqual(a: Highcharts.Point, b: Highcharts.Point) {\n return a?.x === b?.x && a?.y === b?.y && getSeriesId(a?.series) === getSeriesId(b?.series);\n }\n this.set((prev) => {\n return prev.point === null && isEqualArrays(prev.group, group, isGroupEqual)\n ? prev\n : { visible: true, pinned: false, point: null, group };\n });\n }\n\n private updateTooltipCursor = (props: { point: null | Highcharts.Point; group: readonly Highcharts.Point[] }) => {\n this.lastPoint = props.point;\n this.lastGroup = props.group;\n\n const chartType =\n getChartSeries(this.context.chart()).find((s) => s.type === \"pie\" || s.type === \"solidgauge\")?.type ??\n \"cartesian\";\n if (chartType === \"pie\") {\n return this.updateTooltipCursorPie(props.group[0]);\n } else if (chartType === \"solidgauge\") {\n return this.updateTooltipCursorGauge(props.group[0]);\n } else {\n return this.updateTooltipCursorCartesian(props);\n }\n };\n\n private updateTooltipCursorCartesian = ({\n point,\n group,\n }: {\n point: null | Highcharts.Point;\n group: readonly Highcharts.Point[];\n }) => {\n const pointRect = point ? getPointRect(point) : getGroupRect(group.slice(0, 1));\n const groupRect = getGroupRect(group);\n // The cursor is not shown when column series are present (a UX decision).\n const hasColumnSeries = getChartSeries(this.context.chart()).some((s) => s.type === \"column\");\n this.cursor.create(groupRect, point, group, !hasColumnSeries);\n this.targetTrack.rect(this.context.chart().renderer, { ...pointRect, ...this.commonTrackAttrs });\n this.groupTrack.rect(this.context.chart().renderer, { ...groupRect, ...this.commonTrackAttrs });\n };\n\n private updateTooltipCursorPie = (point: Highcharts.Point) => {\n // We only create target track for pie chart as pie chart does not support groups.\n // It is also expected that only \"target\" tooltip position is used for pie charts.\n const pointRect = getPieChartTargetPlacement(point);\n this.targetTrack.rect(this.context.chart().renderer, { ...pointRect, ...this.commonTrackAttrs });\n };\n\n private updateTooltipCursorGauge = (point: Highcharts.Point) => {\n // Solid gauge charts are similar to pie charts in that they have a circular shape\n // and don't support grouping. We use a similar approach to pie charts.\n const pointRect = getSolidGaugeTargetPlacement(point);\n this.targetTrack.rect(this.context.chart().renderer, { ...pointRect, ...this.commonTrackAttrs });\n };\n\n private get commonTrackAttrs() {\n return { fill: \"transparent\", zIndex: -1, \"pointer-events\": \"none\", direction: this.direction };\n }\n\n // We compute the direction from the chart container and then explicitly set it to the track\n // elements, as otherwise the direction check done for track elements always results to \"ltr\".\n private get direction() {\n const isRtl = getIsRtl(this.context.chart().container.parentElement);\n return isRtl ? \"rtl\" : \"ltr\";\n }\n}\n\n// A helper class to draw the cursor elements (include cursor line and matched points markers).\nclass HighlightCursorCartesian {\n private lineElement = new SVGRendererSingle();\n private markerElementsPool = new SVGRendererPool();\n\n public create(target: Rect, point: null | Highcharts.Point, group: readonly Highcharts.Point[], showLine: boolean) {\n this.hide();\n if (!group[0]?.series) {\n return;\n }\n\n const chart = group[0]?.series.chart;\n if (!chart) {\n return;\n }\n if (showLine) {\n // The cursor line is rendered orthogonally to the x axis (when the chart is inverted, the line is rendered horizontally).\n // The line is 1px thick, and is rendered through the center of the target's rect.\n const lineAttrs = chart.inverted\n ? {\n x: chart.plotLeft,\n y: chart.plotTop + target.y - target.height - 1,\n width: chart.plotWidth,\n height: 1,\n }\n : {\n x: target.x + target.width / 2,\n y: chart.plotTop,\n width: 1,\n height: chart.plotHeight,\n };\n this.lineElement.rect(chart.renderer, { ...Styles.cursorLine, ...lineAttrs });\n }\n for (const p of group.filter(this.isPointEligibleForMarker)) {\n if (p.plotX !== undefined && p.plotY !== undefined) {\n const selected = p === point;\n const className = clsx(testClasses[\"highlight-marker\"], selected && testClasses[\"highlight-marker-selected\"]);\n renderMarker({ chart, pool: this.markerElementsPool, point: p, selected, className });\n }\n }\n }\n\n public hide() {\n this.lineElement.hide();\n this.markerElementsPool.hideAll();\n }\n\n public destroy() {\n this.lineElement.destroy();\n this.markerElementsPool.destroyAll();\n }\n\n private isPointEligibleForMarker = (point: Highcharts.Point) => {\n return (\n isPointVisible(point) &&\n !isXThreshold(point.series) &&\n point.series.type !== \"column\" &&\n point.series.type !== \"errorbar\"\n );\n };\n}\n\nfunction getPieChartTargetPlacement(point: Highcharts.Point): Rect {\n // The pie series segments do not provide plotX, plotY to compute the tooltip placement.\n // Instead, there is a `tooltipPos` tuple, which is not covered by TS.\n // See: https://github.com/highcharts/highcharts/issues/23118.\n if (\"tooltipPos\" in point && Array.isArray(point.tooltipPos)) {\n return safeRect({ x: point.tooltipPos[0], y: point.tooltipPos[1], width: 0, height: 0 });\n }\n // We use the alternative, middle, tooltip placement as a fallback, in case the undocumented \"tooltipPos\"\n // is no longer available in the point.\n return getPieMiddlePlacement(point);\n}\n\nfunction getPieMiddlePlacement(point: Highcharts.Point): Rect {\n const chart = point.series.chart;\n const [relativeX, relativeY, relativeDiameter] = point.series.center;\n const plotLeft = chart.plotLeft;\n const plotTop = chart.plotTop;\n const centerX = plotLeft + (typeof relativeX === \"number\" ? relativeX : (relativeX / 100) * chart.plotWidth);\n const centerY = plotTop + (typeof relativeY === \"number\" ? relativeY : (relativeY / 100) * chart.plotHeight);\n const radius =\n (typeof relativeDiameter === \"number\" ? relativeDiameter : (relativeDiameter / 100) * chart.plotWidth) / 2;\n return { x: centerX, y: centerY - radius, width: 1, height: 2 * radius };\n}\n\nfunction getSolidGaugeTargetPlacement(point: Highcharts.Point): Rect {\n const chart = point.series.chart;\n return safeRect({\n x: chart.plotLeft + chart.plotWidth / 2,\n y: chart.plotTop + chart.plotHeight / 2,\n width: 0,\n height: 0,\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"chart-extra-tooltip.js","sourceRoot":"","sources":["../../../../src/core/chart-api/chart-extra-tooltip.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAEzE,OAAO,KAAK,MAAM,MAAM,6BAA6B,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,uDAAuD,CAAC;AACrF,OAAO,UAAU,MAAM,kCAAkC,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACzF,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,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;IAC9B,MAAM,OAAO,GAAG,QAAQ,GAAG,CAAC,OAAO,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,GAAG,GAAG,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC;IAC7G,MAAM,OAAO,GAAG,OAAO,GAAG,CAAC,OAAO,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,GAAG,GAAG,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC;IAC7G,MAAM,MAAM,GACV,CAAC,OAAO,gBAAgB,KAAK,QAAQ,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,gBAAgB,GAAG,GAAG,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IAC7G,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC;AAC3E,CAAC;AAED,SAAS,4BAA4B,CAAC,KAAuB;IAC3D,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC;IACjC,OAAO,QAAQ,CAAC;QACd,CAAC,EAAE,KAAK,CAAC,QAAQ,GAAG,KAAK,CAAC,SAAS,GAAG,CAAC;QACvC,CAAC,EAAE,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC,UAAU,GAAG,CAAC;QACvC,KAAK,EAAE,CAAC;QACR,MAAM,EAAE,CAAC;KACV,CAAC,CAAC;AACL,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport clsx from \"clsx\";\nimport type Highcharts from \"highcharts\";\n\nimport { getIsRtl } from \"@cloudscape-design/component-toolkit/internal\";\n\nimport * as Styles from \"../../internal/chart-styles\";\nimport { renderMarker } from \"../../internal/components/series-marker/render-marker\";\nimport AsyncStore from \"../../internal/utils/async-store\";\nimport { getChartSeries, isPointVisible } from \"../../internal/utils/highcharts\";\nimport { SVGRendererPool, SVGRendererSingle } from \"../../internal/utils/renderer-utils\";\nimport { DebouncedCall, isEqualArrays } from \"../../internal/utils/utils\";\nimport { Rect } from \"../interfaces\";\nimport { getGroupRect, getPointRect, getSeriesId, isXThreshold, safeRect } from \"../utils\";\nimport { ChartExtraContext } from \"./chart-extra-context\";\n\nimport testClasses from \"../test-classes/styles.css.js\";\n\nconst TOOLTIP_LAST_DISMISS_DELAY = 250;\n\n// The reactive state is used to propagate updates to the chart tooltip React component. The tooltip\n// content is to be derived from the target point and group.\nexport interface ReactiveTooltipState {\n visible: boolean;\n pinned: boolean;\n point: null | Highcharts.Point;\n group: readonly Highcharts.Point[];\n}\n\n// Chart helper that implements tooltip placement logic and cursors.\nexport class ChartExtraTooltip extends AsyncStore<ReactiveTooltipState> {\n private context: ChartExtraContext;\n\n // The tooltip lock is used to prevent tooltip position changes shortly after it was dismissed, to\n // deny its immediate re-appearance in the spot under where the dismiss button was.\n public tooltipLock = false;\n private tooltipLockCall = new DebouncedCall();\n private setTooltipLock = () => {\n if (this.get().pinned) {\n this.tooltipLock = true;\n this.tooltipLockCall.call(() => (this.tooltipLock = false), TOOLTIP_LAST_DISMISS_DELAY);\n }\n };\n\n // The cursor is a vertical or horizontal (in inverted charts) line and hollow or filled markers,\n // shown in cartesian charts on top of the matched group or point.\n private cursor = new HighlightCursorCartesian();\n // The track elements are invisible rectangles, compted for the given target point or group.\n // The target track is used for the \"target\" tooltip placement. The group track is used for\n // the \"middle\" and \"outside\" tooltip placement.\n private targetTrack = new SVGRendererSingle();\n private groupTrack = new SVGRendererSingle();\n\n // Cached coordinates to update cursor's position on re-render.\n private lastPoint: null | Highcharts.Point = null;\n private lastGroup: null | readonly Highcharts.Point[] = null;\n\n constructor(context: ChartExtraContext) {\n super({ visible: false, pinned: false, point: null, group: [] });\n this.context = context;\n }\n\n // The targetElement.element can get invalidated by Highcharts, so we cannot use\n // trackRef.current = targetElement.element as it might get invalidated unexpectedly.\n // The getTrack function ensures the latest element reference is given on each request.\n public getTargetTrack = () => (this.targetTrack.element?.element ?? null) as null | SVGElement;\n public getGroupTrack = () => {\n return (this.groupTrack.element?.element ?? null) as null | SVGElement;\n };\n\n public onChartRender() {\n if (this.lastGroup && this.get().visible) {\n this.updateTooltipCursor({ point: this.lastPoint, group: this.lastGroup });\n }\n }\n\n public onChartDestroy() {\n this.cursor.destroy();\n this.targetTrack.destroy();\n this.groupTrack.destroy();\n }\n\n public showTooltipOnPoint(point: Highcharts.Point, matchingGroup: readonly Highcharts.Point[], ignoreLock = false) {\n if (!this.tooltipLock || ignoreLock) {\n this.updateTooltipCursor({ point, group: matchingGroup });\n this.set(() => ({ visible: true, pinned: false, point, group: matchingGroup }));\n }\n }\n\n public showTooltipOnGroup(group: readonly Highcharts.Point[], ignoreLock = false) {\n if (!this.tooltipLock || ignoreLock) {\n this.updateTooltipCursor({ point: null, group });\n this.setGroupIfDifferent(group);\n }\n }\n\n public hideTooltip() {\n this.cursor.hide();\n this.targetTrack.hide();\n this.groupTrack.hide();\n this.setTooltipLock();\n this.set((prev) => ({ ...prev, visible: false, pinned: false }));\n }\n\n public pinTooltip() {\n if (this.context.settings.tooltipEnabled) {\n this.set((prev) => ({ ...prev, visible: true, pinned: true }));\n }\n }\n\n // Avoid re-rendering the tooltip on every cursor position change when hovering over the graph.\n // Just re-render when the groups are different.\n private setGroupIfDifferent(group: readonly Highcharts.Point[]) {\n function isGroupEqual(a: Highcharts.Point, b: Highcharts.Point) {\n return a?.x === b?.x && a?.y === b?.y && getSeriesId(a?.series) === getSeriesId(b?.series);\n }\n this.set((prev) => {\n return prev.point === null && isEqualArrays(prev.group, group, isGroupEqual)\n ? prev\n : { visible: true, pinned: false, point: null, group };\n });\n }\n\n private updateTooltipCursor = (props: { point: null | Highcharts.Point; group: readonly Highcharts.Point[] }) => {\n this.lastPoint = props.point;\n this.lastGroup = props.group;\n\n const chartType =\n getChartSeries(this.context.chart()).find((s) => s.type === \"pie\" || s.type === \"solidgauge\")?.type ??\n \"cartesian\";\n if (chartType === \"pie\") {\n return this.updateTooltipCursorPie(props.group[0]);\n } else if (chartType === \"solidgauge\") {\n return this.updateTooltipCursorGauge(props.group[0]);\n } else {\n return this.updateTooltipCursorCartesian(props);\n }\n };\n\n private updateTooltipCursorCartesian = ({\n point,\n group,\n }: {\n point: null | Highcharts.Point;\n group: readonly Highcharts.Point[];\n }) => {\n const pointRect = point ? getPointRect(point) : getGroupRect(group.slice(0, 1));\n const groupRect = getGroupRect(group);\n // The cursor is not shown when column series are present (a UX decision).\n const hideCursorLine = getChartSeries(this.context.chart()).some(\n (s) => s.type === \"column\" || s.type === \"heatmap\",\n );\n this.cursor.create(groupRect, point, group, !hideCursorLine);\n this.targetTrack.rect(this.context.chart().renderer, { ...pointRect, ...this.commonTrackAttrs });\n this.groupTrack.rect(this.context.chart().renderer, { ...groupRect, ...this.commonTrackAttrs });\n };\n\n private updateTooltipCursorPie = (point: Highcharts.Point) => {\n // We only create target track for pie chart as pie chart does not support groups.\n // It is also expected that only \"target\" tooltip position is used for pie charts.\n const pointRect = getPieChartTargetPlacement(point);\n this.targetTrack.rect(this.context.chart().renderer, { ...pointRect, ...this.commonTrackAttrs });\n };\n\n private updateTooltipCursorGauge = (point: Highcharts.Point) => {\n // Solid gauge charts are similar to pie charts in that they have a circular shape\n // and don't support grouping. We use a similar approach to pie charts.\n const pointRect = getSolidGaugeTargetPlacement(point);\n this.targetTrack.rect(this.context.chart().renderer, { ...pointRect, ...this.commonTrackAttrs });\n };\n\n private get commonTrackAttrs() {\n return { fill: \"transparent\", zIndex: -1, \"pointer-events\": \"none\", direction: this.direction };\n }\n\n // We compute the direction from the chart container and then explicitly set it to the track\n // elements, as otherwise the direction check done for track elements always results to \"ltr\".\n private get direction() {\n const isRtl = getIsRtl(this.context.chart().container.parentElement);\n return isRtl ? \"rtl\" : \"ltr\";\n }\n}\n\n// A helper class to draw the cursor elements (include cursor line and matched points markers).\nclass HighlightCursorCartesian {\n private lineElement = new SVGRendererSingle();\n private markerElementsPool = new SVGRendererPool();\n\n public create(target: Rect, point: null | Highcharts.Point, group: readonly Highcharts.Point[], showLine: boolean) {\n this.hide();\n if (!group[0]?.series) {\n return;\n }\n\n const chart = group[0]?.series.chart;\n if (!chart) {\n return;\n }\n if (showLine) {\n // The cursor line is rendered orthogonally to the x axis (when the chart is inverted, the line is rendered horizontally).\n // The line is 1px thick, and is rendered through the center of the target's rect.\n const lineAttrs = chart.inverted\n ? {\n x: chart.plotLeft,\n y: chart.plotTop + target.y - target.height - 1,\n width: chart.plotWidth,\n height: 1,\n }\n : {\n x: target.x + target.width / 2,\n y: chart.plotTop,\n width: 1,\n height: chart.plotHeight,\n };\n this.lineElement.rect(chart.renderer, { ...Styles.cursorLine, ...lineAttrs });\n }\n for (const p of group.filter(this.isPointEligibleForMarker)) {\n if (p.plotX !== undefined && p.plotY !== undefined) {\n const selected = p === point;\n const className = clsx(testClasses[\"highlight-marker\"], selected && testClasses[\"highlight-marker-selected\"]);\n renderMarker({ chart, pool: this.markerElementsPool, point: p, selected, className });\n }\n }\n }\n\n public hide() {\n this.lineElement.hide();\n this.markerElementsPool.hideAll();\n }\n\n public destroy() {\n this.lineElement.destroy();\n this.markerElementsPool.destroyAll();\n }\n\n private isPointEligibleForMarker = (point: Highcharts.Point) => {\n return (\n isPointVisible(point) &&\n !isXThreshold(point.series) &&\n point.series.type !== \"column\" &&\n point.series.type !== \"errorbar\" &&\n point.series.type !== \"heatmap\"\n );\n };\n}\n\nfunction getPieChartTargetPlacement(point: Highcharts.Point): Rect {\n // The pie series segments do not provide plotX, plotY to compute the tooltip placement.\n // Instead, there is a `tooltipPos` tuple, which is not covered by TS.\n // See: https://github.com/highcharts/highcharts/issues/23118.\n if (\"tooltipPos\" in point && Array.isArray(point.tooltipPos)) {\n return safeRect({ x: point.tooltipPos[0], y: point.tooltipPos[1], width: 0, height: 0 });\n }\n // We use the alternative, middle, tooltip placement as a fallback, in case the undocumented \"tooltipPos\"\n // is no longer available in the point.\n return getPieMiddlePlacement(point);\n}\n\nfunction getPieMiddlePlacement(point: Highcharts.Point): Rect {\n const chart = point.series.chart;\n const [relativeX, relativeY, relativeDiameter] = point.series.center;\n const plotLeft = chart.plotLeft;\n const plotTop = chart.plotTop;\n const centerX = plotLeft + (typeof relativeX === \"number\" ? relativeX : (relativeX / 100) * chart.plotWidth);\n const centerY = plotTop + (typeof relativeY === \"number\" ? relativeY : (relativeY / 100) * chart.plotHeight);\n const radius =\n (typeof relativeDiameter === \"number\" ? relativeDiameter : (relativeDiameter / 100) * chart.plotWidth) / 2;\n return { x: centerX, y: centerY - radius, width: 1, height: 2 * radius };\n}\n\nfunction getSolidGaugeTargetPlacement(point: Highcharts.Point): Rect {\n const chart = point.series.chart;\n return safeRect({\n x: chart.plotLeft + chart.plotWidth / 2,\n y: chart.plotTop + chart.plotHeight / 2,\n width: 0,\n height: 0,\n });\n}\n"]}
|
package/internal/environment.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export var PACKAGE_SOURCE = "chart-components";
|
|
2
|
-
export var PACKAGE_VERSION = "1.0.0 (
|
|
2
|
+
export var PACKAGE_VERSION = "1.0.0 (01c7ecfc)";
|
|
3
3
|
export var THEME = "open-source-visual-refresh";
|
|
4
4
|
export var ALWAYS_VISUAL_REFRESH = true;
|
|
5
5
|
export var SYSTEM = "core";
|
package/internal/manifest.json
CHANGED