Closed schloerke closed 7 years ago
library(ggplot2)
mpg2 <- mpg
mpg2$drv <- as.factor(mpg2$drv)
mpg2$cyl <- as.factor(mpg2$cyl)
load_all(); qplot(displ, hwy, data = mpg2) + facet_trelliscope(~ year, ncol = 2, nrow = 1, scales = "sliced", path = "_ignore/simple_split")
load_all(); qplot(displ, hwy, data = mpg2, color = year) + facet_trelliscope(~ year, ncol = 2, nrow = 1, scales = "sliced", path = "_ignore/simple_split_color")
load_all(); qplot(displ, hwy, data = mpg2) + facet_trelliscope(~ year, ncol = 2, nrow = 1, scales = "sliced", split_layout = FALSE, path = "_ignore/simple_whole")
load_all(); qplot(displ, hwy, data = mpg2, color = year) + facet_trelliscope(~ year, ncol = 2, nrow = 1, scales = "sliced", split_layout = FALSE, path = "_ignore/simple_whole_color")
Thanks for all this! The scales
aspect works great!
I merged this PR and made some edits and put it here: https://github.com/hafen/trelliscopejs/tree/schloerke-legend.
What I did:
split_layout
and has_legend
are now written to displayObj.json
(instead of the global config.json
as it was before). This allows it to vary per-display instead of being a global setting.split_layout
is TRUE
, additional info about the aspect ratio for the left and bottom axes is stored in displayObj.json
because the viewer will need to know this.make_png()
so that I can calculate the final width and height of the axes without calling make_png()
.split_layout
to FALSE
by default and added an error if it is set to TRUE
for now because the viewer can't support it yet. This will take some work on the viewer side of things.Something to think about: When either axis is set to "free" or "sliced", we know the axis will vary per panel so we might as well leave the axes in the plot. Only in the case of an axis being "same" we could just store a single instance of the axis (instead of writing out an axis per panel). That would result in a lot fewer files and calls to make_png()
and would simplify things on the viewer's end. We can discuss this more later.
Solves: #29
Also pulls in PR #27 (which in turn does #26 and #20). Merging this PR would auto merge the other three PRs