diff --git a/src/components/legend/attributes.js b/src/components/legend/attributes.js index 7179f99bcce..73544f6d9c0 100644 --- a/src/components/legend/attributes.js +++ b/src/components/legend/attributes.js @@ -2,7 +2,7 @@ var fontAttrs = require('../../plots/font_attributes'); var colorAttrs = require('../color/attributes'); - +var Drawing = require('../drawing'); module.exports = { bgcolor: { @@ -77,6 +77,16 @@ module.exports = { 'or remain *constant* independent of the symbol size on the graph.' ].join(' ') }, + itemsymbol: { + valType: 'enumerated', + values: ['trace'].concat(Drawing.symbolList), + dflt: 'trace', + editType: 'legend', + description: [ + 'Determines if the legend items symbols use the symbol of the first point in each *trace*', + 'or the specified symbol name.' + ].join(' ') + }, itemwidth: { valType: 'number', min: 30, diff --git a/src/components/legend/defaults.js b/src/components/legend/defaults.js index f1e434d8b6f..3dfc6507a7b 100644 --- a/src/components/legend/defaults.js +++ b/src/components/legend/defaults.js @@ -105,6 +105,7 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { if(helpers.isGrouped(layoutOut.legend)) coerce('tracegroupgap'); coerce('itemsizing'); + coerce('itemsymbol'); coerce('itemwidth'); coerce('itemclick'); diff --git a/src/components/legend/style.js b/src/components/legend/style.js index 0ef881e9af4..e7332de610a 100644 --- a/src/components/legend/style.js +++ b/src/components/legend/style.js @@ -25,6 +25,7 @@ module.exports = function style(s, gd, legend) { var fullLayout = gd._fullLayout; if(!legend) legend = fullLayout.legend; var constantItemSizing = legend.itemsizing === 'constant'; + var customItemSymbol = legend.itemsymbol && legend.itemsymbol !== 'trace'; var itemWidth = legend.itemwidth; var centerPos = (itemWidth + constants.itemGap * 2) / 2; var centerTransform = strTranslate(centerPos, 0); @@ -204,6 +205,10 @@ module.exports = function style(s, gd, legend) { valToBound = cst; } + if(customItemSymbol && attrIn === 'marker.symbol') { + valToBound = legend.itemsymbol; + } + if(bounds) { if(valToBound < bounds[0]) return bounds[0]; else if(valToBound > bounds[1]) return bounds[1];