Skip to content

Commit 173bb1d

Browse files
author
brian.kotek
committed
Relates to plotly#3735, adds itemsymbol: 'constant' legend option, which uses a circle symbol for all legend entries.
1 parent e65718e commit 173bb1d

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

src/components/legend/attributes.js

+10
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,16 @@ module.exports = {
7777
'or remain *constant* independent of the symbol size on the graph.'
7878
].join(' ')
7979
},
80+
itemsymbol: {
81+
valType: 'enumerated',
82+
values: ['trace', 'constant'],
83+
dflt: 'trace',
84+
editType: 'legend',
85+
description: [
86+
'Determines if the legend items symbols use the symbol of the first point in each *trace*',
87+
'or use a *constant* circle symbol.'
88+
].join(' ')
89+
},
8090
itemwidth: {
8191
valType: 'number',
8292
min: 30,

src/components/legend/defaults.js

+1
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) {
105105
if(helpers.isGrouped(layoutOut.legend)) coerce('tracegroupgap');
106106

107107
coerce('itemsizing');
108+
coerce('itemsymbol');
108109
coerce('itemwidth');
109110

110111
coerce('itemclick');

src/components/legend/style.js

+5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ module.exports = function style(s, gd, legend) {
2525
var fullLayout = gd._fullLayout;
2626
if(!legend) legend = fullLayout.legend;
2727
var constantItemSizing = legend.itemsizing === 'constant';
28+
var constantItemSymbol = legend.itemsymbol === 'constant';
2829
var itemWidth = legend.itemwidth;
2930
var centerPos = (itemWidth + constants.itemGap * 2) / 2;
3031
var centerTransform = strTranslate(centerPos, 0);
@@ -203,6 +204,10 @@ module.exports = function style(s, gd, legend) {
203204
if(constantItemSizing && valToBound && cst !== undefined) {
204205
valToBound = cst;
205206
}
207+
208+
if(constantItemSymbol && attrIn === 'marker.symbol') {
209+
valToBound = 'circle';
210+
}
206211

207212
if(bounds) {
208213
if(valToBound < bounds[0]) return bounds[0];

0 commit comments

Comments
 (0)