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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Syndicate_Admin
Administrator
Administrator

Gráfico de viñetas SVG

Hola

He estado tratando de crear gráficos de viñetas dentro de la tabla con variables. No funciona y genera el icono de "imagen". Apuesto a que es un problema relacionado con el código SVG, pero como no soy un experto en él y no puedo encontrar una solución para resolver este problema, estaría encantado de obtener ayuda 🙂 Aquí está el código a continuación, ¡gracias de antemano!

Bullet = 

VAR vBackground = "%23ffffff"

VAR vBarColor = Switch(
    True(),
                [losspln] <= [targetpln], "%2339a964",
                [targetpln] = 0, "%23ffa160",
                [losspln] > [targetpln], "%23cd1319"
                )

VAR vActBarColor = "%23333333"
VAR vTargetBarColor = "%23888888"

// Base Text for drawing
 
VAR vBaseText = 
"data&colon;image/svg+xml;utf8, <svg width='100' height='100' version='1.1' xmlns='http://www.w3.org/2000/svg' style= 'background: " & vBackground & "'>
  <rect  x='0'       y='25'   rx='2' ry='2'   width='100'       height='50'   style='fill:" & vBarColor & ";stroke-width:0;fill-opacity:1' /> 
  <rect  x='0'       y='45'   rx='2' ry='2'   width=""#Actual"" height='10'   style='fill:" & vActBarColor & ";stroke-width:0;fill-opacity:1' />
  <rect  x=""#Budget"" y='30'   rx='2' ry='2'   width='6'         height='40'   style='fill:" & vTargetBarColor & ";stroke:black;stroke-width:0;fill-opacity:1;stroke-opacity:1' />
</svg>"

VAR vObjects = ALL(Resource[Resource Short])

VAR vMaxActual = MAXX( vObjects, [losspln] )
VAR vMaxGoal   = MAXX( vObjects, [targetpln] )

VAR vXAxisRangeBase = MAX( vMaxActual, vMaxGoal )

VAR vActual = INT( DIVIDE( [losspln], vXAxisRangeBase ) * 90 )
VAR vGoal   = INT( DIVIDE( [targetpln],  vXAxisRangeBase ) * 90 )

VAR vReturn = SUBSTITUTE( SUBSTITUTE( vBaseText, "#Actual", vActual ), "#Goal", vGoal )

RETURN IF( [losspln], vReturn, BLANK() )

1 ACCEPTED SOLUTION
Syndicate_Admin
Administrator
Administrator

¿Qué muestra el código svg cuando lo cambias a texto y lo ves en modo de enfoque?

KerKol_1-1634352154506.png

Tendrás que tener cuidado de que tus valores de anchura y altura se escapen correctamente...

width=""#Actual"" tendrá que ser algo así como... width="&"'"&"#Actual"&"'"&"

View solution in original post

2 REPLIES 2
Syndicate_Admin
Administrator
Administrator

¿Qué muestra el código svg cuando lo cambias a texto y lo ves en modo de enfoque?

KerKol_1-1634352154506.png

Tendrás que tener cuidado de que tus valores de anchura y altura se escapen correctamente...

width=""#Actual"" tendrá que ser algo así como... width="&"'"&"#Actual"&"'"&"

Sí, eso obviamente era un problema con los apóstrofos. Cambiado también ' a ""

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors