@@ -53,6 +53,7 @@ let (|ConfirmedCasesMsgCase|DeceasedMsgCase|) str =
5353
5454type DisplayType =
5555 | AbsoluteValues
56+ | Bubbles
5657 | RegionPopulationWeightedValues
5758 | RelativeIncrease
5859with
6162 override this.ToString () =
6263 match this with
6364 | AbsoluteValues -> I18N.t " charts.map.absolute"
65+ | Bubbles -> I18N.t " charts.map.bubbles"
6466 | RegionPopulationWeightedValues -> I18N.t " charts.map.populationShare"
6567 | RelativeIncrease -> I18N.t " charts.map.relativeIncrease"
6668
@@ -329,6 +331,7 @@ let seriesData (state : State) =
329331 let dlabel , value =
330332 match state.DisplayType with
331333 | AbsoluteValues -> (( Some absolute) |> Utils.zeroToNone), absolute
334+ | Bubbles -> None, absolute
332335 | RegionPopulationWeightedValues -> None, 10. * value100k |> System.Math.Round |> int //factor 10 for better resolution in graph
333336 | RelativeIncrease -> None, absolute
334337 let weeklyIncrease =
@@ -352,6 +355,9 @@ let seriesData (state : State) =
352355 | AbsoluteValues ->
353356 if absolute > 0 then float absolute
354357 else 0.0001
358+ | Bubbles ->
359+ if absolute > 0 then float absolute
360+ else 0.0001
355361 | RegionPopulationWeightedValues ->
356362 if value100k > 0.0 then value100k
357363 else 0.0001
@@ -396,17 +402,47 @@ let renderMap (state : State) =
396402
397403 let series geoJson =
398404 {| visible = true
405+ `` type `` = null
406+ mapData = geoJson
407+ data = data
408+ keys = [| " code" ; " value" |]
409+ joinBy = [| key ; " code" |]
410+ colorKey = " value"
411+ nullColor = " white"
412+ borderColor = " #000"
413+ borderWidth = 0.2
414+ minSize = 1
415+ maxSize = " 6%"
416+ mapline = {| animation = {| duration = 0 |} |}
417+ states =
418+ {| normal = {| animation = {| duration = 0 |} |}
419+ hover = {| borderColor = " black" ; animation = {| duration = 0 |} |} |}
420+ colorAxis =
421+ match state.DisplayType with
422+ // white-ish background color for municipalities when we use
423+ // bubbles
424+ | Bubbles -> 1
425+ | _ -> 0
426+ |}
427+
428+ let bubbleSeries geoJson =
429+ {| visible = true
430+ `` type `` = " mapbubble"
399431 mapData = geoJson
400432 data = data
401433 keys = [| " code" ; " value" |]
402434 joinBy = [| key ; " code" |]
435+ colorKey = " value100k"
403436 nullColor = " white"
404437 borderColor = " #000"
405438 borderWidth = 0.2
439+ minSize = 1
440+ maxSize = " 10%"
406441 mapline = {| animation = {| duration = 0 |} |}
407442 states =
408443 {| normal = {| animation = {| duration = 0 |} |}
409444 hover = {| borderColor = " black" ; animation = {| duration = 0 |} |} |}
445+ colorAxis = 0
410446 |}
411447
412448 let sparklineFormatter newCases =
@@ -575,9 +611,48 @@ let renderMap (state : State) =
575611 let colorMin =
576612 match state.DisplayType with
577613 | AbsoluteValues -> 0.9
614+ | Bubbles -> colorMax / 7000.
578615 | RegionPopulationWeightedValues -> colorMax / 7000.
579616 | RelativeIncrease -> - 100.
580617
618+ let whiteMuniColorAxis =
619+ {|
620+ `` type `` = " linear"
621+ visible = false
622+ stops = [| ( 0.000 , " #f8f8f8" ) |]
623+ |} |> pojo
624+
625+ let relativeColorAxis =
626+ {|
627+ `` type `` = " logarithmic"
628+ tickInterval = 0.4
629+ max = colorMax
630+ min = colorMin
631+ endOnTick = false
632+ startOnTick = false
633+ stops =
634+ [|
635+ ( 0.000 , " #ffffff" )
636+ ( 0.001 , " #fff7db" )
637+ ( 0.200 , " #ffefb7" )
638+ ( 0.280 , " #ffe792" )
639+ ( 0.360 , " #ffdf6c" )
640+ ( 0.440 , " #ffb74d" )
641+ ( 0.520 , " #ff8d3c" )
642+ ( 0.600 , " #f85d3a" )
643+ ( 0.680 , " #ea1641" )
644+ ( 0.760 , " #d0004e" )
645+ ( 0.840 , " #ad005b" )
646+ ( 0.920 , " #800066" )
647+ ( 0.999 , " #43006e" )
648+ |]
649+ reversed = true
650+ labels =
651+ {|
652+ formatter = fun () -> jsThis?value
653+ |} |> pojo
654+ |} |> pojo
655+
581656 let colorAxis =
582657 match state.ContentType with
583658 | Deceased ->
@@ -634,36 +709,8 @@ let renderMap (state : State) =
634709 |} |> pojo
635710 |} |> pojo
636711
637- | RegionPopulationWeightedValues ->
638- {|
639- `` type `` = " logarithmic"
640- tickInterval = 0.4
641- max = colorMax
642- min = colorMin
643- endOnTick = false
644- startOnTick = false
645- stops =
646- [|
647- ( 0.000 , " #ffffff" )
648- ( 0.001 , " #fff7db" )
649- ( 0.200 , " #ffefb7" )
650- ( 0.280 , " #ffe792" )
651- ( 0.360 , " #ffdf6c" )
652- ( 0.440 , " #ffb74d" )
653- ( 0.520 , " #ff8d3c" )
654- ( 0.600 , " #f85d3a" )
655- ( 0.680 , " #ea1641" )
656- ( 0.760 , " #d0004e" )
657- ( 0.840 , " #ad005b" )
658- ( 0.920 , " #800066" )
659- ( 0.999 , " #43006e" )
660- |]
661- reversed = true
662- labels =
663- {|
664- formatter = fun () -> jsThis?value
665- |} |> pojo
666- |} |> pojo
712+ | Bubbles -> relativeColorAxis
713+ | RegionPopulationWeightedValues -> relativeColorAxis
667714 | RelativeIncrease ->
668715 {|
669716 `` type `` = " linear"
@@ -708,9 +755,14 @@ let renderMap (state : State) =
708755 {| Highcharts.optionsWithOnLoadEvent " covid19-map" with
709756 title = null
710757 subtitle = {| text = subtitle ; align= " left" ; verticalAlign= " bottom" |}
711- series = [| series geoJson |]
758+ series =
759+ match state.DisplayType with
760+ | Bubbles -> [| series geoJson; bubbleSeries geoJson |]
761+ | _ -> [| series geoJson |]
712762 legend = legend
713- colorAxis = colorAxis
763+ colorAxis = [|
764+ colorAxis; whiteMuniColorAxis
765+ |]
714766 tooltip =
715767 {|
716768 formatter = fun () -> tooltipFormatter state jsThis
@@ -753,7 +805,7 @@ let renderSelectors options currentOption dispatch =
753805let renderDisplayTypeSelector state dispatch =
754806 let selectors =
755807 if state.ContentType = ConfirmedCases && state.MapToDisplay <> MapToDisplay.SkopjeMunicipality
756- then [ RelativeIncrease; AbsoluteValues; RegionPopulationWeightedValues ]
808+ then [ RelativeIncrease; AbsoluteValues; RegionPopulationWeightedValues; Bubbles ]
757809 else [ AbsoluteValues; RegionPopulationWeightedValues ]
758810 Html.div [
759811 prop.className " chart-display-property-selector"
0 commit comments