<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Manipulating SVG file in G Web Development Software</title>
    <link>https://ni.lithium.com/t5/G-Web-Development-Software/Manipulating-SVG-file/m-p/4321201#M604</link>
    <description>&lt;P&gt;There are a lot of ways to approach this problem. I created an example that does the following approach:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Use the HTML Placeholder container to insert the &lt;FONT face="courier new,courier"&gt;svg&lt;/FONT&gt; content directly into the page (instead of using the &lt;FONT face="courier new,courier"&gt;&amp;lt;object&amp;gt;&lt;/FONT&gt; tag)&lt;/LI&gt;
&lt;LI&gt;With the elements directly in the page I can manipulate them like other elements in a page. So in the svg I added &lt;FONT face="courier new,courier"&gt;id&lt;/FONT&gt; attributes, etc. that I can find with the JavaScript&amp;nbsp;&lt;FONT face="courier new,courier"&gt;querySelector&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;In this example I used CSS styles to manipulate the SVG (rotate the svg element with id &lt;FONT face="courier new,courier"&gt;ball&lt;/FONT&gt;)&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ballsvg.gif" style="width: 331px;"&gt;&lt;img src="https://ip1.i.lithium.com/8fb1bd68376591060f5f466c2656b5df0b48ba71/68747470733a2f2f6e692e6c69746869756d2e636f6d2f74352f696d6167652f736572766572706167652f696d6167652d69642f33323134383869363435313630333145343032393542342f696d6167652d73697a652f6c617267653f763d76322670783d393939" role="button" title="ballsvg.gif" alt="ballsvg.gif" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 05 Aug 2023 23:43:17 GMT</pubDate>
    <dc:creator>MilanR</dc:creator>
    <dc:date>2023-08-05T23:43:17Z</dc:date>
    <item>
      <title>Manipulating SVG file</title>
      <link>https://ni.lithium.com/t5/G-Web-Development-Software/Manipulating-SVG-file/m-p/4319693#M597</link>
      <description>&lt;P&gt;Hi folks,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Probably you have any idea about our current issue on updating the svg file using javascript.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;WORKS:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;- Modify HTML source in gweb &amp;lt;/&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Adding the following texts:&lt;/P&gt;
&lt;P&gt;&amp;lt;div id="svg1"&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;object type="image/svg+xml" data="support/picture.svg" width="100%" height="100%"&amp;gt;&lt;BR /&gt;&amp;lt;/object&amp;gt;&amp;lt;/div&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then in JS:&lt;/P&gt;
&lt;P&gt;const svgObject = document.querySelector("#svg1 object");&lt;/P&gt;
&lt;P&gt;const svgDoc = svgObject.contentDocument;&amp;nbsp; &amp;nbsp;//This give XMLDocument object.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;DOES NOT WORK&lt;/STRONG&gt;:&lt;/P&gt;
&lt;P&gt;I used html container, create object element. &lt;STRONG&gt;The svg file is loaded&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;However, I &lt;STRONG&gt;cannot&lt;/STRONG&gt; access the contentDocument.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;Object element creation:&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;const createSVG = function (container, svgPath) {&lt;BR /&gt;const svgObject = document.createElement('object');&lt;BR /&gt;svgObject.type = "image/svg+xml";&lt;BR /&gt;svgObject.data = svgPath;&lt;BR /&gt;&lt;BR /&gt;svgObject.width = '100%';&lt;BR /&gt;svgObject.height = '100%';&lt;BR /&gt;container.appendChild(svgObject);&lt;BR /&gt;return svgObject;&lt;BR /&gt;};&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Access document content as DOM file:&lt;/P&gt;
&lt;P&gt;const svgDoc = svgObject.contentDocument;&amp;nbsp; //This give HTMLDocument instead of XML document.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any idea on how to resolve this as I need to modify the SVG during realtime (update sensor data based on its location in the image).&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2023 09:02:16 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/G-Web-Development-Software/Manipulating-SVG-file/m-p/4319693#M597</guid>
      <dc:creator>irfanabid</dc:creator>
      <dc:date>2023-07-31T09:02:16Z</dc:date>
    </item>
    <item>
      <title>Re: Manipulating SVG file</title>
      <link>https://ni.lithium.com/t5/G-Web-Development-Software/Manipulating-SVG-file/m-p/4321201#M604</link>
      <description>&lt;P&gt;There are a lot of ways to approach this problem. I created an example that does the following approach:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Use the HTML Placeholder container to insert the &lt;FONT face="courier new,courier"&gt;svg&lt;/FONT&gt; content directly into the page (instead of using the &lt;FONT face="courier new,courier"&gt;&amp;lt;object&amp;gt;&lt;/FONT&gt; tag)&lt;/LI&gt;
&lt;LI&gt;With the elements directly in the page I can manipulate them like other elements in a page. So in the svg I added &lt;FONT face="courier new,courier"&gt;id&lt;/FONT&gt; attributes, etc. that I can find with the JavaScript&amp;nbsp;&lt;FONT face="courier new,courier"&gt;querySelector&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;In this example I used CSS styles to manipulate the SVG (rotate the svg element with id &lt;FONT face="courier new,courier"&gt;ball&lt;/FONT&gt;)&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ballsvg.gif" style="width: 331px;"&gt;&lt;img src="https://ip1.i.lithium.com/8fb1bd68376591060f5f466c2656b5df0b48ba71/68747470733a2f2f6e692e6c69746869756d2e636f6d2f74352f696d6167652f736572766572706167652f696d6167652d69642f33323134383869363435313630333145343032393542342f696d6167652d73697a652f6c617267653f763d76322670783d393939" role="button" title="ballsvg.gif" alt="ballsvg.gif" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 05 Aug 2023 23:43:17 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/G-Web-Development-Software/Manipulating-SVG-file/m-p/4321201#M604</guid>
      <dc:creator>MilanR</dc:creator>
      <dc:date>2023-08-05T23:43:17Z</dc:date>
    </item>
    <item>
      <title>Re: Manipulating SVG file</title>
      <link>https://ni.lithium.com/t5/G-Web-Development-Software/Manipulating-SVG-file/m-p/4321203#M605</link>
      <description>&lt;P&gt;Thanks a lot Milan. Really helpful. I will look into it.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 06 Aug 2023 00:22:34 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/G-Web-Development-Software/Manipulating-SVG-file/m-p/4321203#M605</guid>
      <dc:creator>irfanabid</dc:creator>
      <dc:date>2023-08-06T00:22:34Z</dc:date>
    </item>
  </channel>
</rss>

