我是shiny的新用户,并尝试通过库中提供的示例进行培训。 我在使用 highchart 选项时遇到一些问题,我的绘图是一 strip 有点的线,我想控制点的大小。
这是简化的代码:(使用“highchart”库、文件夹“demo”中的示例):
### 代码开始
library("shiny")
library("highcharter")
data(citytemp)
ui <- fluidPage(
h1("Highcharter Demo"),
fluidRow(
column(width = 4, class = "panel",
selectInput("type", label = "Type", width = "100%",
choices = c("line", "column", "bar", "spline")),
selectInput("stacked", label = "Stacked", width = "100%",
choices = c(FALSE, "normal", "percent")),
selectInput("theme", label = "Theme", width = "100%",
choices = c(FALSE, "fivethirtyeight", "economist", "darkunica", "gridlight",
"sandsignika", "null", "handdrwran", "chalk")
)
),
column(width = 8,
highchartOutput("hcontainer",height = "500px")
)
)
)
server = function(input, output) {
output$hcontainer <- renderHighchart({
hc <- highcharts_demo() %>%
hc_rm_series("Berlin") %>%
hc_chart(type = "line") %>%
hc_plotOptions(area = list(
stacking = input$stacked,
lineColor = "#ffffff",
lineWidth = 1,
marker = list(
lineWidth = 1,
radius=10,
lineColor = "#ffffff"
)))%>%
hc_tooltip(pointFormat = '<span style="color:{series.color}">{series.name}</span>:
<b>{point.percentage:.1f}%</b> ({point.y:,.0f} millions)<br/>',
shared = TRUE)
hc
})
}
shinyApp(ui = ui, server = server)
## 代码结束
我做了一些研究,发现您可以使用“标记”及其选项来控制大小。但我的图表看起来完全独立于此功能:我尝试了标记的几个宽度和半径值,但它没有改变任何内容。
有人可以告诉我我做错了什么吗? 非常感谢您的帮助!
最佳答案
您好,您的图表是一条线,因此在 hc_plotOptions
中您应该为一条线而不是一个区域设置选项,例如:
hc_plotOptions(
line = list( # put line here instead of area
stacking = input$stacked,
lineColor = "#ffffff",
lineWidth = 1,
marker = list(
lineWidth = 1,
radius=10,
lineColor = "#ffffff"
)
)
)
关于javascript - Highchart 选项(点大小)- R Shiny ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38992703/