GithubHelp home page GithubHelp logo

g2inr / g2r Goto Github PK

View Code? Open in Web Editor NEW
33.0 9.0 3.0 705 KB

experiments with R and g2

License: Other

R 0.61% JavaScript 99.39%
rstats r visualization interactive htmlwidgets grammar graphics web javascript

g2r's People

Contributors

timelyportfolio avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

g2r's Issues

react or vanilla?

We have two options for g2:

  1. vanilla g2
  2. react bizcharts

Which one fits cleanest into an R API?

Which one offers highest likelihood of continued support, maintenance, and development?

Maintaining two packages seems very like a bad and unsustainable idea.

how to handle noquote?

JSON

jsonlite is an amazing and well-built JSON converter with a focus on reliable conversion back and forth from R structures <-> JSON equivalents. This focus on two-way conversion means that unquoted JavaScript is not supported. I like the idea of using noquote to indicate JavaScript variables, but I struggle with a clean way of piggybacking on top of jsonlite to add this functionality. See ugly hack below.

#  gosh this is ugly and I'm sure highly worst practice
asJSON <- jsonlite:::asJSON
setMethod("asJSON", "ANY", function(x, force = FALSE, ...) {
  if (inherits(x, "noquote")) {
    return(x)
  }
  if (isS4(x) && !is(x, "classRepresentation")) {
    if (isTRUE(force)) {
      return(asJSON(attributes(x), force = force, ...))
    } else {
      stop("No method for S4 class:", class(x))
    }
  } else if (length(class(x)) > 1) {
    # If an object has multiple classes, we recursively try the next class. This is
    # S3 style dispatching that doesn't work by default for formal method definitions
    # There should be a more native way to accomplish this
    return(asJSON(structure(x, class = class(x)[-1]), force = force, ...))
  } else if (isTRUE(force) && existsMethod("asJSON", class(unclass(x)))) {
    # As a last resort we can force encoding using the unclassed object
    return(asJSON(unclass(x), force = force, ...))
  } else if (isTRUE(force)) {
    return(asJSON(NULL))
    warning("No method asJSON S3 class: ", class(x))
  } else {
    # If even that doesn't work, we give up.
    stop("No method asJSON S3 class: ", class(x))
  }
})
assignInNamespace("asJSON", asJSON, ns="jsonlite")
rm(asJSON, envir = .GlobalEnv)

React

A very similar problem occurs with htmltools and tags in the React/JSX ecosystem. See rstudio/htmltools#72 as a proposed workaround. Unfortunately, there has been no communication from RStudio on the viability of this approach. I certainly don't want to manage a fork for this functionality.

sketches

Some code to start working through the integration. This is ugly and very hacky. Of course the ultimate objective is to write a full-featured htmlwidget that is usable for an R user with no knowledge of JavaScript.

See sketch

working on something similar

Hello hello, I wanted to say I have been working on a similar project over at nteetor/golly. Someone just pointed me toward this project.

Perhaps there is a way we can combine forces? I look forward to hearing back from you.

Why g2?

I could find any difference in g2 and Vega on internet. So my question is why g2 and will g2 be supported long enough by js community that we can use it.

I mean Vega is quite time tested and famous library it's easier to find support for it and it's easier to just form ggvis on GitHub.

Why g2? Please do reply

name?

I chose g2r to start the project, but I am by no means wedded to the name? Are there other suggestions?

English API documentation ?

Hi,

Sorry, this is not directly related to the R implementation, but do you know if there is an english version of the API documentation ? Beside a simple tutorial I've only managed to find one in chinese.

Thanks !

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.