Skip to content

Commit 0481395

Browse files
committed
surface connectgaps
1 parent 7e68a2e commit 0481395

File tree

5 files changed

+42
-0
lines changed

5 files changed

+42
-0
lines changed

src/traces/surface/attributes.js

+12
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,18 @@ var attrs = module.exports = overrideAll(extendFlat({
133133
},
134134
hovertemplate: hovertemplateAttrs(),
135135

136+
connectgaps: {
137+
valType: 'boolean',
138+
dflt: false,
139+
role: 'info',
140+
editType: 'calc',
141+
description: [
142+
'Determines whether or not gaps',
143+
'(i.e. {nan} or missing values)',
144+
'in the `z` data are filled in.'
145+
].join(' ')
146+
},
147+
136148
surfacecolor: {
137149
valType: 'data_array',
138150
description: [

src/traces/surface/convert.js

+8
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ var isArrayOrTypedArray = require('../../lib').isArrayOrTypedArray;
1919
var parseColorScale = require('../../lib/gl_format_color').parseColorScale;
2020
var str2RgbaArray = require('../../lib/str2rgbarray');
2121

22+
var interp2d = require('../heatmap/interp2d');
23+
var findEmpties = require('../heatmap/find_empties');
24+
2225
function SurfaceTrace(scene, surface, uid) {
2326
this.scene = scene;
2427
this.uid = uid;
@@ -404,6 +407,11 @@ proto.update = function(data) {
404407
}
405408
}
406409

410+
if(data.connectgaps) {
411+
data._emptypoints = findEmpties(rawCoords[2]);
412+
interp2d(rawCoords[2], data._emptypoints);
413+
}
414+
407415
// Note: log axes are not defined in surfaces yet.
408416
// but they could be defined here...
409417

src/traces/surface/defaults.js

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
5656
'lightposition.y',
5757
'lightposition.z',
5858
'hidesurface',
59+
'connectgaps',
5960
'opacity'
6061
].forEach(function(x) { coerce(x); });
6162

Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"data": [
3+
{
4+
"type": "surface",
5+
"connectgaps": true,
6+
"x": [0, 1, 2, 3],
7+
"y": [0, 1, 2, 3],
8+
"z": [
9+
[1, 1, 1, 1],
10+
[1, null, 2, null],
11+
[1, 1, 1, 1],
12+
[1, null, 0, null]
13+
]
14+
}
15+
],
16+
"layout": {
17+
"title": "Surface interpolate gaps",
18+
"width": 600,
19+
"height": 400
20+
}
21+
}

0 commit comments

Comments
 (0)