Ensure smooth resizing of gauges inside cells and the CEO
parent
e8f7751c30
commit
ee07872f28
|
@ -14,6 +14,7 @@ const DashVisualization = (
|
||||||
onCellRename,
|
onCellRename,
|
||||||
queryConfigs,
|
queryConfigs,
|
||||||
editQueryStatus,
|
editQueryStatus,
|
||||||
|
resizerTopHeight,
|
||||||
},
|
},
|
||||||
{source: {links: {proxy}}}
|
{source: {links: {proxy}}}
|
||||||
) =>
|
) =>
|
||||||
|
@ -27,6 +28,7 @@ const DashVisualization = (
|
||||||
templates={templates}
|
templates={templates}
|
||||||
autoRefresh={autoRefresh}
|
autoRefresh={autoRefresh}
|
||||||
editQueryStatus={editQueryStatus}
|
editQueryStatus={editQueryStatus}
|
||||||
|
resizerTopHeight={resizerTopHeight}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -55,6 +57,7 @@ DashVisualization.propTypes = {
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
onCellRename: func,
|
onCellRename: func,
|
||||||
|
resizerTopHeight: number,
|
||||||
}
|
}
|
||||||
|
|
||||||
DashVisualization.contextTypes = {
|
DashVisualization.contextTypes = {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import lastValues from 'shared/parsing/lastValues'
|
||||||
import Gauge from 'shared/components/Gauge'
|
import Gauge from 'shared/components/Gauge'
|
||||||
|
|
||||||
import {DEFAULT_COLORS} from 'src/dashboards/constants/gaugeColors'
|
import {DEFAULT_COLORS} from 'src/dashboards/constants/gaugeColors'
|
||||||
|
import {DASHBOARD_LAYOUT_ROW_HEIGHT} from 'shared/constants'
|
||||||
|
|
||||||
class GaugeChart extends Component {
|
class GaugeChart extends Component {
|
||||||
shouldComponentUpdate(nextProps, nextState) {
|
shouldComponentUpdate(nextProps, nextState) {
|
||||||
|
@ -11,7 +12,14 @@ class GaugeChart extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {data, cellHeight, isFetchingInitially, colors} = this.props
|
const {
|
||||||
|
data,
|
||||||
|
cellHeight,
|
||||||
|
isFetchingInitially,
|
||||||
|
colors,
|
||||||
|
resizeCoords,
|
||||||
|
resizerTopHeight,
|
||||||
|
} = this.props
|
||||||
|
|
||||||
// If data for this graph is being fetched for the first time, show a graph-wide spinner.
|
// If data for this graph is being fetched for the first time, show a graph-wide spinner.
|
||||||
if (isFetchingInitially) {
|
if (isFetchingInitially) {
|
||||||
|
@ -23,17 +31,34 @@ class GaugeChart extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
const lastValue = lastValues(data)[1]
|
const lastValue = lastValues(data)[1]
|
||||||
|
|
||||||
const precision = 100.0
|
const precision = 100.0
|
||||||
const roundedValue = Math.round(+lastValue * precision) / precision
|
const roundedValue = Math.round(+lastValue * precision) / precision
|
||||||
|
|
||||||
const trueHeight = (cellHeight * 83).toString()
|
// When a new height is passed the Gauge component resizes internally
|
||||||
|
// Passing in a new often ensures the gauge appears sharp
|
||||||
|
|
||||||
|
const initialCellHeight =
|
||||||
|
cellHeight && (cellHeight * DASHBOARD_LAYOUT_ROW_HEIGHT).toString()
|
||||||
|
|
||||||
|
const resizeCoordsHeight =
|
||||||
|
resizeCoords && (resizeCoords.h * DASHBOARD_LAYOUT_ROW_HEIGHT).toString()
|
||||||
|
|
||||||
|
const height = (resizeCoordsHeight ||
|
||||||
|
initialCellHeight ||
|
||||||
|
resizerTopHeight ||
|
||||||
|
300)
|
||||||
|
.toString()
|
||||||
|
|
||||||
|
// console.log('resizeCoordsHeight', resizeCoordsHeight)
|
||||||
|
// console.log('initialCellHeight', initialCellHeight)
|
||||||
|
// console.log('resizerTopHeight', resizerTopHeight)
|
||||||
|
// console.log('height', height)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="single-stat">
|
<div className="single-stat" ref={r => (this.gaugeContainer = r)}>
|
||||||
<Gauge
|
<Gauge
|
||||||
width="400"
|
width="900"
|
||||||
height={trueHeight || 200}
|
height={height}
|
||||||
colors={colors}
|
colors={colors}
|
||||||
gaugePosition={roundedValue}
|
gaugePosition={roundedValue}
|
||||||
/>
|
/>
|
||||||
|
@ -52,6 +77,8 @@ GaugeChart.propTypes = {
|
||||||
data: arrayOf(shape()).isRequired,
|
data: arrayOf(shape()).isRequired,
|
||||||
isFetchingInitially: bool,
|
isFetchingInitially: bool,
|
||||||
cellHeight: number,
|
cellHeight: number,
|
||||||
|
resizerTopHeight: number,
|
||||||
|
resizeCoords: shape(),
|
||||||
colors: arrayOf(
|
colors: arrayOf(
|
||||||
shape({
|
shape({
|
||||||
type: string.isRequired,
|
type: string.isRequired,
|
||||||
|
|
|
@ -21,6 +21,7 @@ const RefreshingGraph = ({
|
||||||
timeRange,
|
timeRange,
|
||||||
cellHeight,
|
cellHeight,
|
||||||
autoRefresh,
|
autoRefresh,
|
||||||
|
resizerTopHeight,
|
||||||
manualRefresh, // when changed, re-mounts the component
|
manualRefresh, // when changed, re-mounts the component
|
||||||
synchronizer,
|
synchronizer,
|
||||||
resizeCoords,
|
resizeCoords,
|
||||||
|
@ -58,6 +59,8 @@ const RefreshingGraph = ({
|
||||||
templates={templates}
|
templates={templates}
|
||||||
autoRefresh={autoRefresh}
|
autoRefresh={autoRefresh}
|
||||||
cellHeight={cellHeight}
|
cellHeight={cellHeight}
|
||||||
|
resizerTopHeight={resizerTopHeight}
|
||||||
|
resizeCoords={resizeCoords}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -99,6 +102,7 @@ RefreshingGraph.propTypes = {
|
||||||
synchronizer: func,
|
synchronizer: func,
|
||||||
type: string.isRequired,
|
type: string.isRequired,
|
||||||
cellHeight: number,
|
cellHeight: number,
|
||||||
|
resizerTopHeight: number,
|
||||||
axes: shape(),
|
axes: shape(),
|
||||||
queries: arrayOf(shape()).isRequired,
|
queries: arrayOf(shape()).isRequired,
|
||||||
editQueryStatus: func,
|
editQueryStatus: func,
|
||||||
|
|
|
@ -131,7 +131,7 @@ class ResizeContainer extends Component {
|
||||||
>
|
>
|
||||||
{React.cloneElement(children[0], {
|
{React.cloneElement(children[0], {
|
||||||
resizerBottomHeight: bottomHeightPixels,
|
resizerBottomHeight: bottomHeightPixels,
|
||||||
resizeTopHeight: topHeightPixels,
|
resizerTopHeight: topHeightPixels,
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
<ResizeHandle
|
<ResizeHandle
|
||||||
|
|
Loading…
Reference in New Issue