Skip to content

Commit 03638ee

Browse files
committed
add mathjax subtitle mock; add addl padding bw sutbtitle and title when title is mathjax
1 parent 2790ec7 commit 03638ee

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/components/titles/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,9 @@ function draw(gd, titleClass, options) {
200200
if(titleElMathGroup && subtitleEl) {
201201
var titleMathHeight = titleElMathGroup.node().getBBox().height;
202202
if(titleMathHeight) {
203-
var newSubtitleY = Number(subtitleEl.attr('y')) + titleMathHeight;
203+
// Increase the y position of the subtitle by the height of the title,
204+
// plus a (somewhat arbitrary) 10px of padding
205+
var newSubtitleY = Number(subtitleEl.attr('y')) + titleMathHeight + 10;
204206
subtitleEl.attr('y', newSubtitleY);
205207
}
206208
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"data": [
3+
{
4+
"x": ["a", "b", "c", "d"],
5+
"y": [100, 23, 27, 40],
6+
"type": "bar"
7+
}
8+
],
9+
"layout": {
10+
"title": {
11+
"text": "$E=mc^2$",
12+
"subtitle": {
13+
"text": "$y = ax^2 + bx + c$"
14+
}
15+
}
16+
}
17+
}

0 commit comments

Comments
 (0)