diff --git a/src/visualizations/App.fs b/src/visualizations/App.fs index ac54a5d77..b84ea1d0a 100644 --- a/src/visualizations/App.fs +++ b/src/visualizations/App.fs @@ -387,8 +387,15 @@ let render (state: State) (_: Msg -> unit) = ClassName = "deceased-chart" ChartTextsGroup = "deceased" Explicit = false - Renderer = fun _ -> DeceasedViz.Rendering.renderChart() - } + Renderer = + fun state -> + match state.StatsData with + | NotAsked -> Html.none + | Loading -> Utils.renderLoading + | Failure error -> Utils.renderErrorLoading error + | Success statsData -> + lazyView DeceasedViz.Rendering.renderChart statsData + } let countriesCasesPer1M = { VisualizationType = CountriesCasesPer1M @@ -532,7 +539,7 @@ let render (state: State) (_: Msg -> unit) = europeMap; sources cases; regionMap; regionsAbs phaseDiagram; spread; - infections; hCenters + infections; hCenters ] let worldVisualizations = diff --git a/src/visualizations/DeceasedViz/Rendering.fs b/src/visualizations/DeceasedViz/Rendering.fs index b33e2da20..a05811e46 100644 --- a/src/visualizations/DeceasedViz/Rendering.fs +++ b/src/visualizations/DeceasedViz/Rendering.fs @@ -11,6 +11,7 @@ open Fable.Core.JsInterop open Browser open Highcharts +open Types let availableDisplayMetrics = [| @@ -48,8 +49,9 @@ module Series = | DeceasedCare -> true, "#a483c7", "deceased-care" | DeceasedOther -> true, "#c59eef", "deceased-rest" -let init() : DeceasedVizState * Cmd = +let init(statsData : StatsData) : DeceasedVizState * Cmd = let state = { + StatsData = statsData PatientsData = [||] Metrics = availableDisplayMetrics.[0] RangeSelectionButtonIndex = 0 @@ -92,7 +94,7 @@ let tooltipFormatter jsThis = let renderChartOptions (state : DeceasedVizState) dispatch = let className = "cases-chart" - let scaleType = Types.ScaleType.Linear + let scaleType = ScaleType.Linear let renderSeries series = @@ -199,5 +201,5 @@ let render (state: DeceasedVizState) dispatch = renderMetricsSelectors state.Metrics (ChangeMetrics >> dispatch) ] -let renderChart() = - React.elmishComponent("CasesChart", init(), update, render) +let renderChart(statsData: StatsData) = + React.elmishComponent("CasesChart", init statsData, update, render) diff --git a/src/visualizations/DeceasedViz/Synthesis.fs b/src/visualizations/DeceasedViz/Synthesis.fs index 90f402085..8d447671f 100644 --- a/src/visualizations/DeceasedViz/Synthesis.fs +++ b/src/visualizations/DeceasedViz/Synthesis.fs @@ -2,8 +2,10 @@ open Data.Patients open DeceasedViz.Analysis +open Types type DeceasedVizState = { + StatsData: StatsData PatientsData : PatientsStats [] Metrics: DisplayMetrics RangeSelectionButtonIndex: int