Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# ignore JS config files/folders
node_modules/
coverage/
src/
lib/
.babelrc
.builderrc
.eslintrc
.npmignore
.editorconfig
.eslintignore
.prettierrc
.circleci
.github

# demo folder has special meaning in R
# this should hopefully make it still
# allow for the possibility to make R demos
demo/.*\.js
demo/.*\.html
demo/.*\.css

# ignore Python files/folders
setup.py
usage.py
setup.py
requirements.txt
MANIFEST.in
CHANGELOG.md
test/
# CRAN has weird LICENSE requirements
LICENSE.txt
^.*\.Rproj$
^\.Rproj\.user$
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [0.0.2] - 2020-08-04
* Added docstring to PivotTable.react.js
* Initial release of dashPivottable R package [#23](https://github.com/plotly/dash-pivottable/pull/23)

## [0.0.1]
## [0.0.1] - 2020-07-31
### Added
* Up-to-date [Contributing instructions](https://github.com/plotly/dash-pivottable/blob/master/CONTRIBUTING.md)
* Up-to-date Readme
Expand Down
15 changes: 15 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Package: dashPivottable
Title: Interactive React-based Pivot Tables for Dash
Version: 0.0.2
Description: Pivot tables are useful for interactive presentation of summary statistics computed for data contained in another table. The 'dashPivottable' package wraps 'react-pivottable', making it easy to add drag-and-drop tables into your Dash for R applications.
Depends: R (>= 3.0.2)
Imports:
Suggests: dash, dashHtmlComponents, jsonlite
Authors@R: c(person("Chris", "Parmer", email = "chris@plotly.com", role = c("aut")), person("Nicolas", "Kruchten", email = "nicolas@plotly.com", role = c("aut")), person("Xing Han", "Lu", email = "xinghan@plotly.com", role = c("trl")), person("Ryan Patrick", "Kyle", email = "ryan@plotly.com", role = c("cre"), comment = c(ORCID = "0000-0002-4958-2844")), person(family = "Plotly Technologies, Inc.", role = "cph"))
License: MIT + file LICENSE
Copyright: Plotly Technologies, Inc.
URL: https://github.com/plotly/dash-pivottable
BugReports: https://github.com/plotly/dash-pivottable/issues
Encoding: UTF-8
LazyData: true
KeepSource: true
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# AUTO GENERATED FILE - DO NOT EDIT

export(dashPivotTable)
18 changes: 18 additions & 0 deletions R/dashPivotTable.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# AUTO GENERATED FILE - DO NOT EDIT

dashPivotTable <- function(id=NULL, data=NULL, hiddenAttributes=NULL, hiddenFromAggregators=NULL, hiddenFromDragDrop=NULL, menuLimit=NULL, unusedOrientationCutoff=NULL, cols=NULL, colOrder=NULL, rows=NULL, rowOrder=NULL, aggregatorName=NULL, vals=NULL, valueFilter=NULL, rendererName=NULL) {

props <- list(id=id, data=data, hiddenAttributes=hiddenAttributes, hiddenFromAggregators=hiddenFromAggregators, hiddenFromDragDrop=hiddenFromDragDrop, menuLimit=menuLimit, unusedOrientationCutoff=unusedOrientationCutoff, cols=cols, colOrder=colOrder, rows=rows, rowOrder=rowOrder, aggregatorName=aggregatorName, vals=vals, valueFilter=valueFilter, rendererName=rendererName)
if (length(props) > 0) {
props <- props[!vapply(props, is.null, logical(1))]
}
component <- list(
props = props,
type = 'PivotTable',
namespace = 'dash_pivottable',
propNames = c('id', 'data', 'hiddenAttributes', 'hiddenFromAggregators', 'hiddenFromDragDrop', 'menuLimit', 'unusedOrientationCutoff', 'cols', 'colOrder', 'rows', 'rowOrder', 'aggregatorName', 'vals', 'valueFilter', 'rendererName'),
package = 'dashPivottable'
)

structure(component, class = c('dash_component', 'list'))
}
9 changes: 9 additions & 0 deletions R/internal.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.dashPivottable_js_metadata <- function() {
deps_metadata <- list(`dash_pivottable` = structure(list(name = "dash_pivottable",
version = "0.0.2", src = list(href = NULL,
file = "deps"), meta = NULL,
script = 'dash_pivottable.min.js',
stylesheet = NULL, head = NULL, attachment = NULL, package = "dashPivottable",
all_files = FALSE), class = "html_dependency"))
return(deps_metadata)
}
121 changes: 121 additions & 0 deletions dash-info.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
pkg_help_description: >-
Pivot tables are useful for interactive presentation of
summary statistics computed for data contained in another table.
The 'dashPivottable' package wraps 'react-pivottable',
making it easy to add drag-and-drop tables into your
Dash for R applications.
pkg_help_title: >-
Interactive React-based Pivot Tables for Dash
pkg_authors: >-
c(person("Chris", "Parmer", email = "chris@plotly.com", role = c("aut")), person("Nicolas", "Kruchten", email = "nicolas@plotly.com", role = c("aut")), person("Xing Han", "Lu", email = "xinghan@plotly.com", role = c("trl")), person("Ryan Patrick", "Kyle", email = "ryan@plotly.com", role = c("cre"), comment = c(ORCID = "0000-0002-4958-2844")), person(family = "Plotly Technologies, Inc.", role = "cph"))
pkg_copyright: >-
Plotly Technologies, Inc.
r_examples:
- name: dashPivotTable
dontrun: FALSE
code: |
# Input data for dashPivottable may be passed in the "list-of-lists"
# format -- scroll down to see an example which demonstrates how
# to pass a data.frame into dashPivottable directly.
library(dash)
library(dashPivottable)
library(dashHtmlComponents)

app <- Dash$new()
app$title("Summary statistics for tips data")

app$layout(
htmlDiv(
list(
dashPivotTable(
id = "table",
data = tips,
cols = list("Day of Week"),
colOrder = "key_a_to_z",
rows = list("Party Size"),
rowOrder = "key_a_to_z",
rendererName = "Grouped Column Chart",
aggregatorName = "Average",
vals = list("Total Bill"),
valueFilter = list("Day of Week"=list("Thursday"=FALSE))
),
htmlDiv(
id = "output"
)
)
)
)

app$callback(output = output(id="output", property="children"),
params = list(input(id="table", property="cols"),
input(id="table", property="rows"),
input(id="table", property="rowOrder"),
input(id="table", property="colOrder"),
input(id="table", property="aggregatorName"),
input(id="table", property="rendererName")),
function(cols, rows, row_order, col_order, aggregator, renderer) {
return(
list(
htmlP(cols, id="columns"),
htmlP(rows, id="rows"),
htmlP(row_order, id="row_order"),
htmlP(col_order, id="col_order"),
htmlP(aggregator, id="aggregator"),
htmlP(renderer, id="renderer")
)
)
}
)

app$run_server(debug=TRUE)

# This example illustrates the use of `df_to_list` to format a data.frame
# for use with dashPivottable
library(dashTable)

app <- Dash$new()
app$title("Summary statistics for iris data")

app$layout(
htmlDiv(
list(
dashPivotTable(
id = "table",
data = df_to_list(Loblolly),
cols = list("Seed"),
colOrder = "key_a_to_z",
rows = list("age"),
rowOrder = "key_a_to_z",
rendererName = "Grouped Column Chart",
aggregatorName = "Average",
vals = list("height")
),
htmlDiv(
id = "output"
)
)
)
)

app$callback(output = output(id="output", property="children"),
params = list(input(id="table", property="cols"),
input(id="table", property="rows"),
input(id="table", property="rowOrder"),
input(id="table", property="colOrder"),
input(id="table", property="aggregatorName"),
input(id="table", property="rendererName")),
function(cols, rows, row_order, col_order, aggregator, renderer) {
return(
list(
htmlP(cols, id="columns"),
htmlP(rows, id="rows"),
htmlP(row_order, id="row_order"),
htmlP(col_order, id="col_order"),
htmlP(aggregator, id="aggregator"),
htmlP(renderer, id="renderer")
)
)
}
)

app$run_server(debug=TRUE)
24 changes: 22 additions & 2 deletions dash_pivottable/PivotTable.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,31 @@

class PivotTable(Component):
"""A PivotTable component.
...
Pivot tables are useful for interactive presentation of
summary statistics computed for data contained in another table.

This function provides a convenient Dash interface
to the `react-pivottable` component, which makes it easy to embed
pivot tables into Dash for R applications.

Within React, the interactive component provided by `react-pivottable`
is `PivotTableUI`, but output rendering is delegated to the non-interactive
`PivotTable` component, which accepts a subset of its properties.
`PivotTable` in turn delegates to a specific renderer component, such as
the default `TableRenderer`, which accepts a subset of the same properties.
Finally, most renderers will create non-React PivotData objects to handle
the actual computations, which also accept a subset of the same properties
as the rest of the stack.

The arguments for this function correspond to properties of the component;
a full list is provided below.

`react-pivottable` was developed by Nicolas Kruchten; source
for this component is available from https://github.com/plotly/react-pivottable.

Keyword arguments:
- id (string; optional): The ID used to identify this component in Dash callbacks
- data (list; optional): The input data
- data (list; optional): data to be summarized
- hiddenAttributes (list; optional): contains attribute names to omit from the UI
- hiddenFromAggregators (list; optional): contains attribute names to omit from the aggregator arguments dropdowns
- hiddenFromDragDrop (list; optional): contains attribute names to omit from the drag'n'drop portion of the UI
Expand Down
Binary file added data/tips.RData
Binary file not shown.
450 changes: 450 additions & 0 deletions inst/deps/dash_pivottable.dev.js

Large diffs are not rendered by default.

68 changes: 68 additions & 0 deletions inst/deps/dash_pivottable.min.js

Large diffs are not rendered by default.

Loading