如何在 R 的 Highchart 图例中添加换行符?
How to add a line break in Highchart legend in R?
我做了一个组织结构图,我需要手动确定文本的换行符。
我正在使用 paste() 将文本与对象的值连接起来。但是休息不起作用。
仿照范例:
library(highcharter)
library(tidyverse)
value <- 1
highchart() %>%
hc_chart(type = 'organization') %>%
hc_add_series(
data = list(
list(from = 'A1', to = 'A2'),
list(from = 'A2', to = 'A3')),
nodes = list(
list(id = 'A1', name = paste("I need to break the text", value, sep="\n"))), #TEXT
nodeWidth = 150) # increasing the width of the box, to illustrate
不要使用 \n
,而是使用 html 标签 <br>
作为分隔符:
library(highcharter)
#> Registered S3 method overwritten by 'quantmod':
#> method from
#> as.zoo.data.frame zoo
library(tidyverse)
value <- 1
highchart() %>%
hc_chart(type = 'organization') %>%
hc_add_series(
data = list(
list(from = 'A1', to = 'A2'),
list(from = 'A2', to = 'A3')),
nodes = list(
list(id = 'A1', name = paste("I need to break the text", value, sep="<br>"))), #TEXT
nodeWidth = 150) # increasing the width of the box, to illustrate
我做了一个组织结构图,我需要手动确定文本的换行符。
我正在使用 paste() 将文本与对象的值连接起来。但是休息不起作用。
仿照范例:
library(highcharter)
library(tidyverse)
value <- 1
highchart() %>%
hc_chart(type = 'organization') %>%
hc_add_series(
data = list(
list(from = 'A1', to = 'A2'),
list(from = 'A2', to = 'A3')),
nodes = list(
list(id = 'A1', name = paste("I need to break the text", value, sep="\n"))), #TEXT
nodeWidth = 150) # increasing the width of the box, to illustrate
不要使用 \n
,而是使用 html 标签 <br>
作为分隔符:
library(highcharter)
#> Registered S3 method overwritten by 'quantmod':
#> method from
#> as.zoo.data.frame zoo
library(tidyverse)
value <- 1
highchart() %>%
hc_chart(type = 'organization') %>%
hc_add_series(
data = list(
list(from = 'A1', to = 'A2'),
list(from = 'A2', to = 'A3')),
nodes = list(
list(id = 'A1', name = paste("I need to break the text", value, sep="<br>"))), #TEXT
nodeWidth = 150) # increasing the width of the box, to illustrate