Reputation: 83
The problem I'm trying to solve using highcharter is exactly the same as the one described in this issue.
I have a half-donut chart whose container takes as much space as the whole circle of the pie would take if it existed, and I want to resize it to just cover the space actually being rendered as a half-donut in order to put other elements below it.
In the demo posted as solution to the original problem (link here). A callback function is used that calls the setSize
method of the Highcharts.Chart
object (link to the method here).
Is there any way to describe an equivalent functionality using highcharter?
Thanks in advance!
Upvotes: 0
Views: 138
Reputation: 884
It's best to do it with chart.events.load, then you can write your JS function there: https://api.highcharts.com/highcharts/chart.events.load
Here you can see how to do it:
library('highcharter')
highchart() %>%
hc_add_series(
type = "pie",
innerSize = '50%',
startAngle = -90,
endAngle = 90,
size = '150%',
dataLabels = list(enabled = FALSE),
data = list(5, 4, 3, 5)
) %>%
hc_chart(events = list(load = JS("function() {
var chart = this;
chart.setSize(chart.plotSizeX, chart.plotSizeX - 700);
}")))
Upvotes: 3