8000 Scatterpolargl by dy · Pull Request #2230 · plotly/plotly.js · GitHub
[go: up one dir, main page]

Skip to content

Scatterpolargl #2230

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

Closed
wants to merge 72 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
58d53e8
move (old) polar code to legacy/ folder
etpinard Nov 20, 2017
853581e
introduce scatterpolar attributes
etpinard Dec 11, 2017
3c8ae5b
introduce polar subplot attributes
etpinard Dec 11, 2017
ca8081b
introduce angles helper module
etpinard Dec 11, 2017
46fe066
first cut polar subplot defaults and draw routines
etpinard Dec 11, 2017
0826ee7
first cut scatterpolar calc/defaults/plot/style/hover
etpinard Dec 11, 2017
9770f2c
misc things to get scatterpolar traces to show up
etpinard Dec 11, 2017
0b85af2
init categories stashes for polar axes
etpinard Dec 11, 2017
cbf19c1
allow ticksuffix dflt to be passed via option
etpinard Dec 11, 2017
86204a6
get polar axis updates to work
etpinard Dec 11, 2017
0027f53
add legacy deprecation warnings
etpinard Dec 11, 2017
4cdc301
remove obsolete check for polar in registry
etpinard Dec 11, 2017
a5a719c
get snapshot redraw function right for (new) polar
etpinard Dec 11, 2017
da720aa
improve scatterpolar hover
etpinard Dec 11, 2017
04a886b
use subplot ref in scatterternary hover pointData
etpinard Dec 11, 2017
22cf4ba
expose a few things out of cartesian dragbox for :recycle:
etpinard Dec 11, 2017
122dd0b
uber wip polar main drag interaction
etpinard Dec 11, 2017
689414c
add radial axis drag interactions
etpinard Dec 11, 2017
543b615
first cut polar mocks!
etpinard Dec 11, 2017
b64928d
regl-ify scattergl by dfcreative
etpinard Dec 12, 2017
963d3fd
Merge branch 'polar' into scatterpolargl
etpinard Dec 12, 2017
1701284
first steps for scatterpolargl
etpinard Dec 12, 2017
46c58a9
Refactor scattergl to allow for scatterpolargl extension
dy Dec 13, 2017
aa2ed4f
Make basic scatterpolargl trace
dy Dec 14, 2017
ef5fa9e
Fix polargl hover
dy Dec 14, 2017
54b3f1c
Merge branch 'master' into polar
etpinard Dec 15, 2017
17503cb
make scatter{ternary,polar,carpet} Scatter.style reuse straight-up
etpinard Dec 14, 2017
7b0f718
add test for commit 86204a6 (ternary ax tickfont relayouts)
etpinard Dec 14, 2017
fbea869
:palm_tree: domain attributes
etpinard Dec 14, 2017
1e769f0
make non-zero radialaxis.range[0] work
etpinard Dec 14, 2017
f53495e
make radial/angular axis visible: false cases work
etpinard Dec 14, 2017
c5a3a72
1st pass isPtWithinSector algo
etpinard Dec 15, 2017
c452918
Merge remote-tracking branch 'origin/polar' into scatterpolargl
dy Dec 15, 2017
e8276ac
Filter points by range
dy Dec 15, 2017
a8532fa
Bump regl-scatter2d
dy Dec 15, 2017
61e155c
warn -> log for polar deprecation
etpinard Dec 15, 2017
5e874fb
Make toSVG
dy Dec 15, 2017
dd4c3d2
Bump regl-scatter2d
dy Dec 15, 2017
6991e75
Fix gotchas
dy Dec 15, 2017
0de4230
bundle for demo
etpinard Dec 15, 2017
59f3fe7
Replace filtering with discarding
dy Dec 15, 2017
e35e3de
Fix losing data on update
dy Dec 15, 2017
d9723d0
Fix radians thetaunits
dy Dec 15, 2017
5cd24e6
bundle 2 for demo
etpinard Dec 15, 2017
1b077f3
warn -> log for polar deprecation
etpinard Dec 15, 2017
258600d
:hocho: special polygon logic from scatterpolar/plot
etpinard Dec 18, 2017
0a41da5
implement {angular,radial}axis.layer
etpinard Dec 18, 2017
f3a2379
:palm_tree: make filter-visible work for calcdata containers
etpinard Dec 19, 2017
3f5e77b
first cut radial axis drag intractions
etpinard Dec 19, 2017
65b717d
get `polar.sector` working on category angular axes
etpinard Dec 19, 2017
13568a3
fixup isPtWithinSector
etpinard Dec 20, 2017
797fec1
add support for 'log' radial axes
etpinard Dec 20, 2017
0a9278c
fixup axis autotype logic for visible: false traces
etpinard Dec 22, 2017
07a3af7
make sure that angular setting relayout call propagate to tick labels
etpinard Dec 22, 2017
a263c1c
solid zoombox try + some pan work and radial drag fixups
etpinard Dec 22, 2017
356c1c5
[wip] some scatterpolar hover label tests
etpinard Dec 22, 2017
7c0dccc
Merge branch 'polar', remote-tracking branch 'origin' into scatterpol…
etpinard Dec 22, 2017
a695ac6
bundle for demo 2
etpinard Dec 22, 2017
883a30a
add scatterpolargl mock
etpinard Dec 22, 2017
c8c190e
fixup log radial range
etpinard Dec 23, 2017
45eced7
pretty solid zoom/pan interactions
etpinard Dec 23, 2017
f772132
Fix gl2d_click_test
dy Jan 3, 2018
783c617
Fix gl_plot_interact tests
dy Jan 3, 2018
268d3b1
Attempt to fix gl_plot_interact test
dy Jan 3, 2018
ad5ca91
Add gl2d_fonts baseline
dy Jan 3, 2018
2988d18
Adjust test params
dy Jan 3, 2018
02e2554
Merge branch 'master' into scatterpolargl
dy Jan 3, 2018
95b2db1
Make polar selection reflect panning
dy Jan 4, 2018
bfeb39d
Fix polargl selection + pan
dy Jan 4, 2018
8133552
Lintify
dy Jan 4, 2018
61076ce
Handle multiple subplots selection properly
dy Jan 5, 2018
320c4c9
Fix single-color open markers
dy Jan 11, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Filter points by range
  • Loading branch information
