Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
bfialkoff
Helper I
Helper I

Path to asset is treated as url not local file

I am trying to create a rect object and set its fill using a pattern. So I create a defs element, create a pattern, set an image and in the fill property of the rect object set it fill using the css url. Like so: 

 

 

 

this.imageRect = this.svg
                .append('rect')
                .classed('engine-rect', true);

            let defs = this.svg
                .append('defs');
            
            defs.append('pattern')
                .attr({
                    id: 'image',
                    height: '100%',
                    width: '100%',
                    patternContentUnits: 'objectBoundingBox'
                })
                .append('image')
                .attr({
                    height: 1,
                    width: 1,
                    preserveAspectRatio: 'none',
                    'xlink:href': "../assets/engine_part.png"
                })

this.imageRect
                .attr({
                    x: 50,
                    y: 50,
                    width: 50,
                    height: 50,
                    fill: 'url(#image)'
                })

This doesn't work. When I inspect the defs element in the browser I see the following:

Untitled.png

I can see that PowerBI is treating the path to the image as a link and not a local file. How can I fix this? 

0 REPLIES 0

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Kudoed Authors