forked from plotly/documentation
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
892d7c9
commit 08ee0d4
Showing
5 changed files
with
477 additions
and
36 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
.../plotly_js/layout/3d-surface-lighting/2018-11-21-3d_surface_lighting_plotly_js_index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 4 additions & 32 deletions
36
_posts/python/javascript-controls/figureWidgets/slider-widget.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,206 @@ | ||
--- | ||
title: Tables in R | Examples | Plotly | ||
name: Tables | ||
permalink: r/table/ | ||
description: How to make tables in R with Plotly. | ||
layout: base | ||
thumbnail: thumbnail/table.gif | ||
language: r | ||
has_thumbnail: true | ||
display_as: basic | ||
order: 7.1 | ||
output: | ||
html_document: | ||
keep_md: true | ||
--- | ||
|
||
```{r, echo = FALSE, message=FALSE} | ||
knitr::opts_chunk$set(message = FALSE, warning=FALSE) | ||
Sys.setenv("plotly_username"="RPlotBot") | ||
Sys.setenv("plotly_api_key"="q0lz6r5efr") | ||
``` | ||
### New to Plotly? | ||
|
||
Plotly's R library is free and open source!<br> | ||
[Get started](https://plot.ly/r/getting-started/) by downloading the client and [reading the primer](https://plot.ly/r/getting-started/).<br> | ||
You can set up Plotly to work in [online](https://plot.ly/r/getting-started/#hosting-graphs-in-your-online-plotly-account) or [offline](https://plot.ly/r/offline/) mode.<br> | ||
We also have a quick-reference [cheatsheet](https://images.plot.ly/plotly-documentation/images/r_cheat_sheet.pdf) (new!) to help you get started! | ||
|
||
### Version Check | ||
|
||
Version 4 of Plotly's R package is now [available](https://plot.ly/r/getting-started/#installation)!<br> | ||
Check out [this post](http://moderndata.plot.ly/upgrading-to-plotly-4-0-and-above/) for more information on breaking changes and new features available in this version. | ||
```{r} | ||
library(plotly) | ||
packageVersion('plotly') | ||
``` | ||
|
||
### Basic Table | ||
|
||
```{r, results = 'hide'} | ||
library(plotly) | ||
p <- plot_ly( | ||
type = 'table', | ||
columnwidth = c(100, 100), | ||
columnorder = c(0, 1), | ||
header = list( | ||
values = list(list(c("Cut")), | ||
list(c("Price")) | ||
), | ||
align = c("center", "center"), | ||
line = list(width = 1, color = 'black'), | ||
fill = list(color = c("grey", "grey")), | ||
font = list(family = "Arial", size = 14, color = "white") | ||
), | ||
cells = list( | ||
values = list(c(diamonds$cut),c(diamonds$price)), | ||
align = c("center", "center"), | ||
line = list(color = "black", width = 1), | ||
font = list(family = "Arial", size = 12, color = c("black")) | ||
)) | ||
# Create a shareable link to your chart | ||
# Set up API credentials: https://plot.ly/r/getting-started | ||
chart_link = api_create(p, filename="table-basic") | ||
chart_link | ||
``` | ||
|
||
```{r, echo=FALSE} | ||
chart_link | ||
``` | ||
|
||
### Styled Table | ||
|
||
```{r, results = 'hide'} | ||
library(plotly) | ||
p <- plot_ly( | ||
type = 'table', | ||
header = list( | ||
values = list(list('<b>EXPENSES</b>'), | ||
list('<b>Q1</b>'), | ||
list('<b>Q2</b>'), | ||
list('<b>Q3</b>'), | ||
list('<b>Q4</b>')), | ||
line = list(color = '#506784'), | ||
fill = list(color = '#119DFF'), | ||
align = c('left','center'), | ||
font = list(color = 'white', size = 12) | ||
), | ||
cells = list( | ||
values = list( | ||
c('Salaries', 'Office', 'Merchandise', 'Legal', '<b>TOTAL</b>'), | ||
c(1200000, 20000, 80000, 2000, 12120000), | ||
c(1300000, 20000, 70000, 2000, 130902000), | ||
c(1300000, 20000, 120000, 2000, 131222000), | ||
c(1400000, 20000, 90000, 2000, 14102000)), | ||
line = list(color = '#506784'), | ||
fill = list(color = c('#25FEFD', 'white')), | ||
align = c('left', 'center'), | ||
font = list(color = c('#506784'), size = 12) | ||
)) | ||
# Create a shareable link to your chart | ||
# Set up API credentials: https://plot.ly/r/getting-started | ||
chart_link = api_create(p, filename="table-styled") | ||
chart_link | ||
``` | ||
|
||
```{r, echo=FALSE} | ||
chart_link | ||
``` | ||
|
||
### Table From a Dataframe | ||
|
||
```{r, results = 'hide'} | ||
library(plotly) | ||
headerValues <- list() | ||
for (i in (0:ncol(mtcars))) { | ||
name <- names(mtcars)[i] | ||
headerValues[i] <- name | ||
} | ||
headerValues <- append(headerValues, "<b>Cars</b>", after = 0) | ||
cellValues <- list() | ||
for (i in (0:ncol(mtcars))) { | ||
row <- mtcars[i] | ||
cellValues[i] <- row | ||
} | ||
cellValues <- append(cellValues, list(rownames(mtcars)), after = 0) | ||
p <- plot_ly( | ||
type = 'table', | ||
header = list( | ||
values = headerValues, | ||
align = c('left', rep('center', ncol(mtcars))), | ||
line = list(width = 1, color = 'black'), | ||
fill = list(color = 'rgb(235, 100, 230)'), | ||
font = list(family = "Arial", size = 14, color = "white") | ||
), | ||
cells = list( | ||
values = cellValues, | ||
align = c('left', rep('center', ncol(mtcars))), | ||
line = list(color = "black", width = 1), | ||
fill = list(color = c('rgb(235, 193, 238)', 'rgba(228, 222, 249, 0.65)')), | ||
font = list(family = "Arial", size = 12, color = c("black")) | ||
)) | ||
# Create a shareable link to your chart | ||
# Set up API credentials: https://plot.ly/r/getting-started | ||
chart_link = api_create(p, filename="table-df") | ||
chart_link | ||
``` | ||
|
||
```{r, echo=FALSE} | ||
chart_link | ||
``` | ||
|
||
### Changing Size of Rows and Columns | ||
|
||
```{r, results = 'hide'} | ||
values <- list(c('Salaries', 'Office', 'Merchandise', 'Legal', '<b>TOTAL<br>EXPENSES</b>'), c("Lorem ipsum dolor sit amet, tollit discere inermis pri ut. Eos ea iusto timeam, an prima laboramus vim. Id usu aeterno adversarium, summo mollis timeam vel ad", | ||
"Lorem ipsum dolor sit amet, tollit discere inermis pri ut. Eos ea iusto timeam, an prima laboramus vim. Id usu aeterno adversarium, summo mollis timeam vel ad", | ||
"Lorem ipsum dolor sit amet, tollit discere inermis pri ut. Eos ea iusto timeam, an prima laboramus vim. Id usu aeterno adversarium, summo mollis timeam vel ad", | ||
"Lorem ipsum dolor sit amet, tollit discere inermis pri ut. Eos ea iusto timeam, an prima laboramus vim. Id usu aeterno adversarium, summo mollis timeam vel ad", | ||
"Lorem ipsum dolor sit amet, tollit discere inermis pri ut. Eos ea iusto timeam, an prima laboramus vim. Id usu aeterno adversarium, summo mollis timeam vel ad")) | ||
p <- plot_ly( | ||
type = 'table', | ||
columnorder = c(1,2), | ||
columnwidth = c(80,400), | ||
header = list( | ||
values = list(list('<b>EXPENSES</b><br>as of July 2017'), | ||
list('<b>DESCRIPTION</b>')), | ||
line = list(color = '#506784'), | ||
fill = list(color = '#119DFF'), | ||
align = c('left','center'), | ||
font = list(color = 'white', size = 12), | ||
height = 40 | ||
), | ||
cells = list( | ||
values = values, | ||
line = list(color = '#506784'), | ||
fill = list(color = c('#25FEFD', 'white')), | ||
align = c('left', 'center'), | ||
font = list(color = c('#506784'), size = 12), | ||
height = 30 | ||
)) | ||
# Create a shareable link to your chart | ||
# Set up API credentials: https://plot.ly/r/getting-started | ||
chart_link = api_create(p, filename="table-text") | ||
chart_link | ||
``` | ||
|
||
```{r, echo=FALSE} | ||
chart_link | ||
``` | ||
|
||
#Reference | ||
|
||
See [https://plot.ly/r/reference/#table](https://plot.ly/r/reference/#table) for more information and chart attribute options! | ||
|
Oops, something went wrong.