Skip to content
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

Display a colorscale when scatter3d.line.showscale is set #3384

Merged
merged 6 commits into from Jan 14, 2019
@@ -41,19 +41,28 @@ module.exports = function connectColorbar(gd, cd, moduleOpts) {

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

This comment has been minimized.

Copy link
@etpinard

etpinard Jan 2, 2019

Member

.... and let's make this Array.isArray(moduleOpts.container) ? ....

moduleOpts.container.split(' | ') :
[moduleOpts.container];

gd._fullLayout._infolayer.selectAll('.' + cbId).remove();
if(!container || !container.showscale) return;
for(var i = 0; i < containerNames.length; i++) {
var containerName = containerNames[i];

var cb = cd[0].t.cb = drawColorbar(gd, cbId);
var container = containerName ? trace[containerName] : trace;

var scl = container.reversescale ?
flipScale(container.colorscale) :
container.colorscale;
gd._fullLayout._infolayer.selectAll('.' + cbId).remove();
if(!container || !container.showscale) continue;

cb.fillgradient(scl)
.zrange([container[moduleOpts.min], container[moduleOpts.max]])
.options(container.colorbar)();
var cb = cd[0].t.cb = drawColorbar(gd, cbId);

var scl = container.reversescale ?
flipScale(container.colorscale) :
container.colorscale;

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

return;
}
};
@@ -18,7 +18,7 @@ module.exports = function lineDefaults(traceIn, traceOut, defaultColor, layout,
coerce('line.color', defaultColor);

if(hasColorscale(traceIn, 'line')) {
colorscaleDefaults(traceIn, traceOut, layout, coerce, {prefix: 'line.', cLetter: 'c', noScale: true});
colorscaleDefaults(traceIn, traceOut, layout, coerce, {prefix: 'line.', cLetter: 'c'});
} else {
var lineColorDflt = (isArrayOrTypedArray(markerColor) ? false : markerColor) || defaultColor;
coerce('line.color', lineColorDflt);
@@ -31,9 +31,6 @@ var lineAttrs = extendFlat({
description: 'Sets the dash style of the lines.'
}
}, colorAttributes('line'));
// not yet implemented
delete lineAttrs.showscale;
delete lineAttrs.colorbar;

function makeProjectionAttr(axLetter) {
return {
@@ -14,7 +14,11 @@ Scatter3D.plot = require('./convert');
Scatter3D.attributes = require('./attributes');
Scatter3D.markerSymbols = require('../../constants/gl3d_markers');
Scatter3D.supplyDefaults = require('./defaults');
Scatter3D.colorbar = require('../scatter/marker_colorbar');
Scatter3D.colorbar = {
container: 'marker | line',

This comment has been minimized.

Copy link
@etpinard

etpinard Jan 2, 2019

Member

Hmm. That | business is a little too hacky for my taste.

Could you make this:

 Scatter3D.colorbar = [{
  container: 'marker',
  min: 'cmin',
  max: 'cmax'
}, {
  container: 'line',
  min: 'cmin',
  max: 'cmax'
}]

? Thank you!

min: 'cmin',
max: 'cmax'
};
Scatter3D.calc = require('./calc');

Scatter3D.moduleType = 'trace';
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.