-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixing resizing for charts on dashboard (#10706)
- Loading branch information
1 parent
82b37aa
commit 08b9535
Showing
7 changed files
with
107 additions
and
53 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
66 changes: 66 additions & 0 deletions
66
src/core_plugins/metrics/public/visualizations/components/resize.js
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,66 @@ | ||
import React, { Component, PropTypes } from 'react'; | ||
import { findDOMNode } from 'react-dom'; | ||
class Resize extends Component { | ||
|
||
constructor(props) { | ||
super(props); | ||
this.state = {}; | ||
this.handleResize = this.handleResize.bind(this); | ||
} | ||
|
||
checkSize() { | ||
const el = findDOMNode(this.el); | ||
this.timeout = setTimeout(() => { | ||
const { currentHeight, currentWidth } = this.state; | ||
if (currentHeight !== el.clientHeight || currentWidth !== el.clientWidth) { | ||
this.setState({ | ||
currentWidth: el.parentNode.clientWidth, | ||
currentHeight: el.parentNode.clientHeight | ||
}); | ||
this.handleResize(); | ||
} | ||
this.checkSize(); | ||
}, this.props.frequency); | ||
} | ||
|
||
componentDidMount() { | ||
const el = findDOMNode(this.el); | ||
const currentWidth = el.parentNode.clientWidth; | ||
const currentHeight = el.parentNode.clientHeight; | ||
this.setState({ currentHeight, currentWidth }); | ||
this.checkSize(); | ||
} | ||
|
||
componentWillUnmount() { | ||
clearTimeout(this.timeout); | ||
} | ||
|
||
handleResize() { | ||
if (this.props.onResize) this.props.onResize(); | ||
} | ||
|
||
render() { | ||
const style = this.props.style || {}; | ||
const className = this.props.className || ''; | ||
return( | ||
<div | ||
style={style} | ||
className={className} | ||
ref={(el) => this.el = el} > | ||
{this.props.children} | ||
</div> | ||
); | ||
} | ||
|
||
} | ||
|
||
Resize.defaultProps = { | ||
frequency: 500 | ||
}; | ||
|
||
Resize.propTypes = { | ||
frequency: PropTypes.number, | ||
onResize: PropTypes.func | ||
}; | ||
|
||
export default Resize; |
1 change: 1 addition & 0 deletions
1
src/core_plugins/metrics/public/visualizations/less/includes/metric.less
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
.rhythm_metric { | ||
font-size: 100%; | ||
position: relative; | ||
display: flex; | ||
flex-direction: column; | ||
|