gcor71
September 26, 2023, 4:44pm
1
After the rather smart @Suvrutt_Gurjar , I have attempted to make my own terribly simple SVG image with text overlay, but canβt seem to get it right - ending up with a small warning triangle every time.
Expert eyes that can spot (and guide me) on my rookie mistakes would be appreciated.
My effort is based - possibly too closely - on https://www.googlecloudcommunity.com/gc/Tips-Tricks/Dashboards-with-dynamic-text-overlay-on-SVG-images/m-p/516875
I have the following columns defined:
_backdrop : Long text : Virtual column
"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWlnaHQ9IjUwMCIgdmlld0JveD0iMCAwIDUwMCA1MDAiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IGlkPSJSZWN0YW5nbGUgMSIgd2lkdGg9IjUwMCIgaGVpZ2h0PSI1MDAiIGZpbGw9IiM4RDREQ0MiLz4KPC9zdmc+Cg=="β
_attribute : Text : Virtual column
"MEMBER NAME"β
SVG : Image : Virtual column
CONCATENATE("data:image/svg+xml;utf8,<svg version=""1.1""
xmlns=""http://www.w3.org/2000/svg"" xmlns:xlink=""http://www.w3.org/1999/xlink""
width=""500"" height=""500"">
<image x=""0"" y="" 0 "" width=""500"" height=""500""
xlink:href=""",[_backdrop],"""/>
<text font-family=""Verdana"" font-size=""25"" x=""170"" y=""140""
fill=""rgb(46, 139, 87)"">",[_attribute],"</text>
</svg>")β
The result:
Thank you, in advance.
Please try the following code. Please note the changes around [Attribute] column
CONCATENATE(βdata:image/svg+xml;utf8,<svg version=ββ1.1"β
xmlns=ββhttp://www.w3.org/2000/svg ββ xmlns:xlink=ββhttp://www.w3.org/1999/xlink ββ
width=ββ500"β height=ββ500"β>
<image x=ββ0"β y=β" 0 ββ width=ββ500"β height=ββ500"β
xlink:href=βββ,[_backdrop],βββ/>
<text font-family=ββVerdanaββ font-size=ββ25"β x=ββ170"β y=ββ140"β
fill=ββrgb(46, 139, 87)ββ>βββ,[_attribute],βββ
β)β
1 Like
SkrOYC
September 26, 2023, 6:00pm
3
When dealing with SVG, you can notice that the data in the SVG uses double quotes.
AppSheet, as a no-code oriented platform, accepts either single or double quotes, same for comma and semicolon.
Try using single quotes in your expressions, like this:
CONCATENATE(
'data:image/svg+xml;utf8,<svg version="1.1"
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
width="500" height="500">
<image x="0" y=" 0 " width="500" height="500"
xlink:href="',[_backdrop],'"/>
<text font-family="Verdana" font-size="25" x="170" y="140" fill="rgb(46, 139, 87)">',[_attribute],'</text>
</svg>'
)
1 Like
SkrOYC
September 26, 2023, 6:33pm
4
Btw, I took some minutes to explore this a bit, and if you are using an image just to display a background color, this may be a better solution:
CONCATENATE(
'data:image/svg+xml;utf8,<svg version="1.1"
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
width="600" height="400">
<rect width="100%" height="100%" fill="%23909090"/>
<text font-size="96" x="50%" y="50%" alignment-baseline="middle" text-anchor="middle" fill="rgb(255, 255, 255)">',
[YourText],
'</text>
</svg>'
)
In the example above, Iβm using a bigger text, which is centered, and replaced the image tag with , which is a gray color object that uses the whole available space
1 Like
gcor71
September 26, 2023, 7:25pm
5
@Suvrutt_Gurjar , @SkrOYC , youβve both been very generous with your replies - however, something is still wrong. There are no red flags in the editor, and Iβve tried all three alternatives for the SVG (image, virtual) column. Iβm now suspicious of the _background (long text, virtual) column.
Any other suggestions? Is there a way I can test the individual components to find the fault?
SkrOYC
September 26, 2023, 7:29pm
6
Using the Test section in the Expression Assistant.
Btw, we can even use gradients⦠this is great:
CONCATENATE(
'data:image/svg+xml;utf8,<svg version="1.1"
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
width="100%" height="100%">
<rect width="100%" height="100%" fill="url(%23MyGradient)"/>
<defs>
<linearGradient id="MyGradient" x1="0%" y1="0%" x2="100%" y2="0%">
<stop offset="0%" style="stop-color:%23909090;stop-opacity:1" />
<stop offset="100%" style="stop-color:%23FFFFFF;stop-opacity:1" />
</linearGradient>
</defs>
<text font-size="96" x="50%" y="50%" alignment-baseline="middle" text-anchor="middle" fill="%23FFFFFF">',
[YourText],
'</text>
</svg>'
)
1 Like
gcor71
September 26, 2023, 7:44pm
7
Still not working for me.
TEST, using your gradient example, returns
data:image/svg+xml;utf8,<svg version="1.1"
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
width="100%" height="100%">
<rect width="100%" height="100%" fill="url(%23MyGradient)"/>
<defs>
<linearGradient id="MyGradient" x1="0%" y1="0%" x2="100%" y2="0%">
<stop offset="0%" style="stop-color:%23909090;stop-opacity:1" />
<stop offset="100%" style="stop-color:%23FFFFFF;stop-opacity:1" />
</linearGradient>
</defs>
<text font-size="96" x="50%" y="50%" alignment-baseline="middle" text-anchor="middle" fill="%23FFFFFF">MEMBER NAME</text>
</svg>
TEST, using @Suvrutt_Gurjar 's reply at the top, returns
data:image/svg+xml;utf8,<svg version="1.1"
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
width="500" height="500">
<image x="0" y=" 0 " width="500" height="500"
xlink:href="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWlnaHQ9IjUwMCIgdmlld0JveD0iMCAwIDUwMCA1MDAiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IGlkPSJSZWN0YW5nbGUgMSIgd2lkdGg9IjUwMCIgaGVpZ2h0PSI1MDAiIGZpbGw9IiM4RDREQ0MiLz4KPC9zdmc+Cg=="/>
<text font-family="Verdana" font-size="25" x="170" y="140"
fill="rgb(46, 139, 87)">"MEMBER NAME"</text>
</svg>
The DATA definitions for the columns are:
Any other suggestions? I feel Iβm closeβ¦