diff --git a/ui/src/dashboards/components/Visualization.js b/ui/src/dashboards/components/Visualization.js index 0197bbec88..a4376c9143 100644 --- a/ui/src/dashboards/components/Visualization.js +++ b/ui/src/dashboards/components/Visualization.js @@ -14,6 +14,7 @@ const DashVisualization = ( onCellRename, queryConfigs, editQueryStatus, + resizerTopHeight, }, {source: {links: {proxy}}} ) => @@ -27,6 +28,7 @@ const DashVisualization = ( templates={templates} autoRefresh={autoRefresh} editQueryStatus={editQueryStatus} + resizerTopHeight={resizerTopHeight} /> @@ -55,6 +57,7 @@ DashVisualization.propTypes = { }), }), onCellRename: func, + resizerTopHeight: number, } DashVisualization.contextTypes = { diff --git a/ui/src/shared/components/GaugeChart.js b/ui/src/shared/components/GaugeChart.js index d06c121d4d..7e24475663 100644 --- a/ui/src/shared/components/GaugeChart.js +++ b/ui/src/shared/components/GaugeChart.js @@ -4,6 +4,7 @@ import lastValues from 'shared/parsing/lastValues' import Gauge from 'shared/components/Gauge' import {DEFAULT_COLORS} from 'src/dashboards/constants/gaugeColors' +import {DASHBOARD_LAYOUT_ROW_HEIGHT} from 'shared/constants' class GaugeChart extends Component { shouldComponentUpdate(nextProps, nextState) { @@ -11,7 +12,14 @@ class GaugeChart extends Component { } 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 (isFetchingInitially) { @@ -23,17 +31,34 @@ class GaugeChart extends Component { } const lastValue = lastValues(data)[1] - const precision = 100.0 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 ( -