Skip to content

Fix mathjax placement in ternary aaxis titles #3513

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 5, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lib/svg_text_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ exports.convertToTspans = function(_context, gd, _callback) {
else if(svgClass[0] === 'l') {
newSvg.attr({x: _context.attr('x'), y: dy - (newSvgH / 2)});
}
else if(svgClass[0] === 'a') {
else if(svgClass[0] === 'a' && svgClass.indexOf('atitle') === -1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we use

if(svgClass === 'atitle') {

here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would that be better?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering of an edge case where 'atitle' appears in other position in the text.
Though I was not able find any word containing those letters in order!
Anyway could we use this condition instead to test if atitle only occurs at the start of the string?

else if(svgClass[0] === 'a' && svgClass.indexOf('atitle') !== 0) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Done in -> c7878b3

newSvg.attr({x: 0, y: dy});
}
else {
Expand Down
Binary file added test/image/baselines/ternary-mathjax.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
57 changes: 57 additions & 0 deletions test/image/mocks/ternary-mathjax.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"data": [
{
"type": "scatterternary",
"mode": "markers",
"a": [75],
"b": [25],
"c": [0],
"text": ["point 1"],
"marker": {
"symbol": 100,
"color": "#DB7365",
"size": 14,
"line": {
"width": 2
}
}
}
],
"layout": {
"ternary": {
"sum": 100,
"aaxis": {
"title": {
"text": "$A^2$"
},
"showline": true,
"showgrid": true
},
"baxis": {
"title": {
"text": "$B^2$"
},
"showline": true,
"showgrid": true
},
"caxis": {
"title": {
"text": "$C^2$"
},
"showline": true,
"showgrid": true
}
},
"annotations": [
{
"showarrow": false,
"text": "Simple Ternary Plot with Markers",
"x": 0.5,
"y": 1.3,
"font": {
"size": 15
}
}
]
}
}