Skip to content

Point cluster dev #2499

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

Merged
merged 27 commits into from
Mar 28, 2018
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
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
69 changes: 40 additions & 29 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@
"glslify": "^6.1.1",
"has-hover": "^1.0.1",
"has-passive-events": "^1.0.0",
"kdgrass": "^1.0.1",
"mapbox-gl": "0.44.1",
"matrix-camera-controller": "^2.1.3",
"mouse-change": "^1.4.0",
Expand All @@ -96,11 +95,12 @@
"ndarray-fill": "^1.0.2",
"ndarray-homography": "^1.0.0",
"ndarray-ops": "^1.2.2",
"point-cluster": "^3.1.1",
"polybooljs": "^1.2.0",
"regl": "^1.3.1",
"regl-error2d": "^2.0.3",
"regl-line2d": "^2.1.5",
"regl-scatter2d": "^2.1.17",
"regl-scatter2d": "github:dfcreative/regl-scatter2d",
"right-now": "^1.0.0",
"robust-orientation": "^1.1.3",
"sane-topojson": "^2.0.0",
Expand Down
15 changes: 9 additions & 6 deletions src/traces/scattergl/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var createRegl = require('regl');
var createScatter = require('regl-scatter2d');
var createLine = require('regl-line2d');
var createError = require('regl-error2d');
var kdtree = require('kdgrass');
var cluster = require('point-cluster');
var arrayRange = require('array-range');

