簡體   English   中英

如何在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

在此處輸入圖片說明

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM