Skip to content

Commit 75481ed

Browse files
committed
Pie chart vertical legend: fixed call stack exception, and redesigned sizing logic for the legend.
1 parent b2f2a29 commit 75481ed

7 files changed

Lines changed: 18 additions & 11 deletions

File tree

CHANGELOG_ION.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# plotly.js ION changelog
22

3+
## [1.33.1-ion36] -- 2020-05-18
4+
5+
### Vertical legend in pie chart sizing caused call stack exception.
6+
7+
38
## [1.33.1-ion35] -- 2020-04-27
49

510
### Regression in ion31. Chart wrongly autosized at startup

dist_ion/plotly-ion.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32811,7 +32811,7 @@ exports.svgAttrs = {
3281132811
var Plotly = require('./plotly');
3281232812

3281332813
// package version injected by `npm run preprocess`
32814-
exports.version = '1.33.1-ion35';
32814+
exports.version = '1.33.1-ion36';
3281532815

3281632816
// inject promise polyfill
3281732817
require('es6-promise').polyfill();
@@ -38109,8 +38109,9 @@ function buildSVGText(containerNode, str, gd, IONFormat) {
3810938109

3811038110
// In case ION new line logic applies to the legend labels
3811138111
var numCharsInLabel = 17;
38112-
if (gd._fullLayout._hasPie && gd._fullLayout.legend && gd._fullLayout.legend.orientation === 'v' && gd._fullLayout.width > 220 && gd.data.length === 1) {
38113-
numCharsInLabel = 5 + Math.ceil((gd._fullLayout.width - 220)/25);
38112+
38113+
if (gd._fullLayout._hasPie && gd._fullLayout.legend && gd._fullLayout.legend.orientation === 'v' && gd._fullLayout.width > 170 && gd.data.length === 1) {
38114+
numCharsInLabel = 5 + Math.floor((gd._fullLayout.width - 170)/22);
3811438115
}
3811538116

3811638117
// In case BR is already used for hovertooltip custom formatting
@@ -38129,7 +38130,7 @@ function buildSVGText(containerNode, str, gd, IONFormat) {
3812938130
} else {
3813038131
strION = strION.substr(0, upToPos) + "<br>" + strION.substr(upToPos);
3813138132
}
38132-
if (strION.length > numCharsInLabel * 2) {
38133+
if (strION.length - 4 > numCharsInLabel * 2) {
3813338134
strION = strION.substr(0, (numCharsInLabel * 2) + 4 - 3 ) + "...";
3813438135
}
3813538136
}

dist_ion/plotly-ion.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "plotly.js",
3-
"version": "1.33.1-ion35",
3+
"version": "1.33.1-ion36",
44
"description": "The open source javascript graphing library that powers plotly",
55
"license": "MIT",
66
"main": "./lib/index.js",

src/assets/geo_assets.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ var saneTopojson = require('sane-topojson');
1212

1313

1414
// package version injected by `npm run preprocess`
15-
exports.version = '1.33.1-ion35';exports.topojson = saneTopojson;
15+
exports.version = '1.33.1-ion36';exports.topojson = saneTopojson;

src/core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
var Plotly = require('./plotly');
1616

1717
// package version injected by `npm run preprocess`
18-
exports.version = '1.33.1-ion35';
18+
exports.version = '1.33.1-ion36';
1919

2020
// inject promise polyfill
2121
require('es6-promise').polyfill();

src/lib/svg_text_utils.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,9 @@ function buildSVGText(containerNode, str, gd, IONFormat) {
428428

429429
// In case ION new line logic applies to the legend labels
430430
var numCharsInLabel = 17;
431-
if (gd._fullLayout._hasPie && gd._fullLayout.legend && gd._fullLayout.legend.orientation === 'v' && gd._fullLayout.width > 220 && gd.data.length === 1) {
432-
numCharsInLabel = 5 + Math.ceil((gd._fullLayout.width - 220)/25);
431+
432+
if (gd._fullLayout._hasPie && gd._fullLayout.legend && gd._fullLayout.legend.orientation === 'v' && gd._fullLayout.width > 170 && gd.data.length === 1) {
433+
numCharsInLabel = 5 + Math.floor((gd._fullLayout.width - 170)/22);
433434
}
434435

435436
// In case BR is already used for hovertooltip custom formatting
@@ -448,7 +449,7 @@ function buildSVGText(containerNode, str, gd, IONFormat) {
448449
} else {
449450
strION = strION.substr(0, upToPos) + "<br>" + strION.substr(upToPos);
450451
}
451-
if (strION.length > numCharsInLabel * 2) {
452+
if (strION.length - 4 > numCharsInLabel * 2) {
452453
strION = strION.substr(0, (numCharsInLabel * 2) + 4 - 3 ) + "...";
453454
}
454455
}

0 commit comments

Comments
 (0)