Skip to content

Commit

Permalink
[add] Heamap translation
Browse files Browse the repository at this point in the history
  • Loading branch information
swsoyee committed May 7, 2020
1 parent 50d01f8 commit 5c4d53e
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 23 deletions.
89 changes: 69 additions & 20 deletions 03_Components/Main/ConfirmedHeatmap.server.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# 日次都道府県別新規発生数 ====
output$confirmedHeatmap <- renderEcharts4r({
data <- melt(byDate, id.vars = "date")
data[variable %in% colnames(byDate)[2:48]] %>%
data <- data[variable %in% colnames(byDate)[2:48]]
data[, variable := sapply(as.character(variable), i18n$t)]
data %>%
e_chart(date) %>%
e_heatmap(variable, value, label = list(show = T, fontSize = 5)) %>%
e_visual_map(
Expand Down Expand Up @@ -30,20 +32,34 @@ output$confirmedHeatmap <- renderEcharts4r({
e_mark_line(
data = list(
xAxis = "2020-04-07",
label = list(formatter = i18n$t("4月7日\n緊急事態宣言"), position = "start")
label = list(
formatter = i18n$t("4月7日\n緊急事態宣言"),
position = "start"
)
),
lineStyle = list(opacity = 0.5),
silent = T,
symbol = "circle", symbolSize = 4
symbol = "circle",
symbolSize = 4
) %>%
e_grid(
right = "8%",
bottom = "15%",
left = "2%"
) %>%
e_grid(right = "8%", bottom = "15%", left = "2%") %>%
e_title(text = i18n$t("日次都道府県別新規発生数")) %>%
e_tooltip(formatter = htmlwidgets::JS("
e_tooltip(
formatter = htmlwidgets::JS(
"
function(params) {
console.log(params)
return(`${params.value[0]}<br>${params.value[1]}:${Math.round(params.value[2])}日`)
return(`${params.value[0]}<br>${params.value[1]}:${Math.round(params.value[2])}",
i18n$t(""),
"`)
}
"))
"
)
)
})

# 倍加時間の経時的変化====
Expand All @@ -56,19 +72,38 @@ output$confirmedHeatmapDoublingTime <- renderEcharts4r({
dt$date <- byDate$date

dt <- melt(dt, id.vars = "date")
dt[variable %in% colnames(byDate)[2:48]] %>%
dt <- dt[variable %in% colnames(byDate)[2:48]]
dt[, variable := sapply(as.character(variable), i18n$t)]
dt %>%
e_chart(date) %>%
e_heatmap(variable, value,
label = list(show = T, fontSize = 5, formatter = htmlwidgets::JS("
e_heatmap(
variable,
value,
label = list(
show = T,
fontSize = 5,
formatter = htmlwidgets::JS(
"
function(params) {
return(Math.round(Number(params.value[2])))
}
")),
"
)
),
itemStyle = list(borderWidth = 1, borderColor = "rgb(255, 255, 255, 0.2)")
) %>%
e_visual_map(
value,
inRange = list(color = c("white", darkRed, middleRed, middleYellow, lightYellow, "#F6F7FA")),
inRange = list(
color = c(
"white",
darkRed,
middleRed,
middleYellow,
lightYellow,
"#F6F7FA"
)
),
type = "piecewise",
splitList = list(
list(min = 12),
Expand All @@ -92,20 +127,34 @@ output$confirmedHeatmapDoublingTime <- renderEcharts4r({
e_mark_line(
data = list(
xAxis = "2020-04-07",
label = list(formatter = i18n$t("4月7日\n緊急事態宣言"), position = "start")
label = list(
formatter = i18n$t("4月7日\n緊急事態宣言"),
position = "start"
)
),
lineStyle = list(opacity = 0.5),
silent = T,
symbol = "circle", symbolSize = 4
symbol = "circle",
symbolSize = 4
) %>%
e_grid(
right = "8%",
bottom = "15%",
left = "2%"
) %>%
e_grid(right = "8%", bottom = "15%", left = "2%") %>%
e_title(text = sprintf(i18n$t("倍加時間の経時的変化(直近%s日間で計算)"), 7)) %>%
e_tooltip(formatter = htmlwidgets::JS("
e_tooltip(
formatter = htmlwidgets::JS(
"
function(params) {
console.log(params)
return(`${params.value[0]}<br>${params.value[1]}:${Math.round(params.value[2])}日`)
return(`${params.value[0]}<br>${params.value[1]}:${Math.round(params.value[2])}",
i18n$t(""),
"`)
}
"))
"
)
)
})

output$confirmedHeatmapWrapper <- renderUI({
Expand All @@ -119,9 +168,9 @@ output$confirmedHeatmapWrapper <- renderUI({
output$confirmedHeatmapDoublingTimeOptions <- renderUI({
if (input$confirmedHeatmapSelector == "confirmedHeatmapDoublingTime") {
tagList(
tags$p("日数の計算式は以下になります:"),
tags$p(i18n$t("日数の計算式は以下になります:")),
withMathJax("$$7log2 \\div log(\\frac{day_7N}{day_0N})$$"),
helpText("N:累積感染者数")
helpText(i18n$t("N:累積感染者数"))
)
}
})
4 changes: 2 additions & 2 deletions 04_Pages/Main/Main.ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ fluidPage(
inputId = "confirmedHeatmapSelector",
label = i18n$t("ヒートマップ選択"),
size = "sm", justified = T,
choices = list("日次新規" = "confirmedHeatmap",
"倍加時間" = "confirmedHeatmapDoublingTime"),
choiceNames = c(i18n$t("日次新規"), i18n$t("倍加時間")),
choiceValues = list("confirmedHeatmap", "confirmedHeatmapDoublingTime"),
status = "danger"
),
style = "margin-top:5px;"
Expand Down
22 changes: 21 additions & 1 deletion www/lang/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,29 @@
},
{
"ja": "倍加時間の経時的変化(直近%s日間で計算)",
"cn": "翻倍所需时间的变化趋势(以最近%s天间隔计算)",
"cn": "翻倍需时的变化趋势(以最近%s天间隔计算)",
"en": "Change in doubling time over time (calculated over the last %s days)"
},
{
"ja": "倍加時間",
"cn": "翻倍需时",
"en": "Doubling Time"
},
{
"ja": "日次新規",
"cn": "每日新增",
"en": "New daily"
},
{
"ja": "日数の計算式は以下になります:",
"cn": "天数计算方法如下式所示:",
"en": "The number of days is calculated by the following formula: "
},
{
"ja": "N:累積感染者数",
"cn": "N:累计确诊人数",
"en": "N: Cumulative number of infected"
},
{
"ja": "コールセンター(累計)",
"cn": "咨询热线(累计)",
Expand Down

0 comments on commit 5c4d53e

Please sign in to comment.