Skip to content

Commit

Permalink
DeceasedViz now uses ChartType DU (#770)
Browse files Browse the repository at this point in the history
  • Loading branch information
breki committed Dec 24, 2020
1 parent 42a821f commit b7d2fae
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
1 change: 0 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# TODO

- https://github.com/sledilnik/website/issues/770
- move AgeGroupsTimeline analysis and synthesis code to a common namespace
- try to reuse code from AgeGroupsTimeline

- new OWID export
Expand Down
4 changes: 3 additions & 1 deletion src/visualizations/DeceasedViz/Analysis.fs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module DeceasedViz.Analysis

open DataVisualization.ChartingTypes

type DisplayMetricsType =
| HospitalsToDate
| HospitalsToday
Expand All @@ -9,7 +11,7 @@ type DisplayMetricsType =
type VisualizationPage = {
Id: string
MetricsType: DisplayMetricsType
ChartType: string
ChartType: ChartType
}

let (|HospitalMetricsType|_|) (metricsType: DisplayMetricsType) =
Expand Down
19 changes: 13 additions & 6 deletions src/visualizations/DeceasedViz/Rendering.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module DeceasedViz.Rendering

open System
open Data.Patients
open DataVisualization.ChartingTypes
open DeceasedViz.Analysis
open DeceasedViz.Synthesis
open Elmish
Expand All @@ -16,15 +17,15 @@ open Types

let availablePages = [|
{ Id = "deceasedToDate"
MetricsType = HospitalsToDate; ChartType = "normal" }
MetricsType = HospitalsToDate; ChartType = StackedBarNormal }
{ Id = "deceasedToDateRelative"
MetricsType = HospitalsToDate; ChartType = "percent" }
MetricsType = HospitalsToDate; ChartType = StackedBarPercent }
{ Id = "deceasedToday"
MetricsType = HospitalsToday; ChartType = "normal" }
MetricsType = HospitalsToday; ChartType = StackedBarNormal }
{ Id = "deceasedTodayRelative"
MetricsType = HospitalsToday; ChartType = "percent" }
MetricsType = HospitalsToday; ChartType = StackedBarPercent }
{ Id = "deceasedToDateByAge"
MetricsType = ByAgeToDate; ChartType = "percent" }
MetricsType = ByAgeToDate; ChartType = StackedBarPercent }
|]

type Msg =
Expand Down Expand Up @@ -86,6 +87,12 @@ let renderChartOptions (state : DeceasedVizState) dispatch =
true
res

let stacking =
match state.Page.ChartType with
| StackedBarNormal -> "normal"
| StackedBarPercent -> "percent"
| _ -> invalidOp "not supported"

let baseOptions =
basicChartOptions
scaleType className
Expand All @@ -100,7 +107,7 @@ let renderChartOptions (state : DeceasedVizState) dispatch =
groupPadding = 0
pointPadding = 0
borderWidth = 0 |}
series = {| stacking = state.Page.ChartType; crisp = true
series = {| stacking = stacking; crisp = true
borderWidth = 0
pointPadding = 0; groupPadding = 0
|}
Expand Down

0 comments on commit b7d2fae

Please sign in to comment.