在 highchart R 中更改 Fontsize 和 boxsize
Change Fontsize and boxsize in highchart R
我正在尝试创建一个自动化的组织结构图。
但它是不可读的。我想更改字体大小和框的大小
代码如下
pl <- highchart() %>%
hc_chart(type = 'organization') %>%
hc_title(text = 'Klarna ownership structure')%>%
hc_caption(text = 'Ownership from left to right')%>%
hc_add_series(
data = list(
list(from = 'Klarna Holding AB Sweden', to = 'Klarna Runway AB Sweden', weight = 1),
list(from = 'Klarna Runway AB Sweden', to = 'Toplooks LCC USA', weight = 1),
list(from = 'Klarna Holding AB Sweden', to = 'Larkan Holding AB Sweden', weight = 1),
list(from = 'Larkan Holding AB Sweden', to = 'Larkan AB', weight = 1),
list(from = 'Larkan Holding AB Sweden', to = 'Klarna Midco AB Sweden', weight = 1),
list(from = 'Klarna Holding AB Sweden', to = 'Klarna Midco AB Sweden', weight = 1),
list(from = 'Larkan AB', to = 'Klarna Bank AB Sweden', weight = 1),
list(from = 'Klarna Midco AB Sweden', to = 'Klarna Bank AB Sweden', weight = 1),
list(from = 'SEQUOIA CAPITAL United Kingdom', to = 'Klarna Holding AB Sweden', weight = 1),
list(from = 'Silver Lake Partners USA', to = 'Klarna Holding AB Sweden', weight = 1),
list(from = 'Bestseller Group Denmark', to = 'Klarna Holding AB Sweden', weight = 1),
list(from = 'Dragoneer USA', to = 'Klarna Holding AB Sweden', weight = 1),
list(from = 'Permira UK', to = 'Klarna Holding AB Sweden', weight = 1),
list(from = 'Visa USA', to = 'Klarna Holding AB Sweden', weight = 1),
list(from = 'Atomico UK', to = 'Klarna Holding AB Sweden', weight = 1),
list(from = 'Klarna Bank AB Sweden', to = 'Analyzd Technologies Ltd Cyprus', weight = 1),
list(from = 'Klarna Bank AB Sweden', to = 'Ident Inkasso AB Sweden', weight = 1),
list(from = 'Klarna Bank AB Sweden', to = 'Klarna Australia Holding Pty Ltd Australia', weight = 1),
list(from = 'Klarna Bank AB Sweden', to = 'Klarna Austria GmbH Austria', weight = 1),
list(from = 'Klarna Bank AB Sweden', to = 'Klarna Belgium N.V Belgium', weight = 1),
list(from = 'Klarna Bank AB Sweden', to = 'Klarna B.V. The Netherlands', weight = 1),
list(from = 'Klarna Bank AB Sweden', to = 'Klarna Germany Holding GmbH Germany', weight = 1),
list(from = 'Klarna Bank AB Sweden', to = 'Klarna GmbH Germany', weight = 1),
list(from = 'Klarna Bank AB Sweden', to = 'Klarna Inc The United States', weight = 1),
list(from = 'Klarna Bank AB Sweden', to = 'Klarna Italy S.r.l. Italy', weight = 1),
list(from = 'Klarna Bank AB Sweden', to = 'Klarna Norge AS Norway', weight = 1),
list(from = 'Klarna Bank AB Sweden', to = 'Klarna Oy Finland', weight = 1),
list(from = 'Klarna Bank AB Sweden', to = 'Klarna Spain S.L. Spain', weight = 1),
list(from = 'Klarna Bank AB Sweden', to = 'Klarna UK Limited UK', weight = 1),
list(from = 'Klarna Bank AB Sweden', to = 'Search Engine Marketing Sweden AB Sweden', weight = 1),
list(from = 'Klarna Bank AB Sweden', to = 'BillPay GmbH Germany', weight = 1),
list(from = 'Klarna Germany Holding GmbH Germany', to = 'Sofort GmbH', weight = 1),
list(from = 'Klarna Australia Holding Pty Ltd Australia', to = 'Klarna Australia Pty Ltd Australia', weight = 1),
list(from = 'Klarna Australia Holding Pty Ltd Australia', to = 'Klarna New Zealand Ltd New Zealand', weight = 1),
list(from = 'Analyzd Technologies Ltd Cyprus', to = 'Klarna Ltd ?', weight = 1)
))%>%
hc_theme(hc_theme_ft())
pl
如何更改字体大小和方框大小?
试图 google 它但它总是 java 或其他东西,我无法将它正确转换为 R.
问候克里斯蒂安
您可以将 JavaScript 代码包装在 R 中以使用 Highcharts JS API 来实现该目的。您可以在此处找到解释如何执行此操作的文章:https://www.highcharts.com/blog/tutorials/working-with-highcharts-javascript-syntax-in-r/?fbclid=IwAR1AipximplJVYVQbBerc2nu7xDe3Vn7o4HOtmPMU_Ntrzf4SgLyNtc9KVk
然后使用 dataLabels.style.fontSize 选项更改文本大小:
https://api.highcharts.com/highcharts/series.organization.dataLabels.style.fontSize
关于更改节点的高度,这里是一个附加选项,如高度。请看我在下面的演示中所做的:
library(highcharter)
highchart() %>%
hc_chart(type = 'organization') %>%
hc_add_series(
data = list(
list(from = 'Brazil', to = 'Portugal'),
list(from = 'Brazil', to = 'Spain'),
list(from = 'Poland', to = 'England'))
) %>%
hc_chart(events = list(load = JS("function() {
var chart = this;
chart.update({
chart: {
backgroundColor: '#FCFFC5'
},
plotOptions: {
series: {
dataLabels: {
style: {
fontSize: '6px'
}
},
nodes: [{
id: 'Brazil',
height: 20
}]
}
}
})
}
")
))
我正在尝试创建一个自动化的组织结构图。 但它是不可读的。我想更改字体大小和框的大小
代码如下
pl <- highchart() %>%
hc_chart(type = 'organization') %>%
hc_title(text = 'Klarna ownership structure')%>%
hc_caption(text = 'Ownership from left to right')%>%
hc_add_series(
data = list(
list(from = 'Klarna Holding AB Sweden', to = 'Klarna Runway AB Sweden', weight = 1),
list(from = 'Klarna Runway AB Sweden', to = 'Toplooks LCC USA', weight = 1),
list(from = 'Klarna Holding AB Sweden', to = 'Larkan Holding AB Sweden', weight = 1),
list(from = 'Larkan Holding AB Sweden', to = 'Larkan AB', weight = 1),
list(from = 'Larkan Holding AB Sweden', to = 'Klarna Midco AB Sweden', weight = 1),
list(from = 'Klarna Holding AB Sweden', to = 'Klarna Midco AB Sweden', weight = 1),
list(from = 'Larkan AB', to = 'Klarna Bank AB Sweden', weight = 1),
list(from = 'Klarna Midco AB Sweden', to = 'Klarna Bank AB Sweden', weight = 1),
list(from = 'SEQUOIA CAPITAL United Kingdom', to = 'Klarna Holding AB Sweden', weight = 1),
list(from = 'Silver Lake Partners USA', to = 'Klarna Holding AB Sweden', weight = 1),
list(from = 'Bestseller Group Denmark', to = 'Klarna Holding AB Sweden', weight = 1),
list(from = 'Dragoneer USA', to = 'Klarna Holding AB Sweden', weight = 1),
list(from = 'Permira UK', to = 'Klarna Holding AB Sweden', weight = 1),
list(from = 'Visa USA', to = 'Klarna Holding AB Sweden', weight = 1),
list(from = 'Atomico UK', to = 'Klarna Holding AB Sweden', weight = 1),
list(from = 'Klarna Bank AB Sweden', to = 'Analyzd Technologies Ltd Cyprus', weight = 1),
list(from = 'Klarna Bank AB Sweden', to = 'Ident Inkasso AB Sweden', weight = 1),
list(from = 'Klarna Bank AB Sweden', to = 'Klarna Australia Holding Pty Ltd Australia', weight = 1),
list(from = 'Klarna Bank AB Sweden', to = 'Klarna Austria GmbH Austria', weight = 1),
list(from = 'Klarna Bank AB Sweden', to = 'Klarna Belgium N.V Belgium', weight = 1),
list(from = 'Klarna Bank AB Sweden', to = 'Klarna B.V. The Netherlands', weight = 1),
list(from = 'Klarna Bank AB Sweden', to = 'Klarna Germany Holding GmbH Germany', weight = 1),
list(from = 'Klarna Bank AB Sweden', to = 'Klarna GmbH Germany', weight = 1),
list(from = 'Klarna Bank AB Sweden', to = 'Klarna Inc The United States', weight = 1),
list(from = 'Klarna Bank AB Sweden', to = 'Klarna Italy S.r.l. Italy', weight = 1),
list(from = 'Klarna Bank AB Sweden', to = 'Klarna Norge AS Norway', weight = 1),
list(from = 'Klarna Bank AB Sweden', to = 'Klarna Oy Finland', weight = 1),
list(from = 'Klarna Bank AB Sweden', to = 'Klarna Spain S.L. Spain', weight = 1),
list(from = 'Klarna Bank AB Sweden', to = 'Klarna UK Limited UK', weight = 1),
list(from = 'Klarna Bank AB Sweden', to = 'Search Engine Marketing Sweden AB Sweden', weight = 1),
list(from = 'Klarna Bank AB Sweden', to = 'BillPay GmbH Germany', weight = 1),
list(from = 'Klarna Germany Holding GmbH Germany', to = 'Sofort GmbH', weight = 1),
list(from = 'Klarna Australia Holding Pty Ltd Australia', to = 'Klarna Australia Pty Ltd Australia', weight = 1),
list(from = 'Klarna Australia Holding Pty Ltd Australia', to = 'Klarna New Zealand Ltd New Zealand', weight = 1),
list(from = 'Analyzd Technologies Ltd Cyprus', to = 'Klarna Ltd ?', weight = 1)
))%>%
hc_theme(hc_theme_ft())
pl
如何更改字体大小和方框大小? 试图 google 它但它总是 java 或其他东西,我无法将它正确转换为 R.
问候克里斯蒂安
您可以将 JavaScript 代码包装在 R 中以使用 Highcharts JS API 来实现该目的。您可以在此处找到解释如何执行此操作的文章:https://www.highcharts.com/blog/tutorials/working-with-highcharts-javascript-syntax-in-r/?fbclid=IwAR1AipximplJVYVQbBerc2nu7xDe3Vn7o4HOtmPMU_Ntrzf4SgLyNtc9KVk
然后使用 dataLabels.style.fontSize 选项更改文本大小: https://api.highcharts.com/highcharts/series.organization.dataLabels.style.fontSize
关于更改节点的高度,这里是一个附加选项,如高度。请看我在下面的演示中所做的:
library(highcharter)
highchart() %>%
hc_chart(type = 'organization') %>%
hc_add_series(
data = list(
list(from = 'Brazil', to = 'Portugal'),
list(from = 'Brazil', to = 'Spain'),
list(from = 'Poland', to = 'England'))
) %>%
hc_chart(events = list(load = JS("function() {
var chart = this;
chart.update({
chart: {
backgroundColor: '#FCFFC5'
},
plotOptions: {
series: {
dataLabels: {
style: {
fontSize: '6px'
}
},
nodes: [{
id: 'Brazil',
height: 20
}]
}
}
})
}
")
))