Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 700dcd9

Browse files
author
Sebastian Wojtowicz
committed
[TASK] read img tag from label and create image svg
1 parent cb73267 commit 700dcd9

File tree

2 files changed

+51
-2
lines changed

2 files changed

+51
-2
lines changed

dist/plotly.js

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181615,6 +181615,45 @@ module.exports = function(gd, svg, calcData, layout, callbacks) {
181615181615
.attr('d', textGuidePath)
181616181616
.attr('transform', sankeyInverseTransform);
181617181617

181618+
181619+
181620+
var nodeLabelImage = nodeCentered.selectAll('.' + 'node-label-image')
181621+
.data(repeat);
181622+
181623+
nodeLabelImage.enter()
181624+
.append('image')
181625+
.classed('node-label-image', true)
181626+
.attr('xlink:href', function(d) {
181627+
var label = d.node.label;
181628+
181629+
var IMG_REGEX = /(.*)(<img src=[\"\'])([^\"\']+)(.*[\"\']\s*[^\/]*\/>)(.*)/i;
181630+
var foundUrl = '';
181631+
181632+
label.replace(IMG_REGEX,
181633+
function(match, textA, prefix, url, suffix, textB) {
181634+
foundUrl = url;
181635+
return url;
181636+
}
181637+
);
181638+
181639+
return foundUrl;
181640+
})
181641+
.attr('style', 'transform: translateY(-9px) translateX(0px)')
181642+
// .attr('width', function(d) {
181643+
// var label = d.node.label;
181644+
// var IMG_WIDTH_REGEX = /(<img src=["][^"]+["]\s*width=\")(\d+)(\"[^\/]*\/>)/i;
181645+
// var width = '';
181646+
// label.replace(IMG_WIDTH_REGEX, function(match, imgTag, numberValue) {
181647+
// width = numberValue;
181648+
// return numberValue;
181649+
// });
181650+
// debugger;
181651+
// return width;
181652+
// })
181653+
.attr('width', '16')
181654+
.attr('height', '16');
181655+
181656+
181618181657
var nodeLabel = nodeCentered.selectAll('.' + c.cn.nodeLabel)
181619181658
.data(repeat);
181620181659

@@ -181649,7 +181688,17 @@ module.exports = function(gd, svg, calcData, layout, callbacks) {
181649181688
.style('fill', nodeTextColor);
181650181689

181651181690
nodeLabelTextPath
181652-
.text(function(d) {return d.horizontal || d.node.dy > 5 ? d.node.label : '';})
181691+
.text(function(d) {
181692+
var label = d.node.label;
181693+
var IMG_REGEX = /(.*)(<img src=[\"\'])([^\"\']+)(.*[\"\']\s*[^\/]*\/>)(.*)/i;
181694+
var imgTag = '';
181695+
label = label.replace(IMG_REGEX,
181696+
function(match, textA, prefix, url, suffix, textB) {
181697+
return textA + textB;
181698+
}
181699+
);
181700+
return d.horizontal || d.node.dy > 5 ? label : '';
181701+
})
181653181702
.attr('text-anchor', function(d) {return d.horizontal && d.left ? 'end' : 'start';});
181654181703

181655181704
nodeLabelTextPath

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.49.5",
3+
"version": "1.49.6",
44
"description": "The open source javascript graphing library that powers plotly",
55
"license": "MIT",
66
"main": "./lib/index.js",

0 commit comments

Comments
 (0)