Skip to content

Commit 1a8369b

Browse files
authored
Merge pull request #7043 from plotly/partial-strikethrough-underline-text
Add '<s>' and '<u>' pseudo html options for strike-through and underlining SVG text
2 parents 9adfc12 + 783b877 commit 1a8369b

File tree

7 files changed

+9
-6
lines changed

7 files changed

+9
-6
lines changed

draftlogs/7043_add.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Introduce "<u>" and "<s>" pseudo html tags to underline and strike-through SVG text elements [[#7043](https://github.com/plotly/plotly.js/pull/7043)]

src/components/annotations/attributes.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ module.exports = templatedArray('annotation', {
5050
'Sets the text associated with this annotation.',
5151
'Plotly uses a subset of HTML tags to do things like',
5252
'newline (<br>), bold (<b></b>), italics (<i></i>),',
53-
'hyperlinks (<a href=\'...\'></a>). Tags <em>, <sup>, <sub>',
53+
'hyperlinks (<a href=\'...\'></a>). Tags <em>, <sup>, <sub>, <s>, <u>',
5454
'<span> are also supported.'
5555
].join(' ')
5656
},

src/components/fx/hover.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2273,7 +2273,7 @@ function spikesChanged(gd, oldspikepoints) {
22732273
function plainText(s, len) {
22742274
return svgTextUtils.plainText(s || '', {
22752275
len: len,
2276-
allowedTags: ['br', 'sub', 'sup', 'b', 'i', 'em']
2276+
allowedTags: ['br', 'sub', 'sup', 'b', 'i', 'em', 's', 'u']
22772277
});
22782278
}
22792279

src/lib/svg_text_utils.js

+2
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,8 @@ var TAG_STYLES = {
330330
// baseline below
331331
sup: 'font-size:70%',
332332
sub: 'font-size:70%',
333+
s: 'text-decoration:line-through',
334+
u: 'text-decoration:underline',
333335
b: 'font-weight:bold',
334336
i: 'font-style:italic',
335337
a: 'cursor:pointer',
Loading

test/image/mocks/pie_title_middle_center_multiline.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"data": [
33
{
44
"values": [955, 405, 360, 310, 295],
5-
"labels": ["Mandarin", "Spanish", "English", "Hindi", "Arabic"],
5+
"labels": ["Mandarin", "Spanish", "<u>English</u>", "Hindi", "Arabic"],
66
"textinfo": "label+percent",
77
"hole": 0.4,
88
"title":{
@@ -14,7 +14,7 @@
1414
],
1515
"layout": {
1616
"title": {
17-
"text": "Top 5 languages by number of native speakers (2010, est.)"
17+
"text": "Top <s>10</s> 5 languages by number of <u>native</u> speakers (<s>2009</s> 2010, est.)"
1818
},
1919
"height": 600,
2020
"width": 600

test/plot-schema.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1118,7 +1118,7 @@
11181118
"valType": "string"
11191119
},
11201120
"text": {
1121-
"description": "Sets the text associated with this annotation. Plotly uses a subset of HTML tags to do things like newline (<br>), bold (<b></b>), italics (<i></i>), hyperlinks (<a href='...'></a>). Tags <em>, <sup>, <sub> <span> are also supported.",
1121+
"description": "Sets the text associated with this annotation. Plotly uses a subset of HTML tags to do things like newline (<br>), bold (<b></b>), italics (<i></i>), hyperlinks (<a href='...'></a>). Tags <em>, <sup>, <sub>, <s>, <u> <span> are also supported.",
11221122
"editType": "calc+arraydraw",
11231123
"valType": "string"
11241124
},
@@ -6660,7 +6660,7 @@
66606660
"valType": "string"
66616661
},
66626662
"text": {
6663-
"description": "Sets the text associated with this annotation. Plotly uses a subset of HTML tags to do things like newline (<br>), bold (<b></b>), italics (<i></i>), hyperlinks (<a href='...'></a>). Tags <em>, <sup>, <sub> <span> are also supported.",
6663+
"description": "Sets the text associated with this annotation. Plotly uses a subset of HTML tags to do things like newline (<br>), bold (<b></b>), italics (<i></i>), hyperlinks (<a href='...'></a>). Tags <em>, <sup>, <sub>, <s>, <u> <span> are also supported.",
66646664
"editType": "calc",
66656665
"valType": "string"
66666666
},

0 commit comments

Comments
 (0)