Skip to content

Commit

Permalink
Now long legend labels do not have ellipsis.
Browse files Browse the repository at this point in the history
  • Loading branch information
michelezanda committed Oct 20, 2017
1 parent 01c9891 commit 429b840
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 26 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG_ION.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# plotly.js ION changelog

## [1.28.3-ion43] -- 2017-10-20

### Fix part I
- Legend labels do not have any more ellipsis


## [1.28.3-ion42] -- 2017-10-19

### Fixed
Expand Down
14 changes: 4 additions & 10 deletions dist_ion/plotly-ion.js
Original file line number Diff line number Diff line change
Expand Up @@ -22727,16 +22727,10 @@ function drawTexts(g, gd) {
trace = legendItem.trace,
isPie = Registry.traceIs(trace, 'pie'),
traceIndex = trace.index,
name = isPie ? legendItem.label : trace.name;

// ion: legend label ellipsis
var maxCharLength = 20;
var drawnText = name;
if (name.length > maxCharLength) {
var firstLen = Math.floor(maxCharLength / 2);
var lastLen = maxCharLength - firstLen - 1;
drawnText = drawnText.substr(0, firstLen) + '…' + drawnText.substr(-lastLen);
}
name = isPie ? legendItem.label : trace.name;

// ion
var drawnText = name;

var text = g.selectAll('text.legendtext')
.data([0]);
Expand Down
10 changes: 5 additions & 5 deletions dist_ion/plotly-ion.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "plotly.js",
"version": "1.28.3-ion42",
"version": "1.28.3-ion43",
"description": "The open source javascript graphing library that powers plotly",
"license": "MIT",
"main": "./lib/index.js",
Expand Down
14 changes: 4 additions & 10 deletions src/components/legend/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,16 +382,10 @@ function drawTexts(g, gd) {
trace = legendItem.trace,
isPie = Registry.traceIs(trace, 'pie'),
traceIndex = trace.index,
name = isPie ? legendItem.label : trace.name;

// ion: legend label ellipsis
var maxCharLength = 20;
var drawnText = name;
if (name.length > maxCharLength) {
var firstLen = Math.floor(maxCharLength / 2);
var lastLen = maxCharLength - firstLen - 1;
drawnText = drawnText.substr(0, firstLen) + '…' + drawnText.substr(-lastLen);
}
name = isPie ? legendItem.label : trace.name;

// ion
var drawnText = name;

var text = g.selectAll('text.legendtext')
.data([0]);
Expand Down

0 comments on commit 429b840

Please sign in to comment.