根据所选输入显示图形

问题描述

我想根据第一个选项卡中的选择输入,在另一个选项卡中显示图形。

对于“自动”,我想在TAB B中显示一个图形(名为“ graph_auto”),如果选择了“ boat”,我想在TAB B中显示一个图形(名为“ graph_boat”)。我做到了:

 public function addCustomer(Request $request) {
    $userManager = new UserManager();
    
    $userName=$request->input('customerName');
    $phoneNumber=$request->input('phoneNumber');
    $address=$request->input('address');
    $email=$request->input('email');
    $password="customer";
    
    $userManager->addCustomer($userName,$phoneNumber,$address,$email,$password);
}

但是我被迫根据所选产品显示图形。我们如何从另一个选项卡访问选定的输入?一些帮助将不胜感激

解决方法

这是您要记住的吗(请注意,第一个情节不起作用)?

---
title: "my report"

output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
    social: menu

runtime: shiny
---


```{r setup,include=FALSE}
library(htmltools)
library(flextable)
library(plotly)



my_data = data.frame(product = rep(c("auto","boat"),each=2),year = c("2009","2011","2005","2019"),price = c("10 000","20 000","7 000","60 000"),speed = c("220","250","70","140"))
```


RESULTS
=======================================================================


Column
-----------------------------------------------------------------------

### TAB A

```{r}
selectInput("product","",choices = my_data$product)

renderUI({
  out <- subset(my_data,product ==input$product)
  htmltools_value((flextable(out)))
})
```


Column 
-----------------------------------------------------------------------

### TAB B
```{r}
# if "auto" is selected,then display this graphic
renderPlotly({
  if (input$product == "auto") {
    plot_ly(midwest,x = ~percollege,color = ~state,type = "box")
  }
  # if "boat" is selected,then display this graphic
  if (input$product == "boat") {
    plot_ly(midwest,type = "box",width = 600,height = 400)
  }
})
```

您实际上不需要在flexdashboard中包含闪亮应用程序的结构,而只需在单个UI / render元素中包含。看看the help page

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...