Merge pull request #717 from MrRamka/bugfix/nan
Fix NaN and null values
This commit is contained in:
Коммит
cee2c156dc
|
@ -24,6 +24,7 @@ export namespace Scale {
|
|||
public domainMax: number;
|
||||
|
||||
public inferParameters(values: number[]) {
|
||||
values = values.filter(v => !isNaN(v))
|
||||
const scale = scaleLinear()
|
||||
.domain([Math.min(...values), Math.max(...values)])
|
||||
.nice();
|
||||
|
|
|
@ -90,8 +90,8 @@ export class CategoricalScaleNumber extends ScaleClass<
|
|||
public mapDataToAttribute(data: DataValue): AttributeValue {
|
||||
const attrs = this.state.attributes;
|
||||
const props = this.object.properties;
|
||||
const number = props.mapping[data.toString()];
|
||||
return number * attrs.rangeScale;
|
||||
const number = props.mapping[data ? data?.toString() : null];
|
||||
return (number ?? 0) * attrs.rangeScale;
|
||||
}
|
||||
|
||||
public buildConstraint(
|
||||
|
@ -101,7 +101,7 @@ export class CategoricalScaleNumber extends ScaleClass<
|
|||
) {
|
||||
const attrs = this.state.attributes;
|
||||
const props = this.object.properties;
|
||||
const k = props.mapping[data.toString()];
|
||||
const k = props.mapping[data?.toString()];
|
||||
solver.addLinear(
|
||||
ConstraintStrength.HARD,
|
||||
0,
|
||||
|
@ -207,7 +207,7 @@ export class CategoricalScaleColor extends ScaleClass<
|
|||
|
||||
public mapDataToAttribute(data: DataValue): AttributeValue {
|
||||
const props = this.object.properties;
|
||||
return props.mapping[data.toString()];
|
||||
return props.mapping[data?.toString()];
|
||||
}
|
||||
|
||||
// eslint-disable-next-line
|
||||
|
@ -383,7 +383,7 @@ export class CategoricalScaleEnum extends ScaleClass<
|
|||
|
||||
public mapDataToAttribute(data: DataValue): AttributeValue {
|
||||
const props = this.object.properties;
|
||||
return props.mapping[data.toString()];
|
||||
return props.mapping[data?.toString()];
|
||||
}
|
||||
|
||||
// eslint-disable-next-line
|
||||
|
@ -472,7 +472,7 @@ export class CategoricalScaleBoolean extends ScaleClass<
|
|||
|
||||
public mapDataToAttribute(data: DataValue): AttributeValue {
|
||||
const props = this.object.properties;
|
||||
return props.mapping[data.toString()];
|
||||
return props.mapping[data?.toString()];
|
||||
}
|
||||
|
||||
// eslint-disable-next-line
|
||||
|
@ -555,7 +555,7 @@ export class CategoricalScaleImage extends ScaleClass<
|
|||
|
||||
public mapDataToAttribute(data: DataValue): AttributeValue {
|
||||
const props = this.object.properties;
|
||||
return props.mapping[data.toString()];
|
||||
return props.mapping[data?.toString()];
|
||||
}
|
||||
|
||||
// eslint-disable-next-line
|
||||
|
|
Загрузка…
Ссылка в новой задаче