Skip to content
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.

Implement groupwise() and layer_axial_lines() #393

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

lionel-
Copy link
Contributor

@lionel- lionel- commented Apr 24, 2015

Hello. This implements:

  • groupwise() to set the Vega "group" reference. I named it groupwise() because I found prop_group() to be confusing. An alternative could be from_group().
  • layer_axial_lines() to draw vertical or horizontal lines.

I added support for the rule mark in order to draw the lines. In the future, we'll be able to use the rule mark to implement something like layer_sloped_lines(), but this needs to be fixed first: https://github.com/trifacta/vega/issues/123. Also, it was necessary to prevent ggvis from writing a "from" tag to a mark in the case where no property makes use of data.

Here is an example of using a group property:

ggvis(faithful) %>%
  layer_histograms(~eruptions) %>%
  emit_rects(props(
    x := 0, x2 := groupwise("width", mult = 0.5),
    y := 0, y2 := groupwise("height", mult = 0.5),
    fill := "red"
  ))

groupwise

As for layer_axial_lines(), it will draw one horizontal line for each y data point, and one vertical line for each x data point. Here the vertical lines are drawn from a data set while the horizontal line is set with :=.

lines_data <- data.frame(values = c(2, 4.5))
ggvis(faithful) %>%
  layer_histograms(~eruptions) %>%
  layer_axial_lines(data = lines_data,
    x = ~values, y := 80,
    stroke := "red", strokeWidth := 4
  )

axial

Let me know if you're interested in this PR and I'll send the copyright form.

@lionel-
Copy link
Contributor Author

lionel- commented Apr 24, 2015

CMD CHECK passes when I add:

#' @importFrom dplyr arrange_ distinct_ group_by_ summarise_ mutate_
#'   arrange_ select_ filter_ distinct_ slice_ rename_ transmute_ groups
#'   ungroup

Should I add this to the PR?

@lionel-
Copy link
Contributor Author

lionel- commented Apr 25, 2015

ok, I had to remove manually the offending changes to NAMESPACE. The dplyr verbs were originally exported as export(), and ROxygen turned them into S3methods(). Not sure why since I'm using the same version as used in the repo.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant