8000 DRY up color attributes by monfera · Pull Request #609 · plotly/plotly.js · GitHub
[go: up one dir, main page]

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
581a dry colors - put color spec as the last prop block; use extendFl…
…at everywhere
  • Loading branch information
monfera committed Jun 7, 2016
commit 01d1041d72e58a54780b51aad40b326a766f0e73
15 changes: 8 additions & 7 deletions src/traces/bar/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@

var scatterAttrs = require('../scatter/attributes');
var colorAttributes = require('../../components/colorscale/color_attributes');
var extendDeep = require('../../lib/extend').extendDeep;
var extendFlat = require('../../lib/extend').extendFlat;

var scatterMarkerAttrs = scatterAttrs.marker;
var scatterMarkerLineAttrs = scatterMarkerAttrs.line;


module.exports = {
x: scatterAttrs.x,
x0: scatterAttrs.x0,
Expand All @@ -34,12 +33,14 @@ module.exports = {
'along the vertical (horizontal).'
].join(' ')
},
marker: extendDeep({}, colorAttributes('marker'), {
marker: extendFlat({}, {
showscale: scatterMarkerAttrs.showscale,
line: extendDeep({}, colorAttributes('marker.line'), {
width: scatterMarkerLineAttrs.width
})
}),
line: extendFlat({},
{width: scatterMarkerLineAttrs.width},
colorAttributes('marker.line')
)},
colorAttributes('marker')
),

r: scatterAttrs.r,
t: scatterAttrs.t,
Expand Down
6 changes: 4 additions & 2 deletions src/traces/choropleth/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var extendFlat = require('../../lib/extend').extendFlat;

var ScatterGeoMarkerLineAttrs = ScatterGeoAttrs.marker.line;

