【问题标题】:Highchart Options (points' size) - R shinyHighchart 选项(点的大小) - R 闪亮
【发布时间】:2016-12-23 21:06:33
【问题描述】:

我是闪亮的新用户,并尝试通过库中提供的示例进行培训。 我在使用 highchart 选项时遇到了一些问题,我的绘图是一条带点的线,我想控制点的大小。

这是简化的代码:(使用“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)

##代码结束

我做了一些研究,发现您可以使用“标记”及其选项来控制大小。但是我的图表看起来完全独立于这个功能:我为标记尝试了几个宽度和半径值,它没有改变任何东西。

有人可以告诉我我做错了什么吗? 非常感谢您的帮助!

【问题讨论】:

    标签: javascript r highcharts shiny


    【解决方案1】:

    您好,您的图表是一条线,因此在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"
        )
      )
    )
    

    【讨论】:

    • 谢谢!完美运行! :) (抱歉耽搁了,我当天就回答了,但看起来我的回答没有被考虑)
    猜你喜欢
    • 2018-04-03
    • 2014-07-06
    • 1970-01-01
    • 2019-09-27
    • 1970-01-01
    • 1970-01-01
    • 2016-10-12
    • 1970-01-01
    • 2018-02-08
    相关资源
    最近更新 更多