I am trying to create a simple semicircle donut using rCharts
and the NVD3
javascript library. A minimum reproducible example of a full donut is provided below.
library(rCharts)
data1 <- data.frame(label=c("A","B","C"), value=c("1000","2000","3000"))
n1 <- nPlot(value~label, data = data1, type = "pieChart")
n1$chart(donut=TRUE)
n1
My problem arises when I try to specify the startAngle
and endAngle
options as provided here in the NVD3 documentation, in order to convert this donut into a semicircle donut.
# This gives me a blank Viewer pane
n1$chart(donut=TRUE,
startAngle="#!function(d){return d.startAngle/2-Math.PI/2;}!#",
endAngle="#!function(d){return d.endAngle/2-Math.PI/2;}!#")
n1
Looking at code from this question, it appears that passing startAngle
and endAngle
to the n1$params$chart
may not be the right way to do this, although that is what I would expect based on the fact that donut=TRUE
works.
It is also possible that one of my callback functions has improper syntax - in my experience, this sort of problem can crash entire visualizations. However, I am fairly certain that I have used exactly the same callback function provided in the NVD3 documentation.