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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Svendu
Frequent Visitor

SVG dynamic visual not working in one file but in a new one yes, why?

Dear community, 

 

I am trying to play around with dynamic svg visuals and after trying out several tutorials that never worked in my current working file, I tried it in a new powerBI file and this time it worked.

It is though inconvenient, as I don't want to recreate my whole work in a new pbix. 

Does anyone know why? Are there any settings that may interfere with the results of a measure? Or could relationships in the data models have an impact? 

 

This is the code I tried in 2 places: (the division in the the 1st VAR is numerical to easily test it)

 

Gender_M_Icon = 
//Define the percentage to be coloured 
VAR percentageArea = DIVIDE(70,100)

//Define the colors 
VAR fillColor = "#00477A"
VAR backgroundColor = "#cccccc"

var svg = "data:image/svg+xml;utf8,
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'>

<defs>
    <clipPath id='maskClip'>
        <rect x='0' y='0' width='512' height='"& 512*(1-percentageArea)  &"' />
    </clipPath>
</defs>

<g style='fill:"&fillColor&";'>
	<circle cx='256' cy='51.2' r='51.2'/>
	<path d='M341.333,119.467H170.667c-23.564,0-42.667,19.103-42.667,42.667v128c0,14.138,11.461,25.6,25.6,25.6
				c14.138,0,25.6-11.461,25.6-25.6V179.2h17.067v307.2c0,14.138,11.462,25.6,25.6,25.6s25.6-11.461,25.6-25.6V315.733h17.067V486.4
				c0,14.138,11.462,25.6,25.6,25.6s25.6-11.461,25.6-25.6V179.2H332.8v110.933c0,14.138,11.462,25.6,25.6,25.6
				s25.6-11.461,25.6-25.6v-128C384,138.569,364.898,119.467,341.333,119.467z'/>
</g>

<g style='fill:"&backgroundColor&";clip-path:url(#maskClip)'>
	<circle cx='256' cy='51.2' r='51.2'/>
	<path d='M341.333,119.467H170.667c-23.564,0-42.667,19.103-42.667,42.667v128c0,14.138,11.461,25.6,25.6,25.6
				c14.138,0,25.6-11.461,25.6-25.6V179.2h17.067v307.2c0,14.138,11.462,25.6,25.6,25.6s25.6-11.461,25.6-25.6V315.733h17.067V486.4
				c0,14.138,11.462,25.6,25.6,25.6s25.6-11.461,25.6-25.6V179.2H332.8v110.933c0,14.138,11.462,25.6,25.6,25.6
				s25.6-11.461,25.6-25.6v-128C384,138.569,364.898,119.467,341.333,119.467z'/>
</g>

</svg>
"
return svg

 

 

In my current working document, it renders: 

Svendu_0-1671117269980.png

In a new one it renders properly the 70%:

Svendu_1-1671117301646.png

 

Any clue? 

 

1 REPLY 1
v-luwang-msft
Community Support
Community Support

HI @Svendu ,

Could you pls share your pbix file ,remember to remove confidential data.

 

 

Best Regards

Lucien

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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