Skip to content

Commit 0bd246e

Browse files
authored
Merge pull request #1135 from cmu-delphi/sgatzl/exxtended_hosp
feat: extended color scale generalization
2 parents d461d7a + 27702dd commit 0bd246e

File tree

6 files changed

+10
-7
lines changed

6 files changed

+10
-7
lines changed

src/data/meta.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ function deriveMetaSensors(metadata: EpiDataMetaSourceInfo[]): {
136136
m.format === 'per100k' ? 'per 100k' : m.format === 'percent' ? 'per 100' : units[m.format] || units.raw,
137137
colorScale: colorScales[m.high_values_are],
138138
vegaColorScale: vegaColorScales[m.high_values_are],
139-
useExtendedColorScale: isCasesSignal(key),
139+
extendedColorScale: isCasesSignal(key),
140140
links: sm.link.map((d) => `<a href="${d.href}">${d.alt}</a>`),
141141
credits: credits,
142142
formatValue: formatter[m.format] || formatter.raw,

src/data/sensor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export interface Sensor {
6868
readonly signalTooltip: string; // short text description
6969
readonly colorScale: (this: void, v: number) => string;
7070
readonly vegaColorScale: string;
71-
readonly useExtendedColorScale: boolean;
71+
readonly extendedColorScale: boolean;
7272

7373
readonly links: readonly string[]; // more information links
7474
readonly credits?: string; // credit text
@@ -134,7 +134,7 @@ export function ensureSensorStructure(sensor: Partial<Sensor> & { name: string;
134134
signalTooltip: sensor.signalTooltip || 'No description available',
135135
colorScale: colorScales[highValuesAre],
136136
vegaColorScale: vegaColorScales[highValuesAre],
137-
useExtendedColorScale: isCasesSignal(key),
137+
extendedColorScale: isCasesSignal(key),
138138

139139
links: [],
140140
credits: 'We are happy for you to use this data in products and publications.',

src/stores/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export interface SensorConfig {
1414
signal: string;
1515
signalTooltip: string;
1616
description: string;
17+
extendedColorScale?: boolean;
1718

1819
unit?: string;
1920
unitShort?: string;

src/stores/descriptions.raw.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ Name: COVID Cases
7878
Id: jhu-csse
7979
Signal: confirmed_7dav_incidence_prop
8080
Highlight: [default]
81+
ExtendedColorScale: true
8182

8283

8384
SignalTooltip: Newly reported COVID-19 cases per 100,000 people, based on data from Johns Hopkins University
@@ -88,6 +89,7 @@ Description: This data shows the number of COVID-19 confirmed cases newly report
8889
Name: COVID Hospital Admissions
8990
Id: hhs
9091
Signal: confirmed_admissions_covid_1d_prop_7dav
92+
ExtendedColorScale: true
9193

9294

9395
SignalTooltip: Confirmed COVID-19 hospital admissions per 100,000 people

src/stores/params.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ export class SensorParam {
166166
}
167167

168168
vegaSchemeDomain(level: RegionLevel = 'county'): { domain: [number, number]; scheme: string; domainMid?: number } {
169-
if (!this.value.useExtendedColorScale) {
169+
if (!this.value.extendedColorScale) {
170170
return {
171171
domain: this.domain(level),
172172
scheme: this.value.vegaColorScale,
@@ -181,12 +181,12 @@ export class SensorParam {
181181
}
182182

183183
createValueScale(level: RegionLevel = 'county'): (v: number) => number {
184-
const domain = this.domain(level, this.value.useExtendedColorScale);
184+
const domain = this.domain(level, this.value.extendedColorScale);
185185
return scaleLinear().domain([domain[0], domain[domain.length - 1]]);
186186
}
187187

188188
createColorScale(level: RegionLevel = 'county'): (v: number) => string {
189-
const extended = this.value.useExtendedColorScale;
189+
const extended = this.value.extendedColorScale;
190190
const domain = this.domain(level, extended);
191191
if (!extended) {
192192
return scaleSequential(this.value.colorScale).domain(domain).clamp(true);

src/stores/questions.raw.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Category: Symptoms
2929
Question: |
3030
Do you personally know someone in your local community who has COVID-like symptoms?
3131
Signal: smoothed_whh_cmnty_cli
32-
AddedInWave: 1
32+
AddedInWave: 2
3333

3434

3535
---

0 commit comments

Comments
 (0)