Skip to content
This repository has been archived by the owner on Apr 21, 2022. It is now read-only.

Commit

Permalink
adding error handling for no results in the LFG viz
Browse files Browse the repository at this point in the history
  • Loading branch information
noahamac committed Jan 9, 2020
1 parent 1d134e9 commit 468b8b7
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/examples/liquid_fill_gauge/liquid_fill_gauge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ const vis: LiquidFillGaugeVisualization = {
this.svg.attr('id', elementId)
},
// Render in response to the data or settings changing
updateAsync(data, element, config, queryResponse, details, done) {
update(data, element, config, queryResponse, details) {
if (!handleErrors(this, queryResponse, {
min_pivots: 0, max_pivots: 0,
min_dimensions: 0, max_dimensions: undefined,
Expand All @@ -222,15 +222,13 @@ const vis: LiquidFillGaugeVisualization = {
if (gaugeConfig.maxValue <= 0) {
this.addError({ group: 'config', title: 'Max value must be greater than zero.' })
return
} else if (data.length == 0) {
this.addError({ title: 'No results.' });
return;
} else {
this.clearErrors('config')
}
}
if (data.length == 0) {
// @ts-ignore
this.addError({ group: 'data', title: 'No results.' })
done()
}

const datumField = queryResponse.fields.measure_like[0]
const datum = data[0][datumField.name]
Expand Down

0 comments on commit 468b8b7

Please sign in to comment.