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
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 - scatter3d
  • Loading branch information
monfera committed Jun 7, 2016
commit 7e7a6db2ec4490cf49e0f00f1a7f1f1eb7ba8c16
30 changes: 11 additions & 19 deletions src/traces/scatter3d/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
'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 @@ -101,8 +104,10 @@ module.exports = {
width: scatterLineAttrs.width,
dash: scatterLineAttrs.dash
},
marker: { // Parity with scatter.js?
color: scatterMarkerAttrs.color,
// Currently, `marker` etc. contain mixed attributes (colorAttributes
// and a bunch of others); maybe a future API change could wrap parts
// that belong together, under a `colorspec` or similar attribute name.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you elaborate? Maybe give an example of colorspec ?

CB49

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now the API is 'flat': e.g. a JSON would say:

"marker": {
   "symbol": whatever,
   "colorscale": "Greens",
   "cauto": true
}

i.e. the properties relating to color and properties intrinsic to the marker are mixed. A possible (though incompatible) alternative is to keep them organized according to these style groups, e.g.

"marker": {
   "symbol": whatever,
   "colorspec": {
     "colorscale": "Greens",
     "cauto": true
  }
}

(btw. I'm planning to remove the code comment itself)

marker: extendDeep({}, colorAttributes('marker'), { // Parity with scatter.js?
symbol: {
valType: 'enumerated',
values: Object.keys(MARKER_SYMBOLS),
Expand All @@ -126,24 +131,11 @@ module.exports = {
'to an rgba color and use its alpha channel.'
].join(' ')
}),
colorscale: scatterMarkerAttrs.colorscale,
cauto: scatterMarkerAttrs.cauto,
cmax: scatterMarkerAttrs.cmax,
cmin: scatterMarkerAttrs.cmin,
autocolorscale: scatterMarkerAttrs.autocolorscale,
reversescale: scatterMarkerAttrs.reversescale,
showscale: scatterMarkerAttrs.showscale,
line: {
color: scatterMarkerLineAttrs.color,
width: extendFlat({}, scatterMarkerLineAttrs.width, {arrayOk: false}),
colorscale: scatterMarkerLineAttrs.colorscale,
cauto: scatterMarkerLineAttrs.cauto,
cmax: scatterMarkerLineAttrs.cmax,
cmin: scatterMarkerLineAttrs.cmin,
autocolorscale: scatterMarkerLineAttrs.autocolorscale,
reversescale: scatterMarkerLineAttrs.reversescale
}
},
line: extendDeep({}, colorAttributes('marker.line'), {
width: extendFlat({}, scatterMarkerLineAttrs.width, {arrayOk: false})
})
}),
textposition: extendFlat({}, scatterAttrs.textposition, {dflt: 'top center'}),
textfont: scatterAttrs.textfont,
_nestedModules: {
Expand Down
0