Thanks to visit codestin.com
Credit goes to github.com

Skip to content

DRY up color attributes #609

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

Merged
merged 15 commits into from
Jun 7, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
581a dry colors - contour
  • Loading branch information
monfera committed Jun 7, 2016
commit bc9f70a65d178c85544c5191994324e2befbe2fc
192 changes: 94 additions & 98 deletions src/traces/contour/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,116 +10,112 @@

var heatmapAttrs = require('../heatmap/attributes');
var scatterAttrs = require('../scatter/attributes');
var colorscaleAttrs = require('../../components/colorscale/attributes');
var extendFlat = require('../../lib/extend').extendFlat;

var scatterLineAttrs = scatterAttrs.line;

module.exports = {
z: heatmapAttrs.z,
x: heatmapAttrs.x,
x0: heatmapAttrs.x0,
dx: heatmapAttrs.dx,
y: heatmapAttrs.y,
y0: heatmapAttrs.y0,
dy: heatmapAttrs.dy,
text: heatmapAttrs.text,
transpose: heatmapAttrs.transpose,
xtype: heatmapAttrs.xtype,
ytype: heatmapAttrs.ytype,
module.exports = extendFlat({},
colorscaleAttrs,
{autocolorscale: extendFlat({}, colorscaleAttrs.autocolorscale, {dflt: false})},
{
z: heatmapAttrs.z,
x: heatmapAttrs.x,
x0: heatmapAttrs.x0,
dx: heatmapAttrs.dx,
y: heatmapAttrs.y,
y0: heatmapAttrs.y0,
dy: heatmapAttrs.dy,
text: heatmapAttrs.text,
transpose: heatmapAttrs.transpose,
xtype: heatmapAttrs.xtype,
ytype: heatmapAttrs.ytype,

zauto: heatmapAttrs.zauto,
zmin: heatmapAttrs.zmin,
zmax: heatmapAttrs.zmax,
colorscale: heatmapAttrs.colorscale,
autocolorscale: heatmapAttrs.autocolorscale,
reversescale: heatmapAttrs.reversescale,
showscale: heatmapAttrs.showscale,
connectgaps: heatmapAttrs.connectgaps,

connectgaps: heatmapAttrs.connectgaps,

autocontour: {
valType: 'boolean',
dflt: true,
role: 'style',
description: [
'Determines whether or not the contour level attributes are',
'picked by an algorithm.',
'If *true*, the number of contour levels can be set in `ncontours`.',
'If *false*, set the contour level attributes in `contours`.'
].join(' ')
},
ncontours: {
valType: 'integer',
dflt: 0,
role: 'style',
description: [
'Sets the number of contour levels.',
'Has an effect only if `autocontour` is *true*.'
].join(' ')
},

contours: {
start: {
valType: 'number',
dflt: null,
role: 'style',
description: 'Sets the starting contour level value.'
},
end: {
valType: 'number',
dflt: null,
role: 'style',
description: 'Sets the end contour level value.'
},
size: {
valType: 'number',
dflt: null,
role: 'style',
description: 'Sets the step between each contour level.'
},
coloring: {
valType: 'enumerated',
values: ['fill', 'heatmap', 'lines', 'none'],
dflt: 'fill',
autocontour: {
valType: 'boolean',
dflt: true,
role: 'style',
description: [
'Determines the coloring method showing the contour values.',
'If *fill*, coloring is done evenly between each contour level',
'If *heatmap*, a heatmap gradient coloring is applied',
'between each contour level.',
'If *lines*, coloring is done on the contour lines.',
'If *none*, no coloring is applied on this trace.'
'Determines whether or not the contour level attributes are',
'picked by an algorithm.',
'If *true*, the number of contour levels can be set in `ncontours`.',
'If *false*, set the contour level attributes in `contours`.'
].join(' ')
},
showlines: {
valType: 'boolean',
dflt: true,
ncontours: {
valType: 'integer',
dflt: 0,
role: 'style',
description: [
'Determines whether or not the contour lines are drawn.',
'Has only an effect if `contours.coloring` is set to *fill*.'
'Sets the number of contour levels.',
'Has an effect only if `autocontour` is *true*.'
].join(' ')
}
},
},

line: {
color: extendFlat({}, scatterLineAttrs.color, {
description: [
'Sets the color of the contour level.',
'Has no if `contours.coloring` is set to *lines*.'
].join(' ')
}),
width: scatterLineAttrs.width,
dash: scatterLineAttrs.dash,
smoothing: extendFlat({}, scatterLineAttrs.smoothing, {
description: [
'Sets the amount of smoothing for the contour lines,',
'where *0* corresponds to no smoothing.'
].join(' ')
})
},
contours: {
start: {
valType: 'number',
dflt: null,
role: 'style',
description: 'Sets the starting contour level value.'
},
end: {
valType: 'number',
dflt: null,
role: 'style',
description: 'Sets the end contour level value.'
},
size: {
valType: 'number',
dflt: null,
role: 'style',
description: 'Sets the step between each contour level.'
},
coloring: {
valType: 'enumerated',
values: ['fill', 'heatmap', 'lines', 'none'],
dflt: 'fill',
role: 'style',
description: [
'Determines the coloring method showing the contour values.',
'If *fill*, coloring is done evenly between each contour level',
'If *heatmap*, a heatmap gradient coloring is applied',
'between each contour level.',
'If *lines*, coloring is done on the contour lines.',
'If *none*, no coloring is applied on this trace.'
].join(' ')
},
showlines: {
valType: 'boolean',
dflt: true,
role: 'style',
description: [
'Determines whether or not the contour lines are drawn.',
'Has only an effect if `contours.coloring` is set to *fill*.'
].join(' ')
}
},

_nestedModules: {
'colorbar': 'Colorbar'
}
};
line: {
color: extendFlat({}, scatterLineAttrs.color, {
description: [
'Sets the color of the contour level.',
'Has no if `contours.coloring` is set to *lines*.'
].join(' ')
}),
width: scatterLineAttrs.width,
dash: scatterLineAttrs.dash,
smoothing: extendFlat({}, scatterLineAttrs.smoothing, {
description: [
'Sets the amount of smoothing for the contour lines,',
'where *0* corresponds to no smoothing.'
].join(' ')
})
},

_nestedModules: {
'colorbar': 'Colorbar'
}
});
3 changes: 1 addition & 2 deletions src/traces/surface/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@
* LICENSE file in the root directory of this source tree.
*/


'use strict';

var Color = require('../../components/color');
var colorscaleAttrs = require('../../components/colorscale/attributes');
var extendFlat = require('../../lib/extend').extendFlat;


function makeContourProjAttr(axLetter) {
return {
valType: 'boolean',
Expand Down Expand Up @@ -121,6 +119,7 @@ module.exports = {
].join(' ')
},

// Todo this block has a structure of colorscale/attributes.js but with colorscale/color_attributes.js names
cauto: colorscaleAttrs.zauto,
cmin: colorscaleAttrs.zmin,
cmax: colorscaleAttrs.zmax,
Expand Down