Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stemPlot stopped working #238

Open
bbTomas opened this issue Nov 13, 2019 · 2 comments
Open

stemPlot stopped working #238

bbTomas opened this issue Nov 13, 2019 · 2 comments
Assignees

Comments

@bbTomas
Copy link

bbTomas commented Nov 13, 2019

stemPlot does not show anything, it worked in older versions (and stepPlot still works fine in this version)

Reproducible example:

library(dygraphs)
lungDeaths <- cbind(mdeaths, fdeaths)
dygraph(lungDeaths, main = "Deaths from Lung Disease (UK)") %>%
    dyOptions(stemPlot = TRUE)
@przmv przmv self-assigned this Nov 15, 2019
@rschuchmann
Copy link

I just realized that this has something to do with the htmlwidgets package. With htmlwidgets v1.3 the stemplot is working, with the latest version it is not.

@bbTomas
Copy link
Author

bbTomas commented May 2, 2020

I have just realized how to fix the problem. @pshevtsov Please, add the last line of code into R/series.R, function resolveStemPlot:

# provide custom plotter JS
    "function stemPlotter(e) { 
       var ctx = e.drawingContext; 
       var points = e.points; 
       var y_bottom = e.dygraph.toDomYCoord(0);
       ctx.fillStyle = e.color; 
       for (var i = 0; i < points.length; i++) { 
          var p = points[i]; 
          var center_x = p.canvasx;
          var center_y = p.canvasy; 
          ctx.beginPath(); 
          ctx.moveTo(center_x, y_bottom); 
          ctx.lineTo(center_x, center_y); 
          ctx.stroke();
          ctx.beginPath(); 
          ctx.arc(center_x, center_y, 3, 0, 2*Math.PI); 
          ctx.stroke();
       }
    }
    Dygraph.Plotters.StemPlotter = stemPlotter;"     # <--- please add this line of code

The same thing should be probably added into the inst/plotters/stemplot.js file.

bbTomas added a commit to bbTomas/dygraphs that referenced this issue Sep 30, 2020
line 314 fixes issue "stemPlot stopped working rstudio#238"
bbTomas added a commit to bbTomas/dygraphs that referenced this issue Sep 30, 2020
Line 22 fixes issue "stemPlot stopped working rstudio#238"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants