{"action":"created","comment":{"url":"https://api.github.com/repos/plotly/plotly.js/pulls/comments/74613490","id":74613490,"diff_hunk":"@@ -0,0 +1,183 @@\n+/**\n+* Copyright 2012-2016, Plotly, Inc.\n+* All rights reserved.\n+*\n+* This source code is licensed under the MIT license found in the\n+* LICENSE file in the root directory of this source tree.\n+*/\n+\n+'use strict';\n+\n+var createPointcloud2d = require('gl-pointcloud2d');\n+var isNumeric = require('fast-isnumeric');\n+\n+var str2RGBArray = require('../../lib/str2rgbarray');\n+var getTraceColor = require('../scatter/get_trace_color');\n+\n+var AXES = ['xaxis', 'yaxis'];\n+\n+function Pointcloud(scene, uid) {\n+    this.scene = scene;\n+    this.uid = uid;\n+\n+    this.pickXData = [];\n+    this.pickYData = [];\n+    this.xData = [];\n+    this.yData = [];\n+    this.textLabels = [];\n+    this.color = 'rgb(0, 0, 0)';\n+    this.name = '';\n+    this.hoverinfo = 'all';\n+\n+    this.idToIndex = [];\n+    this.bounds = [0, 0, 0, 0];\n+\n+    this.pointcloudOptions = {\n+        positions: new Float32Array(0),\n+        size: 12,\n+        color: [0, 0, 0, 1],\n+        borderSize: 1,\n+        borderColor: [0, 0, 0, 1]\n+    };\n+    this.pointcloud = createPointcloud2d(scene.glplot, this.pointcloudOptions);\n+    this.pointcloud._trace = this; // scene2d requires this prop\n+}\n+\n+var proto = Pointcloud.prototype;\n+\n+proto.handlePick = function(pickResult) {\n+\n+    var index = this.idToIndex[pickResult.pointId];\n+\n+    return {\n+        trace: this,\n+        dataCoord: pickResult.dataCoord,\n+        traceCoord: [\n+            this.pickXData[index],\n+            this.pickYData[index]\n+        ],\n+        textLabel: Array.isArray(this.textLabels) ?\n+            this.textLabels[index] :\n+            this.textLabels,\n+        color: Array.isArray(this.color) ?\n+            this.color[index] :\n+            this.color,\n+        name: this.name,\n+        hoverinfo: this.hoverinfo\n+    };\n+};\n+\n+/**\n+ * Truncate a Float32Array to some length. A wrapper to support environments\n+ * (e.g. node-webkit) that do not implement Float32Array.prototype.slice\n+ */\n+function truncate(float32ArrayIn, len) {\n+    if(Float32Array.slice === undefined) {\n+        var float32ArrayOut = new Float32Array(len);\n+        for(var i = 0; i < len; i++) float32ArrayOut[i] = float32ArrayIn[i];\n+        return float32ArrayOut;\n+    }\n+\n+    return float32ArrayIn.slice(0, len);\n+}\n+\n+proto.update = function(options) {\n+\n+    this.textLabels = options.text;\n+    this.name = options.name;\n+    this.hoverinfo = options.hoverinfo;\n+    this.bounds = [Infinity, Infinity, -Infinity, -Infinity];\n+\n+    this.updateFast(options);\n+\n+    this.color = getTraceColor(options, {});\n+};\n+\n+proto.updateFast = function(options) {\n+    var x = this.xData = this.pickXData = options.x;\n+    var y = this.yData = this.pickYData = options.y;\n+\n+    var len = x.length,\n+        idToIndex = new Array(len),\n+        positions = new Float32Array(2 * len),\n+        bounds = this.bounds,\n+        pId = 0,\n+        ptr = 0;\n+\n+    var xx, yy;\n+\n+    // TODO add 'very fast' mode that bypasses this loop\n+    // TODO bypass this on modebar +/- zoom\n+    for(var i = 0; i < len; ++i) {\n+        xx = x[i];\n+        yy = y[i];\n+\n+        // check for isNaN is faster but doesn't skip over nulls\n+        if(!isNumeric(xx) || !isNumeric(yy)) continue;\n+\n+        idToIndex[pId++] = i;\n+\n+        positions[ptr++] = xx;\n+        positions[ptr++] = yy;\n+\n+        bounds[0] = Math.min(bounds[0], xx);\n+        bounds[1] = Math.min(bounds[1], yy);\n+        bounds[2] = Math.max(bounds[2], xx);\n+        bounds[3] = Math.max(bounds[3], yy);\n+    }\n+\n+    positions = truncate(positions, ptr);\n+    this.idToIndex = idToIndex;\n+\n+    var markerSize;\n+\n+    this.pointcloudOptions.positions = positions;\n+\n+    var markerColor = str2RGBArray(options.marker.color),\n+        borderColor = str2RGBArray(options.marker.line.color),\n+        opacity = options.opacity * options.marker.opacity;\n+\n+    markerColor[3] *= opacity;\n+    this.pointcloudOptions.color = markerColor;\n+\n+    borderColor[3] *= opacity;\n+    this.pointcloudOptions.borderColor = borderColor;\n+\n+    markerSize = options.marker.size;\n+    this.pointcloudOptions.size = markerSize;\n+    this.pointcloudOptions.borderSize = options.marker.line.width;\n+\n+    this.pointcloud.update(this.pointcloudOptions);\n+\n+    // add item for autorange routine\n+    this.expandAxesFast(bounds, markerSize);\n+};\n+\n+proto.expandAxesFast = function(bounds, markerSize) {\n+    var pad = markerSize || 10;\n+    var ax, min, max;\n+\n+    for(var i = 0; i < 2; i++) {\n+        ax = this.scene[AXES[i]];\n+\n+        min = ax._min;\n+        if(!min) min = [];\n+        min.push({ val: bounds[i], pad: pad });\n+\n+        max = ax._max;\n+        if(!max) max = [];\n+        max.push({ val: bounds[i + 2], pad: pad });\n+    }\n+};\n+\n+proto.dispose = function() {\n+    this.pointcloud.dispose();\n+};\n+\n+function createPointcloud(scene, data) {\n+    var plot = new Pointcloud(scene, data.uid);\n+    plot.update(data);\n+    return plot;\n+}\n+\n+module.exports = createPointcloud;","path":"src/traces/pointcloud2d/convert.js","position":183,"original_position":183,"commit_id":"98f90ad8c674c158bdd62119f4a076a058107e3e","original_commit_id":"98f90ad8c674c158bdd62119f4a076a058107e3e","user":{"login":"etpinard","id":6675409,"avatar_url":"https://avatars.githubusercontent.com/u/6675409?v=3","gravatar_id":"","url":"https://api.github.com/users/etpinard","html_url":"https://github.com/etpinard","followers_url":"https://api.github.com/users/etpinard/followers","following_url":"https://api.github.com/users/etpinard/following{/other_user}","gists_url":"https://api.github.com/users/etpinard/gists{/gist_id}","starred_url":"https://api.github.com/users/etpinard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/etpinard/subscriptions","organizations_url":"https://api.github.com/users/etpinard/orgs","repos_url":"https://api.github.com/users/etpinard/repos","events_url":"https://api.github.com/users/etpinard/events{/privacy}","received_events_url":"https://api.github.com/users/etpinard/received_events","type":"User","site_admin":false},"body":"Nicely done.","created_at":"2016-08-12T15:46:39Z","updated_at":"2016-08-12T15:46:39Z","html_url":"https://github.com/plotly/plotly.js/pull/850#discussion_r74613490","pull_request_url":"https://api.github.com/repos/plotly/plotly.js/pulls/850","_links":{"self":{"href":"https://api.github.com/repos/plotly/plotly.js/pulls/comments/74613490"},"html":{"href":"https://github.com/plotly/plotly.js/pull/850#discussion_r74613490"},"pull_request":{"href":"https://api.github.com/repos/plotly/plotly.js/pulls/850"}}},"pull_request":{"url":"https://api.github.com/repos/plotly/plotly.js/pulls/850","id":81137548,"html_url":"https://github.com/plotly/plotly.js/pull/850","diff_url":"https://github.com/plotly/plotly.js/pull/850.diff","patch_url":"https://github.com/plotly/plotly.js/pull/850.patch","issue_url":"https://api.github.com/repos/plotly/plotly.js/issues/850","number":850,"state":"open","locked":false,"title":"[WIP] adding point cloud","user":{"login":"monfera","id":1548516,"avatar_url":"https://avatars.githubusercontent.com/u/1548516?v=3","gravatar_id":"","url":"https://api.github.com/users/monfera","html_url":"https://github.com/monfera","followers_url":"https://api.github.com/users/monfera/followers","following_url":"https://api.github.com/users/monfera/following{/other_user}","gists_url":"https://api.github.com/users/monfera/gists{/gist_id}","starred_url":"https://api.github.com/users/monfera/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monfera/subscriptions","organizations_url":"https://api.github.com/users/monfera/orgs","repos_url":"https://api.github.com/users/monfera/repos","events_url":"https://api.github.com/users/monfera/events{/privacy}","received_events_url":"https://api.github.com/users/monfera/received_events","type":"User","site_admin":false},"body":"This PR contains the plotly.js part of the new `pointcloud2d` trace type.\r\n\r\nWork left involves\r\n\r\n- [ ] changing certain things about sizing\r\n- [ ] removing some disused marker options\r\n- [ ] npm publish `gl-pointcloud2d`\r\n- [ ] image test cases\r\n","created_at":"2016-08-12T15:26:20Z","updated_at":"2016-08-12T15:46:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"39b98eff0d1b0b6c590633b51ac85d780e33ead2","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/plotly/plotly.js/pulls/850/commits","review_comments_url":"https://api.github.com/repos/plotly/plotly.js/pulls/850/comments","review_comment_url":"https://api.github.com/repos/plotly/plotly.js/pulls/comments{/number}","comments_url":"https://api.github.com/repos/plotly/plotly.js/issues/850/comments","statuses_url":"https://api.github.com/repos/plotly/plotly.js/statuses/98f90ad8c674c158bdd62119f4a076a058107e3e","head":{"label":"monfera:pointcloud-squashed","ref":"pointcloud-squashed","sha":"98f90ad8c674c158bdd62119f4a076a058107e3e","user":{"login":"monfera","id":1548516,"avatar_url":"https://avatars.githubusercontent.com/u/1548516?v=3","gravatar_id":"","url":"https://api.github.com/users/monfera","html_url":"https://github.com/monfera","followers_url":"https://api.github.com/users/monfera/followers","following_url":"https://api.github.com/users/monfera/following{/other_user}","gists_url":"https://api.github.com/users/monfera/gists{/gist_id}","starred_url":"https://api.github.com/users/monfera/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monfera/subscriptions","organizations_url":"https://api.github.com/users/monfera/orgs","repos_url":"https://api.github.com/users/monfera/repos","events_url":"https://api.github.com/users/monfera/events{/privacy}","received_events_url":"https://api.github.com/users/monfera/received_events","type":"User","site_admin":false},"repo":{"id":54498444,"name":"plotly.js","full_name":"monfera/plotly.js","owner":{"login":"monfera","id":1548516,"avatar_url":"https://avatars.githubusercontent.com/u/1548516?v=3","gravatar_id":"","url":"https://api.github.com/users/monfera","html_url":"https://github.com/monfera","followers_url":"https://api.github.com/users/monfera/followers","following_url":"https://api.github.com/users/monfera/following{/other_user}","gists_url":"https://api.github.com/users/monfera/gists{/gist_id}","starred_url":"https://api.github.com/users/monfera/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monfera/subscriptions","organizations_url":"https://api.github.com/users/monfera/orgs","repos_url":"https://api.github.com/users/monfera/repos","events_url":"https://api.github.com/users/monfera/events{/privacy}","received_events_url":"https://api.github.com/users/monfera/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/monfera/plotly.js","description":"The open source javascript graphing library that powers plotly","fork":true,"url":"https://api.github.com/repos/monfera/plotly.js","forks_url":"https://api.github.com/repos/monfera/plotly.js/forks","keys_url":"https://api.github.com/repos/monfera/plotly.js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/monfera/plotly.js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/monfera/plotly.js/teams","hooks_url":"https://api.github.com/repos/monfera/plotly.js/hooks","issue_events_url":"https://api.github.com/repos/monfera/plotly.js/issues/events{/number}","events_url":"https://api.github.com/repos/monfera/plotly.js/events","assignees_url":"https://api.github.com/repos/monfera/plotly.js/assignees{/user}","branches_url":"https://api.github.com/repos/monfera/plotly.js/branches{/branch}","tags_url":"https://api.github.com/repos/monfera/plotly.js/tags","blobs_url":"https://api.github.com/repos/monfera/plotly.js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/monfera/plotly.js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/monfera/plotly.js/git/refs{/sha}","trees_url":"https://api.github.com/repos/monfera/plotly.js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/monfera/plotly.js/statuses/{sha}","languages_url":"https://api.github.com/repos/monfera/plotly.js/languages","stargazers_url":"https://api.github.com/repos/monfera/plotly.js/stargazers","contributors_url":"https://api.github.com/repos/monfera/plotly.js/contributors","subscribers_url":"https://api.github.com/repos/monfera/plotly.js/subscribers","subscription_url":"https://api.github.com/repos/monfera/plotly.js/subscription","commits_url":"https://api.github.com/repos/monfera/plotly.js/commits{/sha}","git_commits_url":"https://api.github.com/repos/monfera/plotly.js/git/commits{/sha}","comments_url":"https://api.github.com/repos/monfera/plotly.js/comments{/number}","issue_comment_url":"https://api.github.com/repos/monfera/plotly.js/issues/comments{/number}","contents_url":"https://api.github.com/repos/monfera/plotly.js/contents/{+path}","compare_url":"https://api.github.com/repos/monfera/plotly.js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/monfera/plotly.js/merges","archive_url":"https://api.github.com/repos/monfera/plotly.js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/monfera/plotly.js/downloads","issues_url":"https://api.github.com/repos/monfera/plotly.js/issues{/number}","pulls_url":"https://api.github.com/repos/monfera/plotly.js/pulls{/number}","milestones_url":"https://api.github.com/repos/monfera/plotly.js/milestones{/number}","notifications_url":"https://api.github.com/repos/monfera/plotly.js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/monfera/plotly.js/labels{/name}","releases_url":"https://api.github.com/repos/monfera/plotly.js/releases{/id}","deployments_url":"https://api.github.com/repos/monfera/plotly.js/deployments","created_at":"2016-03-22T18:16:35Z","updated_at":"2016-03-22T18:16:38Z","pushed_at":"2016-08-12T15:33:18Z","git_url":"git://github.com/monfera/plotly.js.git","ssh_url":"git@github.com:monfera/plotly.js.git","clone_url":"https://github.com/monfera/plotly.js.git","svn_url":"https://github.com/monfera/plotly.js","homepage":"https://plot.ly/javascript/","size":128663,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"plotly:master","ref":"master","sha":"2d56127225cb63e7587c81fac96ed06268fe72a9","user":{"login":"plotly","id":5997976,"avatar_url":"https://avatars.githubusercontent.com/u/5997976?v=3","gravatar_id":"","url":"https://api.github.com/users/plotly","html_url":"https://github.com/plotly","followers_url":"https://api.github.com/users/plotly/followers","following_url":"https://api.github.com/users/plotly/following{/other_user}","gists_url":"https://api.github.com/users/plotly/gists{/gist_id}","starred_url":"https://api.github.com/users/plotly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plotly/subscriptions","organizations_url":"https://api.github.com/users/plotly/orgs","repos_url":"https://api.github.com/users/plotly/repos","events_url":"https://api.github.com/users/plotly/events{/privacy}","received_events_url":"https://api.github.com/users/plotly/received_events","type":"Organization","site_admin":false},"repo":{"id":45646037,"name":"plotly.js","full_name":"plotly/plotly.js","owner":{"login":"plotly","id":5997976,"avatar_url":"https://avatars.githubusercontent.com/u/5997976?v=3","gravatar_id":"","url":"https://api.github.com/users/plotly","html_url":"https://github.com/plotly","followers_url":"https://api.github.com/users/plotly/followers","following_url":"https://api.github.com/users/plotly/following{/other_user}","gists_url":"https://api.github.com/users/plotly/gists{/gist_id}","starred_url":"https://api.github.com/users/plotly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plotly/subscriptions","organizations_url":"https://api.github.com/users/plotly/orgs","repos_url":"https://api.github.com/users/plotly/repos","events_url":"https://api.github.com/users/plotly/events{/privacy}","received_events_url":"https://api.github.com/users/plotly/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/plotly/plotly.js","description":"The open source javascript graphing library that powers plotly","fork":false,"url":"https://api.github.com/repos/plotly/plotly.js","forks_url":"https://api.github.com/repos/plotly/plotly.js/forks","keys_url":"https://api.github.com/repos/plotly/plotly.js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/plotly/plotly.js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/plotly/plotly.js/teams","hooks_url":"https://api.github.com/repos/plotly/plotly.js/hooks","issue_events_url":"https://api.github.com/repos/plotly/plotly.js/issues/events{/number}","events_url":"https://api.github.com/repos/plotly/plotly.js/events","assignees_url":"https://api.github.com/repos/plotly/plotly.js/assignees{/user}","branches_url":"https://api.github.com/repos/plotly/plotly.js/branches{/branch}","tags_url":"https://api.github.com/repos/plotly/plotly.js/tags","blobs_url":"https://api.github.com/repos/plotly/plotly.js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/plotly/plotly.js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/plotly/plotly.js/git/refs{/sha}","trees_url":"https://api.github.com/repos/plotly/plotly.js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/plotly/plotly.js/statuses/{sha}","languages_url":"https://api.github.com/repos/plotly/plotly.js/languages","stargazers_url":"https://api.github.com/repos/plotly/plotly.js/stargazers","contributors_url":"https://api.github.com/repos/plotly/plotly.js/contributors","subscribers_url":"https://api.github.com/repos/plotly/plotly.js/subscribers","subscription_url":"https://api.github.com/repos/plotly/plotly.js/subscription","commits_url":"https://api.github.com/repos/plotly/plotly.js/commits{/sha}","git_commits_url":"https://api.github.com/repos/plotly/plotly.js/git/commits{/sha}","comments_url":"https://api.github.com/repos/plotly/plotly.js/comments{/number}","issue_comment_url":"https://api.github.com/repos/plotly/plotly.js/issues/comments{/number}","contents_url":"https://api.github.com/repos/plotly/plotly.js/contents/{+path}","compare_url":"https://api.github.com/repos/plotly/plotly.js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/plotly/plotly.js/merges","archive_url":"https://api.github.com/repos/plotly/plotly.js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/plotly/plotly.js/downloads","issues_url":"https://api.github.com/repos/plotly/plotly.js/issues{/number}","pulls_url":"https://api.github.com/repos/plotly/plotly.js/pulls{/number}","milestones_url":"https://api.github.com/repos/plotly/plotly.js/milestones{/number}","notifications_url":"https://api.github.com/repos/plotly/plotly.js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/plotly/plotly.js/labels{/name}","releases_url":"https://api.github.com/repos/plotly/plotly.js/releases{/id}","deployments_url":"https://api.github.com/repos/plotly/plotly.js/deployments","created_at":"2015-11-05T23:27:17Z","updated_at":"2016-08-12T15:06:47Z","pushed_at":"2016-08-12T15:33:19Z","git_url":"git://github.com/plotly/plotly.js.git","ssh_url":"git@github.com:plotly/plotly.js.git","clone_url":"https://github.com/plotly/plotly.js.git","svn_url":"https://github.com/plotly/plotly.js","homepage":"https://plot.ly/javascript/","size":135311,"stargazers_count":5113,"watchers_count":5113,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":446,"mirror_url":null,"open_issues_count":184,"forks":446,"open_issues":184,"watchers":5113,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/plotly/plotly.js/pulls/850"},"html":{"href":"https://github.com/plotly/plotly.js/pull/850"},"issue":{"href":"https://api.github.com/repos/plotly/plotly.js/issues/850"},"comments":{"href":"https://api.github.com/repos/plotly/plotly.js/issues/850/comments"},"review_comments":{"href":"https://api.github.com/repos/plotly/plotly.js/pulls/850/comments"},"review_comment":{"href":"https://api.github.com/repos/plotly/plotly.js/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/plotly/plotly.js/pulls/850/commits"},"statuses":{"href":"https://api.github.com/repos/plotly/plotly.js/statuses/98f90ad8c674c158bdd62119f4a076a058107e3e"}}}}
{"actor":{"display_login":"etpinard"}}