Skip to content

Commit 7921678

Browse files
authored
Merge pull request #492 from xBimTeam/fix/case-sensitive-discrete-channels
Discrete channels' handling of values is now case insensitive
2 parents cdaaab3 + 03b0cd1 commit 7921678

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

examples/data-visualization/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ viewer.on('loaded', args => {
100100
otherIcon.valueReadout = `20${selectedChannel.unit}`;
101101
}
102102
else if(selectedChannel.channelId === occChannelId){
103-
occupancySource.value = occupancySource.value === "Occupied" ? "Vacant" : "Occupied";
103+
occupancySource.value = occupancySource.value.toLowerCase() === "occupied" ? "vacant" : "occupied";
104104
heatmap.renderSource(occupancySource.id);
105105
sourceIcon.description = `${selectedChannel.description}: ${occupancySource.value}`;
106106
sourceIcon.valueReadout = `${occupancySource.value}`;

src/plugins/DataVisualization/Heatmap/heatmap.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,21 @@ export class Heatmap implements IPlugin {
168168
Object.entries(groups).forEach(([key, val]) => {
169169
const stringVal = val[0].source.value.toString();
170170
const modelId = val[0].product.model;
171-
if (values.includes(stringVal)) {
172-
const colorHex = channel.values[val[0].source.value];
171+
172+
let includesValue = false;
173+
if (channel.dataType === 'string') {
174+
includesValue = values.some(v => v.toLowerCase() === stringVal.toLowerCase());
175+
} else {
176+
includesValue = values.includes(stringVal);
177+
}
178+
179+
if (includesValue) {
180+
let matchingKey = stringVal;
181+
if (channel.dataType === 'string') {
182+
matchingKey = values.find(v => v.toLowerCase() === stringVal.toLowerCase()) || stringVal;
183+
}
184+
185+
const colorHex = channel.values[matchingKey];
173186
let productsIds: number[] = val.map(p => p.product.id);
174187
this._viewer.setStyle(this._colorStylesMap[colorHex], productsIds, modelId);
175188
this._viewer.addState(State.XRAYVISIBLE, productsIds, modelId)

0 commit comments

Comments
 (0)