Working on case cards.
This commit is contained in:
@@ -20,12 +20,14 @@
|
||||
</template>
|
||||
|
||||
<script setup lang='ts'>
|
||||
import cache from '@/data/cache.js'
|
||||
|
||||
const parameters = cache.parameters
|
||||
const { parameters, unknown } = defineProps({
|
||||
parameters: Object,
|
||||
unknown: Boolean
|
||||
})
|
||||
|
||||
const counties = [
|
||||
'All',
|
||||
'-- All --',
|
||||
unknown ? '-- Unknown --' : null,
|
||||
'Appling',
|
||||
'Atkinson',
|
||||
'Bacon',
|
||||
@@ -186,5 +188,5 @@ const counties = [
|
||||
'Wilkes',
|
||||
'Wilkinson',
|
||||
'Worth'
|
||||
]
|
||||
].filter(county => !!county)
|
||||
</script>
|
||||
|
||||
137
src/components/charts/state/cases/ChipsCases.vue
Normal file
137
src/components/charts/state/cases/ChipsCases.vue
Normal file
@@ -0,0 +1,137 @@
|
||||
<template>
|
||||
<StatCard>
|
||||
<template v-slot:heading>Today's Confirmed Cases</template>
|
||||
<template v-slot:value v-if="chips.today_cases != null">
|
||||
{{chips.today_cases.toLocaleString()}}
|
||||
</template>
|
||||
<template v-slot:meta v-if="chips.today_case_change != null">
|
||||
<span v-if="chips.today_case_change > 0">Up </span>
|
||||
<span v-if="chips.today_case_change < 0">Down </span>
|
||||
<span :class="{'font-semibold': true, 'text-red-600': chips.today_case_change > 0, 'text-green-600': chips.today_case_change < 0}">
|
||||
{{Math.abs(chips.today_case_change).toLocaleString()}} ({{chips.today_case_change_percent}}%)
|
||||
</span> compared to yesterday
|
||||
</template>
|
||||
</StatCard>
|
||||
|
||||
<StatCard>
|
||||
<template v-slot:heading>Today's Cases per 10,000 Residents</template>
|
||||
<template v-slot:value v-if="chips.today_cases_per_capita != null">
|
||||
~{{chips.today_cases_per_capita.toLocaleString()}}
|
||||
</template>
|
||||
<template v-slot:meta v-if="chips.population != null">
|
||||
<span class="text-indigo-500 font-semibold">{{chips.today_cases.toLocaleString()}}</span> out of <span class="text-indigo-500 font-semibold">{{chips.population.toLocaleString()}}</span> residents
|
||||
</template>
|
||||
</StatCard>
|
||||
|
||||
<StatCard>
|
||||
<template v-slot:heading>Total Confirmed Cases</template>
|
||||
<template v-slot:value v-if="chips.total_cases != null">
|
||||
{{chips.total_cases.toLocaleString()}}
|
||||
</template>
|
||||
<template v-slot:meta v-if="chips.total_case_change != null">
|
||||
<span class="font-semibold text-indigo-500">
|
||||
{{Math.abs(chips.total_case_change).toLocaleString()}} ({{chips.total_case_change_percent}}%)
|
||||
</span> more than yesterday
|
||||
</template>
|
||||
</StatCard>
|
||||
|
||||
<StatCard>
|
||||
<template v-slot:heading>Total Cases per 10,000 Residents</template>
|
||||
<template v-slot:value v-if="chips.total_cases_per_capita != null">
|
||||
~{{chips.total_cases_per_capita.toLocaleString()}}
|
||||
</template>
|
||||
<template v-slot:meta v-if="chips.total_cases != null && chips.population != null">
|
||||
<span class="text-indigo-500 font-semibold">{{chips.total_cases.toLocaleString()}}</span> out of <span class="text-indigo-500 font-semibold">{{chips.population.toLocaleString()}}</span> residents
|
||||
</template>
|
||||
</StatCard>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { reactive, computed } from 'vue'
|
||||
import { col } from '@/components/charts/util'
|
||||
import store from '@/components/charts/state/cases/store.js'
|
||||
|
||||
const data = store.data
|
||||
|
||||
const chips = reactive({
|
||||
population: computed(() => {
|
||||
if (!data.value) return null
|
||||
|
||||
const r = data.value.rows.at(-1)
|
||||
return col(data, r, 'population')
|
||||
}),
|
||||
|
||||
today_cases: computed(() => {
|
||||
if (!data.value) return null
|
||||
|
||||
const r = data.value.rows.at(-1)
|
||||
return col(data, r, 'cases')
|
||||
}),
|
||||
|
||||
today_case_change: computed(() => {
|
||||
if (!data.value) return null
|
||||
|
||||
const today = col(data, data.value.rows.at(-1), 'cases')
|
||||
const yesterday = col(data, data.value.rows.at(-2), 'cases')
|
||||
return today - yesterday
|
||||
}),
|
||||
|
||||
today_case_change_percent: computed(() => {
|
||||
if (!data.value) return null
|
||||
|
||||
const today = col(data, data.value.rows.at(-1), 'cases')
|
||||
const yesterday = col(data, data.value.rows.at(-2), 'cases')
|
||||
const change = today - yesterday
|
||||
|
||||
const percent = change > 0
|
||||
? ((change / yesterday) * 100)
|
||||
: ((change / today) * 100)
|
||||
|
||||
return Math.abs(percent.toFixed(1))
|
||||
}),
|
||||
|
||||
today_cases_per_capita: computed(() => {
|
||||
if (!data.value) return null
|
||||
|
||||
const r = data.value.rows.at(-1)
|
||||
return Math.round(col(data, r, 'cases_per_capita') * 10000)
|
||||
}),
|
||||
|
||||
total_cases: computed(() => {
|
||||
if (!data.value) return null
|
||||
|
||||
const r = data.value.rows.at(-1)
|
||||
return col(data, r, 'total_cases')
|
||||
}),
|
||||
|
||||
total_case_change: computed(() => {
|
||||
if (!data.value) return null
|
||||
|
||||
const today = col(data, data.value.rows.at(-1), 'total_cases')
|
||||
const yesterday = today - col(data, data.value.rows.at(-1), 'cases')
|
||||
return today - yesterday
|
||||
}),
|
||||
|
||||
total_case_change_percent: computed(() => {
|
||||
if (!data.value) return null
|
||||
|
||||
const today = col(data, data.value.rows.at(-1), 'total_cases')
|
||||
const yesterday = today - col(data, data.value.rows.at(-1), 'cases')
|
||||
const change = today - yesterday
|
||||
|
||||
const percent = change > 0
|
||||
? ((change / yesterday) * 100)
|
||||
: ((change / today) * 100)
|
||||
|
||||
return Math.abs(percent.toFixed(1))
|
||||
}),
|
||||
|
||||
total_cases_per_capita: computed(() => {
|
||||
if (!data.value) return null
|
||||
|
||||
const r = data.value.rows.at(-1)
|
||||
return Math.round(col(data, r, 'total_cases_per_capita') * 10000)
|
||||
})
|
||||
})
|
||||
|
||||
</script>
|
||||
0
src/components/charts/state/cases/MapCases.vue
Normal file
0
src/components/charts/state/cases/MapCases.vue
Normal file
9
src/components/charts/state/cases/ParametersCases.vue
Normal file
9
src/components/charts/state/cases/ParametersCases.vue
Normal file
@@ -0,0 +1,9 @@
|
||||
<template>
|
||||
<SliceSelector :parameters="parameters" :unknown="true"></SliceSelector>
|
||||
</template>
|
||||
|
||||
<script setup lang='ts'>
|
||||
import store from '@/components/charts/state/cases/store.js'
|
||||
|
||||
const parameters = store.parameters
|
||||
</script>
|
||||
68
src/components/charts/state/cases/TrendCases.vue
Normal file
68
src/components/charts/state/cases/TrendCases.vue
Normal file
@@ -0,0 +1,68 @@
|
||||
<template>
|
||||
<Card>
|
||||
<h2 class="mb-6 text-xl text-indigo-900 flex justify-between items-center">
|
||||
Daily PCR Tests Performed
|
||||
|
||||
<select v-model="chart" class="text-base m-0">
|
||||
<option value="calendar">Calendar</option>
|
||||
<option value="line">Line Chart</option>
|
||||
</select>
|
||||
</h2>
|
||||
<JSCharting v-if="chart === 'calendar'" :options="calendarOptions"></JSCharting>
|
||||
<JSCharting v-if="chart === 'line'" :options="areaOptions"></JSCharting>
|
||||
</Card>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed } from 'vue'
|
||||
import { col, colors } from '@/components/charts/util'
|
||||
import store from '@/components/charts/state/testing/store.js'
|
||||
|
||||
const chart = ref('calendar')
|
||||
|
||||
const column = 'pcr_performed'
|
||||
const parameters = store.parameters
|
||||
const data = store.data
|
||||
|
||||
const rows = computed(() => {
|
||||
if (!data.value || !parameters.value) return []
|
||||
return data.value.rows
|
||||
.filter(r => {
|
||||
return col(data, r, 'report_date') >= parameters.value.start && col(data, r, 'report_date') <= parameters.value.end
|
||||
})
|
||||
})
|
||||
|
||||
const calendarOptions = computed(() => {
|
||||
return {
|
||||
type: 'calendar month solid',
|
||||
palette: { colors },
|
||||
calendar_initial: parameters.value ? parameters.value.end : null,
|
||||
data: rows.value.map(r => ([
|
||||
`${col(data, r, 'report_date')} 12:00:00`,
|
||||
col(data, r, column)
|
||||
]))
|
||||
}
|
||||
})
|
||||
|
||||
const areaOptions = computed(() => {
|
||||
return {
|
||||
type: 'lineSpline',
|
||||
legend_visible: false,
|
||||
xAxis: { crosshair_enabled: true, scale_type: 'time' },
|
||||
palette: { colors },
|
||||
defaultSeries: {
|
||||
shape_opacity: 0.55,
|
||||
color: colors[Math.round(colors.length / 2)],
|
||||
defaultPoint_marker_visible: false
|
||||
},
|
||||
series: [
|
||||
{
|
||||
points: rows.value.map(r => ([
|
||||
`${col(data, r, 'report_date')} 12:00:00`,
|
||||
col(data, r, column)
|
||||
]))
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
</script>
|
||||
34
src/components/charts/state/cases/store.js
Normal file
34
src/components/charts/state/cases/store.js
Normal file
@@ -0,0 +1,34 @@
|
||||
import { reactive, ref, watch } from 'vue'
|
||||
|
||||
function formatDate(d) {
|
||||
return [
|
||||
d.getFullYear(),
|
||||
('0' + (d.getMonth() + 1)).slice(-2),
|
||||
('0' + d.getDate()).slice(-2)
|
||||
].join('-');
|
||||
}
|
||||
|
||||
const today = new Date()
|
||||
const end = new Date()
|
||||
const start = new Date(today.valueOf() - 2592000000)
|
||||
|
||||
const store = {
|
||||
parameters: ref({
|
||||
county: '-- All --',
|
||||
start: formatDate(start),
|
||||
end: formatDate(end)
|
||||
}),
|
||||
data: ref(null)
|
||||
}
|
||||
|
||||
async function refreshData() {
|
||||
store.data.value = await fetch(`/data/state/cases/${store.parameters.value.county}.json`).then(res => res.json())
|
||||
}
|
||||
|
||||
watch(() => store.parameters.value.county, () => {
|
||||
refreshData()
|
||||
})
|
||||
|
||||
refreshData()
|
||||
|
||||
export default store
|
||||
@@ -62,9 +62,9 @@
|
||||
<script setup>
|
||||
import { reactive, computed } from 'vue'
|
||||
import { col } from '@/components/charts/util'
|
||||
import cache from '@/data/cache.js'
|
||||
import store from '@/components/charts/state/testing/store.js'
|
||||
|
||||
const data = cache.data
|
||||
const data = store.data
|
||||
|
||||
const chips = reactive({
|
||||
total_tests: computed(() => {
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<template>
|
||||
<SliceSelector :parameters="parameters"></SliceSelector>
|
||||
</template>
|
||||
|
||||
<script setup lang='ts'>
|
||||
import store from '@/components/charts/state/testing/store.js'
|
||||
|
||||
const parameters = store.parameters
|
||||
</script>
|
||||
@@ -16,16 +16,16 @@
|
||||
<script setup>
|
||||
import { ref, computed } from 'vue'
|
||||
import { col, colors } from '@/components/charts/util'
|
||||
import cache from '@/data/cache.js'
|
||||
import store from '@/components/charts/state/testing/store.js'
|
||||
|
||||
const chart = ref('calendar')
|
||||
|
||||
const column = 'antigen_positive'
|
||||
const parameters = cache.parameters
|
||||
const data = cache.data
|
||||
const parameters = store.parameters
|
||||
const data = store.data
|
||||
|
||||
const rows = computed(() => {
|
||||
if (!data.value) return []
|
||||
if (!data.value || !parameters.value) return []
|
||||
return data.value.rows
|
||||
.filter(r => {
|
||||
return col(data, r, 'report_date') >= parameters.value.start && col(data, r, 'report_date') <= parameters.value.end
|
||||
@@ -36,7 +36,7 @@ const calendarOptions = computed(() => {
|
||||
return {
|
||||
type: 'calendar month solid',
|
||||
palette: { colors },
|
||||
calendar_initial: parameters.value.end,
|
||||
calendar_initial: parameters.value ? parameters.value.end : null,
|
||||
data: rows.value.map(r => ([
|
||||
`${col(data, r, 'report_date')} 12:00:00`,
|
||||
col(data, r, column)
|
||||
|
||||
@@ -15,16 +15,16 @@
|
||||
<script setup>
|
||||
import { ref, computed } from 'vue'
|
||||
import { col, colors } from '@/components/charts/util'
|
||||
import cache from '@/data/cache.js'
|
||||
import store from '@/components/charts/state/testing/store.js'
|
||||
|
||||
const chart = ref('calendar')
|
||||
|
||||
const column = 'antigen_performed'
|
||||
const parameters = cache.parameters
|
||||
const data = cache.data
|
||||
const parameters = store.parameters
|
||||
const data = store.data
|
||||
|
||||
const rows = computed(() => {
|
||||
if (!data.value) return []
|
||||
if (!data.value || !parameters.value) return []
|
||||
return data.value.rows
|
||||
.filter(r => {
|
||||
return col(data, r, 'report_date') >= parameters.value.start && col(data, r, 'report_date') <= parameters.value.end
|
||||
@@ -35,7 +35,7 @@ const calendarOptions = computed(() => {
|
||||
return {
|
||||
type: 'calendar month solid',
|
||||
palette: { colors },
|
||||
calendar_initial: parameters.value.end,
|
||||
calendar_initial: parameters.value ? parameters.value.end : null,
|
||||
data: rows.value.map(r => ([
|
||||
`${col(data, r, 'report_date')} 12:00:00`,
|
||||
col(data, r, column)
|
||||
|
||||
@@ -16,16 +16,16 @@
|
||||
<script setup>
|
||||
import { ref, computed } from 'vue'
|
||||
import { col, colors } from '@/components/charts/util'
|
||||
import cache from '@/data/cache.js'
|
||||
import store from '@/components/charts/state/testing/store.js'
|
||||
|
||||
const chart = ref('calendar')
|
||||
|
||||
const column = 'pcr_positive'
|
||||
const parameters = cache.parameters
|
||||
const data = cache.data
|
||||
const parameters = store.parameters
|
||||
const data = store.data
|
||||
|
||||
const rows = computed(() => {
|
||||
if (!data.value) return []
|
||||
if (!data.value || !parameters.value) return []
|
||||
return data.value.rows
|
||||
.filter(r => {
|
||||
return col(data, r, 'report_date') >= parameters.value.start && col(data, r, 'report_date') <= parameters.value.end
|
||||
@@ -36,7 +36,7 @@ const calendarOptions = computed(() => {
|
||||
return {
|
||||
type: 'calendar month solid',
|
||||
palette: { colors },
|
||||
calendar_initial: parameters.value.end,
|
||||
calendar_initial: parameters.value ? parameters.value.end : null,
|
||||
data: rows.value.map(r => ([
|
||||
`${col(data, r, 'report_date')} 12:00:00`,
|
||||
col(data, r, column)
|
||||
|
||||
@@ -16,16 +16,16 @@
|
||||
<script setup>
|
||||
import { ref, computed } from 'vue'
|
||||
import { col, colors } from '@/components/charts/util'
|
||||
import cache from '@/data/cache.js'
|
||||
import store from '@/components/charts/state/testing/store.js'
|
||||
|
||||
const chart = ref('calendar')
|
||||
|
||||
const column = 'pcr_performed'
|
||||
const parameters = cache.parameters
|
||||
const data = cache.data
|
||||
const parameters = store.parameters
|
||||
const data = store.data
|
||||
|
||||
const rows = computed(() => {
|
||||
if (!data.value) return []
|
||||
if (!data.value || !parameters.value) return []
|
||||
return data.value.rows
|
||||
.filter(r => {
|
||||
return col(data, r, 'report_date') >= parameters.value.start && col(data, r, 'report_date') <= parameters.value.end
|
||||
@@ -36,7 +36,7 @@ const calendarOptions = computed(() => {
|
||||
return {
|
||||
type: 'calendar month solid',
|
||||
palette: { colors },
|
||||
calendar_initial: parameters.value.end,
|
||||
calendar_initial: parameters.value ? parameters.value.end : null,
|
||||
data: rows.value.map(r => ([
|
||||
`${col(data, r, 'report_date')} 12:00:00`,
|
||||
col(data, r, column)
|
||||
|
||||
36
src/components/charts/state/testing/store.js
Normal file
36
src/components/charts/state/testing/store.js
Normal file
@@ -0,0 +1,36 @@
|
||||
import { reactive, ref, watch } from 'vue'
|
||||
|
||||
function formatDate(d) {
|
||||
return [
|
||||
d.getFullYear(),
|
||||
('0' + (d.getMonth() + 1)).slice(-2),
|
||||
('0' + d.getDate()).slice(-2)
|
||||
].join('-');
|
||||
}
|
||||
|
||||
const today = new Date()
|
||||
const end = new Date()
|
||||
const start = new Date(today.valueOf() - 2592000000)
|
||||
|
||||
const store = {
|
||||
parameters: ref({
|
||||
county: '-- All --',
|
||||
start: formatDate(start),
|
||||
end: formatDate(end)
|
||||
}),
|
||||
data: ref(null)
|
||||
}
|
||||
|
||||
async function refreshData() {
|
||||
store.data.value = await fetch(`/data/state/testing/${store.parameters.value.county}.json`).then(res => res.json())
|
||||
}
|
||||
|
||||
watch(() => store.parameters.value.county, () => {
|
||||
refreshData()
|
||||
})
|
||||
|
||||
if (globalThis.window) {
|
||||
refreshData()
|
||||
}
|
||||
|
||||
export default store
|
||||
@@ -1,39 +0,0 @@
|
||||
<template></template>
|
||||
|
||||
<script setup>
|
||||
import { watch, onMounted } from 'vue'
|
||||
import cache from '@/data/cache.js'
|
||||
|
||||
const parameters = cache.parameters
|
||||
const data = cache.data
|
||||
|
||||
function formatDate(d) {
|
||||
return [
|
||||
d.getFullYear(),
|
||||
('0' + (d.getMonth() + 1)).slice(-2),
|
||||
('0' + d.getDate()).slice(-2)
|
||||
].join('-');
|
||||
}
|
||||
|
||||
const today = new Date()
|
||||
const end = new Date()
|
||||
const start = new Date(today.valueOf() - 2592000000)
|
||||
|
||||
console.log(start, end)
|
||||
|
||||
parameters.value = {
|
||||
county: 'All',
|
||||
start: formatDate(start),
|
||||
end: formatDate(end),
|
||||
}
|
||||
|
||||
async function refreshData() {
|
||||
data.value = await fetch(`/data/testing-trend/${parameters.value.county}.json`).then(res => res.json())
|
||||
}
|
||||
|
||||
watch(() => parameters.value.county, () => {
|
||||
refreshData()
|
||||
})
|
||||
|
||||
onMounted(() => refreshData())
|
||||
</script>
|
||||
Reference in New Issue
Block a user