Skip to content
This repository has been archived by the owner on Nov 7, 2024. It is now read-only.

DunkelDunkelRot bei Inzidenz > 200 eingefügt #53

Merged
merged 3 commits into from
Nov 12, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions incidence.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: red; icon-glyph: briefcase-medical;
// icon-color: yellow; icon-glyph: file-medical-alt;

/**
* Licence: Robert Koch-Institut (RKI), dl-de/by-2-0
Expand Down Expand Up @@ -38,10 +38,12 @@ const apiUrlStates = `https://services7.arcgis.com/mOBPykOjAyBO2ZKk/arcgis/rest/
const apiUrlNewCases = 'https://services7.arcgis.com/mOBPykOjAyBO2ZKk/arcgis/rest/services/RKI_COVID19/FeatureServer/0/query?f=json&where=NeuerFall%20IN(1%2C%20-1)&returnGeometry=false&spatialRel=esriSpatialRelIntersects&outFields=*&outStatistics=%5B%7B%22statisticType%22%3A%22sum%22%2C%22onStatisticField%22%3A%22AnzahlFall%22%2C%22outStatisticFieldName%22%3A%22value%22%7D%5D&resultType=standard&cacheHint=true'
const apiRUrl = `https://www.rki.de/DE/Content/InfAZ/N/Neuartiges_Coronavirus/Projekte_RKI/Nowcasting_Zahlen_csv.csv?__blob=publicationFile`

const LIMIT_DARKDARKRED = 200
const LIMIT_DARKRED = 100
const LIMIT_RED = 50
const LIMIT_ORANGE = 35
const LIMIT_YELLOW = 25
const LIMIT_DARKDARKRED_COLOR = new Color('490c00')
const LIMIT_DARKRED_COLOR = new Color('a1232b')
const LIMIT_RED_COLOR = new Color('f6000f')
const LIMIT_ORANGE_COLOR = new Color('ff7927')
Expand Down Expand Up @@ -224,7 +226,9 @@ function addIncidence(view, data, useStaticCoordsIndex = false, status = 200) {

// === INCIDENCE
let incidence = formatNumber(todayData.area.incidence.toFixed(1), 1)
if (todayData.area.incidence >= 100) incidence = formatNumber(Math.round(todayData.area.incidence))
if (!MEDIUMWIDGET && todayData.area.incidence >= 100) {
incidence = formatNumber(Math.round(todayData.area.incidence))
}
addLabelTo(stackMainRow, incidence, Font.boldSystemFont(27), getIncidenceColor(todayData.area.incidence))

if (yesterdayData) {
Expand All @@ -242,7 +246,9 @@ function addIncidence(view, data, useStaticCoordsIndex = false, status = 200) {
incidenceBLStack.setPadding(2,3,2,3)

let incidenceBL = formatNumber(todayData.state.incidence.toFixed(1), 1);
if (todayData.state.incidence >= 100) incidenceBL = formatNumber(Math.round(todayData.state.incidence))
if (!MEDIUMWIDGET && todayData.state.incidence >= 100) {
incidenceBL = formatNumber(Math.round(todayData.state.incidence))
}
if (yesterdayData) {
incidenceBL += getTrendArrow(todayData.state.incidence, yesterdayData.state.incidence)
}
Expand Down Expand Up @@ -567,7 +573,9 @@ async function getRValue() {

function getIncidenceColor(incidence) {
let color = LIMIT_GREEN_COLOR
if (incidence >= LIMIT_DARKRED) {
if (incidence > LIMIT_DARKDARKRED) {
color = LIMIT_DARKDARKRED_COLOR
} else if (incidence >= LIMIT_DARKRED) {
color = LIMIT_DARKRED_COLOR
} else if (incidence >= LIMIT_RED) {
color = LIMIT_RED_COLOR
Expand Down Expand Up @@ -683,4 +691,4 @@ function getFilemanager() {
return fm
}

await new IncidenceWidget().init()
await new IncidenceWidget().init()