Skip to content

Commit

Permalink
Fixing tooltips for the age groups pages (#770)
Browse files Browse the repository at this point in the history
  • Loading branch information
breki committed Dec 30, 2020
1 parent f6267ef commit 22a6aa5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
3 changes: 1 addition & 2 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

- https://github.com/sledilnik/website/issues/770
- try using different colors
- using color mixing function
- tooltips
- using color transition from one color to another

- new OWID export
- return back the official URL, once it has been pushed to production
Expand Down
8 changes: 5 additions & 3 deletions src/visualizations/DeceasedViz/Rendering.fs
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,17 @@ let update (msg: Msg) (state: DeceasedVizState) : DeceasedVizState * Cmd<Msg> =

let tooltipFormatter jsThis =
let pts: obj [] = jsThis?points
let total = pts |> Array.map (fun p -> p?point?y |> Utils.optionToInt) |> Array.sum
let fmtDate = pts.[0]?point?fmtDate
let total =
pts |> Array.map (fun p -> p?point?y |> Utils.optionToInt) |> Array.sum
let fmtDate = pts.[0]?point?date

fmtDate
+ "<br>"
+ (pts
|> Seq.map (fun p ->
sprintf """<span style="color:%s">●</span> %s: <b>%s</b>"""
p?series?color p?series?name (I18N.NumberFormat.formatNumber(p?point?y : float)))
p?series?color p?series?name
(I18N.NumberFormat.formatNumber(p?point?y : float)))
|> String.concat "<br>")
+ sprintf """<br><br><span style="color: rgba(0,0,0,0)">●</span> %s: <b>%s</b>"""
(I18N.t "charts.deceased.deceased-total")
Expand Down
6 changes: 3 additions & 3 deletions src/visualizations/DeceasedViz/Synthesis.fs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ let getHospitalsPointTotalValue state series dataPoint : int option =
| _ -> invalidOp "bug"
| _ -> invalidOp "bug"

let constructSeriesData state series =
let constructHospitalsSeriesData state series =
match series.SeriesType with
| HospitalSeriesType ->
state.PatientsData
Expand All @@ -97,7 +97,7 @@ let constructSeriesData state series =
x = dataPoint.Date |> jsTime12h
y = getHospitalsPointValue state series dataPoint
seriesId = series.SeriesId
fmtDate = I18N.tOptions "days.longerDate"
date = I18N.tOptions "days.longerDate"
{| date = dataPoint.Date |}
fmtTotal = getHospitalsPointTotalValue state series dataPoint
|> string
Expand Down Expand Up @@ -125,7 +125,7 @@ let renderAllHospitalSeriesData state =
visible = true
color = series.Color
name = I18N.tt "charts.deceased" series.SeriesId
data = constructSeriesData state series
data = constructHospitalsSeriesData state series
animation = false
|}
|> pojo
Expand Down

0 comments on commit 22a6aa5

Please sign in to comment.