-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: decuple brush cursor from chart rendering
This commit remove the unnecessary style recalculation caused by chancing the cursor style on the document body from the chart_state. This commit also decouple the chart container from the chart renderer, removing multiple rendering caused by the mouse leaving the brush area
- Loading branch information
Showing
7 changed files
with
101 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<ReactiveChartProps> { | ||
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 ( | ||
<div | ||
className={className} | ||
onMouseMove={({ nativeEvent: { offsetX, offsetY } }) => { | ||
setCursorPosition(offsetX, offsetY); | ||
}} | ||
onMouseLeave={() => { | ||
setCursorPosition(-1, -1); | ||
}} | ||
onMouseUp={() => { | ||
if (this.props.chartStore!.isBrushing.get()) { | ||
return; | ||
} | ||
this.props.chartStore!.handleChartClick(); | ||
}} | ||
> | ||
<ReactiveChart /> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export const ChartContainer = inject('chartStore')(observer(ChartContainerComponent)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters