hrbrmstr / taucharts

:bar_chart: An R htmlwidget interface to the TauCharts javascript library
http://rpubs.com/hrbrmstr/taucharts
Other
65 stars 12 forks source link

Add list of to-dos with priority #1

Open timelyportfolio opened 9 years ago

timelyportfolio commented 9 years ago

Happy to help on this one. Do you have a prioritized list of to-dos?

hrbrmstr commented 9 years ago

TODOs

hrbrmstr commented 9 years ago

We can break out each TODO as an issue for separate tracking but the master list can be kept here

timelyportfolio commented 9 years ago

great thanks. I'll get to work on basic factor support even though not in the TODO, and then try to play some with the dates.

vladminsky commented 9 years ago

Hi! R htmlwidget is a great initiative! I'm developer of taucharts and happy to see this project started.

Just wanted to share with you our nearest project plans. Currently we are:

Next plan is to rework and document legend and tooltip plugins since they were implemented on top of pure D3 before plugins concept was stabilized.

Parallel and geo coordinates are in beta now and have several bugs with resizing and ugly labels positioning. They are in queue to be fixed and documented.

Actually strategic goal for this year is to "squeeze out" full power of cartesian coordinates and avoid any new coordinate types for a while (like polar, pie charts etc).

Please don't hesitate to discuss, ask questions or post issues / pull requests to taucharts.

Thanks again! Vladimir Petriko

hrbrmstr commented 9 years ago

Thank you for the sweet javascript charting library! Super-helpful & consistent API for the core feature set. Def let us know if you need us to beta anything.

On Tue, Aug 4, 2015 at 5:50 AM, Petriko Vladimir notifications@github.com wrote:

Hi! R htmlwidget is a great initiative! I'm developer of taucharts and happy to see this project started.

Just wanted to share with you our nearest project plans. Currently we are:

  • re-working CSS to have good isolation and support different themes as well
  • improve examples and documentation

Next plan is to rework and document legend and tooltip plugins since they were implemented on top of pure D3 before plugins concept was stabilized.

Parallel and geo coordinates are in beta now and have several bugs with resizing and ugly labels positioning. They are in queue to be fixed and documented.

Actually strategic goal for this year is to "squeeze out" all power of cartesian coordinates and avoid any new coordinate types for a while (like polar, pie charts etc).

Please don't hesitate to discuss, ask questions or post issues / pull requests to taucharts. Thanks again!

Vladimir Petriko

— Reply to this email directly or view it on GitHub https://github.com/hrbrmstr/taucharts/issues/1#issuecomment-127548382.

timelyportfolio commented 9 years ago

Guess we can start checking some of this off. I checked off plugins even though I know there are some remaining.

hrbrmstr commented 9 years ago

@timelyportfolio I just made a dev branch to avoid me adding things that may not work into master. You should prbly fork that (I made a cpl changes after you got everything back to working)

timelyportfolio commented 9 years ago

Ok, thanks, sounds good.

hrbrmstr commented 9 years ago

I made a stable release (0.1.0) for master branch and update-merged dev branch. New Rpub (with working trendline!) is up as well.

timelyportfolio commented 9 years ago

Great. Have a pull now to add min/max to tau_guide_? based on https://github.com/TargetProcess/tauCharts/issues/34 and #12. It is in my devel/axis_minmax branch if you want to try it first. Fun to dig out the undocumented behavior :)

devtools::install_github("timelyportfolio/taucharts@devel/axis_minmax")

DF <-
    structure(
        list(
            Ranking = structure(
                1:5, .Label = c("Bottom", "Bellow Average",
                                "Average", "Above Average", "Top"), class = "factor"
            ), Prob = c(20L,
                        20L, 20L, 20L, 20L)/100
        ), .Names = c("Ranking", "Prob"), row.names = c(NA,-5L), class = "data.frame"
    )

tauchart(DF) %>% 
    tau_bar(x="Ranking", y="Prob") %>% 
    tau_guide_y(tick_format="%", min = 0, max = 1) 
timelyportfolio commented 9 years ago

If possible, would like to feature this as the htmlwidget of the week. Let me know if this causes any problems.

hrbrmstr commented 9 years ago

go forth and showcase! :grinning:

