Skip to content

Commit

Permalink
Altair4 (#123)
Browse files Browse the repository at this point in the history
* bump version

* update to Vega 4.0.0

* update S3 methods to use altair v4 (vs v3)

patch gallery so examples work using v4

* Point remote to vegawidget master-branch
  • Loading branch information
ijlyttle authored Dec 14, 2019
1 parent 0c902e4 commit e48276f
Show file tree
Hide file tree
Showing 16 changed files with 64 additions and 65 deletions.
8 changes: 5 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: altair
Version: 3.1.1.9000
Version: 4.0.0.9000
Title: Interface to 'Altair'
Description: Interface to 'Altair' <https://altair-viz.github.io>, which itself
is a 'Python' interface to 'Vega-Lite' <https://vega.github.io/vega-lite>.
Expand All @@ -26,7 +26,7 @@ Authors@R: c(
person("Jake", "Vanderplas", comment = "Altair library", role = c("ctb")),
person("Brian", "Granger", comment = "Altair library", role = c("ctb"))
)
SystemRequirements: Python (>= 3.5.0), (Python) Altair (>= 3.1.0)
SystemRequirements: Python (>= 3.5.0), (Python) Altair (>= 4.0.0)
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
Expand All @@ -41,7 +41,7 @@ Imports:
magrittr,
jsonlite,
utils,
vegawidget (>= 0.2.1),
vegawidget (>= 0.2.2.9000),
repr
Suggests:
httr,
Expand All @@ -64,3 +64,5 @@ Suggests:
fs
Roxygen: list(markdown = TRUE)
RoxygenNote: 6.1.1
Remotes:
vegawidget/vegawidget
18 changes: 9 additions & 9 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Generated by roxygen2: do not edit by hand

S3method("&",altair.vegalite.v3.api.TopLevelMixin)
S3method("+",altair.vegalite.v3.api.TopLevelMixin)
S3method("|",altair.vegalite.v3.api.TopLevelMixin)
S3method(as_vegaspec,altair.vegalite.v3.api.TopLevelMixin)
S3method("&",altair.vegalite.v4.api.TopLevelMixin)
S3method("+",altair.vegalite.v4.api.TopLevelMixin)
S3method("|",altair.vegalite.v4.api.TopLevelMixin)
S3method(as_vegaspec,altair.vegalite.v4.api.TopLevelMixin)
S3method(format,altair.vegalite.v2.api.TopLevelMixin)
S3method(format,altair.vegalite.v3.api.TopLevelMixin)
S3method(print,altair.vegalite.v3.api.TopLevelMixin)
S3method(repr_text,altair.vegalite.v3.api.Chart)
S3method(format,altair.vegalite.v4.api.TopLevelMixin)
S3method(print,altair.vegalite.v4.api.TopLevelMixin)
S3method(repr_text,altair.vegalite.v4.api.Chart)
export("%>%")
export(JS)
export(alt)
Expand All @@ -17,10 +17,10 @@ export(as_vegaspec)
export(check_altair)
export(import_vega_data)
export(install_altair)
export(knit_print.altair.vegalite.v3.api.TopLevelMixin)
export(knit_print.altair.vegalite.v4.api.TopLevelMixin)
export(knit_print.vegaspec)
export(renderVegawidget)
export(repr_vegalite3.altair.vegalite.v3.api.Chart)
export(repr_vegalite4.altair.vegalite.v4.api.Chart)
export(vega_embed)
export(vegawidget)
export(vegawidgetOutput)
Expand Down
4 changes: 3 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# altair 3.1.1 (development version)
# altair 4.0.0.9000 (development version)

* Upgrade to Altair 4.0.0

# altair 3.1.1

Expand Down
8 changes: 4 additions & 4 deletions R/concatenation.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@
NULL

is_altair_chart <- function(x) {
inherits(x, "altair.vegalite.v3.api.TopLevelMixin")
inherits(x, "altair.vegalite.v4.api.TopLevelMixin")
}

#' @rdname altair_concatenation
#' @export
#'
"|.altair.vegalite.v3.api.TopLevelMixin" <- function(e1, e2) {
"|.altair.vegalite.v4.api.TopLevelMixin" <- function(e1, e2) {
if (!is_altair_chart(e2)) {
stop("Second argument to | is not an Altair Chart")
}
Expand All @@ -71,7 +71,7 @@ is_altair_chart <- function(x) {
#' @rdname altair_concatenation
#' @export
#'
"+.altair.vegalite.v3.api.TopLevelMixin" <- function(e1, e2) {
"+.altair.vegalite.v4.api.TopLevelMixin" <- function(e1, e2) {
if (!is_altair_chart(e2)) {
stop("Second argument to + is not an Altair Chart")
}
Expand All @@ -81,7 +81,7 @@ is_altair_chart <- function(x) {
#' @rdname altair_concatenation
#' @export
#'
"&.altair.vegalite.v3.api.TopLevelMixin" <- function(e1, e2) {
"&.altair.vegalite.v4.api.TopLevelMixin" <- function(e1, e2) {
if (!is_altair_chart(e2)) {
stop("Second argument to & is not an Altair Chart")
}
Expand Down
6 changes: 3 additions & 3 deletions R/utils-jupyterlab.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ py_mimebundle <- function(obj) {
#' @importFrom repr repr_text
#' @export
#'
repr_text.altair.vegalite.v3.api.Chart <- function(obj) {
repr_text.altair.vegalite.v4.api.Chart <- function(obj) {
py_mimebundle(obj)$`text/plain`
}

Expand All @@ -31,6 +31,6 @@ repr_text.altair.vegalite.v3.api.Chart <- function(obj) {
#' @importFrom repr repr_vegalite2
#' @export
#'
repr_vegalite3.altair.vegalite.v3.api.Chart <- function(obj) {
py_mimebundle(obj)$`application/vnd.vegalite.v3+json`
repr_vegalite4.altair.vegalite.v4.api.Chart <- function(obj) {
py_mimebundle(obj)$`application/vnd.vegalite.v4+json`
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#' @rdname as_vegaspec
#' @export
#'
as_vegaspec.altair.vegalite.v3.api.TopLevelMixin <- function(spec, ...) {
as_vegaspec.altair.vegalite.v4.api.TopLevelMixin <- function(spec, ...) {

# TODO: if needed, insert code to convert your object to
# something that can be coerced to a vegaspec.
Expand All @@ -15,7 +15,7 @@ as_vegaspec.altair.vegalite.v3.api.TopLevelMixin <- function(spec, ...) {

#' @export
#'
print.altair.vegalite.v3.api.TopLevelMixin <- function(x, ...) {
print.altair.vegalite.v4.api.TopLevelMixin <- function(x, ...) {

x <- as_vegaspec(x)

Expand All @@ -24,7 +24,7 @@ print.altair.vegalite.v3.api.TopLevelMixin <- function(x, ...) {

#' @export
#'
format.altair.vegalite.v3.api.TopLevelMixin <- function(x, ...) {
format.altair.vegalite.v4.api.TopLevelMixin <- function(x, ...) {

x <- as_vegaspec(x)

Expand All @@ -35,7 +35,7 @@ format.altair.vegalite.v3.api.TopLevelMixin <- function(x, ...) {
#' @rdname knit_print.vegaspec
#' @export
#'
knit_print.altair.vegalite.v3.api.TopLevelMixin <- function(spec, ..., options = NULL) {
knit_print.altair.vegalite.v4.api.TopLevelMixin <- function(spec, ..., options = NULL) {

spec <- as_vegaspec(spec)

Expand Down
2 changes: 1 addition & 1 deletion R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ on_altair_error <- function(e) {
.onLoad <- function(libname, pkgname) {

# sets the supported version
options(altair.python.version = "3.1.0")
options(altair.python.version = "4.0.0")

alt <<-
reticulate::import(
Expand Down
12 changes: 6 additions & 6 deletions man/altair_concatenation.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 4 additions & 6 deletions man/as_vegaspec.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 4 additions & 6 deletions man/knit_print.vegaspec.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkgdown/_pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ reference:
contents:
- vegawidget
- vega_embed
- knit_print.altair.vegalite.v3.api.TopLevelMixin
- knit_print.altair.vegalite.v4.api.TopLevelMixin
- image
- title: Package
desc: Overview of the package
Expand Down
20 changes: 10 additions & 10 deletions vignettes/example-gallery-02-bar-charts.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -228,28 +228,28 @@ glimpse(data)
#### Chart

```{r}
a <-
bar <-
alt$Chart(data = data)$
mark_bar()$
encode(
x = "project:O",
y = "score:Q"
)
)$
properties(width = alt$Step(40))
b <-
tick <-
alt$Chart(data = data)$
mark_tick(color = "red")$
mark_tick(
color = "red",
thickness = 2,
size = 40 * 0.9
)$
encode(
x = "project:O",
y = "goal:Q"
)
chart <-
(a + b)$
# controls the width of the tick
configure_tick(thickness = 2, bandSize = 35)$
# controls the width of the bar
configure_scale(rangeStep = 40)
chart <- (bar + tick)
chart
```
Expand Down
5 changes: 2 additions & 3 deletions vignettes/example-gallery-09-case-studies.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ chart <-
op = "sum",
order = "descending"
),
scale = alt$Scale(rangeStep = 20),
axis = alt$Axis(grid = TRUE)
),
color = alt$Color("year:N", legend = alt$Legend(title = "Year")),
Expand All @@ -178,6 +177,7 @@ chart <-
)
)
)$
properties(height = alt$Step(20))$
configure_view(stroke = "transparent")
chart
Expand Down Expand Up @@ -1275,11 +1275,10 @@ chart <-
title = "Population",
axis = alt$Axis(format = "~s")
),
facet = "year:O"
facet = alt$Facet("year:O", columns = 5)
)$
properties(
title = "US Age Distribution By Year",
columns = 5,
width = 90,
height = 80
)
Expand Down
4 changes: 2 additions & 2 deletions vignettes/example-gallery-10-other-charts.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ chart <-
x = alt$X("median(yield)", scale=alt$Scale(zero = FALSE)),
y = "variety:O",
color = "year:N",
facet = "site:O"
facet = alt$Facet("site:O", columns = 2)
)$
properties(columns = 2, width = 200, height = 100)
properties(width = 200, height = 100)
chart
```
Expand Down

0 comments on commit e48276f

Please sign in to comment.