From 468b8b778a18a8694ee8ea56c4c8131e7a4afe1a Mon Sep 17 00:00:00 2001 From: noahamac Date: Wed, 8 Jan 2020 16:43:27 -0800 Subject: [PATCH] adding error handling for no results in the LFG viz --- src/examples/liquid_fill_gauge/liquid_fill_gauge.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/examples/liquid_fill_gauge/liquid_fill_gauge.ts b/src/examples/liquid_fill_gauge/liquid_fill_gauge.ts index f74ccd89..c3babdde 100644 --- a/src/examples/liquid_fill_gauge/liquid_fill_gauge.ts +++ b/src/examples/liquid_fill_gauge/liquid_fill_gauge.ts @@ -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, @@ -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]