Skip to content

Commit

Permalink
Activate coalescing in layouts for assoc scatter
Browse files Browse the repository at this point in the history
  • Loading branch information
abought committed Oct 13, 2020
1 parent 01ecbcd commit e3d2b37
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
7 changes: 4 additions & 3 deletions esm/components/data_layer/scatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ const default_layout = {
tooltip_positioning: 'horizontal',
color: '#888888',
coalesce: {
// Should we try to combine adjacent insignificant ("some region of interest") points
// Options to control whether and how to combine adjacent insignificant ("within region of interest") points
// to improve rendering performance?
active: true,
active: false,
max_points: 800, // Many plots are 800-2400 px wide, so, more than 1 datum per pixel of average region width
// These are expressed in terms of data value and will be converted to pixels internally.
// Define the "region of interest", like "bottom half of plot"; any points outside this region are taken as is
// Values are expressed in terms of data value and will be converted to pixels internally.
x_min: '-Infinity',
x_max: 'Infinity',
y_min: 0,
Expand Down
3 changes: 3 additions & 0 deletions esm/layouts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ const association_pvalues_layer = {
namespace: { 'assoc': 'assoc', 'ld': 'ld' },
id: 'associationpvalues',
type: 'scatter',
coalesce: {
active: true,
},
point_shape: {
scale_function: 'if',
field: '{{namespace[ld]}}isrefvar',
Expand Down
16 changes: 15 additions & 1 deletion test/unit/helpers/test_render.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('Coordinate coalescing', function () {
});
describe('coalesce_scatter_points', function () {
it('handles wide spans for any y within bounds', function () {
var actual = coalesce_scatter_points(
const actual = coalesce_scatter_points(
this.sample_data,
-Infinity, Infinity, 3,
0, 1, Infinity
Expand Down Expand Up @@ -116,5 +116,19 @@ describe('Coordinate coalescing', function () {
assert.equal(actual.length, expected.length, 'Found correct number of items');
assert.deepStrictEqual(actual, expected, 'Specified items are present');
});

it('always adds points that are explicitly marked significant', function () {
const sample_data = _addSymbols([
{ x: 0, y: 0.5, lz_highlight_match: true },
{ x: 1, y: 0.9, lz_highlight_match: true },
{ x: 2, y: 0.999, lz_highlight_match: true },
]);
const actual = coalesce_scatter_points(
sample_data,
-Infinity, Infinity, 3,
0, 1, Infinity
);
assert.deepStrictEqual(actual, sample_data, 'Significant points do not coalesce');
});
});
});

0 comments on commit e3d2b37

Please sign in to comment.