Skip to content

Commit

Permalink
make drawing/attributes.dash - and clean up some dashes that don't fi…
Browse files Browse the repository at this point in the history
…t the pattern
  • Loading branch information
alexcjohnson committed Apr 17, 2017
1 parent 75121d2 commit bd11567
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 43 deletions.
26 changes: 26 additions & 0 deletions src/components/drawing/attributes.js
@@ -0,0 +1,26 @@
/**
* Copyright 2012-2017, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/


'use strict';

exports.dash = {
valType: 'string',
// string type usually doesn't take values... this one should really be
// a special type or at least a special coercion function, from the GUI
// you only get these values but elsewhere the user can supply a list of
// dash lengths in px, and it will be honored
values: ['solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'],
dflt: 'solid',
role: 'style',
description: [
'Sets the dash style of lines. Set to a dash type string',
'(*solid*, *dot*, *dash*, *longdash*, *dashdot*, or *longdashdot*)',
'or a dash length list in px (eg *5px,10px,2px,2px*).'
].join(' ')
};
7 changes: 3 additions & 4 deletions src/components/shapes/attributes.js
Expand Up @@ -9,11 +9,10 @@
'use strict';

var annAttrs = require('../annotations/attributes');
var scatterAttrs = require('../../traces/scatter/attributes');
var scatterLineAttrs = require('../../traces/scatter/attributes').line;
var dash = require('../drawing/attributes').dash;
var extendFlat = require('../../lib/extend').extendFlat;

var scatterLineAttrs = scatterAttrs.line;

module.exports = {
_isLinkedToArray: 'shape',

Expand Down Expand Up @@ -151,7 +150,7 @@ module.exports = {
line: {
color: scatterLineAttrs.color,
width: scatterLineAttrs.width,
dash: scatterLineAttrs.dash,
dash: dash,
role: 'info'
},
fillcolor: {
Expand Down
16 changes: 2 additions & 14 deletions src/plots/cartesian/layout_attributes.js
Expand Up @@ -10,6 +10,7 @@

var fontAttrs = require('../font_attributes');
var colorAttrs = require('../../components/color/attributes');
var dash = require('../../components/drawing/attributes').dash;
var extendFlat = require('../../lib/extend').extendFlat;

var constants = require('./constants');
Expand Down Expand Up @@ -300,20 +301,7 @@ module.exports = {
role: 'style',
description: 'Sets the width (in px) of the zero line.'
},
spikedash: {
valType: 'string',
// string type usually doesn't take values... this one should really be
// a special type or at least a special coercion function, from the GUI
// you only get these values but elsewhere the user can supply a list of
// dash lengths in px, and it will be honored
values: ['solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'],
dflt: 'dash',
role: 'style',
description: [
'Sets the style of the lines. Set to a dash string type',
'or a dash length in px.'
].join(' ')
},
spikedash: extendFlat({}, dash, {dflt: 'dash'}),
spikemode: {
valType: 'flaglist',
flags: ['toaxis', 'across', 'marker'],
Expand Down
3 changes: 2 additions & 1 deletion src/traces/contour/attributes.js
Expand Up @@ -12,6 +12,7 @@ var heatmapAttrs = require('../heatmap/attributes');
var scatterAttrs = require('../scatter/attributes');
var colorscaleAttrs = require('../../components/colorscale/attributes');
var colorbarAttrs = require('../../components/colorbar/attributes');
var dash = require('../../components/drawing/attributes').dash;
var extendFlat = require('../../lib/extend').extendFlat;

var scatterLineAttrs = scatterAttrs.line;
Expand Down Expand Up @@ -118,7 +119,7 @@ module.exports = extendFlat({}, {
].join(' ')
}),
width: scatterLineAttrs.width,
dash: scatterLineAttrs.dash,
dash: dash,
smoothing: extendFlat({}, scatterLineAttrs.smoothing, {
description: [
'Sets the amount of smoothing for the contour lines,',
Expand Down
11 changes: 6 additions & 5 deletions src/traces/ohlc/attributes.js
Expand Up @@ -11,6 +11,7 @@

var Lib = require('../../lib');
var scatterAttrs = require('../scatter/attributes');
var dash = require('../../components/drawing/attributes').dash;

var INCREASING_COLOR = '#3D9970';
var DECREASING_COLOR = '#FF4136';
Expand Down Expand Up @@ -38,9 +39,9 @@ var directionAttrs = {
},

line: {
color: Lib.extendFlat({}, lineAttrs.color),
width: Lib.extendFlat({}, lineAttrs.width),
dash: Lib.extendFlat({}, lineAttrs.dash),
color: lineAttrs.color,
width: lineAttrs.width,
dash: dash,
}
};

Expand Down Expand Up @@ -87,9 +88,9 @@ module.exports = {
'`decreasing.line.width`.'
].join(' ')
}),
dash: Lib.extendFlat({}, lineAttrs.dash, {
dash: Lib.extendFlat({}, dash, {
description: [
lineAttrs.dash,
dash.description,
'Note that this style setting can also be set per',
'direction via `increasing.line.dash` and',
'`decreasing.line.dash`.'
Expand Down
16 changes: 2 additions & 14 deletions src/traces/scatter/attributes.js
Expand Up @@ -11,6 +11,7 @@
var colorAttributes = require('../../components/colorscale/color_attributes');
var errorBarAttrs = require('../../components/errorbars/attributes');
var colorbarAttrs = require('../../components/colorbar/attributes');
var dash = require('../../components/drawing/attributes').dash;

var Drawing = require('../../components/drawing');
var constants = require('./constants');
Expand Down Expand Up @@ -163,20 +164,7 @@ module.exports = {
'*0* corresponds to no smoothing (equivalent to a *linear* shape).'
].join(' ')
},
dash: {
valType: 'string',
// string type usually doesn't take values... this one should really be
// a special type or at least a special coercion function, from the GUI
// you only get these values but elsewhere the user can supply a list of
// dash lengths in px, and it will be honored
values: ['solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'],
dflt: 'solid',
role: 'style',
description: [
'Sets the style of the lines. Set to a dash string type',
'or a dash length in px.'
].join(' ')
},
dash: dash,
simplify: {
valType: 'boolean',
dflt: true,
Expand Down
9 changes: 8 additions & 1 deletion src/traces/scatter3d/attributes.js
Expand Up @@ -11,6 +11,7 @@
var scatterAttrs = require('../scatter/attributes');
var colorAttributes = require('../../components/colorscale/color_attributes');
var errorBarAttrs = require('../../components/errorbars/attributes');
var DASHES = require('../../constants/gl3d_dashes');

var MARKER_SYMBOLS = require('../../constants/gl_markers');
var extendFlat = require('../../lib/extend').extendFlat;
Expand Down Expand Up @@ -114,7 +115,13 @@ module.exports = {
connectgaps: scatterAttrs.connectgaps,
line: extendFlat({}, {
width: scatterLineAttrs.width,
dash: scatterLineAttrs.dash,
dash: {
valType: 'enumerated',
values: Object.keys(DASHES),
dflt: 'solid',
role: 'style',
description: 'Sets the dash style of the lines.'
},
showscale: {
valType: 'boolean',
role: 'info',
Expand Down
3 changes: 2 additions & 1 deletion src/traces/scattergeo/attributes.js
Expand Up @@ -11,6 +11,7 @@
var scatterAttrs = require('../scatter/attributes');
var plotAttrs = require('../../plots/attributes');
var colorAttributes = require('../../components/colorscale/color_attributes');
var dash = require('../../components/drawing/attributes').dash;

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

Expand Down Expand Up @@ -79,7 +80,7 @@ module.exports = {
line: {
color: scatterLineAttrs.color,
width: scatterLineAttrs.width,
dash: scatterLineAttrs.dash
dash: dash
},
connectgaps: scatterAttrs.connectgaps,

Expand Down
4 changes: 2 additions & 2 deletions src/traces/scattermapbox/attributes.js
Expand Up @@ -61,10 +61,10 @@ module.exports = {

line: {
color: lineAttrs.color,
width: lineAttrs.width,
width: lineAttrs.width

// TODO
dash: lineAttrs.dash
// dash: dash
},

connectgaps: scatterAttrs.connectgaps,
Expand Down
3 changes: 2 additions & 1 deletion src/traces/scatterternary/attributes.js
Expand Up @@ -12,6 +12,7 @@ var scatterAttrs = require('../scatter/attributes');
var plotAttrs = require('../../plots/attributes');
var colorAttributes = require('../../components/colorscale/color_attributes');
var colorbarAttrs = require('../../components/colorbar/attributes');
var dash = require('../../components/drawing/attributes').dash;

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

Expand Down Expand Up @@ -88,7 +89,7 @@ module.exports = {
line: {
color: scatterLineAttrs.color,
width: scatterLineAttrs.width,
dash: scatterLineAttrs.dash,
dash: dash,
shape: extendFlat({}, scatterLineAttrs.shape,
{values: ['linear', 'spline']}),
smoothing: scatterLineAttrs.smoothing
Expand Down

0 comments on commit bd11567

Please sign in to comment.