R Language Pack Translation--translation

Source: Internet
Author: User

Shiny-cheatsheet

Jiahui works from: Baidu Encyclopedia

. Cool Look Skin Skins

The dashboard includes many themes or skins. The default is Blue blue, in addition, there are other colors, including: Black ,purple purple,green Green, Red ,yellow , yellow and so on. It can be set using dashboardpage (skin = "Blue"), dashboardpage (skin = "BLACK"), and so on.

UI <-dashboardpage (skin = "BLACK",

Dashboardheader (title = "Value boxes"),

Dashboardsidebar (),

Dashboardbody ()

)

Logoff Panels logout panel

( This requires shinydashboard 0.5.1 or a later version to display.) before the shinydashboard app runs the shiny server, an authenticated user is required to log on , The panel displays the user name and logout link in the upper-right corner.

The Logout panel integrates better with Shinydashboard . As you can see in the above , the default logoff panel section obscures the drop-down menu icon. We can add a user panel with dynamic UI ( generated on the server ) and hide the default logout panel , as shown below :

Program:

Library (Shiny)

Library (Shinydashboard)

Library (HTTR)

Library (Jsonlite)

Library (data.table)

Library (DPLYR)

Library (Rvest)

Library (MAGRITTR)

UI <-Dashboardpage (

Dashboardheader (

title = "SSP Logout",

Dropdownmenu (type = "Messages", Badgestatus = "Success",

Messageitem ("Message 1", "Content of a Message.")

)

),

Dashboardsidebar (

# Custom CSS to hide the default logout panel

Tags$head (Tags$style (HTML ('. shiny-server-account {display:none;} ')),

# The Dynamically-generated user panel

Uioutput ("Userpanel"),

Sidebarmenu (

MenuItem ("menu item 1", Icon = Shiny::icon ("Calendar"))

)

),

Dashboardbody ()

)

Server <-function (input, output, session) {

# Generate The dynamic UI for the logout panel

Output$userpanel <-Renderui ({

# Session$user is non-null only in authenticated sessions

if (!is.null (Session$user)) {

Sidebaruserpanel (

Span ("Logged in as", Session$user),

Subtitle = A (Icon ("Sign-out"), "Logout", href= "__logout__"))

}

})

}

Shinyapp (UI, Server)

Other programs:

Library (Shiny)

Library (Shinydashboard)

Library (HTTR)

Library (Jsonlite)

Library (data.table)

Library (DPLYR)

Library (Rvest)

Library (MAGRITTR)

Header <-Dashboardheader (title= "CYBER Dashboard")

Sidebar <-Dashboardsidebar ()

Body <-Dashboardbody (

Fluidpage (

Fluidrow (

A (href= "http://isc.sans.org/",

Target= "_blank", Uioutput ("Infocon")),

A (href= "http://www.symantec.com/security_response/threatcon/",

Target= "_blank", Uioutput ("Threatcon")),

A (href= "http://webapp.iss.net/gtoc/",

Target= "_blank", Uioutput ("Alertcon"))

)

)

)

UI <-Dashboardpage (header, sidebar, body, skin= "black")

Server <-function (input, output) {

Output$infocon <-Renderui ({

Infocon_url <-"Https://isc.sans.edu/api/infocon?json"

Infocon <-Fromjson (Content (GET (infocon_url)))

Valuebox (

Value= "Yellow",

subtitle= "SANS Infocon",

Icon=icon ("Bullseye"),

Color=ifelse (infocon$status== "test", "Blue", Infocon$status)

)

})

Output$threatcon <-Renderui ({

PG <-HTML ("http://www.symantec.com/security_response/#")

PG%>%

Html_nodes ("Div.colcontentthreatcon > A")%>%

Html_text ()%>%

Extract (1), Threatcon_text

Tcon_map <-C ("Green", "yellow", "orange", "Red")

Names (Tcon_map) <-C (' Level 1 ', ' Level 2 ', ' Level 3 ', ' Level 4 ')

Threatcon_color <-Unname (Tcon_map[gsub (":. *$", "", Threatcon_text)])

Threatcon_text <-gsub ("^.*:", "", Threatcon_text)

Valuebox (

Value=threatcon_text,

subtitle= "Symantec Threatcon",

Icon=icon ("Tachometer"),

Color=threatcon_color

)

})

Output$alertcon <-Renderui ({

PG <-HTML ("http://xforce.iss.net/")

PG%>%

Html_nodes (xpath= "//td[@class = ' newsevents ']/p")%>%

Html_text ()%>%

Gsub ("-.*$", "",.) Alertcon_text

Acon_map <-C ("Green", "blue", "yellow", "red")

Names (Acon_map) <-C ("Alertcon 1", "Alertcon 2", "Alertcon 3", "Alertcon 4")

Alertcon_color <-unname (Acon_map[alertcon_text])

Valuebox (

Value=alertcon_text,

subtitle= "IBM X-force",

Icon=icon ("Warning"),

Color=alertcon_color

)

})

}

Shinyapp (UI, Server)

CSS

You can add custom CSS to your apps by creating a www/subdirectory to your app and adding a CSS file there. Suppose, for example, your want to change the title font of your dashboard to the same font as the rest of the dashboard, s O that it looks like this:

To does this, first create a file named Www/custom.css with the following:

. Main-header. Logo {

font-family: "Georgia", Times, "Times New Roman", serif;

Font-weight:bold;

font-size:24px;

}

Then refer to, CSS file from the UI of the Your app:

# # UI. R # #

Dashboardpage (

Dashboardheader (title = "Custom font"),

Dashboardsidebar (),

Dashboardbody (

Tags$head (

Tags$link (rel = "stylesheet", type = "Text/css", href = "custom.css")

)

)

)

A second-to-include CSS is-put it directly in the UI code for your app:

# # UI. R # #

Dashboardpage (

Dashboardheader (title = "Custom font"),

Dashboardsidebar (),

Dashboardbody (

Tags$head (Tags$style (HTML ('. Main-header. Logo {

font-family: "Georgia", Times, "Times New Roman", serif;

Font-weight:bold;

font-size:24px;

}

‘))) )

)

4.4 Long Title

In some cases, the title of this wish to use won ' t fit in the default width in the header bar. You can make the space for the title wider with the Titlewidth option. In this example, we've increased the width for the title to Pixels, and also set the background color of the title is A (using custom CSS) to be the same as the rest of the header bar.

Shinyapp (

UI = Dashboardpage (

Dashboardheader (

title = "Example of a long title that needs more space",

Titlewidth = 450

),

Dashboardsidebar (),

Dashboardbody (

# Also Add some custom CSS to make the title background area the same

# Color as the rest of the header.

Tags$head (Tags$style (HTML ('. Skin-blue. Main-header. Logo {

}

. skin-blue. Main-header. logo:hover {

Background-color: #3c8dbc;

}

‘))) )

),

Server = function (input, output) {}

)

side bar width Sidebar width

The width of the sidebar, you can use the width option. This example has a wider title and sidebar:

Shinyapp (

UI = Dashboardpage (

Dashboardheader (

title = "title and sidebar pixels wide",

Titlewidth = 350

),

Dashboardsidebar (

width = 350,

Sidebarmenu (

MenuItem ("Menu Item")

)

),

Dashboardbody ()

),

Server = function (input, output) {}

)

R Language Pack Translation--translation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.