Skip to content

Commit 32ce7a9

Browse files
committed
【examples】疫情地图处理数据暂缺的情况 review by xiongjj
1 parent 12f6f2b commit 32ce7a9

File tree

3 files changed

+40
-22
lines changed

3 files changed

+40
-22
lines changed

examples/component/components_ncp_china_vue.html

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -127,24 +127,32 @@
127127
},
128128
'china-incrementConfirmed': {
129129
tooltip: function(properties) {
130+
if (isNaN(properties['confirmedAdd'])) {
131+
return resources.text_ncp_nodata_tooltip.replace('{name}', properties['省份']);
132+
}
130133
return resources.text_ncp_incrementConfirmed_tooltip
131134
.replace('{name}', properties['省份'])
132135
.replace('{confirmedAdd}', properties['confirmedAdd']);
133136
},
134137
title: resources.text_ncp_incrementConfirmed_title,
135138
'fill-color': [
136139
'case',
137-
['>=', ['get', 'confirmedAdd'], 200],
138-
'#d7301f',
139-
['>=', ['get', 'confirmedAdd'], 100],
140-
'#ef6548',
141-
['>=', ['get', 'confirmedAdd'], 50],
142-
'#fc8d59',
143-
['>=', ['get', 'confirmedAdd'], 10],
144-
'#fdbb84',
145-
['>=', ['get', 'confirmedAdd'], 1],
146-
'#fdd49e',
147-
'#F4F4F4'
140+
['has', 'confirmedAdd'],
141+
[
142+
'case',
143+
['>=', ['get', 'confirmedAdd'], 200],
144+
'#d7301f',
145+
['>=', ['get', 'confirmedAdd'], 100],
146+
'#ef6548',
147+
['>=', ['get', 'confirmedAdd'], 50],
148+
'#fc8d59',
149+
['>=', ['get', 'confirmedAdd'], 10],
150+
'#fdbb84',
151+
['>=', ['get', 'confirmedAdd'], 1],
152+
'#fdd49e',
153+
'#F4F4F4'
154+
],
155+
'#D9D9D9'
148156
],
149157
'text-field': [
150158
'concat',
@@ -155,24 +163,32 @@
155163
},
156164
'china-nowConfirmed': {
157165
tooltip: function(properties) {
166+
if (isNaN(properties['nowConfirmed'])) {
167+
return resources.text_ncp_nodata_tooltip.replace('{name}', properties['省份']);
168+
}
158169
return resources.text_ncp_nowConfirmed_tooltip
159170
.replace('{name}', properties['省份'])
160171
.replace('{nowConfirmed}', properties['nowConfirmed']);
161172
},
162173
title: resources.text_ncp_nowConfirmed_title,
163174
'fill-color': [
164175
'case',
165-
['>=', ['get', 'nowConfirmed'], 200],
166-
'#d7301f',
167-
['>=', ['get', 'nowConfirmed'], 100],
168-
'#ef6548',
169-
['>=', ['get', 'nowConfirmed'], 50],
170-
'#fc8d59',
171-
['>=', ['get', 'nowConfirmed'], 10],
172-
'#fdbb84',
173-
['>=', ['get', 'nowConfirmed'], 1],
174-
'#fdd49e',
175-
'#F4F4F4'
176+
['has', 'nowConfirmed'],
177+
[
178+
'case',
179+
['>=', ['get', 'nowConfirmed'], 200],
180+
'#d7301f',
181+
['>=', ['get', 'nowConfirmed'], 100],
182+
'#ef6548',
183+
['>=', ['get', 'nowConfirmed'], 50],
184+
'#fc8d59',
185+
['>=', ['get', 'nowConfirmed'], 10],
186+
'#fdbb84',
187+
['>=', ['get', 'nowConfirmed'], 1],
188+
'#fdd49e',
189+
'#F4F4F4'
190+
],
191+
'#D9D9D9'
176192
],
177193
'text-field': ['get', '省份'],
178194
'line-color': '#83838D'

examples/locales/en-US/resources.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,6 +1378,7 @@ window.examplesResources = {
13781378
'text_ncp_nowConfirmed':"Current Confirmed",
13791379
'text_ncp_incrementConfirmed':"New Confirmed",
13801380
'text_ncp_incidence':"Reported Incidence",
1381+
'text_ncp_nodata_tooltip':"{name}: No Data",
13811382
'text_ncp_riskLevel_tooltip':"{name}: No new confirmed for {daysNoConfirmedAdd} consecutive days",
13821383
'text_ncp_riskLevel_tooltip1':"{name}: The highest newly diagnosed in the past 3 days {daysMaxConfirmedAdd}<br>New confirmed {confirmedAdd} yesterday",
13831384
'text_ncp_riskLevel_title':"Epidemic Risk Level Map",

examples/locales/zh-CN/resources.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,6 +1324,7 @@ window.examplesResources = {
13241324
'text_ncp_nowConfirmed':"现有确诊",
13251325
'text_ncp_incrementConfirmed':"新增确诊",
13261326
'text_ncp_incidence':"报告发病率",
1327+
'text_ncp_nodata_tooltip':"{name}:数据暂缺",
13271328
'text_ncp_riskLevel_tooltip':"{name}:连续 {daysNoConfirmedAdd} 天无新增确诊",
13281329
'text_ncp_riskLevel_tooltip1':"{name}:近3天最高新增确诊 {daysMaxConfirmedAdd}<br>昨新增确诊 {confirmedAdd}",
13291330
'text_ncp_riskLevel_title':"疫情风险等级图",

0 commit comments

Comments
 (0)