条件y轴标签取决于输入

时间:2015-08-24 19:04:08

标签: shiny dygraphs

我正在尝试根据输入更改y轴标签。我正在使用dygraphs和Shiny。我的猜测是input$type不正确,但我不确定......感谢任何帮助!

if (input$type== 'Power'){
  dygraph(TempData, main = "Battery Data") %>%
  dyAxis("y", label = "Watts")
}
if (input$type== 'Current'){
  dygraph(TempData, main = "Battery Data") %>%
  dyAxis("y", label = "Amps")
  }
dygraph(TempData, main = "Temperature") %>%
dyAxis("y", label = "Temp (C)")


  })

})

1 个答案:

答案 0 :(得分:0)

Solved!  The fix is below:

      if (colnames(Data1xts$Watts) == "Watts"){
        dygraph(TempData, main = "Battery Data") %>%
        dyAxis("y", label = "Watts (W)")
      }
    if (colnames(Data1xts$Volts) == "Volts"){
      dygraph(TempData, main = "Battery Data") %>%
      dyAxis("y", label = "Volts (V)")
    }
    else 
      dygraph(TempData, main = "Battery Data") %>%
      dyAxis("y", label = "Temp (C)")

  })

})