var Registry = require('../../registry');
Expand Down Expand Up @@ -72,7 +72,7 @@ function calc(gd, trace) {
// and it is also
if(xa.type !== 'log' && ya.type !== 'log') {
// FIXME: delegate this to webworker
stash.tree = kdtree(positions, 512);
stash.tree = cluster(positions);
} else {
var ids = stash.ids = new Array(count);
for(i = 0; i < count; i++) {
Expand Down Expand Up @@ -104,6 +104,12 @@ function calc(gd, trace) {
if(opts.line && !scene.line2d) scene.line2d = true;
if((opts.errorX || opts.errorY) && !scene.error2d) scene.error2d = true;

// FIXME: organize it in a more appropriate manner, probably in sceneOptions
// put point-cluster instance for optimized regl calc
if(opts.marker && count >= TOO_MANY_POINTS) {
opts.marker.cluster = stash.tree;
}

// save scene opts batch
scene.lineOptions.push(opts.line);
scene.errorXOptions.push(opts.errorX);
Expand Down Expand Up @@ -547,10 +553,7 @@ function plot(gd, subplot, cdata) {
// create select2d
if(!scene.select2d) {
// create scatter instance by cloning scatter2d
scene.select2d = createScatter(
fullLayout._glcanvas.data()[1].regl,
{clone: scene.scatter2d}
);
scene.select2d = createScatter(fullLayout._glcanvas.data()[1].regl);
}

if(scene.scatter2d && scene.selectBatch && scene.selectBatch.length) {
Expand Down
9 changes: 7 additions & 2 deletions src/traces/scatterpolargl/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

'use strict';

var kdtree = require('kdgrass');
var cluster = require('point-cluster');
var isNumeric = require('fast-isnumeric');

var ScatterGl = require('../scattergl');
Expand Down Expand Up @@ -106,6 +106,12 @@ function plot(container, subplot, cdata) {
if(options.line && !scene.line2d) scene.line2d = true;
if((options.errorX || options.errorY) && !scene.error2d) scene.error2d = true;

stash.tree = cluster(positions);

if(options.marker) {
Copy link
Contributor

Choose a reason for hiding this comment

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

this should probably be options.marker && count >= TOO_MANY_POINTS like in scattergl/convert.js

options.marker.cluster = stash.tree;
}

// bring positions to selected/unselected options
if(subTypes.hasMarkers(trace)) {
options.selected.positions = options.unselected.positions = options.marker.positions;
Expand All @@ -132,7 +138,6 @@ function plot(container, subplot, cdata) {
stash.theta = thetaArray;
stash.positions = positions;
stash.count = count;
stash.tree = kdtree(positions, 512);
});

return ScatterGl.plot(container, subplot, cdata);
Expand Down
2 changes: 1 addition & 1 deletion tasks/test_syntax.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ function assertES5() {
});

var files = constants.partialBundlePaths.map(function(f) { return f.dist; });
files.unshift(constants.pathToPlotlyDist);
files.unshift(constants.pathToPlotlyBuild, constants.pathToPlotlyDist);

var report = cli.executeOnFiles(files);
var formatter = cli.getFormatter();
Expand Down
Binary file modified test/image/baselines/gl2d_14.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/gl2d_17.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/gl2d_annotations.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/gl2d_axes_booleans.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/gl2d_axes_labels.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/gl2d_axes_labels2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/gl2d_axes_lines.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/gl2d_axes_range_manual.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/gl2d_axes_range_mode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/gl2d_axes_range_type.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/gl2d_clean-number.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/gl2d_date_axes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/gl2d_error_bars.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/gl2d_fonts.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/gl2d_layout_image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/gl2d_line_aligned.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/gl2d_line_dash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/gl2d_multiple-traces-axes-labels.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/gl2d_multiple-traces-axes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/gl2d_multiple_subplots.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/gl2d_scatter-color-clustering.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/gl2d_scatter-colorscale-colorbar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/gl2d_scatter-colorscale-points.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/gl2d_scatter-subplot-panel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/gl2d_scatter_fill_self_next.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/gl2d_shapes_below_traces.png
Binary file modified test/image/baselines/gl2d_simple_inset.png
Binary file modified test/image/baselines/gl2d_size_margins.png
Binary file modified test/image/baselines/gl2d_stacked_coupled_subplots.png
Binary file modified test/image/baselines/gl2d_stacked_subplots.png
Binary file modified test/image/baselines/gl2d_tick-labels.png
Binary file modified test/image/baselines/glpolar_scatter.png
Binary file modified test/image/baselines/glpolar_style.png
2 changes: 1 addition & 1 deletion test/jasmine/tests/gl2d_click_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ var mock4 = {
layout: {}
};

describe('@gl Test hover and click interactions', function() {
describe('@gl @flaky Test hover and click interactions', function() {
var gd;

function makeHoverFn(gd, x, y) {
Expand Down
12 changes: 6 additions & 6 deletions test/jasmine/tests/gl2d_plot_interact_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ describe('@gl Test gl2d plots', function() {
.then(done);
});

it('supports 1D and 2D Zoom', function(done) {
it('@flaky supports 1D and 2D Zoom', function(done) {
var centerX;
var centerY;

Expand Down Expand Up @@ -571,7 +571,7 @@ describe('@gl Test gl2d plots', function() {
.then(done);
});

it('supports axis constraints with zoom', function(done) {
it('@flaky supports axis constraints with zoom', function(done) {
var centerX;
var centerY;

Expand Down Expand Up @@ -638,7 +638,7 @@ describe('@gl Test gl2d plots', function() {
.then(done);
});

it('should change plot type with incomplete data', function(done) {
it('@flaky should change plot type with incomplete data', function(done) {
Plotly.plot(gd, [{}]);
expect(function() {
Plotly.restyle(gd, {type: 'scattergl', x: [[1]]}, 0);
Expand All @@ -651,7 +651,7 @@ describe('@gl Test gl2d plots', function() {
done();
});

it('data-referenced annotations should update on drag', function(done) {
it('@flaky data-referenced annotations should update on drag', function(done) {
function assertAnnotation(xy) {
var ann = d3.select('g.annotation-text-g').select('g');
var translate = Drawing.getTranslate(ann);
Expand Down Expand Up @@ -694,7 +694,7 @@ describe('@gl Test gl2d plots', function() {
.then(done);
});

it('should not scroll document while panning', function(done) {
it('@flaky should not scroll document while panning', function(done) {
var mock = {
data: [
{ type: 'scattergl', y: [1, 2, 3], x: [1, 2, 3] }
Expand Down Expand Up @@ -856,7 +856,7 @@ describe('@gl Test gl2d plots', function() {
.then(done);
});

it('should remove fill2d', function(done) {
it('@flaky should remove fill2d', function(done) {
var mock = require('@mocks/gl2d_axes_labels2.json');

Plotly.plot(gd, mock.data, mock.layout)
Expand Down