Skip to content

Commit

Permalink
tweaks to deal with ES version in RStudio
Browse files Browse the repository at this point in the history
  • Loading branch information
Laura Wilson authored and Laura Wilson committed May 24, 2017
1 parent 9534d67 commit adf6f79
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions inst/htmlwidgets/scatterplotThree.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ Widget.scatter = function(w, h)
mouse.y = -2 * (ev.clientY - canvasRect.top) / canvasRect.height + 1;
raycaster.setFromCamera(mouse, _this.camera);
var I = raycaster.intersectObject(_this.pointgroup, true);
if(I.length > 0)
if(I && I.length > 0)
{
if(I[0].object.type == "Points")
{
Expand Down Expand Up @@ -588,13 +588,14 @@ Widget.scatter = function(w, h)
// helper function to add text to 'object'
function addText(object, string, scale, x, y, z, color)
{
var log2 = function(x) {return Math.log(x) / Math.log(2);}; // no Math.log2 function in RStudio on Windows :(
var canvas = document.createElement('canvas');
var context = canvas.getContext('2d');
scale = scale / 4;
context.fillStyle = "#" + color.getHexString();
context.textAlign = 'center';
context.font = fontaxis;
var size = Math.max(64, Math.pow(2, Math.ceil(Math.log2(context.measureText(string).width))));
var size = Math.max(64, Math.pow(2, Math.ceil(log2(context.measureText(string).width))));
canvas.width = size;
canvas.height = size;
scale = scale * (size / 128);
Expand Down

1 comment on commit adf6f79

@lintr-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

R/scatterplot.R:265:30: style: Remove spaces before the left parenthesis in a function call.

x <- lapply(x, function(x) (x[, 1:3, drop=FALSE] - rep(mn, each = n)) / (rep(mx - mn, each = n)))
                             ^

Please sign in to comment.