From a53c7d7abe0d74373a00e37879402459803accc6 Mon Sep 17 00:00:00 2001 From: Andrew Watkins Date: Tue, 24 Oct 2017 13:39:16 -0700 Subject: [PATCH 1/5] Fix error to console when range is zero for dygraph logscale --- ui/src/shared/components/Dygraph.js | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/ui/src/shared/components/Dygraph.js b/ui/src/shared/components/Dygraph.js index 43f21725c..95caa9efa 100644 --- a/ui/src/shared/components/Dygraph.js +++ b/ui/src/shared/components/Dygraph.js @@ -43,7 +43,6 @@ export default class Dygraph extends Component { componentDidMount() { const { axes: {y, y2}, - ruleValues, isGraphFilled: fillGraph, isBarGraph, options, @@ -63,9 +62,7 @@ export default class Dygraph extends Component { plugins: [new Dygraphs.Plugins.Crosshair({direction: 'vertical'})], axes: { y: { - valueRange: options.stackedGraph - ? getStackedRange(y.bounds) - : getRange(timeSeries, y.bounds, ruleValues), + valueRange: this.getYRange(timeSeries), axisLabelFormatter: (yval, __, opts) => numberValueFormatter(yval, opts, y.prefix, y.suffix), axisLabelWidth: this.getLabelWidth(), @@ -130,7 +127,7 @@ export default class Dygraph extends Component { } componentDidUpdate() { - const {labels, axes: {y, y2}, options, ruleValues, isBarGraph} = this.props + const {labels, axes: {y, y2}, options, isBarGraph} = this.props const dygraph = this.dygraph if (!dygraph) { @@ -149,9 +146,7 @@ export default class Dygraph extends Component { ylabel: this.getLabel('y'), axes: { y: { - valueRange: options.stackedGraph - ? getStackedRange(y.bounds) - : getRange(timeSeries, y.bounds, ruleValues), + valueRange: this.getYRange(timeSeries), axisLabelFormatter: (yval, __, opts) => numberValueFormatter(yval, opts, y.prefix, y.suffix), axisLabelWidth: this.getLabelWidth(), @@ -176,6 +171,24 @@ export default class Dygraph extends Component { this.props.setResolution(w) } + getYRange = timeSeries => { + const {options, axes: {y}, ruleValues} = this.props + + if (options.stackedGraph) { + return getStackedRange(y.bounds) + } + + const range = getRange(timeSeries, y.bounds, ruleValues) + const [min, max] = range + + // Bug in Dygraph calculates a negative range for logscale when min range is 0 + if (y.scale === LOG && min <= 0) { + return [0.1, max] + } + + return range + } + handleZoom = (lower, upper) => { const {onZoom} = this.props From edaa0fed99715416c5fafc7c91309859b8de2dcf Mon Sep 17 00:00:00 2001 From: Andrew Watkins Date: Tue, 24 Oct 2017 13:39:50 -0700 Subject: [PATCH 2/5] Prevent user from deprecating number to below zero if logscale --- ui/src/dashboards/components/AxesOptions.js | 3 +++ ui/src/shared/components/ClickOutsideInput.js | 3 +++ ui/src/shared/components/Dygraph.js | 2 +- ui/src/shared/components/OptIn.js | 7 ++++--- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ui/src/dashboards/components/AxesOptions.js b/ui/src/dashboards/components/AxesOptions.js index d44640ea7..fcce69a05 100644 --- a/ui/src/dashboards/components/AxesOptions.js +++ b/ui/src/dashboards/components/AxesOptions.js @@ -6,6 +6,7 @@ import {Tabber, Tab} from 'src/dashboards/components/Tabber' import {DISPLAY_OPTIONS, TOOLTIP_CONTENT} from 'src/dashboards/constants' const {LINEAR, LOG, BASE_2, BASE_10} = DISPLAY_OPTIONS +const getInputMin = scale => (scale === LOG ? '0' : null) const AxesOptions = ({ axes: {y: {bounds, label, prefix, suffix, base, scale, defaultYLabel}}, @@ -38,6 +39,7 @@ const AxesOptions = ({ customValue={min} onSetValue={onSetYAxisBoundMin} type="number" + min={getInputMin(scale)} />
@@ -47,6 +49,7 @@ const AxesOptions = ({ customValue={max} onSetValue={onSetYAxisBoundMax} type="number" + min={getInputMin(scale)} />
(this.customValueInput = el) render() { - const {fixedPlaceholder, customPlaceholder, type} = this.props + const {fixedPlaceholder, customPlaceholder, type, min} = this.props const {useCustomValue, customValue} = this.state return ( @@ -110,6 +110,7 @@ class OptIn extends Component { > -
Date: Tue, 24 Oct 2017 13:49:31 -0700 Subject: [PATCH 3/5] Update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2615c899d..d6269b676 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## v1.3.11.0 [unreleased] ### Bug Fixes +1. [#2157](https://github.com/influxdata/chronograf/pull/2157): Fix logscale producing console errors when only one point in graph ### Features ### UI Improvements From bbc6c76a61c6b5168178f2774b8de7d2ca3590ec Mon Sep 17 00:00:00 2001 From: Andrew Watkins Date: Tue, 24 Oct 2017 14:28:37 -0700 Subject: [PATCH 4/5] Fix cannot connect to source false error flag --- ui/src/dashboards/actions/index.js | 3 ++- ui/src/shared/parsing/index.js | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ui/src/dashboards/actions/index.js b/ui/src/dashboards/actions/index.js index b151b5e19..0108e3ab9 100644 --- a/ui/src/dashboards/actions/index.js +++ b/ui/src/dashboards/actions/index.js @@ -281,7 +281,8 @@ export const updateTempVarValues = (source, dashboard) => async dispatch => { results.forEach(({data}, i) => { const {type, query, id} = tempsWithQueries[i] - const vals = parsers[type](data, query.tagKey || query.measurement)[type] + const parsed = parsers[type](data, query.tagKey || query.measurement) + const vals = parsed[type] dispatch(editTemplateVariableValues(dashboard.id, id, vals)) }) } catch (error) { diff --git a/ui/src/shared/parsing/index.js b/ui/src/shared/parsing/index.js index 7ac11b03b..5ea98db42 100644 --- a/ui/src/shared/parsing/index.js +++ b/ui/src/shared/parsing/index.js @@ -1,3 +1,4 @@ +import _ from 'lodash' import databases from 'shared/parsing/showDatabases' import measurements from 'shared/parsing/showMeasurements' import fieldKeys from 'shared/parsing/showFieldKeys' @@ -8,16 +9,19 @@ const parsers = { databases, measurements: data => { const {errors, measurementSets} = measurements(data) - return {errors, measurements: measurementSets[0].measurements} + return { + errors, + measurements: _.get(measurementSets, ['0', 'measurements'], []), + } }, fieldKeys: (data, key) => { const {errors, fieldSets} = fieldKeys(data) - return {errors, fieldKeys: fieldSets[key]} + return {errors, fieldKeys: _.get(fieldSets, key, [])} }, tagKeys, tagValues: (data, key) => { const {errors, tags} = tagValues(data) - return {errors, tagValues: tags[key]} + return {errors, tagValues: _.get(tags, key, [])} }, } From b5e6eb784afce37329888090bdc53e61c0cca056 Mon Sep 17 00:00:00 2001 From: Andrew Watkins Date: Tue, 24 Oct 2017 14:38:57 -0700 Subject: [PATCH 5/5] Update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2615c899d..a797bea68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## v1.3.11.0 [unreleased] ### Bug Fixes +1. [#2158](https://github.com/influxdata/chronograf/pull/2158): Fix 'Cannot connect to source' false error flag on Dashboard page ### Features ### UI Improvements