Skip to content
This repository has been archived by the owner on May 13, 2022. It is now read-only.

Commit

Permalink
Use booster data in charts
Browse files Browse the repository at this point in the history
Issue: #43
  • Loading branch information
mathiasbynens committed Nov 19, 2021
1 parent 425bfbc commit 569ebbe
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
frappe-charts.esm.js
tmp
node_modules
package-lock.json
Expand Down
18 changes: 14 additions & 4 deletions build-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,16 @@ let maxCount = 0;
let oldestDate = '9001-12-31';
let latestDate = '1970-01-01';
let latestPubDate = '1970-01-01';
for (const {date, pubDate, state, onlyPartiallyVaccinatedCumulative, onlyPartiallyVaccinatedPercent, atLeastPartiallyVaccinatedCumulative, atLeastPartiallyVaccinatedPercent, fullyVaccinatedCumulative, fullyVaccinatedPercent, totalDosesCumulative, initialDosesCumulative, finalDosesCumulative, initialDosesPercent, finalDosesPercent, initialDosesCumulativeBioNTech, finalDosesCumulativeBioNTech, initialDosesCumulativeModerna, finalDosesCumulativeModerna, initialDosesCumulativeAstraZeneca, finalDosesCumulativeAstraZeneca, finalDosesCumulativeJohnsonAndJohnson, onlyPartiallyVaccinatedCumulativeBioNTech, onlyPartiallyVaccinatedCumulativeModerna, onlyPartiallyVaccinatedCumulativeAstraZeneca, fullyVaccinatedCumulativeBioNTech, fullyVaccinatedCumulativeModerna, fullyVaccinatedCumulativeAstraZeneca, fullyVaccinatedCumulativeJohnsonAndJohnson} of records) {
for (const {date, pubDate, state, onlyPartiallyVaccinatedCumulative, onlyPartiallyVaccinatedPercent, atLeastPartiallyVaccinatedCumulative, atLeastPartiallyVaccinatedPercent, fullyVaccinatedCumulative, fullyVaccinatedPercent, totalDosesCumulative, initialDosesCumulative, finalDosesCumulative, initialDosesPercent, finalDosesPercent, initialDosesCumulativeBioNTech, finalDosesCumulativeBioNTech, initialDosesCumulativeModerna, finalDosesCumulativeModerna, initialDosesCumulativeAstraZeneca, finalDosesCumulativeAstraZeneca, finalDosesCumulativeJohnsonAndJohnson, boosterDosesCumulative, boosterDosesCumulativeBioNTech, boosterDosesCumulativeModerna, boosterDosesCumulativeJohnsonAndJohnson, onlyPartiallyVaccinatedCumulativeBioNTech, onlyPartiallyVaccinatedCumulativeModerna, onlyPartiallyVaccinatedCumulativeAstraZeneca, fullyVaccinatedCumulativeBioNTech, fullyVaccinatedCumulativeModerna, fullyVaccinatedCumulativeAstraZeneca, fullyVaccinatedCumulativeJohnsonAndJohnson} of records) {
if (state !== BUNDESWEHR) states.add(state);
const countInitialDoses = Number(initialDosesCumulative);
const countFinalDoses = Number(finalDosesCumulative);
const countBoosterDoses = Number(boosterDosesCumulative);
const countTotal = Number(totalDosesCumulative);
const countBioNTech = Number(initialDosesCumulativeBioNTech) + Number(finalDosesCumulativeBioNTech);
const countModerna = Number(initialDosesCumulativeModerna) + Number(finalDosesCumulativeModerna);
const countBioNTech = Number(initialDosesCumulativeBioNTech) + Number(finalDosesCumulativeBioNTech) + Number(boosterDosesCumulativeBioNTech);
const countModerna = Number(initialDosesCumulativeModerna) + Number(finalDosesCumulativeModerna) + Number(boosterDosesCumulativeModerna);
const countAstraZeneca = Number(initialDosesCumulativeAstraZeneca) + Number(finalDosesCumulativeAstraZeneca);
const countJohnsonAndJohnson = Number(finalDosesCumulativeJohnsonAndJohnson);
const countJohnsonAndJohnson = Number(finalDosesCumulativeJohnsonAndJohnson) + + Number(boosterDosesCumulativeJohnsonAndJohnson);
if (countTotal > maxCount) {
maxCount = countTotal;
}
Expand All @@ -83,6 +84,7 @@ for (const {date, pubDate, state, onlyPartiallyVaccinatedCumulative, onlyPartial
cumulativeTotal: countTotal,
cumulativeInitial: countInitialDoses,
cumulativeFinal: countFinalDoses,
cumulativeBooster: countBoosterDoses,
cumulativeTotalBioNTech: countBioNTech,
cumulativeTotalModerna: countModerna,
cumulativeTotalAstraZeneca: countAstraZeneca,
Expand All @@ -102,6 +104,7 @@ for (const {date, pubDate, state, onlyPartiallyVaccinatedCumulative, onlyPartial
fullyVaccinatedCumulativeModerna: Number(fullyVaccinatedCumulativeModerna),
fullyVaccinatedCumulativeAstraZeneca: Number(fullyVaccinatedCumulativeAstraZeneca),
fullyVaccinatedCumulativeJohnsonAndJohnson: Number(fullyVaccinatedCumulativeJohnsonAndJohnson),

});
}

Expand Down Expand Up @@ -781,12 +784,14 @@ function generateStateData(desiredState) {
const countsTotal = [];
const countsInitialDose = [];
const countsFinalDose = [];
const countsBoosterDose = [];
const countsAvailable = [];
for (const [date, entry] of sortedMap) {
const data = entry.get(desiredState);
countsTotal.push(data.cumulativeTotal);
countsInitialDose.push(data.cumulativeInitial);
countsFinalDose.push(data.cumulativeFinal);
countsBoosterDose.push(data.cumulativeBooster);
const availableDoses = cumulativeDeliveryMap.get(date).get(desiredState);
countsAvailable.push(availableDoses);
}
Expand All @@ -811,6 +816,11 @@ function generateStateData(desiredState) {
chartType: 'line',
values: countsFinalDose,
},
{
name: 'Booster doses',
chartType: 'line',
values: countsBoosterDose,
},
);

const data = {
Expand Down
2 changes: 1 addition & 1 deletion index.html

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions templates/chart.template
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<div id="chart-cumulative-germany" class="chart"></div>
<script type="module">
import { Chart } from 'https://unpkg.com/[email protected]/dist/frappe-charts.esm.js';
//import { Chart } from './frappe-charts.esm.js';

const formatter = new Intl.NumberFormat('en');

Expand Down

0 comments on commit 569ebbe

Please sign in to comment.