Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"gl-plot2d": "^1.2.0",
"gl-plot3d": "^1.5.1",
"gl-pointcloud2d": "^1.0.0",
"gl-scatter2d": "^1.2.1",
"gl-scatter2d": "^1.2.2",
"gl-scatter2d-fancy": "^1.2.1",
"gl-scatter3d": "^1.0.4",
"gl-select-box": "^1.0.1",
Expand Down
101 changes: 101 additions & 0 deletions test/jasmine/tests/gl2d_click_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,28 @@ describe('Test hover and click interactions', function() {
'autosize': true
}
};
var mock4 = {
data: [
{
x: [1, 2, 3, 4],
y: [12, 3, 14, 4],
type: 'scattergl',
mode: 'markers'
},
{
x: [4, 5, 6, 7],
y: [1, 31, 24, 14],
type: 'scattergl',
mode: 'markers'
},
{
x: [8, 9, 10, 11],
y: [18, 13, 10, 3],
type: 'scattergl',
mode: 'markers'
}],
layout: {}
};

var mockCopy, gd;

Expand Down Expand Up @@ -340,6 +362,85 @@ describe('Test hover and click interactions', function() {

});

it('scattergl', function(done) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks very much!


var modifiedMockCopy = Lib.extendDeep({}, mock4);

Plotly.plot(gd, modifiedMockCopy.data, modifiedMockCopy.layout)

.then(new Promise(function() {

gd.on('plotly_hover', function(data) {
futureData = data;
});

hover(435, 216);

window.setTimeout(function() {

expect(futureData.points.length).toEqual(1);

var pt = futureData.points[0];

expect(Object.keys(pt)).toEqual([
'x', 'y', 'curveNumber', 'pointNumber', 'data', 'fullData', 'xaxis', 'yaxis'
]);

expect(pt.x).toEqual(8);
expect(pt.y).toEqual(18);
expect(pt.curveNumber).toEqual(2);
expect(pt.pointNumber).toEqual(0);
expect(pt.fullData.length).toEqual(3);
expect(typeof pt.data.uid).toEqual('string');
expect(pt.xaxis.domain.length).toEqual(2);
expect(pt.yaxis.domain.length).toEqual(2);

done();
}, 350);
}));
});

it('scattergl-fancy', function(done) {

var modifiedMockCopy = Lib.extendDeep({}, mock4);
modifiedMockCopy.data[0].mode = 'markers+lines';
modifiedMockCopy.data[1].mode = 'markers+lines';
modifiedMockCopy.data[2].mode = 'markers+lines';

Plotly.plot(gd, modifiedMockCopy.data, modifiedMockCopy.layout)

.then(new Promise(function() {

gd.on('plotly_hover', function(data) {
futureData = data;
});

hover(435, 216);

window.setTimeout(function() {

expect(futureData.points.length).toEqual(1);

var pt = futureData.points[0];

expect(Object.keys(pt)).toEqual([
'x', 'y', 'curveNumber', 'pointNumber', 'data', 'fullData', 'xaxis', 'yaxis'
]);

expect(pt.x).toEqual(8);
expect(pt.y).toEqual(18);
expect(pt.curveNumber).toEqual(2);
expect(pt.pointNumber).toEqual(0);
expect(pt.fullData.length).toEqual(3);
expect(typeof pt.data.uid).toEqual('string');
expect(pt.xaxis.domain.length).toEqual(2);
expect(pt.yaxis.domain.length).toEqual(2);

done();
}, 350);
}));
});

it('contourgl', function(done) {

var modifiedMockCopy = Lib.extendDeep({}, mock3);
Expand Down