Skip to content

Commit

Permalink
Redesigning the series data generation to be more suitable for age gr…
Browse files Browse the repository at this point in the history
…oups (#770)
  • Loading branch information
breki committed Dec 23, 2020
1 parent 48cfb2b commit 4aad574
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
2 changes: 2 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
- for age groups, we cannot have pre-determined list of series,
they should be based on the actual data - only those with actual
deceased should be present
- instead of exposing `pageSeries` function, we need a function that
generates _all_ of series data based on the `MetricsType`

- new OWID export
- return back the official URL, once it has been pushed to production
Expand Down
15 changes: 1 addition & 14 deletions src/visualizations/DeceasedViz/Rendering.fs
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,6 @@ let renderChartOptions (state : DeceasedVizState) dispatch =
let className = "cases-chart"
let scaleType = ScaleType.Linear

let renderSeriesData series =
{|
``type`` = "column"
visible = true
color = series.Color
name = I18N.tt "charts.deceased" series.SeriesId
data = constructSeriesData state series
|}
|> pojo

let allSeriesData =
pageSeries state |> Array.map renderSeriesData

let onRangeSelectorButtonClick(buttonIndex: int) =
let res (_ : Browser.Types.Event) =
RangeSelectionChanged buttonIndex |> dispatch
Expand All @@ -104,7 +91,7 @@ let renderChartOptions (state : DeceasedVizState) dispatch =
scaleType className
state.RangeSelectionButtonIndex onRangeSelectorButtonClick
{| baseOptions with
series = allSeriesData
series = renderAllSeriesData state
plotOptions = pojo
{|
column = pojo
Expand Down
21 changes: 18 additions & 3 deletions src/visualizations/DeceasedViz/Synthesis.fs
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,8 @@ let constructSeriesData state series =
|> Array.ofSeq
| AgeGroupSeriesType -> invalidOp "todo"

let pageSeries state =
match state.Page.MetricsType with
| HospitalMetricsType ->
let renderAllHospitalSeriesData state =
let hospitalSeries =
[|
{ SeriesType = DeceasedInIcu
SeriesId = "deceased-icu"; Color = "#6d5b80" }
Expand All @@ -118,5 +117,21 @@ let pageSeries state =
{ SeriesType = DeceasedOther
SeriesId = "deceased-rest"; Color = "#c59eef" }
|]

let renderSeriesData series =
{|
``type`` = "column"
visible = true
color = series.Color
name = I18N.tt "charts.deceased" series.SeriesId
data = constructSeriesData state series
|}
|> pojo

hospitalSeries |> Array.map renderSeriesData

let renderAllSeriesData state =
match state.Page.MetricsType with
| HospitalMetricsType -> renderAllHospitalSeriesData state
| AgeGroupsMetricsType -> invalidOp "todo"
| _ -> invalidOp "todo"

0 comments on commit 4aad574

Please sign in to comment.