Skip to content

Commit

Permalink
[Bug] visual channels cannot read property 'label' of undefined (#1804)
Browse files Browse the repository at this point in the history
* Fix crash: visualchannels cannot read property 'label' of undefined

Signed-off-by: Shan He <heshan0131@gmail.com>
  • Loading branch information
heshan0131 committed May 4, 2022
1 parent b7c6c8d commit 8ac5bbc
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/layers/base-layer.ts
Expand Up @@ -473,14 +473,17 @@ class Layer {
* @returns
*/
getVisualChannelDescription(key: string): VisualChannelDescription {
const label = this.visConfigSettings[this.visualChannels[key].range].label;
// e.g. label: Color, measure: Vehicle Type
const channel = this.visualChannels[key];
if (!channel) return {label: '', measure: ''};
const rangeSettings = this.visConfigSettings[channel.range];
const fieldSettings = this.config[channel.field];
const label = rangeSettings?.label;
return {
label: typeof label === 'function' ? label(this.config) : label,
measure: this.config[this.visualChannels[key].field]
? this.config[this.visualChannels[key].field].displayName ||
this.config[this.visualChannels[key].field].name
: this.visualChannels[key].defaultMeasure
measure: fieldSettings
? fieldSettings.displayName || fieldSettings.name
: channel.defaultMeasure
};
}

Expand Down

0 comments on commit 8ac5bbc

Please sign in to comment.