Skip to content

Commit 9b66bee

Browse files
author
Jon M. Mease
committed
Support Rich text / Latex in category labels (ticktext)
1 parent 340ae53 commit 9b66bee

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/traces/parcats/parcats.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ var Fx = require('../../components/fx');
1414
var Lib = require('../../lib');
1515
var Drawing = require('../../components/drawing');
1616
var tinycolor = require('tinycolor2');
17+
var svgTextUtils = require('../../lib/svg_text_utils');
1718

1819
function performPlot(parcatsModels, graphDiv, layout, svg) {
1920

@@ -269,6 +270,7 @@ function performPlot(parcatsModels, graphDiv, layout, svg) {
269270
/** @param {CategoryViewModel} catModel*/
270271
function(catModel) {
271272
Drawing.font(d3.select(this), catModel.parcatsViewModel.categorylabelfont);
273+
svgTextUtils.convertToTspans(d3.select(this), graphDiv);
272274
});
273275

274276
// Initialize dimension label
@@ -1370,7 +1372,25 @@ function updateSvgCategories(parcatsViewModel, hasTransition) {
13701372
// Place label to the left of category
13711373
return -5;
13721374
}
1373-
});
1375+
})
1376+
.each(function(d) {
1377+
// Update attriubutes of <tspan> elements
1378+
var newX;
1379+
var newAnchor;
1380+
if(catInRightDim(d)) {
1381+
// Place label to the right of category
1382+
newX = d.width + 5;
1383+
newAnchor = 'start'
1384+
} else {
1385+
// Place label to the left of category
1386+
newX = -5;
1387+
newAnchor = 'end'
1388+
}
1389+
d3.select(this)
1390+
.selectAll('tspan')
1391+
.attr('x', newX)
1392+
.attr('text-anchor', newAnchor);
1393+
});
13741394

13751395
// Update bands
13761396
// Initialize color band rects

0 commit comments

Comments
 (0)