Skip to content

Commit

Permalink
Introducing StatsData to the Deceased chart (#770)
Browse files Browse the repository at this point in the history
  • Loading branch information
breki committed Dec 22, 2020
1 parent 471cc77 commit e830cf6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
13 changes: 10 additions & 3 deletions src/visualizations/App.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -532,7 +539,7 @@ let render (state: State) (_: Msg -> unit) =
europeMap; sources
cases; regionMap; regionsAbs
phaseDiagram; spread;
infections; hCenters
infections; hCenters
]

let worldVisualizations =
Expand Down
10 changes: 6 additions & 4 deletions src/visualizations/DeceasedViz/Rendering.fs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ open Fable.Core.JsInterop
open Browser

open Highcharts
open Types


let availableDisplayMetrics = [|
Expand Down Expand Up @@ -48,8 +49,9 @@ module Series =
| DeceasedCare -> true, "#a483c7", "deceased-care"
| DeceasedOther -> true, "#c59eef", "deceased-rest"

let init() : DeceasedVizState * Cmd<Msg> =
let init(statsData : StatsData) : DeceasedVizState * Cmd<Msg> =
let state = {
StatsData = statsData
PatientsData = [||]
Metrics = availableDisplayMetrics.[0]
RangeSelectionButtonIndex = 0
Expand Down Expand Up @@ -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 =

Expand Down Expand Up @@ -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)
2 changes: 2 additions & 0 deletions src/visualizations/DeceasedViz/Synthesis.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

open Data.Patients
open DeceasedViz.Analysis
open Types

type DeceasedVizState = {
StatsData: StatsData
PatientsData : PatientsStats []
Metrics: DisplayMetrics
RangeSelectionButtonIndex: int
Expand Down

0 comments on commit e830cf6

Please sign in to comment.