-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
On-par autorange for scattergl #2404
Merged
Merged
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
909120e
make scattergl dragmode relayout replot not recalc
etpinard 5316c47
large lint commit in scattergl/index.js
etpinard 0aa0f5e
improvements to Scattergl.calc
etpinard 39ef5a9
update baselines
etpinard 36b4e25
update jasmine tests for new scattergl auto-ranges
etpinard 40f93f7
add svg vs gl scatter autorange :lock:s
etpinard 98d2407
use c2l instead of d2l
etpinard 01a8443
:hocho: TODOs
etpinard c15722f
add mock :lock:ing down cleanNumber for scattergl
etpinard File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -833,3 +833,103 @@ describe('@gl Test gl2d plots', function() { | |
.then(done); | ||
}); | ||
}); | ||
|
||
describe('Test scattergl autorange:', function() { | ||
afterEach(destroyGraphDiv); | ||
|
||
describe('should return the same value as SVG scatter for ~small~ data', function() { | ||
var specs = [ | ||
{name: 'lines+markers', fig: require('@mocks/gl2d_10.json')}, | ||
{name: 'bubbles', fig: require('@mocks/gl2d_12.json')}, | ||
{name: 'line on log axes', fig: require('@mocks/gl2d_14.json')}, | ||
{name: 'fill to zero', fig: require('@mocks/gl2d_axes_labels2.json')}, | ||
{name: 'annotations', fig: require('@mocks/gl2d_annotations.json')} | ||
]; | ||
|
||
specs.forEach(function(s) { | ||
it('- case ' + s.name, function(done) { | ||
var gd = createGraphDiv(); | ||
var glRangeX; | ||
var glRangeY; | ||
|
||
// ensure the mocks have auto-range turned on | ||
var glFig = Lib.extendDeep({}, s.fig); | ||
Lib.extendDeep(glFig.layout, {xaxis: {autorange: true}}); | ||
Lib.extendDeep(glFig.layout, {yaxis: {autorange: true}}); | ||
|
||
var svgFig = Lib.extendDeep({}, glFig); | ||
svgFig.data.forEach(function(t) { t.type = 'scatter'; }); | ||
|
||
Plotly.newPlot(gd, glFig).then(function() { | ||
glRangeX = gd._fullLayout.xaxis.range; | ||
glRangeY = gd._fullLayout.yaxis.range; | ||
}) | ||
.then(function() { | ||
return Plotly.newPlot(gd, svgFig); | ||
}) | ||
.then(function() { | ||
expect(gd._fullLayout.xaxis.range).toBeCloseToArray(glRangeX, 'x range'); | ||
expect(gd._fullLayout.yaxis.range).toBeCloseToArray(glRangeY, 'y range'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Beautiful test! |
||
}) | ||
.catch(fail) | ||
.then(done); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('should return the approximative values for ~big~ data', function() { | ||
beforeEach(function() { | ||
spyOn(ScatterGl, 'plot'); | ||
}); | ||
|
||
// threshold for 'fast' axis expansion routine | ||
var N = 1e5; | ||
var x = new Array(N); | ||
var y = new Array(N); | ||
var ms = new Array(N); | ||
|
||
Lib.seedPseudoRandom(); | ||
|
||
for(var i = 0; i < N; i++) { | ||
x[i] = Lib.pseudoRandom(); | ||
y[i] = Lib.pseudoRandom(); | ||
ms[i] = 10 * Lib.pseudoRandom() + 20; | ||
} | ||
|
||
it('- case scalar marker.size', function(done) { | ||
var gd = createGraphDiv(); | ||
|
||
Plotly.newPlot(gd, [{ | ||
type: 'scattergl', | ||
mode: 'markers', | ||
x: x, | ||
y: y, | ||
marker: {size: 10} | ||
}]) | ||
.then(function() { | ||
expect(gd._fullLayout.xaxis.range).toBeCloseToArray([-0.02, 1.02], 'x range'); | ||
expect(gd._fullLayout.yaxis.range).toBeCloseToArray([-0.04, 1.04], 'y range'); | ||
}) | ||
.catch(fail) | ||
.then(done); | ||
}); | ||
|
||
it('- case array marker.size', function(done) { | ||
var gd = createGraphDiv(); | ||
|
||
Plotly.newPlot(gd, [{ | ||
type: 'scattergl', | ||
mode: 'markers', | ||
x: x, | ||
y: y, | ||
marker: {size: ms} | ||
}]) | ||
.then(function() { | ||
expect(gd._fullLayout.xaxis.range).toBeCloseToArray([-0.05, 1.05], 'x range'); | ||
expect(gd._fullLayout.yaxis.range).toBeCloseToArray([-0.11, 1.11], 'y range'); | ||
}) | ||
.catch(fail) | ||
.then(done); | ||
}); | ||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lovely!