module.exports = extendFlat({}, colorscaleAttrs, {
module.exports = extendFlat({}, {
locations: {
valType: 'data_array',
description: [
Expand Down Expand Up @@ -44,4 +44,6 @@ module.exports = extendFlat({}, colorscaleAttrs, {
_nestedModules: {
'colorbar': 'Colorbar'
}
});
},
colorscaleAttrs
);
7 changes: 4 additions & 3 deletions src/traces/contour/attributes.js
8000
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ var extendFlat = require('../../lib/extend').extendFlat;
var scatterLineAttrs = scatterAttrs.line;

module.exports = extendFlat({},
colorscaleAttrs,
{autocolorscale: extendFlat({}, colorscaleAttrs.autocolorscale, {dflt: false})},
{
z: heatmapAttrs.z,
x: heatmapAttrs.x,
Expand Down Expand Up @@ -118,4 +116,7 @@ module.exports = extendFlat({},
_nestedModules: {
'colorbar': 'Colorbar'
}
});
},
colorscaleAttrs,
{autocolorscale: extendFlat({}, colorscaleAttrs.autocolorscale, {dflt: false})}
);
8 changes: 4 additions & 4 deletions src/traces/heatmap/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ var colorscaleAttrs = require('../../components/colorscale/attributes');

var extendFlat = require('../../lib/extend').extendFlat;


module.exports = extendFlat({},
colorscaleAttrs,
{autocolorscale: extendFlat({}, colorscaleAttrs.autocolorscale, {dflt: false})},
{
z: {
valType: 'data_array',
Expand Down Expand Up @@ -83,4 +80,7 @@ module.exports = extendFlat({},
_nestedModules: {
'colorbar': 'Colorbar'
}
});
},
colorscaleAttrs,
{autocolorscale: extendFlat({}, colorscaleAttrs.autocolorscale, {dflt: false})}
);
17 changes: 8 additions & 9 deletions src/traces/histogram/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,16 @@
* LICENSE file in the root directory of this source tree.
*/


'use strict';

var barAttrs = require('../bar/attributes');
var colorAttributes = require('../../components/colorscale/color_attributes');

var extendFlat = require('../../lib').extendFlat;
var extendDeep = require('../../lib/extend').extendDeep;
var extendFlat = require('../../lib/extend').extendDeep;

var barMarkerAttrs = barAttrs.marker;
var barMarkerLineAttrs = barMarkerAttrs.line;


module.exports = {
x: {
valType: 'data_array',
Expand Down Expand Up @@ -115,12 +112,14 @@ module.exports = {
},
ybins: makeBinsAttr('y'),

marker: extendDeep({}, colorAttributes('marker'), {
marker: extendFlat({}, {
showscale: barMarkerAttrs.showscale,
line: extendDeep({}, colorAttributes('marker.line'), {
width: extendFlat({}, barMarkerLineAttrs.width, {dflt: 0})
})
}),
line: extendFlat({},
{width: extendFlat({}, barMarkerLineAttrs.width, {dflt: 0})},
colorAttributes('marker.line'))
},
colorAttributes('marker')
),

_nestedModules: {
'error_y': 'ErrorBars',
Expand Down
7 changes: 4 additions & 3 deletions src/traces/histogram2d/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ var colorscaleAttrs = require('../../components/colorscale/attributes');
var extendFlat = require('../../lib/extend').extendFlat;

module.exports = extendFlat({},
colorscaleAttrs,
{autocolorscale: extendFlat({}, colorscaleAttrs.autocolorscale, {dflt: false})},
{
x: histogramAttrs.x,
y: histogramAttrs.y,
Expand Down Expand Up @@ -46,4 +44,7 @@ module.exports = extendFlat({},
_nestedModules: {
'colorbar': 'Colorbar'
}
});
},
colorscaleAttrs,
{autocolorscale: extendFlat({}, colorscaleAttrs.autocolorscale, {dflt: false})}
);
6 changes: 4 additions & 2 deletions src/traces/histogram2dcontour/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var colorscaleAttrs = require('../../components/colorscale/attributes');

var extendFlat = require('../../lib/extend').extendFlat;

module.exports = extendFlat({}, colorscaleAttrs, {
module.exports = extendFlat({}, {
x: histogram2dAttrs.x,
y: histogram2dAttrs.y,
z: histogram2dAttrs.z,
Expand All @@ -37,4 +37,6 @@ module.exports = extendFlat({}, colorscaleAttrs, {
_nestedModules: {
'colorbar': 'Colorbar'
}
});
},
colorscaleAttrs
);
15 changes: 9 additions & 6 deletions src/traces/scatter/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ var Drawing = require('../../components/drawing');

var constants = require('./constants');

var extendDeep = require('../../lib/extend').extendDeep;

var extendFlat = require('../../lib/extend').extendFlat;

module.exports = {
x: {
Expand Down Expand Up @@ -185,7 +184,7 @@ module.exports = {
'marker color, or marker line color, whichever is available.'
].join(' ')
},
marker: extendDeep({}, colorAttributes('marker'), {
marker: extendFlat({}, {
symbol: {
valType: 'enumerated',
values: Drawing.symbolList,
Expand Down Expand Up @@ -266,16 +265,20 @@ module.exports = {
'Determines whether or not a colorbar is displayed.'
].join(' ')
},
line: extendDeep({}, colorAttributes('marker.line'), {
line: extendFlat({}, {
width: {
valType: 'number',
min: 0,
arrayOk: true,
role: 'style',
description: 'Sets the width (in px) of the lines bounding the marker points.'
}
})
}),
},
colorAttributes('marker.line')
)
},
colorAttributes('marker')
),
textposition: {
valType: 'enumerated',
values: [
Expand Down
15 changes: 8 additions & 7 deletions src/traces/scatter3d/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@
* LICENSE file in the root directory of this source tree.
*/


'use strict';

var scatterAttrs = require('../scatter/attributes');
var colorAttributes = require('../../components/colorscale/color_attributes');

var MARKER_SYMBOLS = require('../../constants/gl_markers');
var extendFlat = require('../../lib/extend').extendFlat;
var extendDeep = require('../../lib/extend').extendDeep;

var scatterLineAttrs = scatterAttrs.line,
scatterMarkerAttrs = scatterAttrs.marker,
Expand Down Expand Up @@ -104,7 +102,7 @@ module.exports = {
width: scatterLineAttrs.width,
dash: scatterLineAttrs.dash
},
marker: extendDeep({}, colorAttributes('marker'), { // Parity with scatter.js?
marker: extendFlat({}, { // Parity with scatter.js?
symbol: {
valType: 'enumerated',
values: Object.keys(MARKER_SYMBOLS),
Expand All @@ -129,10 +127,13 @@ module.exports = {
].join(' ')
}),
showscale: scatterMarkerAttrs.showscale,
line: extendDeep({}, colorAttributes('marker.line'), {
width: extendFlat({}, scatterMarkerLineAttrs.width, {arrayOk: false})
})
}),
line: extendFlat({},
{width: extendFlat({}, scatterMarkerLineAttrs.width, {arrayOk: false})},
colorAttributes('marker.line')
)
},
colorAttributes('marker')
),
textposition: extendFlat({}, scatterAttrs.textposition, {dflt: 'top center'}),
textfont: scatterAttrs.textfont,
_nestedModules: {
Expand Down
15 changes: 8 additions & 7 deletions src/traces/scattergeo/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@ var plotAttrs = require('../../plots/attributes');
var colorAttributes = require('../../components/colorscale/color_attributes');

var extendFlat = require('../../lib/extend').extendFlat;
var extendDeep = require('../../lib/extend').extendDeep;

var scatterMarkerAttrs = scatterAttrs.marker,
scatterLineAttrs = scatterAttrs.line,
scatterMarkerLineAttrs = scatterMarkerAttrs.line;


module.exports = {
lon: {
valType: 'data_array',
Expand Down Expand Up @@ -63,18 +61,21 @@ module.exports = {
width: scatterLineAttrs.width,
dash: scatterLineAttrs.dash
},
marker: extendDeep({}, colorAttributes('marker'), {
marker: extendFlat({}, {
symbol: scatterMarkerAttrs.symbol,
opacity: scatterMarkerAttrs.opacity,
size: scatterMarkerAttrs.size,
sizeref: scatterMarkerAttrs.sizeref,
sizemin: scatterMarkerAttrs.sizemin,
sizemode: scatterMarkerAttrs.sizemode,
showscale: scatterMarkerAttrs.showscale,
line: extendDeep({}, colorAttributes('marker.line'), {
width: scatterMarkerLineAttrs.width
})
}),
line: extendFlat({},
{width: scatterMarkerLineAttrs.width},
colorAttributes('marker.line')
)
},
colorAttributes('marker')
),
textfont: scatterAttrs.textfont,
textposition: scatterAttrs.textposition,
hoverinfo: extendFlat({}, plotAttrs.hoverinfo, {
Expand Down
15 changes: 8 additions & 7 deletions src/traces/scatterternary/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@ var plotAttrs = require('../../plots/attributes');
var colorAttributes = require('../../components/colorscale/color_attributes');

var extendFlat = require('../../lib/extend').extendFlat;
var extendDeep = require('../../lib/extend').extendDeep;

var scatterMarkerAttrs = scatterAttrs.marker,
scatterLineAttrs = scatterAttrs.line,
scatterMarkerLineAttrs = scatterMarkerAttrs.line;


module.exports = {
a: {
valType: 'data_array',
Expand Down Expand Up @@ -98,7 +96,7 @@ module.exports = {
].join(' ')
}),
fillcolor: scatterAttrs.fillcolor,
marker: extendDeep({}, colorAttributes('marker'), {
marker: extendFlat({}, {
symbol: scatterMarkerAttrs.symbol,
opacity: scatterMarkerAttrs.opacity,
maxdisplayed: scatterMarkerAttrs.maxdisplayed,
Expand All @@ -107,10 +105,13 @@ module.exports = {
sizemin: scatterMarkerAttrs.sizemin,
sizemode: scatterMarkerAttrs.sizemode,
showscale: scatterMarkerAttrs.showscale,
line: extendDeep({}, colorAttributes('marker'.line), {
width: scatterMarkerLineAttrs.width
})
}),
line: extendFlat({},
{width: scatterMarkerLineAttrs.width},
colorAttributes('marker'.line)
)
},
colorAttributes('marker')
),
textfont: scatterAttrs.textfont,
textposition: scatterAttrs.textposition,
hoverinfo: extendFlat({}, plotAttrs.hoverinfo, {
Expand Down
0