edwindj / daff

Diff, patch and merge for data.frames, see http://paulfitz.github.io/daff/
https://edwindj.github.io/daff/
Other
153 stars 18 forks source link

Add htmlwidgets #3

Open edwindj opened 9 years ago

edwindj commented 9 years ago

An htmlwidgets version of daff will allow for data_diff in shiny and rmarkdown.

timelyportfolio commented 9 years ago

How do you want this to look? Do you want it to be like the handsontable implementation on paulfitz.github.io/daff? I think this would be a good start and happy to start putting together.

timelyportfolio commented 9 years ago

The other project I have been experimenting with heavily is https://github.com/benjamine/jsondiffpatch.

edwindj commented 9 years ago

Seems fine to me to start with the implementation of daff (note that render_diff does exactly that). For a later version I may be nice to use bootstrap3 css style, so it integrates nicely with shiny/rmarkdown.

edwindj commented 9 years ago

I was not familiar with this project (https://github.com/benjamine/jsondiffpatch), looks nice!

timelyportfolio commented 9 years ago

Aim of the projects is similar, but jsondiffpatch more focused on non-tabular. What is nice about jsondiffpatch is the built in html renderer, so making a htmlwidget is much easier.

timelyportfolio commented 9 years ago

Just wanted to circle back to this. There are lots of easy improvements without even a full htmlwidget implementation. I think a full implementation would be nice, but for now I'll submit a pull with the simple change. Sorry it has taken me so long.

timelyportfolio commented 9 years ago

Here is the non-htmlwidget implementation https://github.com/timelyportfolio/daff/tree/feature/htmltools using just the helpful htmltools from RStudio. The quick win here is now render_diff will show up in rmarkdown documents, which I demonstrated with this silly vignette.

image

Also, here is an example in Shiny.

library(shiny)
library(daff)

ui <- fluidPage( uiOutput("daff") )

server <- function(input,output,session){
  output$daff <- renderUI({
    y <- iris[1:3,]
    x <- y
    invalidateLater(1000, session)

    x[,1] <- jitter(y[,1])
    patch <- diff_data(y, x)
    render_diff(patch, fragment = F)
  })
}
shinyApp(ui,server)

I would enjoy your thoughts on this. Thanks.

happyshows commented 8 years ago

Hi, is there any progress on this one? I think render_diff is pretty close to the htmlwidget convention, just last mile to wrap in the standard format

dylanbeaudette commented 7 years ago

This is excellent work, thank you. Any progress on embedding render_diff output within an rmarkdown document?

dylanbeaudette commented 7 years ago

Here is my local hack to get daff chunks into rmarkdown HTML documents:

  1. add a "style.css" with a copy of the daff CSS to the YAML header
  2. wrap chunks with this function:
    # temp hack to get daff chunks into an rmarkdown doc
    wrapDaffHTML <- function(chunkHTML, chunkTitle) {
    cat("<div class='highlighter' style='align:center; font-size:80%;'>")
    cat(paste0("<h3>", chunkTitle, "</h3>"))
    cat(chunkHTML)
    cat("</div><br><br>")
    }

    I am sure there is a better way, but this seems to work OK. It would be nice to get the summary HTML chunks, but I can live without those for now.

edwindj commented 7 years ago

Thx for your suggestions! I will work on rendering to markdown next week.