Giter VIP home page Giter VIP logo

detourr's People

Contributors

casperhart avatar certifiedwaif avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

detourr's Issues

simplify `palette` argument

Rather than removing the palette argument entirely, I think we could restrict it to being a function, and not allow a vector of colours to be used. That way we can simplify the logic significantly, and users can use tour_aes(colour = I(...)) if they need more granular control.

facetting

New args rows = NULL and cols = NULL to support small multiples.
allcenter-301

snapshot and export

would you like to add a "snapshot" button and then be able to export to svg/png/jpg? it is useful for your thesis writing too.

black out with {crosstalk}

library(detourr)
library(crosstalk)
library(plotly)
library(DT)

shared_flea <- SharedData$new(tourr::flea)

a <- plot_ly(shared_flea, x = ~ tars1, y = ~ head) %>% 
  add_markers() %>% 
  highlight(on = "plotly_click", dynamic = TRUE)
b <- animate_tour(
  shared_flea,
  tour_path = tourr::grand_tour(2),
  display = display_scatter(tour_aes(colour = species)),
  width = "100%"
)
c <- datatable(shared_flea, width = "100%")

bscols(widths = 4,
  list(
    filter_checkbox("species", "Species", shared_flea, ~species),
    filter_slider("head", "Head", shared_flea, ~head, width = "100%"),
    c
  ),
  a, b
)

image

Point Selection & Colouring

Ability to select points and modify colour when the animation is paused, such that the colour persists when the animation is played again.
Would require a controls panel to be completed first, so that you can switch between orbit controls and point selection.

rlang::warn() namespace issue

library(d3tourr)
animate_tour(
  tourr::olive, -area,
  display = display_scatter(tour_aes(colour = region)),
  render_opts = list(max_bases = 10)
)
#> Error in warn("`colour` aesthetic is of type double, but only discrete colours are implemented"): could not find function "warn"

Created on 2021-07-18 by the reprex package (v2.0.0)

support {crosstalk} object

We can leverage other html widgets in R through {crosstalk} to link with animate_tour(), so we don't need to reinvent the wheel for 1-dimensional graphics or parallel coordinates etc.

Separate Three.js from bundle

The Three.js code should be bundled separately from the main JS code because it seldom changes, and should reduce the size at which the repository grows as the TS code changes.

Less verbose user API

I personally find the current user interface a bit clunky, especially the need to use render_opts = list(...) to change the max_bases argument, and usingtour_aes for aesthetics.

I propose the following changes:

  • removing render_opts in favour of individual arguments for max_bases, fps, etc.
  • using one-sided formulas for aesthetic arguments, similar to plotly.

So instead of:

library(d3tourr)
animate_tour(
  tourr::olive, -area,
  display = display_scatter(tour_aes(colour = region)),
  render_opts = list(max_bases = 10)
)

We would have:

library(d3tourr)
animate_tour(
  tourr::olive, -area,
  display = display_scatter(colour = ~region),
  max_bases = 10
)

@earowang let me know what you think

Antialiasing

Points don't render well on low DPI monitors. This can be improved by adding antialiasing to the shaders.

Refactoring for better extensibility

Currently we have one HTML Widget implemented, which is scatter_widget. However this is starting to get pretty big and unwieldy, so I propose splitting it out in to separate widgets, and renaming to display_scatter to match the R function e.g. splitting in to multiple classes such as:

  • display_scatter (core, abstract class)
    • display_scatter_3d (inherits from display_scatter)
    • display_scatter_2d (inherits from display_scatter)

The 2d and 3d versions differ only by their shaders, control behaviour, camera, and matrix multiplication function, so the extensions for 2d and 3d would be relatively small. Once this is implemented, further extensions like the slice tour would become much easier. For instance, we could create:

  • display_slice_3d (inherits from display_scatter_3d)
  • display_slice_2d (inherits from display_scatter_2d)
  • display_depth (inherits from display_scatter_3d (no 2d version))

Note that in R, we would still use a single display_scatter function, and infer whether the 2d or 3d version should be used based on the tour path provided.

Let me know your thoughts on this @earowang. I know inheritance can become a bit of a mess if not done properly, so I want to make sure I'm not overcomplicating it.

`size` parameter in `display_scatter`

Add size parameter to display_scatter, and remove the existing size calculation code based on n. This is a simple size parameter, and NOT an aesthetic.

