From 1d134e9cd87ddc300af34031f23a3cbab6c8e51f Mon Sep 17 00:00:00 2001 From: noahamac Date: Wed, 8 Jan 2020 15:54:40 -0800 Subject: [PATCH 1/3] adds error handling for no results in LFG --- src/examples/liquid_fill_gauge/liquid_fill_gauge.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/examples/liquid_fill_gauge/liquid_fill_gauge.ts b/src/examples/liquid_fill_gauge/liquid_fill_gauge.ts index 86c2dd8e..f74ccd89 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 - update(data, element, config, queryResponse) { + updateAsync(data, element, config, queryResponse, details, done) { if (!handleErrors(this, queryResponse, { min_pivots: 0, max_pivots: 0, min_dimensions: 0, max_dimensions: undefined, @@ -226,6 +226,11 @@ const vis: LiquidFillGaugeVisualization = { 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] From 468b8b778a18a8694ee8ea56c4c8131e7a4afe1a Mon Sep 17 00:00:00 2001 From: noahamac Date: Wed, 8 Jan 2020 16:43:27 -0800 Subject: [PATCH 2/3] 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] From 00d336f8ba96627f3a4a895f6fb7f42999d98f75 Mon Sep 17 00:00:00 2001 From: noahamac Date: Wed, 8 Jan 2020 16:51:29 -0800 Subject: [PATCH 3/3] getting around TS errors --- src/examples/liquid_fill_gauge/liquid_fill_gauge.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/examples/liquid_fill_gauge/liquid_fill_gauge.ts b/src/examples/liquid_fill_gauge/liquid_fill_gauge.ts index c3babdde..16c38395 100644 --- a/src/examples/liquid_fill_gauge/liquid_fill_gauge.ts +++ b/src/examples/liquid_fill_gauge/liquid_fill_gauge.ts @@ -222,9 +222,9 @@ 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 if (data.length === 0) { + this.addError({ title: 'No results.' }) + return } else { this.clearErrors('config') }