Skip to content

Commit

Permalink
Merge branch 'main' into global-error-handler
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenthoms authored Sep 14, 2023
2 parents 7b8cb36 + 1951a2f commit a79cdef
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,25 @@ export class TreeData {
private _stringifiedData: string;
private _nodeData: TreeDataNodeMetaData[];
private _allowOrOperator: boolean;
private _allowWildcards: boolean;

constructor({
treeData,
delimiter,
allowOrOperator,
allowWildcards,
}: {
treeData: TreeDataNode[];
delimiter: string;
allowOrOperator: boolean;
allowWildcards: boolean;
}) {
this._treeData = treeData;
this._delimiter = delimiter;
this._nodeData = [];
this._stringifiedData = "";
this._allowOrOperator = allowOrOperator;
this._allowWildcards = allowWildcards;

this.populateNodes();
}
Expand Down Expand Up @@ -125,6 +129,13 @@ export class TreeData {
}

private adjustNodeName(nodeName: string): string {
if (!this._allowWildcards) {
return this.replaceAll(
this.replaceAll(this.replaceAll(this.escapeRegExp(nodeName), ":", ""), "*", "\\*"),
"?",
"\\."
);
}
return this.activateOrStatements(
this.replaceAll(
this.replaceAll(this.replaceAll(this.escapeRegExp(nodeName), ":", ""), "*", '[^:"]*'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ export class SmartNodeSelectorComponent extends React.Component<SmartNodeSelecto
treeData: props.data,
delimiter: props.delimiter,
allowOrOperator: props.useBetaFeatures || false,
allowWildcards: props.maxNumSelectedNodes !== 1,
});
} catch (e) {
this.treeData = null;
Expand Down Expand Up @@ -250,6 +251,7 @@ export class SmartNodeSelectorComponent extends React.Component<SmartNodeSelecto
treeData: this.props.data,
delimiter: this.props.delimiter,
allowOrOperator: this.props.useBetaFeatures || false,
allowWildcards: this.props.maxNumSelectedNodes !== 1,
});
} catch (e) {
this.treeData = null;
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/lib/components/VectorSelector/vectorSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export class VectorSelectorComponent extends SmartNodeSelectorComponent {
treeData: this.modifyTreeData(props.data, props.numMetaNodes, this.vectorDefinitions),
delimiter: props.delimiter,
allowOrOperator: props.useBetaFeatures || false,
allowWildcards: this.props.maxNumSelectedNodes !== 1,
});
} catch (e) {
this.treeData = null;
Expand Down Expand Up @@ -116,6 +117,7 @@ export class VectorSelectorComponent extends SmartNodeSelectorComponent {
treeData: this.modifyTreeData(this.props.data, this.props.numMetaNodes, this.vectorDefinitions),
delimiter: this.props.delimiter,
allowOrOperator: this.props.useBetaFeatures || false,
allowWildcards: this.props.maxNumSelectedNodes !== 1,
});
} catch (e) {
this.treeData = null;
Expand Down
32 changes: 24 additions & 8 deletions frontend/src/lib/utils/ColorScale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,28 @@ export class ColorScale {
}

private calcNormalizedValue(value: number, min: number, max: number): number {
let normalizedValue = 0;
if (this._gradientType === ColorScaleGradientType.Sequential) {
normalizedValue = (value - min) / (max - min);
} else if (this._gradientType === ColorScaleGradientType.Diverging) {
if (max === min) {
return 1;
}
return (value - min) / (max - min);
}
if (this._gradientType === ColorScaleGradientType.Diverging) {
if (max === min) {
return 0.5;
}
if (value < this._divMidPoint) {
normalizedValue = ((value - min) / (this._divMidPoint - min)) * 0.5;
} else {
normalizedValue = 0.5 * (1 + (value - this._divMidPoint) / (max - this._divMidPoint));
if (this._divMidPoint === min) {
return 0.5;
}
return ((value - min) / (this._divMidPoint - min)) * 0.5;
}
if (this._divMidPoint === max) {
return 0.5;
}
return 0.5 * (1 + (value - this._divMidPoint) / (max - this._divMidPoint));
}

return normalizedValue;
return 0;
}

getColorPalette(): ColorPalette {
Expand Down Expand Up @@ -128,6 +138,12 @@ export class ColorScale {
}

getPlotlyColorScale(): [number, string][] {
if (this._min === this._max) {
return [
[0, this.getColorForValue(this._min)],
[1, this.getColorForValue(this._max)],
];
}
const plotlyColorScale: [number, string][] = [];
for (let i = 0; i <= 100; i++) {
if (i > 0) {
Expand Down

0 comments on commit a79cdef

Please sign in to comment.