@earowang should this parameter be called size, or cex?

unit tests

Can we start to use unit testing, which would help to prevent regression bugs when new features are implemented?

Commit bundled JS code

  • Commit bundled JS so that the package can be installed via remotes::install_github
  • Add hooks to prevent committing TS code without updating the corresponding bundle

User interface

just jotting down some ideas about UI:

animate_tour(
  data, # data set
  cols, # data columns for tours, tidy eval with {tidyselect}
  tour_path = grand_tour(),
  display = d3_display_xy(tour_aes(...), center = TRUE, axes = "center"), # ... => <colour =, shape =, size =,> 
  rescale = TRUE,
  sphere = FALSE,
  render_opts = list(
    start = NULL,
    aps = 1,
    fps = 10,
    max_frames = Inf)
)

Background colour

With viridis as the default palette, the yellow can be hard to see. Defaulting to a light grey background similar to ggplot2 should help, with a parameter so it can be overridden.

Colour legend

This could be achieved by overlaying an SVG over the canvas, and drawing the legend using d3-legend.js

`pkgdown` site

  • Create site using pkgdown (i.e. gh pages), preferably with support for embedded htmlwidgets in examples.
  • Add github action to automatically build and deploy on merge to main

fail to render for big data sets

library(d3tourr)
library(tourr)
big_olive <- olive[rep(1:nrow(olive), 300), ]
dim(big_olive)
animate_tour(
  big_olive, -area,
  display = display_scatter(tour_aes(colour = region)),
  render_opts = list(max_bases = 10)
)

Can't render for a data set of 171K obs. What's the maximum number of obs can we handle atm? Shall we give an informative error message when it exceeds the limit?

slider instead of reset

Actually, it may be worth adding a slider to be able to forward/backward and play/pause/reset at the bottom, which is more flexible than play/pause and reset buttons.

Palette option in `display_scatter`

Add a parameter pal in display_scatter to allow the user to specify the colour palette.

  • Can be either:
    • a character vector of R colours, e.g. what is returned by the base R palette() function.
    • a function which takes a parameter n and returns a vector similar to above. e.g. gray.colors, 'palette.colors`, or a palette function from an external package.

For continuous colour aesthetics, the values will be binned accordingly, with a default of n=8 if pal is a function. This will allow continuous palettes to be used.

For character / factor colour aesthetics, n will default to the number of levels. If pal is a character vector and there is a length mismatch between the palette and number of factor levels, recycle the palette with a warning.

So that the user can have full control of the colours, we may also want to check if the specified aesthetic column is a valid hex colour vector, and use that if no palette is specified.

crosstalk filtering

Add filtering capabilities to crosstalk.

Also refactor to move crosstalk out of scatter_widget.ts and in to display_scatter.js. This seems to be a common pattern in other libraries like {DT} and {d3scatter}, and avoids awkwardly referencing globals from TS.

hover / label aesthetic

Add label aesthetic so that individual points can be identified by hovering the mouse over them.

merge `axes` and `labels` arguments

Can we merge axes and labels into one arg, i.e. axes = TRUE

TRUE: default to column names for axis labels
FALSE: remove both axes and labels
NULL: axes without labels
An unnamed vector of labels with the same length as cols
A named vector in the form c("h" = "head"), where head is renamed to h.

cross-talked tour not showing with Safari

Not sure why b isn't showing up with Safari?

library(detourr)
library(crosstalk)
library(plotly)
library(DT)

shared_flea <- SharedData$new(tourr::flea)

a <- plot_ly(shared_flea, x = ~ tars1, y = ~ head) %>% 
  add_markers() %>% 
  highlight(on = "plotly_click", dynamic = TRUE)
b <- animate_tour(
  shared_flea,
  tour_path = tourr::grand_tour(2),
  display = display_scatter(tour_aes(colour = species)),
  width = "100%"
)
c <- datatable(shared_flea)

bscols(
  list(
    filter_checkbox("species", "Species", shared_flea, ~species),
    filter_slider("head", "Head", shared_flea, ~head, width = "100%")
  ),
  a, b, c
)

hard-pause to prevent redrawing when plot is idle

The default pause behaviour continues to redraw the elements on the canvas to support interactions like panning, orbit, zoom, etc.. If there are no interactions the drawing should be stopped entirely to reduce GPU / CPU usage.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.