dySliderInput plugin and minor bug fix#135
Open
jeffreyhanson wants to merge 1 commit into
Open
Conversation
Member
|
This is a great PR and I very much look forward to merging it! I'm tied up this week but will have a look early the following week. |
Collaborator
|
@jeffreyhanson Could you please divide your PR into several smaller ones to easier review and merge? |
Contributor
Author
|
I'm sorry I don't have any time to work on this for the foreseeable future. Please feel free to close this PR if needed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
dySliderInput
Overview
This pull request includes a
dySliderInputplugin that turns dygraphs into a slider input widget. Check out this online demo at shinyapps.io. Dygraphs offers great potential for many plugins and I think it would be great if these were all available from this package so that users can easily access them. To that end, I have added functions for this plugin and the other plugins (dyUnzoomanddyCrosshair) so that users can use these plugins. It also fixes a bug in returning date-times from dygraphs.How does dySliderInput work?
I have written a dygraphs plugin called
dySliderInputin javascript. This plugin can be compiled using thedyPluginfunction and added to an existingdygraphobject. Once added to adygraphobject, users can click on the dygraph and a bar will be added to mark closest data point (which can be accessed programatically usinginput$dygraph_click$date). Additionally, users can animate the slider bar by clicking on the play button. The animation can be customised similar to that inshiny::sliderInputusing theshiny::animationOptionsfunction. This plugin is best used when in conjunction with other widgets. For instance, it could be used with the leaflet R package to show spatio-temporal data (as shown in the demo). This plugin is compatible with thedyRangeSelector. I have included the above demo as an example in the package.Proposed usage of dySliderInput
List of changes
Here I will list all the changes I have made to this package, and my rationale behind them.
dySliderInput
NAMESPACE: Now includes thedySliderInputfunction and functions it uses in other packages (grDevices::col2rgb,shiny::icon, andshiny::animationOptions).DESCRIPTION: ThedySliderInputfunction uses theanimationOptionsandiconfunctions from shiny. Thus I have added 'shiny' to the imports section of the package. Additionally, becausedevtools::check()does not allow packages to listed under imports and enchances, I have removed shiny from enhances.R/plugins.R: I have added thedySliderInputfunction to allow users to add this plugin.tests/testthat/test-slider-input.R: This provides a test for thedySliderInputfunction.inst/examples/shiny_2: I have added the code for thedySliderInputdemo here.inst/examples/plugins/sliderinput.js: This include the code for thedySliderInputplugin.Bug fix
inst/htmlwidgets/dygraphs.js:input$dygraph_clickandinput$dygraph_date_windowvariables in a shiny session. The variables are based on a call tonew Date(x)in javascript. However, just returning this can cause the returned dates to be incorrect.Dateobject. To do this, I have included ashinyValueFormatterfunction that uses the function that generates x-axis labels (xValueFormatterFixedTZorxValueFormatter) to correctly parse the string.xValueFormatteroriginally made a call toDate().toLocaleStringwhich uses different date-time formats depending on the environment, I have changed this to manually parse the same date-time format returned fromxValueFormatterFixedTZ(but without the time-zone information).DyUnzoom and dyCrosshair functions
NAMESPACE: Now includes thedygraphs::dyCrosshair,dygraphs::dyUnzoomfunctions.R/plugins.R: I have added thedyCrosshair,dyUnzoomfunctions to allow users to add these plugins.tests/testthat/test-crosshair.R: This provides a test for thedyCrosshairfunction.tests/testthat/test-unzoom.R: This provides a test for thedyUnzoomfunction.Miscellaneous
I really would like to see the
dySliderInputwidget incorporated into the dygraphs R package, so please let me know if you disagree with any of these changes, and I will update my PR accordingly.