Skip to content

Commit bd11567

Browse files
committed
make drawing/attributes.dash - and clean up some dashes that don't fit the pattern
1 parent 75121d2 commit bd11567

File tree

10 files changed

+55
-43
lines changed

10 files changed

+55
-43
lines changed

src/components/drawing/attributes.js

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* Copyright 2012-2017, Plotly, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
10+
'use strict';
11+
12+
exports.dash = {
13+
valType: 'string',
14+
// string type usually doesn't take values... this one should really be
15+
// a special type or at least a special coercion function, from the GUI
16+
// you only get these values but elsewhere the user can supply a list of
17+
// dash lengths in px, and it will be honored
18+
values: ['solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'],
19+
dflt: 'solid',
20+
role: 'style',
21+
description: [
22+
'Sets the dash style of lines. Set to a dash type string',
23+
'(*solid*, *dot*, *dash*, *longdash*, *dashdot*, or *longdashdot*)',
24+
'or a dash length list in px (eg *5px,10px,2px,2px*).'
25+
].join(' ')
26+
};

src/components/shapes/attributes.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@
99
'use strict';
1010

1111
var annAttrs = require('../annotations/attributes');
12-
var scatterAttrs = require('../../traces/scatter/attributes');
12+
var scatterLineAttrs = require('../../traces/scatter/attributes').line;
13+
var dash = require('../drawing/attributes').dash;
1314
var extendFlat = require('../../lib/extend').extendFlat;
1415

