Skip to content

Commit a115e4e

Browse files
committed
Enhance readability in legend groupdefaults
1 parent 8f983db commit a115e4e

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/components/legend/defaults.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function groupDefaults(legendId, layoutIn, layoutOut, fullData) {
5252
};
5353
fullData
5454
.filter(isPieWithLegendArray)
55-
.map(function (trace, idx) {
55+
.forEach(function (trace) {
5656
if (trace.visible) {
5757
legendTraceCount++;
5858
}
@@ -61,13 +61,11 @@ function groupDefaults(legendId, layoutIn, layoutOut, fullData) {
6161
if(legend === legendId) {
6262
// showlegend can be undefined, boolean or a boolean array.
6363
// will fall back to default if undefined or if array index is out-of-range
64-
if(
65-
!Array.isArray(trace.showlegend)
66-
? trace.showlegend || trace._dfltShowLegend
67-
: trace.showlegend[index] == null
68-
? trace._dfltShowLegend
69-
: trace.showlegend[index]
70-
) {
64+
var showInLegend = trace.showlegend || trace._dfltShowLegend;
65+
if (Array.isArray(trace.showlegend)) {
66+
showInLegend = trace.showlegend[index] ?? trace._dfltShowLegend;
67+
}
68+
if(showInLegend) {
7169
legendReallyHasATrace = true;
7270
legendTraceCount++;
7371
}

0 commit comments

Comments
 (0)