Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-enable growth plot #608

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
7d70424
#606: cleaned up SpreadChart.fs a little
breki Oct 12, 2020
6593428
#606: more cleaning up of SpreadChart.fs a little
breki Oct 12, 2020
4b6bf87
#606: more cleaning up of SpreadChart.fs a little
breki Oct 12, 2020
1354034
#606: more cleaning up of SpreadChart.fs a little
breki Oct 12, 2020
1978b84
#606: more cleaning up of SpreadChart.fs a little
breki Oct 12, 2020
2acc9f2
Merge branch 'master' of github.com:slo-covid-19/website into issues/606
breki Oct 15, 2020
58c16e2
Merge branch 'master' of github.com:slo-covid-19/website into issues/606
breki Oct 18, 2020
2610c1a
Merge branch 'master' into issues/606
lukarenko Oct 23, 2020
7e60d34
new colors for world map
sebastjancizel Oct 23, 2020
13e83c5
legend fix
lukarenko Oct 24, 2020
b0dddda
Muni/Region map: show newCases in tooltip, not active
lukarenko Oct 24, 2020
be1b2b2
Merge pull request #640 from sledilnik/worldmap_new_colors
lukarenko Oct 24, 2020
5e170e9
Country green/red list update
lukarenko Oct 24, 2020
587c55c
SWE admin region fix
lukarenko Oct 24, 2020
6ac7a21
#606: merge from master
breki Oct 24, 2020
c5d0ec8
#606: more cleaning up of SpreadChart.fs a little
breki Oct 12, 2020
e56bcbc
#606: more cleaning up of SpreadChart.fs a little
breki Oct 12, 2020
7178b92
#606: more cleaning up of SpreadChart.fs a little
breki Oct 12, 2020
20a27b2
#606: more cleaning up of SpreadChart.fs a little
breki Oct 12, 2020
66f6e25
#606: updated todo
breki Oct 18, 2020
9d79238
#606: merge from master
breki Oct 24, 2020
7cf6b45
Merge remote-tracking branch 'origin/issues/606' into issues/606
breki Oct 24, 2020
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
9 changes: 9 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# TODO

- https://github.com/sledilnik/website/issues/606
- calculate doubling time of active cases
- use this value to show the projection
- show previous week, current, next 7, 14 days


- https://github.com/sledilnik/website/issues/606


## New countries chart
- deaths per cases (windowed, averaged)

Expand Down
2 changes: 1 addition & 1 deletion src/locales/sl.json
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@
"oneDay": "En dan",
"oneWeek": "En teden",
"oneMonth": "En mesec",
"ifExpGrowth": "Če bi primeri naraščali eksponentno s podvajanjem na 7 dni, potem bi lahko pričakovali:",
"ifExpGrowth": "Če bi se okužba širila eksponentno s takšnim podvajanjem, kot je sedaj (na {0} dni), potem bi lahko pričakovali:",
"today": "Danes",
"inOneWeek": "Čez en teden",
"inTwoWeeks": "Čez dva tedna",
Expand Down
92 changes: 61 additions & 31 deletions src/visualizations/EuropeMapChart.fs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ let greenCountries =
[
("AUS", "")
("NZL", "")
("SRB", "")
("URY", "")
]

