Skip to content

Commit fbb299b

Browse files
committedOct 11, 2016
legend: add logic for 'ohlc' and 'candlestick' in legend name edits
- so that editing legend item text restyles increasing / decreasing 'name' instead of trace-wide name
1 parent 2b1918c commit fbb299b

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed
 

Diff for: ‎src/components/legend/draw.js

+18-1
Original file line numberDiff line numberDiff line change
@@ -367,10 +367,27 @@ function drawTexts(g, gd) {
367367
.call(textLayout)
368368
.on('edit', function(text) {
369369
this.attr({'data-unformatted': text});
370+
370371
this.text(text)
371372
.call(textLayout);
373+
372374
if(!this.text()) text = ' \u0020\u0020 ';
373-
Plotly.restyle(gd, 'name', text, traceIndex);
375+
376+
var fullInput = legendItem.trace._fullInput || {},
377+
astr;
378+
379+
// N.B. this block isn't super clean,
380+
// and only works for for 'ohlc' and 'candlestick',
381+
// but should be generalized for other one-to-many transforms
382+
if(['ohlc', 'candlestick'].indexOf(fullInput.type) !== -1) {
383+
var transforms = legendItem.trace.transforms,
384+
direction = transforms[transforms.length - 1].direction;
385+
386+
astr = direction + '.legenditem.name';
387+
}
388+
else astr = 'name';
389+
390+
Plotly.restyle(gd, astr, text, traceIndex);
374391
});
375392
}
376393
else text.call(textLayout);

0 commit comments

Comments
 (0)