15-
var scatterLineAttrs = scatterAttrs.line;
16-
1716
module.exports = {
1817
_isLinkedToArray: 'shape',
1918

@@ -151,7 +150,7 @@ module.exports = {
151150
line: {
152151
color: scatterLineAttrs.color,
153152
width: scatterLineAttrs.width,
154-
dash: scatterLineAttrs.dash,
153+
dash: dash,
155154
role: 'info'
156155
},
157156
fillcolor: {

src/plots/cartesian/layout_attributes.js

+2-14
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
var fontAttrs = require('../font_attributes');
1212
var colorAttrs = require('../../components/color/attributes');
13+
var dash = require('../../components/drawing/attributes').dash;
1314
var extendFlat = require('../../lib/extend').extendFlat;
1415

1516
var constants = require('./constants');
@@ -300,20 +301,7 @@ module.exports = {
300301
role: 'style',
301302
description: 'Sets the width (in px) of the zero line.'
302303
},
303-
spikedash: {
304-
valType: 'string',
305-
// string type usually doesn't take values... this one should really be
306-
// a special type or at least a special coercion function, from the GUI
307-
// you only get these values but elsewhere the user can supply a list of
308-
// dash lengths in px, and it will be honored
309-
values: ['solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'],
310-
dflt: 'dash',
311-
role: 'style',
312-
description: [
313-
'Sets the style of the lines. Set to a dash string type',
314-
'or a dash length in px.'
315-
].join(' ')
316-
},
304+
spikedash: extendFlat({}, dash, {dflt: 'dash'}),
317305
spikemode: {
318306
valType: 'flaglist',
319307
flags: ['toaxis', 'across', 'marker'],

src/traces/contour/attributes.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ var heatmapAttrs = require('../heatmap/attributes');
1212
var scatterAttrs = require('../scatter/attributes');
1313
var colorscaleAttrs = require('../../components/colorscale/attributes');
1414
var colorbarAttrs = require('../../components/colorbar/attributes');
15+
var dash = require('../../components/drawing/attributes').dash;
1516
var extendFlat = require('../../lib/extend').extendFlat;
1617

1718
var scatterLineAttrs = scatterAttrs.line;
@@ -118,7 +119,7 @@ module.exports = extendFlat({}, {
118119
].join(' ')
119120
}),
120121
width: scatterLineAttrs.width,
121-
dash: scatterLineAttrs.dash,
122+
dash: dash,
122123
smoothing: extendFlat({}, scatterLineAttrs.smoothing, {
123124
description: [
124125
'Sets the amount of smoothing for the contour lines,',

src/traces/ohlc/attributes.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
var Lib = require('../../lib');
1313
var scatterAttrs = require('../scatter/attributes');
14+
var dash = require('../../components/drawing/attributes').dash;
1415

1516
var INCREASING_COLOR = '#3D9970';
1617
var DECREASING_COLOR = '#FF4136';
@@ -38,9 +39,9 @@ var directionAttrs = {
3839
},
3940

4041
line: {
41-
color: Lib.extendFlat({}, lineAttrs.color),
42-
width: Lib.extendFlat({}, lineAttrs.width),
43-
dash: Lib.extendFlat({}, lineAttrs.dash),
42+
color: lineAttrs.color,
43+
width: lineAttrs.width,
44+
dash: dash,
4445
}
4546
};
4647

@@ -87,9 +88,9 @@ module.exports = {
8788
'`decreasing.line.width`.'
8889
].join(' ')
8990
}),
90-
dash: Lib.extendFlat({}, lineAttrs.dash, {
91+
dash: Lib.extendFlat({}, dash, {
9192
description: [
92-
lineAttrs.dash,
93+
dash.description,
9394
'Note that this style setting can also be set per',
9495
'direction via `increasing.line.dash` and',
9596
'`decreasing.line.dash`.'

src/traces/scatter/attributes.js

+2-14
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
var colorAttributes = require('../../components/colorscale/color_attributes');
1212
var errorBarAttrs = require('../../components/errorbars/attributes');
1313
var colorbarAttrs = require('../../components/colorbar/attributes');
14+
var dash = require('../../components/drawing/attributes').dash;
1415

1516
var Drawing = require('../../components/drawing');
1617
var constants = require('./constants');
@@ -163,20 +164,7 @@ module.exports = {
163164
'*0* corresponds to no smoothing (equivalent to a *linear* shape).'
164165
].join(' ')
165166
},
166-
dash: {
167-
valType: 'string',
168-
// string type usually doesn't take values... this one should really be
169-
// a special type or at least a special coercion function, from the GUI
170-
// you only get these values but elsewhere the user can supply a list of
171-
// dash lengths in px, and it will be honored
172-
values: ['solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'],
173-
dflt: 'solid',
174-
role: 'style',
175-
description: [
176-
'Sets the style of the lines. Set to a dash string type',
177-
'or a dash length in px.'
178-
].join(' ')
179-
},
167+
dash: dash,
180168
simplify: {
181169
valType: 'boolean',
182170
dflt: true,

src/traces/scatter3d/attributes.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
var scatterAttrs = require('../scatter/attributes');
1212
var colorAttributes = require('../../components/colorscale/color_attributes');
1313
var errorBarAttrs = require('../../components/errorbars/attributes');
14+
var DASHES = require('../../constants/gl3d_dashes');
1415

1516
var MARKER_SYMBOLS = require('../../constants/gl_markers');
1617
var extendFlat = require('../../lib/extend').extendFlat;
@@ -114,7 +115,13 @@ module.exports = {
114115
connectgaps: scatterAttrs.connectgaps,
115116
line: extendFlat({}, {
116117
width: scatterLineAttrs.width,
117-
dash: scatterLineAttrs.dash,
118+
dash: {
119+
valType: 'enumerated',
120+
values: Object.keys(DASHES),
121+
dflt: 'solid',
122+
role: 'style',
123+
description: 'Sets the dash style of the lines.'
124+
},
118125
showscale: {
119126
valType: 'boolean',
120127
role: 'info',

src/traces/scattergeo/attributes.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
var scatterAttrs = require('../scatter/attributes');
1212
var plotAttrs = require('../../plots/attributes');
1313
var colorAttributes = require('../../components/colorscale/color_attributes');
14+
var dash = require('../../components/drawing/attributes').dash;
1415

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

@@ -79,7 +80,7 @@ module.exports = {
7980
line: {
8081
color: scatterLineAttrs.color,
8182
width: scatterLineAttrs.width,
82-
dash: scatterLineAttrs.dash
83+
dash: dash
8384
},
8485
connectgaps: scatterAttrs.connectgaps,
8586

src/traces/scattermapbox/attributes.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ module.exports = {
6161

6262
line: {
6363
color: lineAttrs.color,
64-
width: lineAttrs.width,
64+
width: lineAttrs.width
6565

6666
// TODO
67-
dash: lineAttrs.dash
67+
// dash: dash
6868
},
6969

7070
connectgaps: scatterAttrs.connectgaps,

src/traces/scatterternary/attributes.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ var scatterAttrs = require('../scatter/attributes');
1212
var plotAttrs = require('../../plots/attributes');
1313
var colorAttributes = require('../../components/colorscale/color_attributes');
1414
var colorbarAttrs = require('../../components/colorbar/attributes');
15+
var dash = require('../../components/drawing/attributes').dash;
1516

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

@@ -88,7 +89,7 @@ module.exports = {
8889
line: {
8990
color: scatterLineAttrs.color,
9091
width: scatterLineAttrs.width,
91-
dash: scatterLineAttrs.dash,
92+
dash: dash,
9293
shape: extendFlat({}, scatterLineAttrs.shape,
9394
{values: ['linear', 'spline']}),
9495
smoothing: scatterLineAttrs.smoothing

0 commit comments

Comments
 (0)