On Tue, Aug 4, 2015 at 3:41 PM, timelyportfolio notifications@github.com wrote:

If possible, would like to feature this as the htmlwidget of the week. Let me know if this causes any problems.

— Reply to this email directly or view it on GitHub https://github.com/hrbrmstr/taucharts/issues/1#issuecomment-127731500.

hrbrmstr commented 9 years ago

re: #12, aye, I think we're definitely full-on headed into "pry the details from the javascript files" vs "read the API docs" territory. good. times.

hrbrmstr commented 9 years ago

You may want to sync the dev branch before doing too much more hacking.

benporter commented 9 years ago

cool package!

suggested to do item: provide an example of how to use taucharts with shiny

ThoDuyNguyen commented 9 years ago

The package is so cool. Shiny example is more than welcome.

ThoDuyNguyen commented 9 years ago

@benporter : I find an example from another issue and modify it a bit for an example. Here you go

# This is the server logic for a Shiny web application.
# You can find out more about building applications with Shiny here:
#
# http://shiny.rstudio.com
#

library(shiny)
library(htmlwidgets)
library(taucharts)

shinyServer(function(input, output) {
    scatter_dat <-
        structure(
            list(
                team = c("d", "d", "d", "d", "l", "l", "l", "l",
                         "k", "k", "k", "k"), cycleTime = c(1L, 2L, 3L, 4L, 2L, 3L, 4L,
                                                            5L, 2L, 3L, 4L, 5L), effort = c(1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L,
                                                                                            4L, 5L, 6L, 8L), count = c(1L, 5L, 8L, 3L, 1L, 5L, 8L, 3L, 1L,
                                                                                                                       5L, 8L, 3L), priority = c(
                                                                                                                           "low", "low", "medium", "high", "low",
                                                                                                                           "low", "medium", "high", "low", "low", "medium", "high"
                                                                                                                       )
            ), .Names = c("team",
                          "cycleTime", "effort", "count", "priority"), class = "data.frame", row.names = c(NA, 12L)
        )

    line_dat <-
        structure(
            list(
                type = c(
                    "us", "us", "us", "us", "us", "us", "bug",
                    "bug", "bug", "bug", "bug"
                ), count = c(0L, 10L, 15L, 12L, 16L,
                             13L, 21L, 19L, 23L, 26L, 23L), date = c(
                                 "12-2013", "01-2014",
                                 "02-2014", "03-2014", "04-2014", "05-2014", "01-2014", "02-2014",
                                 "03-2014", "04-2014", "05-2014"
                             )
            ), .Names = c("type", "count",
                          "date"), class = "data.frame", row.names = c(NA, 11L)
        )

    bar_dat <-
        structure(
            list(
                team = c("d", "d", "d", "d", "l", "l", "l", "l",
                         "k", "k", "k", "k"), cycleTime = c(1L, 2L, 3L, 4L, 2L, 3L, 4L,
                                                            5L, 2L, 3L, 4L, 5L), effort = c(1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L,
                                                                                            4L, 5L, 6L, 8L), count = c(1L, 5L, 8L, 3L, 1L, 5L, 8L, 3L, 1L,
                                                                                                                       5L, 8L, 3L), priority = c(
                                                                                                                           "low", "low", "medium", "high", "low",
                                                                                                                           "low", "medium", "high", "low", "low", "medium", "high"
                                                                                                                       )
            ), .Names = c("team",
                          "cycleTime", "effort", "count", "priority"), class = "data.frame", row.names = c(NA, 12L)
        )

    car_dat <-
        structure(
            list(
                car = c(
                    "Toyota Prius+", "Volvo S60", "BMV X5",
                    "Infinity FX", "Mercedes Vito", "Peugeot 3008", "Subaru Forester",
                    "Lexus RX", "Bentley Continental"
                ), co2 = c(96L, 135L, 197L,
                           238L, 203L, 155L, 186L, 233L, 246L), hp = c(99L, 150L, 306L,
                                                                       238L, 95L, 120L, 150L, 188L, 507L), euroEco = c(
                                                                           "eco", "eco",
                                                                           "non-eco", "non-eco", "non-eco", "non-eco", "non-eco", "non-eco",
                                                                           "non-eco"
                                                                       ), power = c(
                                                                           "low", "normal", "high", "high", "low",
                                                                           "low", "normal", "normal", "high"
                                                                       )
            ), .Names = c("car", "co2",
                          "hp", "euroEco", "power"), class = "data.frame", row.names = c(NA, 9L)
        )

    splom_dat <-
        structure(
            list(
                param1 = c(
                    "hp", "hp", "hp", "co2", "co2", "co2",
                    "mpg", "mpg", "mpg", "hp", "hp", "hp", "co2", "co2", "co2", "mpg",
                    "mpg", "mpg", "hp", "hp", "hp", "co2", "co2", "co2", "mpg", "mpg",
                    "mpg", "hp", "hp", "hp", "co2", "co2", "co2", "mpg", "mpg", "mpg",
                    "hp", "hp", "hp", "co2", "co2", "co2", "mpg", "mpg", "mpg", "hp",
                    "hp", "hp", "co2", "co2", "co2", "mpg", "mpg", "mpg", "hp", "hp",
                    "hp", "co2", "co2", "co2", "mpg", "mpg", "mpg", "hp", "hp", "hp",
                    "co2", "co2", "co2", "mpg", "mpg", "mpg", "hp", "hp", "hp", "co2",
                    "co2", "co2", "mpg", "mpg", "mpg"
                ), param2 = c(
                    "hp", "co2", "mpg",
                    "hp", "co2", "mpg", "hp", "co2", "mpg", "hp", "co2", "mpg", "hp",
                    "co2", "mpg", "hp", "co2", "mpg", "hp", "co2", "mpg", "hp", "co2",
                    "mpg", "hp", "co2", "mpg", "hp", "co2", "mpg", "hp", "co2", "mpg",
                    "hp", "co2", "mpg", "hp", "co2", "mpg", "hp", "co2", "mpg", "hp",
                    "co2", "mpg", "hp", "co2", "mpg", "hp", "co2", "mpg", "hp", "co2",
                    "mpg", "hp", "co2", "mpg", "hp", "co2", "mpg", "hp", "co2", "mpg",
                    "hp", "co2", "mpg", "hp", "co2", "mpg", "hp", "co2", "mpg", "hp",
                    "co2", "mpg", "hp", "co2", "mpg", "hp", "co2", "mpg"
                ), value1 = c(
                    99,
                    99, 99, 96, 96, 96, 3.8, 3.8, 3.8, 150, 150, 150, 135, 135, 135,
                    7.4, 7.4, 7.4, 306, 306, 306, 197, 197, 197, 11.2, 11.2, 11.2,
                    238, 238, 238, 238, 238, 238, 11.2, 11.2, 11.2, 95, 95, 95, 203,
                    203, 203, 9.4, 9.4, 9.4, 120, 120, 120, 155, 155, 155, 9.2, 9.2,
                    9.2, 150, 150, 150, 186, 186, 186, 10.4, 10.4, 10.4, 188, 188,
                    188, 233, 233, 233, 13.3, 13.3, 13.3, 507, 507, 507, 246, 246,
                    246, 15.4, 15.4, 15.4
                ), value2 = c(
                    99, 96, 3.8, 99, 96, 3.8,
                    99, 96, 3.8, 150, 135, 7.4, 150, 135, 7.4, 150, 135, 7.4, 306,
                    197, 11.2, 306, 197, 11.2, 306, 197, 11.2, 238, 238, 11.2, 238,
                    238, 11.2, 238, 238, 11.2, 95, 203, 9.4, 95, 203, 9.4, 95, 203,
                    9.4, 120, 155, 9.2, 120, 155, 9.2, 120, 155, 9.2, 150, 186, 10.4,
                    150, 186, 10.4, 150, 186, 10.4, 188, 233, 13.3, 188, 233, 13.3,
                    188, 233, 13.3, 507, 246, 15.4, 507, 246, 15.4, 507, 246, 15.4
                )
            ), .Names = c("param1", "param2", "value1", "value2"), class = "data.frame", row.names = c(NA,
                                                                                                       81L)
        )

    output$bar <- renderTaucharts({
        tauchart(bar_dat) %>% tau_bar("team", "effort", color = "priority") %>%
            tau_legend() %>% tau_tooltip()
    })

    output$line <- renderTaucharts({
        tauchart(line_dat) %>% 
            tau_line("date", "count", color = "type") %>% 
            tau_guide_x(label="Month") %>% 
            tau_guide_y(label="Count of completed entities", label_padding=50) %>% 
            tau_guide_padding(70, 70, 10, 10) %>%
            tau_legend() %>%
            tau_tooltip()
    })
})

