Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 56848a4

Browse filesBrowse files
committed
fixes plotly#2591 - use isArrayOrTypedArray in gl_format_color.js
1 parent 2b1713d commit 56848a4
Copy full SHA for 56848a4

File tree

Expand file treeCollapse file tree

2 files changed

+36
-4
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+36
-4
lines changed

‎src/lib/gl_format_color.js

Copy file name to clipboardExpand all lines: src/lib/gl_format_color.js
+5-4Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ var rgba = require('color-normalize');
1414

1515
var Colorscale = require('../components/colorscale');
1616
var colorDflt = require('../components/color/attributes').defaultLine;
17+
var isArrayOrTypedArray = require('./is_array').isArrayOrTypedArray;
1718

1819
var colorDfltRgba = rgba(colorDflt);
1920
var opacityDflt = 1;
@@ -37,10 +38,10 @@ function validateOpacity(opacityIn) {
3738
}
3839

3940
function formatColor(containerIn, opacityIn, len) {
40-
var colorIn = containerIn.color,
41-
isArrayColorIn = Array.isArray(colorIn),
42-
isArrayOpacityIn = Array.isArray(opacityIn),
43-
colorOut = [];
41+
var colorIn = containerIn.color;
42+
var isArrayColorIn = isArrayOrTypedArray(colorIn);
43+
var isArrayOpacityIn = isArrayOrTypedArray(opacityIn);
44+
var colorOut = [];
4445

4546
var sclFunc, getColor, getOpacity, colori, opacityi;
4647

‎test/jasmine/tests/gl2d_plot_interact_test.js

Copy file name to clipboardExpand all lines: test/jasmine/tests/gl2d_plot_interact_test.js
+31Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -917,6 +917,37 @@ describe('@gl Test gl2d plots', function() {
917917
.catch(fail)
918918
.then(done);
919919
});
920+
921+
it('should work with typed array', function(done) {
922+
Plotly.plot(gd, [{
923+
type: 'scattergl',
924+
mode: 'markers',
925+
x: new Float32Array([1, 2, 3]),
926+
y: new Float32Array([1, 2, 1]),
927+
marker: {
928+
size: 20,
929+
colorscale: [[0, 'gray'], [1, 'red']],
930+
cmin: 0,
931+
cmax: 1,
932+
showscale: true,
933+
color: new Float32Array([0, 0.5, 1.0])
934+
}
935+
}])
936+
.then(function() {
937+
var opts = gd.calcdata[0][0].t._scene.markerOptions[0];
938+
939+
expect(opts.colors).toBeCloseTo2DArray([
940+
[0.5, 0.5, 0.5, 1],
941+
[0.75, 0.25, 0.25, 1],
942+
[1, 0, 0, 1]
943+
]);
944+
945+
expect(opts.positions)
946+
.toBeCloseToArray([1, 1, 2, 2, 3, 1]);
947+
})
948+
.catch(fail)
949+
.then(done);
950+
});
920951
});
921952

922953
describe('Test scattergl autorange:', function() {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.