Expand All @@ -141,7 +140,7 @@ let redCountries =
("AGO", "")
("ARG", "")
("ARM", "")
("AUT", "administrativne enote: Dunaj")
("AUT", "vse razen administrativne enote Koroška (Kärnten)")
("AZE", "")
("BAH", "")
("BHR", "")
Expand All @@ -150,7 +149,7 @@ let redCountries =
("BLZ", "")
("BLR", "")
("BEN", "")
("BGR", "administrativna enota: Blagoevgrad")
("BGR", "administrativna enota: Blagoevgrad, Rasgrad, Sliven, Sofia (mesto Sofija), Targovishte")
("BOL", "")
("BIH", "")
("BRA", "")
Expand All @@ -167,30 +166,34 @@ let redCountries =
("ECU", "")
("GNQ", "")
("ERI", "")
("EST", "administrativna enota: Ida-Viru")
("EST", "administrativna enota: Jogeva")
("SWZ", "")
("ETH", "")
("PHL", "")
("FRA", "vse administrativne enote razen Grand-Est; čezmorsko ozemlje: Francoska Gvajana, Guadeloupe, Sveti Martin, La Réunion")
("FIN", "administrativna enota: Österbotten")
("FRA", "vse administrativne enote celinske Francije, čezmorsko ozemlje: Francoska Gvajana, Guadeloupe, Sveti Martin, La Réunion, Martinique")
("GAB", "")
("GMB", "")
("GHA", "")
("GEO", "")
("GUY", "")
("GTM", "")
("GIN", "")
("GNB", "")
("HTI", "")
("HND", "")
("HRV", "administrativne enote: Brodsko-posavska, Dubrovniško-neretvanska, Liško-senjska, Požeško-slavonska, Splitsko-dalmatinska, Virovitiško-podravska")
("HRV", "administrativne enote: Bjelovarsko-bilogorska, Dubrovniško-neretvanska, Karlovška, Krapinsko-zagorska, Liško-senjska, Medžimurska, Osiješko-baranjska, Požeško-slavonska, Sisaško-moslavška, Splitsko-dalmatinska, Varaždinska, Virovitiško-podravska, Vukovarsko-sremska, Zagreb (celotna županija, vključno z mestom Zagreb)")
("IND", "")
("IDN", "")
("IRQ", "")
("IRN", "")
("IRL", "administrativna enota: Dublin, Cavan, Donegal, Leitrim, Monaghan, Sligo")
("IRL", "")
("ISL", "")
("ITA", "administrativne enote: Abruzzo, Valle d'Aosta, Campania, Emilia-Romagna, Friuli Venezia Giulia, Lazio, Liguria, Lombardia, Piedmont, Sardegna, Toscana, Umbria, Veneto, Provincia autonoma di Bolzano – Alto Adige")
("ISR", "")
("JAM", "")
("YEM", "")
("JOR", "")
("ZAF", "")
("SSD", "")
("CMR", "")
Expand All @@ -209,33 +212,35 @@ let redCountries =
("LBN", "")
("LBR", "")
("LBY", "")
("LTU", "administrativna enota: Šiaulių")
("LIE", "")
("LTU", "administrativna enota: Šiaulių, Kaunas")
("LUX", "")
("MDG", "")
("HUN", "administrativne enote: Budimpešta, Csongrád-Csanád, Győr-Moson-Sopron, Pest, Vas")
("HUN", "administrativne enote: Budimpešta, Baranya, Borsod-Abaúj-Zemplén, Csongrád-Csanád, Győr-Moson-Sopron, Pest, Hajdú-Bihar, Heves, Jász-Nagykun-Szolnok, Komárom-Esztergom, Nógrád, Pešta (Pest), Somogy, Szabolcs-Szatmár-Bereg, Vas, Veszprém, Zala")
("MWL", "")
("MDV", "")
("MLI", "")
("MLT", "")
("MAR", "")
("MRT", "")
("MEX", "")
("MDA", "")
("MNG", "")
("MOZ", "")
("NAM", "")
("NPL", "")
("NIG", "")
("NGA", "")
("NIC", "")
("NLD", "vse administrativna enote razen Zeeland in Limburg; čezmorsko ozemlje: Aruba, Saint Maarten")
("NLD", "")
("OMN", "")
("PAK", "")
("PAN", "")
("PNG", "")
("PRY", "")
("PER", "")
("PRT", "administrativna enota: Lizbona")
("ROU", "administrativne enote: Bacău, Bihor, Brăila, Brașov, Bukarešta, Caras Severin, Covasna, Neamt, Iasi, Ilfov, Prahova, Vâlcea, Vaslui")
("POL", "")
("PRT", "administrativna enota: Lizbona (Lisboa), Norte")
("ROU", "")
("RUS", "")
("SLV", "")
("STP", "")
Expand All @@ -246,15 +251,18 @@ let redCountries =
("SLE", "")
("SYR", "")
("CIV", "")
("SVK", "")
("SOM", "")
("CAF", "")
("SUR", "")
("ESP", "")
("CHE", "administrativne enote: Ženeva, Vaud")
("ESP", "vse administrativne enote razen Kanarski otoki (Islas Canarias)")
("SWE", "administrativne enote: Jämtland, Jönköping, Örebro, Östergötland, Stockholm, Uppsala")
("CHE", "")
("TJK", "")
("TZA", "")
("TGO", "")
("TTO", "")
("TUN", "")
("TUR", "")
("TKM", "")
("UKR", "")
Expand All @@ -264,8 +272,6 @@ let redCountries =
("ZMB", "")
("USA", "")
("ARE", "")
("GBR", "administrativna enota: Severna Irska, Severna Anglija, Severozahodna Anglija, Wales, Yorkshire in Humberside, Škotska; čezmorsko ozemlje Gibraltar")
("CPV", "")
("ZWE", "")
]

