Skip to content

Commit 5959e3c

Browse files
authored
Merge pull request #1149 from cmu-delphi/sgratzl/uncertainty_marker
fix uncertainty hint for multiple regions
2 parents e9c6e2e + 7317950 commit 5959e3c

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/blocks/HistoryLineChart.svelte

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@
252252
}-${sensor.isWeeklySignal ? formatWeek(timeFrame.max_week) : formatDateISO(timeFrame.max)}${suffix}`;
253253
}
254254
255-
function injectRanges(spec, timeFrame, annotations) {
255+
function injectRanges(spec, timeFrame, annotations, multipleRegions) {
256256
if (annotations.length > 0) {
257257
spec.layer.unshift(genAnnotationLayer(annotations, timeFrame));
258258
}
@@ -264,7 +264,7 @@
264264
}
265265
const uncertaintyAnnotation = annotations.find((d) => d.uncertainty);
266266
if (uncertaintyAnnotation) {
267-
spec.layer.push(genUncertaintyLayer(uncertaintyAnnotation, { color }));
267+
spec.layer.push(genUncertaintyLayer(uncertaintyAnnotation, { color, multipleRegions }));
268268
}
269269
return spec;
270270
}
@@ -295,6 +295,7 @@
295295
}),
296296
timeFrame,
297297
annotations.filter((d) => !d.isAllTime),
298+
regions.length > 1,
298299
);
299300
$: data = raw
300301
? loadSingleData(sensor, region, timeFrame)

src/specs/lineSpec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,13 @@ export function genUncertaintyLayer(
205205
{
206206
dateField = 'date_value',
207207
valueField = 'value',
208+
compareField = 'displayName',
209+
multipleRegions,
208210
}: {
209211
dateField?: string;
210212
valueField?: string;
213+
compareField?: string;
214+
multipleRegions?: boolean;
211215
},
212216
): NormalizedUnitSpec {
213217
const start = toTimeValue(annotation.dates[0]);
@@ -234,6 +238,12 @@ export function genUncertaintyLayer(
234238
field: valueField,
235239
type: 'quantitative',
236240
},
241+
detail: multipleRegions
242+
? {
243+
field: compareField,
244+
type: 'nominal',
245+
}
246+
: undefined,
237247
},
238248
};
239249
}

0 commit comments

Comments
 (0)