Merge pull request #5821 from influxdata/5820/no_data_chart

fix(ui/flux): skip missing values in line chart instead of returning zeros
pull/5824/head
Pavel Závora 2021-09-30 11:02:49 +02:00 committed by GitHub
commit 9e29f95d3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 2 deletions

View File

@ -15,7 +15,7 @@
1. [#5810](https://github.com/influxdata/chronograf/pull/5810): Repair calculation of flux query range duration.
1. [#5815](https://github.com/influxdata/chronograf/pull/5815): Update time range of flux queries on dashboard zoom.
1. [#5818](https://github.com/influxdata/chronograf/pull/5818): Support Firefox private mode.
1. [#5821](https://github.com/influxdata/chronograf/pull/5821): Skip missing values in line chart instead of returning zeros.
### Other

View File

@ -36,7 +36,7 @@ export const fluxTablesToDygraphWork = (
for (const [seriesName, value] of Object.entries(values)) {
const i = allColumnNames.indexOf(seriesName) + DATE_INDEX_OFFSET
dygraphValuesByTime[date][i] = Number(value)
dygraphValuesByTime[date][i] = value === '' ? null : Number(value)
}
}
}

View File

@ -192,3 +192,14 @@ export const ERROR_RESPONSE = `#datatype,string,string
#default,,
,error,reference
,${ERROR}`
export const WINDOWED_WITH_EMPTY = `
#group,false,false,true,true,false,false,true,true
#datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,double,string,string
#default,_result,,,,,,,
,result,table,_start,_stop,_time,_value,_field,_measurement
,,0,2020-12-31T23:00:00Z,2021-01-01T04:00:00Z,2021-01-01T02:44:10Z,,value,temperature2
,,0,2020-12-31T23:00:00Z,2021-01-01T04:00:00Z,2021-01-01T02:45:00Z,22,value,temperature2
,,0,2020-12-31T23:00:00Z,2021-01-01T04:00:00Z,2021-01-01T02:45:50Z,,value,temperature2
,,0,2020-12-31T23:00:00Z,2021-01-01T04:00:00Z,2021-01-01T02:46:40Z,23,value,temperature2
,,0,2020-12-31T23:00:00Z,2021-01-01T04:00:00Z,2021-01-01T02:47:30Z,,value,temperature2`

View File

@ -5,6 +5,7 @@ import {
MISMATCHED,
MULTI_VALUE_ROW,
MIXED_DATATYPES,
WINDOWED_WITH_EMPTY,
} from 'test/shared/parsing/flux/constants'
describe('fluxTablesToDygraph', () => {
@ -70,4 +71,17 @@ describe('fluxTablesToDygraph', () => {
}
expect(actual).toEqual(expected)
})
it('returns null if value is not available', () => {
const fluxTables = parseResponse(WINDOWED_WITH_EMPTY)
const actual = fluxTablesToDygraph(fluxTables)
const expected = [
[new Date('2021-01-01T02:44:10Z'), null],
[new Date('2021-01-01T02:45:00Z'), 22],
[new Date('2021-01-01T02:45:50Z'), null],
[new Date('2021-01-01T02:46:40Z'), 23],
[new Date('2021-01-01T02:47:30Z'), null],
]
expect(actual.dygraphsData).toEqual(expected)
})
})