Expand Down Expand Up @@ -473,18 +479,18 @@ let mapData state =
match state.ChartType with
| TwoWeekIncidence ->
{| baseRec with
value = incidence100k
value = max (float incidence100k) 0.001
color = null
dataLabels = {| enabled = false |} |}
| Restrictions ->
{| baseRec with
value = cd.ImportedFrom
value = float cd.ImportedFrom
color = cd.RestrictionColor
dataLabels = {| enabled = cd.ImportedFrom > 0 |} |}
| _ ->
{| code = code
country = ""
value = 0
value = 0.1
color = null
dataLabels = {| enabled = false |}
incidence100k = 0
Expand All @@ -504,8 +510,8 @@ let renderMap state geoJson _ =
let enabled = state.ChartType = TwoWeekIncidence
{| enabled = enabled
title = {| text = null |}
align = "left"
verticalAlign = "bottom"
align = if state.MapToDisplay = World then "left" else "right"
verticalAlign = if state.MapToDisplay = World then "bottom" else "top"
layout = "vertical"
floating = true
borderWidth = 1
Expand All @@ -514,15 +520,39 @@ let renderMap state geoJson _ =
|> pojo

let colorAxis =
{| dataClassColor = "category"
dataClasses =
[| {| from = 0; color = "#ffffcc" |}
{| from = 25; color = "#feb24c" |}
{| from = 50; color = "#e31a1c" |}
{| from = 100; color = "#bd0026" |}
{| from = 200; color = "#800026" |}
{| from = 400; color = "#930044" |} |] |}
|> pojo
{|
``type`` =
match state.ChartType with
| TwoWeekIncidence -> "logarithmic"
| Restrictions -> "linear"
tickInterval = 0.4
max = 7000
min = 1
endOnTick = false
startOnTick = false
stops =
[|
(0.000,"#ffffff")
(0.001,"#fff7db")
(0.200,"#ffefb7")
(0.280,"#ffe792")
(0.360,"#ffdf6c")
(0.440,"#ffb74d")
(0.520,"#ff8d3c")
(0.600,"#f85d3a")
(0.680,"#ea1641")
(0.760,"#d0004e")
(0.840,"#ad005b")
(0.920,"#800066")
(0.999,"#43006e")
|]
reversed = true
labels =
{|
formatter = fun() -> jsThis?value
|} |> pojo
|} |> pojo


let tooltipFormatter jsThis =
let points = jsThis?point
Expand Down
5 changes: 0 additions & 5 deletions src/visualizations/Highcharts.fs
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,6 @@ let shadedWeekendPlotBands =
let showDoublingTimeFeatures =
true

// if set to true:
// - SpreadChart will show exponential growth pages
let showExpGrowthFeatures =
false

let addContainmentMeasuresFlags
(startDate: JsTimestamp)
(endDate: JsTimestamp option) =
Expand Down
27 changes: 12 additions & 15 deletions src/visualizations/MapChart.fs
Original file line number Diff line number Diff line change
Expand Up @@ -248,20 +248,17 @@ let seriesData (state : State) =

seq {
for areaData in state.Data do
let dlabel, value, absolute, value100k, totalConfirmed, weeklyIncrease, population, activeCasesValue, activeCasesMaxValue =
let dlabel, value, absolute, value100k, totalConfirmed, weeklyIncrease, population, newCases, newCasesMax =
match areaData.Cases with
| None -> None, 0.0001, 0, 0., 0, 0., areaData.Population, null, 0
| Some totalCases ->
let confirmedCasesValue = totalCases |> Seq.map (fun dp -> dp.TotalConfirmedCases) |> Seq.choose id |> Seq.toArray
let activeCasesValue =
let newCases =
confirmedCasesValue
|> Array.mapi (fun i cc ->
if i >= 14
then cc - confirmedCasesValue.[i-14]
else cc)
|> Array.mapi (fun i cc -> if i > 0 then cc - confirmedCasesValue.[i-1] else cc)
|> Array.skip (confirmedCasesValue.Length - 60) // we only show last 60 days
|> Seq.toArray
let activeCasesMaxValue = activeCasesValue |> Seq.max
let newCasesMax = newCases |> Seq.max
let deceasedValue = totalCases |> Seq.map (fun dp -> dp.TotalDeceasedCases) |> Seq.choose id |> Seq.toArray
let values =
match state.ContentType with
Expand Down Expand Up @@ -328,7 +325,7 @@ let seriesData (state : State) =
| 0 -> 0.
| x -> float x + Math.E |> Math.Log

dlabel, scaled, absolute, value100k, totalConfirmed.Value, weeklyIncrease, areaData.Population, activeCasesValue, activeCasesMaxValue
dlabel, scaled, absolute, value100k, totalConfirmed.Value, weeklyIncrease, areaData.Population, newCases, newCasesMax
{|
code = areaData.Code
area = areaData.Name
Expand All @@ -340,8 +337,8 @@ let seriesData (state : State) =
population = population
dlabel = dlabel
dataLabels = {| enabled = true; format = "{point.dlabel}" |}
activeCasesValue = activeCasesValue
activeCasesMaxValue = activeCasesMaxValue
newCases = newCases
newCasesMax = newCasesMax
|}
} |> Seq.toArray

Expand Down Expand Up @@ -382,8 +379,8 @@ let renderMap (state : State) =
let value100k = points?value100k
let totalConfirmed = points?totalConfirmed
let weeklyIncrease = points?weeklyIncrease
let activeCasesValue = points?activeCasesValue
let activeCasesMaxValue = points?activeCasesMaxValue
let newCases = points?newCases
let newCasesMax = points?newCasesMax
let population = points?population
let pctPopulation = float absolute * 100.0 / float population
let fmtStr = sprintf "%s: <b>%d</b>" (I18N.t "charts.map.populationC") population
Expand All @@ -393,12 +390,12 @@ let renderMap (state : State) =

s.Append "<p><div class='bars'>" |> ignore

match activeCasesValue with
match newCases with
| null -> null
| _ ->
activeCasesValue
newCases
|> Array.iter (fun area ->
let barHeight = Math.Ceiling(float area * float barMaxHeight / activeCasesMaxValue)
let barHeight = Math.Ceiling(float area * float barMaxHeight / newCasesMax)
let barHtml = sprintf "<div class='bar-wrapper'><div class='bar' style='height: %Apx'></div></div>" (int barHeight)
s.Append barHtml |> ignore)
s.Append "</div>" |> ignore
Expand Down
2 changes: 1 addition & 1 deletion src/visualizations/MunicipalitiesChart.fs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ let init (queryObj : obj) (data : RegionsData) : State * Cmd<Msg> =
if activeCases.IsSome && activeCases.Value >= 5
then
dp
|> Seq.map (fun dp -> {| Date = dp.Date ; Value = dp.ActiveCases |})
|> Seq.map (fun dp -> (dp.Date,dp.ActiveCases))
|> Seq.toList
|> Utils.findDoublingTime
else None
Expand Down
Loading