# This is the user-interface definition of a Shiny web application.
# You can find out more about building applications with Shiny here:
#
# http://shiny.rstudio.com
#

library(shiny)
library(htmlwidgets)
library(taucharts)

shinyUI(fluidPage(

  # Application title
  titlePanel("Old Faithful Geyser Data"),

  # Sidebar with a slider input for number of bins
  sidebarPanel(width = 3,
               selectInput(
                   "data", label = h4("Data available:"),
                   choices = c("none", "little", "some", "lots"),
                   selected = 1
               )),
  mainPanel(
    tabsetPanel(
        tabPanel("bar", tauchartsOutput("bar")),
        tabPanel("line", tauchartsOutput("line"))
    )
  )
))
hrbrmstr commented 9 years ago

@ThoDuyNguyen thx for piecing and example together! I just pushed 0.2.5.9000 to the dev branch. It has a new function run_tau_app(). If run with no parameters it will display a list of available built-in apps to run (which is just this one at the moment) and when run with an app name (e.g. run_tau_app("tau01")) will display the location of the app (so it's easy to find the source files) and then run the app. If you can provide your full name I can add you as a contributor to the DESCRIPTION file.

ThoDuyNguyen commented 9 years ago

@hrbrmstr : You can use my name: "Thọ Duy Nguyễn". If you want to make Shiny examples to put into the package, please let me know. I'm planning to use this library for my Shiny dashboard so I think I will have many demos. Kind regards .

happyshows commented 9 years ago

@hrbrmstr just come here to thump up for this package :+1: and maybe add publish to CRAN as to-do item?

hrbrmstr commented 9 years ago

doh! super-good idea. that is def missing and we def need to try to get it on CRAN

On Wed, Aug 5, 2015 at 9:52 PM, Shows Le notifications@github.com wrote:

@hrbrmstr https://github.com/hrbrmstr just come here to thump up for this package [image: :+1:] and maybe add publish to CRAN as to-do item?

— Reply to this email directly or view it on GitHub https://github.com/hrbrmstr/taucharts/issues/1#issuecomment-128208057.

pssguy commented 9 years ago

Great package

TODO requests

Sort out Dates ( I know!) inc ability to show different in tooltip and axis. eg tt 26 Sep 2003, whilst axis just shows years(once!)

ability to angle legend labels

chart title

same opacity on points and legend - or preferably ability to set as required

encourage taucharts guys to do an equivalent of ggplot geom_rect. Or something that can have as background a time period eg presidents time in office, basketball managers tenure as backing to a, say, linechart

More to come(I'm sure)

Keep up the good work

hrbrmstr commented 9 years ago

Danke! A cpl quick comments:

Keep'em coming!

pssguy commented 9 years ago

@hrbrmstr

happyshows commented 9 years ago

@hrbrmstr

One key function missing across almost all htmlwidgets (except for visNetwork) is to return value of selected item. It will open a whole lot of opportunities for answering 'what's next' type of questions. To me this is an extremely important feature for interactive drill down, but somehow it's not mandated by htmlwidgets. Can this be part of to do list?

hrbrmstr commented 9 years ago

Return value of which selected item? Back to R? In the JavaScript?

timelyportfolio commented 9 years ago

I'm guessing https://github.com/DataKnowledge/visNetwork/issues/14 and the broader discussion https://github.com/ramnathv/htmlwidgets/issues/86. Was just playing with this in taucharts last night using the tasks functionality. I'll try to work up some code, but for now it will be a hack.

hrbrmstr commented 9 years ago

is this something taucharts even supports directly (i.e. if they change naming conventions/etc this will break, right?)

happyshows commented 9 years ago

back to R (shiny), in visNetwork there's an option to fetch node. visOptions(nodesIdSelection = TRUE), and the selected id is returned via input$visobjectname_selected

timelyportfolio commented 9 years ago

Yes, it will break, and that is why I hesitated to even discuss.

hrbrmstr commented 9 years ago

@happyshows If you could, perhaps, put a feature issue request to the TauCharts JS folks to provide this functionality so we could add it officially (and properly) vs a hack, it'd be most appreciated.

happyshows commented 9 years ago

@hrbrmstr cool, will look into that.

timelyportfolio commented 9 years ago

Alright, @happyshows here is an example using tau_tasks to add an event listener. I'll caution again this is a hack, but it does demonstrate the power of tasks to completely customize behavior. As an example how this is not really generic and difficult to implement on our side, tau_legend() will remove our click handling elements, so we lose click handling when the legend is toggled.

in JavaScript

In this case, you might want to trigger other actions in JavaScript based on a click event on a TauCharts bar. I'm using a bar chart but this should work for the other chart types also, since I kept the CSS selector generic.

library(taucharts)

esoph_tbl <- xtabs( ncases ~ agegp + alcgp, esoph )

tauchart(esoph_tbl) %>%
  tau_bar( "agegp", "Freq", "alcgp" ) %>%
  tau_tasks(
'
function(){
  d3.select(this.el).selectAll(\'[class^="graphical-report"] .i-role-datum\')[0].forEach(
    function(el){
      el.addEventListener( "click", function(e) {
        alert( "clicked " + JSON.stringify(d3.select(e.target).datum().data) );
      })
    })
}
'
  )

in Shiny

Here we can send the clicked data from TauCharts back to R in Shiny. As a simple example, the data for the clicked bar will be output in a textOutput.

library(shiny)
library(htmlwidgets)
library(taucharts)

ui <- list(
  tauchartsOutput( 'mytauchart' )
  ,textOutput( "messages", container = p)
)

server <- function( input, output, session ){
  output$mytauchart <- renderTaucharts({
    tauchart(esoph_tbl) %>%
      tau_bar( "agegp", "Freq", "alcgp" ) %>%
      tau_tasks(
        '
function(){
  var el_id = this.el.id;
  d3.select(this.el).selectAll(\'[class^="graphical-report"] .i-role-datum\')[0].forEach(
    function(el){
      el.addEventListener( "click", function(e) {
        Shiny.onInputChange(
          el_id + "_click",
          {data:d3.select(e.target).datum().data}
        )
      })
    })
}
'
      )
  })

    # from https://github.com/rstudio/leaflet/blob/master/inst/examples/shiny.R
    v <- reactiveValues(msg = "")

    observeEvent(input$mytauchart_click, {
      v$msg <- paste("Clicked ", input$mytauchart_click$data)
    })

    output$messages <- renderText(v$msg)

}

shinyApp(ui,server)
happyshows commented 9 years ago

@timelyportfolio thanks for the explanation and solution.

timelyportfolio commented 9 years ago

@hrbrmstr , I can try to implement this https://github.com/TargetProcess/tauCharts/issues/68, but I thought you might have ideas, so I didn't want to head down the wrong path. cc @happyshows

bob-rietveld commented 9 years ago

Hi, thanks for making this great widget, super useful. I have been making some nice charts and wanted to share / export them. Would it be possible to add a save to png function? I found a tauchart implementation here http://blog.taucharts.com/svg-to-png/.

Cheers,

Bob

timelyportfolio commented 9 years ago

@good-marketing svg styles make exporting any svg based chart really tricky. For now, see if http://www.buildingwidgets.com/blog/2015/4/9/week-14-exporting-widget might help. Let me know. I haven't tried it yet with taucharts. Well, actually I just tried it with no luck. I'll try to debug and let you know.

hrbrmstr commented 9 years ago

I still like the phantomjs approach - https://github.com/ramnathv/htmlwidgets/issues/95 and have used widgetThumbnail (https://github.com/hafen/trelliscope/blob/master/R/thumb.R) on more than one occasion (more for streamgraph than this pkg tho). I realize phantomjs is a heavy dependency and would not easily get widgets on CRAN. however, there's nothing stopping folks from using that function w/o it being embedded in a pkg (it works with any widget AFAICanTell).

happyshows commented 8 years ago

@timelyportfolio just want to follow up with you, any luck so far with the click hanlding update? Or let's just wait till Joe Cheng release the new mechanism via Shiny?

timelyportfolio commented 8 years ago

@happyshows have not had a chance yet, but I do intend to address in the next 3 weeks.