dy committed Dec 15, 2017
commit e8276acb9fd0ab6d79a0ba7e001ca6684f39cf5d
67 changes: 34 additions & 33 deletions src/traces/scattergl/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,13 @@ ScatterGl.calc = function calc(container, trace) {
}

// create scene
var scene = ScatterGl.scene(container, subplot, trace, positions, options);
var scene = ScatterGl.scene(container, subplot);

// set flags to create scene renderers
if(options.fill && !scene.fill2d) scene.fill2d = true;
if(options.marker && !scene.scatter2d) scene.scatter2d = true;
if(options.line && !scene.line2d) scene.line2d = true;
if((options.errorX || options.errorY) && !scene.error2d) scene.error2d = true;

// save scene options batch
scene.lineOptions.push(options.line);
Expand Down Expand Up @@ -516,11 +522,9 @@ ScatterGl.sceneOptions = function sceneOptions(container, subplot, trace, positi


// make sure scene exists on subplot
ScatterGl.scene = function getScene(container, subplot, trace, positions, options) {
ScatterGl.scene = function getScene(container, subplot) {
var scene = subplot._scene;
var layout = container._fullLayout;
var xaxis = Axes.getFromId(container, trace.xaxis);
var yaxis = Axes.getFromId(container, trace.yaxis);

if(!subplot._scene) {
scene = subplot._scene = {
Expand All @@ -542,10 +546,10 @@ ScatterGl.scene = function getScene(container, subplot, trace, positions, option
unselectBatch: null,

// regl- component stubs, initialized in dirty plot call
fill2d: !!options.fill,
scatter2d: !!options.marker,
error2d: !!(options.errorX || options.errorY),
line2d: !!options.line,
fill2d: false,
scatter2d: false,
error2d: false,
line2d: false,
select2d: null
};

Expand All @@ -566,7 +570,6 @@ ScatterGl.scene = function getScene(container, subplot, trace, positions, option

// draw traces in proper order
scene.draw = function draw() {

for(var i = 0; i < scene.count; i++) {
if(scene.fill2d) scene.fill2d.draw(i);
if(scene.line2d) {
Expand Down Expand Up @@ -594,27 +597,31 @@ ScatterGl.scene = function getScene(container, subplot, trace, positions, option
scene.clear = function clear() {
var vpSize = layout._size, width = layout.width, height = layout.height;
var vp = [
vpSize.l + (xaxis ? xaxis.domain[0] : 0) * vpSize.w,
vpSize.b + (yaxis ? yaxis.domain[0] : 0) * vpSize.h,
(width - vpSize.r) - (1 - (xaxis ? xaxis.domain[1] : 1)) * vpSize.w,
(height - vpSize.t) - (1 - (yaxis ? yaxis.domain[1] : 1)) * vpSize.h
vpSize.l,
vpSize.b,
(width - vpSize.r),
(height - vpSize.t)
];

var gl, regl;

regl = scene.select2d.regl;
gl = regl._gl;
gl.enable(gl.SCISSOR_TEST);
gl.scissor(vp[0], vp[1], vp[2] - vp[0], vp[3] - vp[1]);
gl.clearColor(0, 0, 0, 0);
gl.clear(gl.COLOR_BUFFER_BIT);

regl = scene.scatter2d.regl;
gl = regl._gl;
gl.enable(gl.SCISSOR_TEST);
gl.scissor(vp[0], vp[1], vp[2] - vp[0], vp[3] - vp[1]);
gl.clearColor(0, 0, 0, 0);
gl.clear(gl.COLOR_BUFFER_BIT);
if(scene.select2d) {
regl = scene.select2d.regl;
gl = regl._gl;
gl.enable(gl.SCISSOR_TEST);
gl.scissor(vp[0], vp[1], vp[2] - vp[0], vp[3] - vp[1]);
gl.clearColor(0, 0, 0, 0);
gl.clear(gl.COLOR_BUFFER_BIT);
}

if(scene.scatter2d) {
regl = scene.scatter2d.regl;
gl = regl._gl;
gl.enable(gl.SCISSOR_TEST);
gl.scissor(vp[0], vp[1], vp[2] - vp[0], vp[3] - vp[1]);
gl.clearColor(0, 0, 0, 0);
gl.clear(gl.COLOR_BUFFER_BIT);
}
};

// remove selection
Expand Down Expand Up @@ -648,12 +655,6 @@ ScatterGl.scene = function getScene(container, subplot, trace, positions, option
delete subplot._scene;
};
}
else {
if(!!options.fill && !scene.fill2d) scene.fill2d = true;
if(!!options.marker && !scene.scatter2d) scene.scatter2d = true;
if(!!options.line && !scene.line2d) scene.line2d = true;
if(!!(options.errorX || options.errorY) && !scene.error2d) scene.error2d = true;
}

// In case if we have scene from the last calc - reset data
if(!scene.dirty) {
Expand Down Expand Up @@ -942,7 +943,7 @@ ScatterGl.plot = function plot(container, subplot, cdata) {
} : null;
});

// uploat batch data to GPU
// uploat viewport/range data to GPU
if(scene.fill2d) {
scene.fill2d.update(vpRange);
}
Expand Down
161 changes: 100 additions & 61 deletions src/traces/scatterpolargl/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,42 +15,23 @@ var Axes = require('../../plots/cartesian/axes');
var kdtree = require('kdgrass');
var Lib = require('../../lib');


function calc(container, trace) {
var layout = container._fullLayout;
var subplotId = trace.subplot;
var radialAxis = layout[subplotId].radialaxis;
var angularAxis = layout[subplotId].angularaxis;
var rArray = radialAxis.makeCalcdata(trace, 'r');
var thetaArray = angularAxis.makeCalcdata(trace, 'theta');
var count = rArray.length;
var stash = {};
var subplot = layout[subplotId];

var positions = new Array(count * 2), x = Array(count), y = Array(count);

function c2rad(v) {
return angularAxis.c2rad(v, trace.thetaunit);
}

for(var i = 0; i < count; i++) {
var r = rArray[i];
var theta = thetaArray[i];

if(isNumeric(r) && isNumeric(theta)) {
var rad = c2rad(theta);

x[i] = positions[i * 2] = r * Math.cos(rad);
y[i] = positions[i * 2 + 1] = r * Math.sin(rad);
} else {
x[i] = y[i] = 8000 positions[i * 2] = positions[i * 2 + 1] = NaN;
}
}

calcColorscales(trace);

stash.r = rArray;
stash.theta = thetaArray;

var options = ScatterGl.sceneOptions(container, subplot, trace, positions);

// FIXME: remove this once .plot API gets compatible w/others
stash.container = container;

Axes.expand(radialAxis, rArray, {tozero: true});

Expand All @@ -59,48 +40,106 @@ function calc(container, trace) {
Axes.expand(angularAxis, thetaArray);
}

var scene = ScatterGl.scene(container, subplot, trace, positions, options);

// save scene options batch
scene.lineOptions.push(options.line);
scene.errorXOptions.push(options.errorX);
scene.errorYOptions.push(options.errorY);
scene.fillOptions.push(options.fill);
scene.markerOptions.push(options.marker);
scene.selectedOptions.push(options.selected);
scene.unselectedOptions.push(options.unselected);
scene.count++;

// stash scene ref
stash.scene = scene;
stash.index = scene.count - 1;
stash.x = x;
stash.y = y;
stash.rawx = x;
stash.rawy = y;
stash.r = rArray;
stash.theta = thetaArray;
stash.positions = positions;
stash.count = count;
return [{x: false, y: false, t: stash, trace: trace}];
}

// FIXME: remove this later on once we get rid of .plot wrapper
stash.container = container;

// FIXME: delegate this to webworker
stash.tree = kdtree(positions, 512);
// var ids = stash.ids = Array(count);
// for(i = 0; i < count; i++) {
// ids[i] = i;
// }
function plot(subplot, cdata) {
var stash = cdata[0][0].t;
var container = stash.container;
var radialAxis = subplot.radialAxis;
var angularAxis = subplot.angularAxis;
var rRange = radialAxis.range;
var thetaRange = angularAxis.range;

var scene = ScatterGl.scene(container, subplot);
scene.clear();

cdata.forEach(function(cdscatter, traceIndex) {
if(!cdscatter || !cdscatter[0] || !cdscatter[0].trace) return;
var cd = cdscatter[0];
var trace = cd.trace;
var stash = cd.t;
var rArray = stash.r;
var thetaArray = stash.theta;
var i, r, theta;

// filter out by range
var newRadialArray = [];
var newThetaArray = [];

for(i = 0; i < rArray.length; i++) {
r = rArray[i], theta = thetaArray[i];

if(theta < 0) theta += 360;

if(r >= rRange[0] && r <= rRange[1] && theta >= thetaRange[0] && theta <= thetaRange[1]) {
newRadialArray.push(r);
newThetaArray.push(theta);
}
}

return [{x: false, y: false, t: stash, trace: trace}];
}
rArray = newRadialArray;
thetaArray = newThetaArray;

var count = rArray.length;
var positions = new Array(count * 2), x = Array(count), y = Array(count);

function c2rad(v) {
return angularAxis.c2rad(v, trace.thetaunit);
}

for(i = 0; i < count; i++) {
r = rArray[i];
theta = thetaArray[i];

if(isNumeric(r) && isNumeric(theta)) {
var rad = c2rad(theta);

x[i] = positions[i * 2] = r * Math.cos(rad);
y[i] = positions[i * 2 + 1] = r * Math.sin(rad);
} else {
x[i] = y[i] = positions[i * 2] = positions[i * 2 + 1] = NaN;
}
}

// FIXME: remove this wrapper once .plot args get consistent order
function plot(plotinfo, cdata) {
var container = cdata[0][0].t.container;
return ScatterGl.plot(container, plotinfo, cdata);
var options = ScatterGl.sceneOptions(container, subplot, trace, positions);

// set flags to create scene renderers
if(options.fill && !scene.fill2d) scene.fill2d = true;
if(options.marker && !scene.scatter2d) scene.scatter2d = true;
if(options.line && !scene.line2d) scene.line2d = true;
if((options.errorX || options.errorY) && !scene.error2d) scene.error2d = true;

// save scene options batch
scene.lineOptions.push(options.line);
scene.errorXOptions.push(options.errorX);
scene.errorYOptions.push(options.errorY);
scene.fillOptions.push(options.fill);
scene.markerOptions.push(options.marker);
scene.selectedOptions.push(options.selected);
scene.unselectedOptions.push(options.unselected);
scene.count = cdata.length;

// stash scene ref
stash.scene = scene;
stash.index = traceIndex;
stash.x = x;
stash.y = y;
stash.rawx = x;
stash.rawy = y;
stash.r = rArray;
stash.theta = thetaArray;
stash.positions = positions;
stash.count = count;
stash.tree = kdtree(positions, 512);
// var ids = stash.ids = Array(count);
// for(i = 0; i < count; i++) {
// ids[i] = i;
// }
});

return ScatterGl.plot(container, subplot, cdata);
}


Expand Down
0