diff --git a/.playground/playgroud.tsx b/.playground/playgroud.tsx
index bf77de95a6..4572220b38 100644
--- a/.playground/playgroud.tsx
+++ b/.playground/playgroud.tsx
@@ -59,7 +59,7 @@ function renderChart(
return (
-
+
{
@@ -552,8 +545,6 @@ export class ChartStore {
this.highlightedGeometries.clear();
this.tooltipData.clear();
- document.body.style.cursor = 'default';
-
if (this.onCursorUpdateListener && this.isActiveChart.get()) {
this.onCursorUpdateListener();
}
diff --git a/src/components/_container.scss b/src/components/_container.scss
index a1dd5b6068..214ee859c0 100644
--- a/src/components/_container.scss
+++ b/src/components/_container.scss
@@ -17,3 +17,22 @@
.echChart--isBrushEnabled {
cursor: crosshair;
}
+
+.echChartCursorContainer {
+ position: absolute;
+ top: 0;
+ bottom: 0;
+ right: 0;
+ left: 0;
+ box-sizing: border-box;
+}
+
+.echChartResizer {
+ z-index: -10000000;
+ position: absolute;
+ bottom: 0;
+ top: 0;
+ left: 0;
+ right: 0;
+ box-sizing: border-box;
+}
\ No newline at end of file
diff --git a/src/components/chart.tsx b/src/components/chart.tsx
index a2bafc6d6a..ac0b629486 100644
--- a/src/components/chart.tsx
+++ b/src/components/chart.tsx
@@ -10,7 +10,7 @@ import { Crosshair } from './crosshair';
import { Highlighter } from './highlighter';
import { Legend } from './legend/legend';
import { LegendButton } from './legend/legend_button';
-import { ReactiveChart as ReactChart } from './react_canvas/reactive_chart';
+import { ChartContainer } from './react_canvas/chart_container';
import { Tooltips } from './tooltips';
import { CursorEvent } from '../specs/settings';
import { ChartSize, getChartSize } from '../utils/chart_size';
@@ -75,8 +75,8 @@ export class Chart extends React.Component {
{// TODO reenable when SVG rendered is aligned with canvas one
- renderer === 'svg' && }
- {renderer === 'canvas' && }
+ renderer === 'svg' && }
+ {renderer === 'canvas' && }
diff --git a/src/components/chart_resizer.tsx b/src/components/chart_resizer.tsx
index 1a6ea13b82..10cd605997 100644
--- a/src/components/chart_resizer.tsx
+++ b/src/components/chart_resizer.tsx
@@ -35,20 +35,7 @@ class Resizer extends React.Component {
};
render() {
- return (
-
- );
+ return ;
}
private handleResize = (entries: ResizeObserverEntry[]) => {
diff --git a/src/components/react_canvas/chart_container.tsx b/src/components/react_canvas/chart_container.tsx
new file mode 100644
index 0000000000..0313139a73
--- /dev/null
+++ b/src/components/react_canvas/chart_container.tsx
@@ -0,0 +1,45 @@
+import React from 'react';
+import classNames from 'classnames';
+import { inject, observer } from 'mobx-react';
+import { ChartStore } from '../../chart_types/xy_chart/store/chart_state';
+import { ReactiveChart } from './reactive_chart';
+interface ReactiveChartProps {
+ chartStore?: ChartStore; // FIX until we find a better way on ts mobx
+}
+
+class ChartContainerComponent extends React.Component {
+ static displayName = 'ChartContainer';
+
+ render() {
+ const { initialized } = this.props.chartStore!;
+ if (!initialized.get()) {
+ return null;
+ }
+ const className = classNames('echChartCursorContainer', {
+ 'echChart--isBrushEnabled': this.props.chartStore!.isCrosshairCursorVisible.get(),
+ });
+ const { setCursorPosition } = this.props.chartStore!;
+
+ return (
+ {
+ setCursorPosition(offsetX, offsetY);
+ }}
+ onMouseLeave={() => {
+ setCursorPosition(-1, -1);
+ }}
+ onMouseUp={() => {
+ if (this.props.chartStore!.isBrushing.get()) {
+ return;
+ }
+ this.props.chartStore!.handleChartClick();
+ }}
+ >
+
+
+ );
+ }
+}
+
+export const ChartContainer = inject('chartStore')(observer(ChartContainerComponent));
diff --git a/src/components/react_canvas/reactive_chart.tsx b/src/components/react_canvas/reactive_chart.tsx
index a347d2da96..cc8d68e5f1 100644
--- a/src/components/react_canvas/reactive_chart.tsx
+++ b/src/components/react_canvas/reactive_chart.tsx
@@ -1,4 +1,3 @@
-import classNames from 'classnames';
import { inject, observer } from 'mobx-react';
import React from 'react';
import { Layer, Rect, Stage } from 'react-konva';
@@ -352,7 +351,6 @@ class Chart extends React.Component {
chartRotation,
chartTransform,
debug,
- setCursorPosition,
isChartEmpty,
legendCollapsed,
legendPosition,
@@ -406,76 +404,48 @@ class Chart extends React.Component {
clipHeight: chartDimensions.height,
};
- const className = classNames({
- 'echChart--isBrushEnabled': this.props.chartStore!.isCrosshairCursorVisible.get(),
- });
-
return (
- {
- setCursorPosition(offsetX, offsetY);
+ width: '100%',
+ height: '100%',
}}
- onMouseLeave={() => {
- setCursorPosition(-1, -1);
- }}
- onMouseUp={() => {
- if (this.props.chartStore!.isBrushing.get()) {
- return;
- }
- this.props.chartStore!.handleChartClick();
- }}
- className={className}
+ {...brushProps}
>
-
+ {this.renderGrids()}
+
+
+
-
- {this.renderGrids()}
-
-
-
- {this.sortAndRenderElements()}
-
+ {this.sortAndRenderElements()}
+
+
+ {debug && this.renderDebugChartBorders()}
+
+ {isBrushEnabled && (
- {debug && this.renderDebugChartBorders()}
+ {this.renderBrushTool()}
- {isBrushEnabled && (
-
- {this.renderBrushTool()}
-
- )}
+ )}
-
- {this.renderAxes()}
-
+
+ {this.renderAxes()}
+
-
- {this.renderBarValues()}
-
-
-
+
+ {this.renderBarValues()}
+
+
);
}