diff --git a/src/components/drawing/attributes.js b/src/components/drawing/attributes.js new file mode 100644 index 00000000000..0ea5dbe3620 --- /dev/null +++ b/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(' ') +}; diff --git a/src/components/shapes/attributes.js b/src/components/shapes/attributes.js index a8974f2825e..83407b34067 100644 --- a/src/components/shapes/attributes.js +++ b/src/components/shapes/attributes.js @@ -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', @@ -151,7 +150,7 @@ module.exports = { line: { color: scatterLineAttrs.color, width: scatterLineAttrs.width, - dash: scatterLineAttrs.dash, + dash: dash, role: 'info' }, fillcolor: { diff --git a/src/plots/cartesian/layout_attributes.js b/src/plots/cartesian/layout_attributes.js index ccbbd8597a5..f85f3bdf551 100644 --- a/src/plots/cartesian/layout_attributes.js +++ b/src/plots/cartesian/layout_attributes.js @@ -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'); @@ -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'], diff --git a/src/traces/contour/attributes.js b/src/traces/contour/attributes.js index ee547aa5dbe..069a965af9c 100644 --- a/src/traces/contour/attributes.js +++ b/src/traces/contour/attributes.js @@ -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; @@ -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,', diff --git a/src/traces/ohlc/attributes.js b/src/traces/ohlc/attributes.js index 02d50c76486..938a1d1c81a 100644 --- a/src/traces/ohlc/attributes.js +++ b/src/traces/ohlc/attributes.js @@ -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'; @@ -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, } }; @@ -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`.' diff --git a/src/traces/scatter/attributes.js b/src/traces/scatter/attributes.js index 38b3015a4bb..d1bc72ba14c 100644 --- a/src/traces/scatter/attributes.js +++ b/src/traces/scatter/attributes.js @@ -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'); @@ -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, diff --git a/src/traces/scatter3d/attributes.js b/src/traces/scatter3d/attributes.js index ac0b957be63..7a74fd5b256 100644 --- a/src/traces/scatter3d/attributes.js +++ b/src/traces/scatter3d/attributes.js @@ -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; @@ -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', diff --git a/src/traces/scattergeo/attributes.js b/src/traces/scattergeo/attributes.js index 1b5ddeffc19..a341110e24f 100644 --- a/src/traces/scattergeo/attributes.js +++ b/src/traces/scattergeo/attributes.js @@ -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; @@ -79,7 +80,7 @@ module.exports = { line: { color: scatterLineAttrs.color, width: scatterLineAttrs.width, - dash: scatterLineAttrs.dash + dash: dash }, connectgaps: scatterAttrs.connectgaps, diff --git a/src/traces/scattermapbox/attributes.js b/src/traces/scattermapbox/attributes.js index 1518093db19..c061f1141aa 100644 --- a/src/traces/scattermapbox/attributes.js +++ b/src/traces/scattermapbox/attributes.js @@ -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, diff --git a/src/traces/scatterternary/attributes.js b/src/traces/scatterternary/attributes.js index b0c0d4a2acf..4e8c36c48a8 100644 --- a/src/traces/scatterternary/attributes.js +++ b/src/traces/scatterternary/attributes.js @@ -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; @@ -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