11<template >
22 <div class =" overview" >
33 <div class =" title" >
4- {{ title }}
4+ {{ result. title }}
55 <a class =" close" href =" #" @click.prevent =" onClose" >
66 <svg xmlns =" http://www.w3.org/2000/svg" viewBox =" 0 0 16 16" fill =" none" >
77 <g opacity =" 0.3" >
1414 <div class =" content" >
1515 <div class =" section cases" >
1616 <p >Known Cases</p >
17- <Latest :data =" latest" :invert =" true" />
17+ <Latest :data =" result. latest" :invert =" true" />
1818 </div >
1919 <div class =" section chart" >
2020 <p >Timeline</p >
2121 <p class =" sub" >Click or Drag chart to view daily cases</p >
2222 <client-only >
23- <apexchart height =" 320" type =" line" :options =" chartOptions" :series =" series" ></apexchart >
23+ <apexchart height =" 320" type =" line" :options =" chartOptions" :series =" result. series" ></apexchart >
2424 </client-only >
2525 </div >
2626 <div class =" section timeline" >
2727 <p >Daily</p >
2828 <ul >
2929 <li
30- v-for =" (item, index) in timeline"
30+ v-for =" (item, index) in result. timeline"
3131 :key =" index" >
3232 <span class =" timestamp" >{{ item.timestamp.month }} {{ item.timestamp.date }}, {{ item.timestamp.year }}</span >
3333 <span class =" summary" v-html =" item.summary" />
@@ -51,13 +51,6 @@ export default {
5151 ... mapGetters ([
5252 ' result'
5353 ]),
54- title () {
55- const o = this .result
56- return o .province ? ` ${ o .province } , ${ o .country } ` : o .country
57- },
58- latest () {
59- return this .result .latest
60- },
6154 chartOptions () {
6255 return {
6356 chart: {
@@ -72,14 +65,14 @@ export default {
7265 dataLabels: {
7366 enabled: false
7467 },
75- colors: [" #ffa500" , " #b20000" , " #66a266" ],
68+ colors: [' #ffa500' , ' #b20000' , ' #66a266' ],
7669 stroke: {
7770 width: [4 , 4 , 4 ]
7871 },
7972 xaxis: {
80- type: " datetime" ,
73+ type: ' datetime' ,
8174 labels: {
82- format: " dd MMM"
75+ format: ' dd MMM'
8376 }
8477 },
8578 yaxis: {
@@ -91,60 +84,9 @@ export default {
9184 },
9285 legend: {
9386 show: false ,
94- horizontalAlign: " left"
87+ horizontalAlign: ' left'
9588 }
9689 }
97- },
98- series () {
99- const timelineConfirmed = Object .entries (this .result .timelines .confirmed .timeline ).map (o => o)
100- const timelineDeaths = Object .entries (this .result .timelines .deaths .timeline ).map (o => o)
101- const timelineRecovered = Object .entries (this .result .timelines .recovered .timeline ).map (o => o)
102- return [
103- {
104- name: " Confirmed" ,
105- data: timelineConfirmed
106- },
107- {
108- name: " Deaths" ,
109- data: timelineDeaths
110- },
111- {
112- name: " Recovered" ,
113- data: timelineRecovered
114- }
115- ]
116- },
117- timeline () {
118- const isPlural = (name , total , s ) => {
119- return ` <span class="${ name} ">${ total} </span> ${ s}${ (total > 1 ) ? ' s' : ' ' } `
120- }
121- const isContinue = (a , b ) => {
122- return a && b ? ' , ' : a && ! b ? ' and ' : ' '
123- }
124- const perDayConfirmed = this .getPerDay (Object .entries (this .result .timelines .confirmed .timeline ))
125- const perDayDeaths = this .getPerDay (Object .entries (this .result .timelines .deaths .timeline ))
126- const perDayRecovered = this .getPerDay (Object .entries (this .result .timelines .recovered .timeline ))
127- const perDayCases = Object .entries (perDayConfirmed).map ((o , index ) => {
128- let summary = ' '
129- if (o[1 ] || perDayDeaths[o[0 ]] || perDayRecovered[o[0 ]]) {
130- if (o[1 ]) {
131- summary += ` ${ isPlural (' confirmed' , o[1 ], ' confirmed case' )} `
132- }
133- if (perDayDeaths[o[0 ]]) {
134- summary += isContinue (o[1 ], perDayRecovered[o[0 ]])
135- summary += ` ${ isPlural (' deaths' , perDayDeaths[o[0 ]], ' death' )} `
136- }
137- if (perDayRecovered[o[0 ]]) {
138- summary += isContinue (o[1 ], perDayDeaths[o[0 ]])
139- summary += ` <span class="recovered">${ perDayRecovered[o[0 ]]} </span> recovered`
140- }
141- }
142- return {
143- timestamp: this .formatDate (o[0 ]),
144- summary: summary + ' .'
145- }
146- })
147- return perDayCases .filter (o => o .summary !== ' .' )
14890 }
14991 },
15092 data () {
@@ -153,29 +95,6 @@ export default {
15395 methods: {
15496 onClose () {
15597 this .$emit (' close' )
156- },
157- formatDate (val ) {
158- const d = new Date (val)
159- const dtf = new Intl.DateTimeFormat (' en' , {
160- year: ' numeric' ,
161- month: ' short' ,
162- day: ' 2-digit'
163- })
164- const [{ value: mo }, , { value: da }, , { value: ye }] = dtf .formatToParts (d)
165- return {
166- month: mo,
167- date: da,
168- year: ye
169- }
170- },
171- getPerDay (data ) {
172- let temp = 0
173- const trueTimeline = {}
174- data .forEach (a => {
175- trueTimeline[a[0 ]] = a[1 ] > temp ? a[1 ] - temp : 0
176- temp = a[1 ]
177- })
178- return trueTimeline
17998 }
18099 }
181100}
@@ -300,7 +219,6 @@ export default {
300219 padding-right : 16px ;
301220 font-weight : 700 ;
302221 color : #585858 ;
303- text-transform : uppercase ;
304222 min-width : 100px ;
305223 }
306224
0 commit comments