diff --git a/.playground/playgroud.tsx b/.playground/playgroud.tsx index 18ee1971c5..a447cd6e88 100644 --- a/.playground/playgroud.tsx +++ b/.playground/playgroud.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { Chart, Settings, TooltipType, LineSeries } from '../src'; +import { Chart, Settings, TooltipType, BarSeries } from '../src'; import { KIBANA_METRICS } from '../src/utils/data_samples/test_dataset_kibana'; export class Playground extends React.Component { chartRef: React.RefObject = React.createRef(); @@ -34,11 +34,35 @@ export class Playground extends React.Component {
- + + + + + + +
diff --git a/src/chart_types/xy_chart/renderer/dom/highlighter.tsx b/src/chart_types/xy_chart/renderer/dom/highlighter.tsx index bff9fe9d1e..53743889b0 100644 --- a/src/chart_types/xy_chart/renderer/dom/highlighter.tsx +++ b/src/chart_types/xy_chart/renderer/dom/highlighter.tsx @@ -12,8 +12,9 @@ import { getChartRotationSelector } from '../../../../state/selectors/get_chart_ import { computeChartDimensionsSelector } from '../../state/selectors/compute_chart_dimensions'; interface HighlighterProps { - highlightedGeometries: IndexedGeometry[]; initialized: boolean; + chartId: string; + highlightedGeometries: IndexedGeometry[]; chartTransform: Transform; chartDimensions: Dimensions; chartRotation: Rotation; @@ -23,15 +24,16 @@ class HighlighterComponent extends React.Component { static displayName = 'Highlighter'; render() { - const { highlightedGeometries, chartTransform, chartDimensions, chartRotation } = this.props; + const { highlightedGeometries, chartTransform, chartDimensions, chartRotation, chartId } = this.props; const left = chartDimensions.left + chartTransform.x; const top = chartDimensions.top + chartTransform.y; const clipWidth = [90, -90].includes(chartRotation) ? chartDimensions.height : chartDimensions.width; const clipHeight = [90, -90].includes(chartRotation) ? chartDimensions.width : chartDimensions.height; + const clipPathId = `echHighlighterClipPath__${chartId}`; return ( - + @@ -59,7 +61,7 @@ class HighlighterComponent extends React.Component { width={geom.width} height={geom.height} className="echHighlighter__rect" - clipPath="url(#echHighlighterClipPath)" + clipPath={`url(${clipPathId})`} /> ); })} @@ -73,6 +75,7 @@ const mapStateToProps = (state: GlobalChartState): HighlighterProps => { if (!isInitialized(state)) { return { initialized: false, + chartId: state.chartId, highlightedGeometries: [], chartTransform: { x: 0, @@ -85,6 +88,7 @@ const mapStateToProps = (state: GlobalChartState): HighlighterProps => { } return { initialized: true, + chartId: state.chartId, highlightedGeometries: getHighlightedGeomsSelector(state), chartTransform: computeChartTransformSelector(state), chartDimensions: computeChartDimensionsSelector(state).chartDimensions,