Skip to content

Commit 51fc434

Browse files
committed
Simplify code for calculation of pie showlegend defaults
1 parent b968041 commit 51fc434

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/components/legend/defaults.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,10 @@ function groupDefaults(legendId, layoutIn, layoutOut, fullData) {
5959
for(var index = 0; index < trace._length; index++) {
6060
var legend = (Array.isArray(trace.legend) ? trace.legend[index] : trace.legend) || 'legend';
6161
if(legend === legendId) {
62-
// showlegend can be undefined, boolean or a boolean array.
63-
// will fall back to default if undefined or if array index is out-of-range
64-
var showInLegend = trace.showlegend || trace._dfltShowLegend;
65-
if (Array.isArray(trace.showlegend)) {
66-
showInLegend = trace.showlegend[index] ?? trace._dfltShowLegend;
67-
}
68-
if(showInLegend) {
62+
// showlegend can be boolean or a boolean array.
63+
// will fall back to default if array index is out-of-range
64+
const showInLegend = Array.isArray(trace.showlegend) ? trace.showlegend[index] : trace.showlegend;
65+
if (showInLegend || trace._dfltShowLegend) {
6966
legendReallyHasATrace = true;
7067
legendTraceCount++;
7168
}

0 commit comments

Comments
 (0)