Skip to content

Commit

Permalink
revised code with new mock
Browse files Browse the repository at this point in the history
  • Loading branch information
archmoj committed Jan 3, 2019
1 parent 912e554 commit 707c017
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 11 deletions.
10 changes: 4 additions & 6 deletions src/components/colorbar/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,10 @@ module.exports = function connectColorbar(gd, cd, moduleOpts) {

var trace = cd[0].trace;
var cbId = 'cb' + trace.uid;
var containerNames = (moduleOpts.container) ?
moduleOpts.container.split(' | ') :
[moduleOpts.container];
moduleOpts = Array.isArray(moduleOpts) ? moduleOpts : [moduleOpts];

for(var i = 0; i < containerNames.length; i++) {
var containerName = containerNames[i];
for(var i = 0; i < moduleOpts.length; i++) {
var containerName = moduleOpts[i].container;

var container = containerName ? trace[containerName] : trace;

Expand All @@ -60,7 +58,7 @@ module.exports = function connectColorbar(gd, cd, moduleOpts) {
container.colorscale;

cb.fillgradient(scl)
.zrange([container[moduleOpts.min], container[moduleOpts.max]])
.zrange([container[moduleOpts[i].min], container[moduleOpts[i].max]])
.options(container.colorbar)();

return;
Expand Down
16 changes: 11 additions & 5 deletions src/traces/scatter3d/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,17 @@ Scatter3D.plot = require('./convert');
Scatter3D.attributes = require('./attributes');
Scatter3D.markerSymbols = require('../../constants/gl3d_markers');
Scatter3D.supplyDefaults = require('./defaults');
Scatter3D.colorbar = {
container: 'marker | line',
min: 'cmin',
max: 'cmax'
};
Scatter3D.colorbar = [
{
container: 'marker',
min: 'cmin',
max: 'cmax'
}, {
container: 'line',
min: 'cmin',
max: 'cmax'
}
];
Scatter3D.calc = require('./calc');

Scatter3D.moduleType = 'trace';
Expand Down
21 changes: 21 additions & 0 deletions test/image/mocks/gl3d_scatter3d-line-or-marker-colorscale.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"data": [
{
"x": [1, 2, 4, 8, 16],
"y": [-1, -2, -4, -8, -16],
"z": [0, 1, 0, 1, 0],
"type": "scatter3d",
"mode": "lines",
"line": {
"color": [0, 0.25, 0.5, 0.75, 1.0],
"showscale": true,
"width": 10
}
}
],
"layout": {
"title": "Scatter3d show scale with line colors",
"width": 600,
"height": 600
}
}

0 comments on commit 707c017

Please sign in to comment.