<?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: How to replace/remove SVG-Elements by using EventListener in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/How-to-replace-remove-SVG-Elements-by-using-EventListener/m-p/389310#M11572</link>
    <description>&lt;P&gt;At first , &lt;STRONG&gt;"this.absline.parent"&lt;/STRONG&gt; is not correct. It seems you should use something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;d3.select(this.absline.parent).selectAll("*").remove();&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We would also recommend not to remove/create an element for each event&amp;nbsp;as adding/removing elements from DOM is a very expensive operation.&lt;/P&gt;
&lt;P&gt;It'd be better to keep a single element and change its position for each event.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt; color: #333333;"&gt;Ignat Vilesov,&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt; color: #333333;"&gt;Software Engineer&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt; color: #333333;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt; color: #333333;"&gt;Microsoft Power BI Custom Visuals&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;&lt;A href="mailto:pbicvsupport@microsoft.com" target="_blank"&gt;&lt;SPAN&gt;pbicvsupport@microsoft.com&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 04 Apr 2018 07:25:07 GMT</pubDate>
    <dc:creator>v-viig</dc:creator>
    <dc:date>2018-04-04T07:25:07Z</dc:date>
    <item>
      <title>How to replace/remove SVG-Elements by using EventListener</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/How-to-replace-remove-SVG-Elements-by-using-EventListener/m-p/388583#M11546</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;im trying to figure out how to replace/remove svg-elements instead of creating new ones&amp;nbsp;while using an eventListener.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;when i move the slider handle to the right, it also moves the line. But for every step it creates new lines without removing the lines which were created before (i only want 1 line on my graph based on the slider handles position)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The start position was 50. i moved it to about 65:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried removing the child-elements by using:&lt;/P&gt;&lt;PRE&gt;d3.select("this.absline.parent").selectAll("*").remove();&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but this didnt worked for me.&lt;/P&gt;&lt;P&gt;is there a index-value that i can access to remove all lines except for the newest one?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Or does somebody have a better solution for this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;here is my code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;// mySlider: HTML Range-Slider Element&lt;BR /&gt;this.mySlider.addEventListener("mousemove", (event) =&amp;gt; { 
        this.getx = parseInt((event.target as HTMLInputElement).value); // getx: number (gets the value based on the sliders handle position)
&lt;BR /&gt;        var rot = 1; // used to rotate the line&lt;BR /&gt;
        // SVG Line-Element
        var absline = this.g
		.append('g')
		.append('rect')
                .classed('bar', true)
		.attr("x", absx(this.getx)) // Position on the x-axis based on the "absx"-Scale
		.attr("width", 2)
                .attr("y", absy(d3.max(dat, function (d) { return d.counter })))
		.attr("height", gHeight)
		.attr("transform", "rotate(" + rot + "," + absx(this.getx) + "," + absy(d3.max(dat, function (d) { return d.counter })) + ")");
		
});&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Apr 2018 11:26:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/How-to-replace-remove-SVG-Elements-by-using-EventListener/m-p/388583#M11546</guid>
      <dc:creator>az2451</dc:creator>
      <dc:date>2018-04-04T11:26:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace/remove SVG-Elements by using EventListener</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/How-to-replace-remove-SVG-Elements-by-using-EventListener/m-p/389310#M11572</link>
      <description>&lt;P&gt;At first , &lt;STRONG&gt;"this.absline.parent"&lt;/STRONG&gt; is not correct. It seems you should use something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;d3.select(this.absline.parent).selectAll("*").remove();&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We would also recommend not to remove/create an element for each event&amp;nbsp;as adding/removing elements from DOM is a very expensive operation.&lt;/P&gt;
&lt;P&gt;It'd be better to keep a single element and change its position for each event.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt; color: #333333;"&gt;Ignat Vilesov,&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt; color: #333333;"&gt;Software Engineer&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt; color: #333333;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt; color: #333333;"&gt;Microsoft Power BI Custom Visuals&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;&lt;A href="mailto:pbicvsupport@microsoft.com" target="_blank"&gt;&lt;SPAN&gt;pbicvsupport@microsoft.com&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Apr 2018 07:25:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/How-to-replace-remove-SVG-Elements-by-using-EventListener/m-p/389310#M11572</guid>
      <dc:creator>v-viig</dc:creator>
      <dc:date>2018-04-04T07:25:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace/remove SVG-Elements by using EventListener</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/How-to-replace-remove-SVG-Elements-by-using-EventListener/m-p/389550#M11576</link>
      <description>&lt;P&gt;Thank you very much.&lt;/P&gt;&lt;P&gt;yes it makes more sense to create 1 static object and change it for each event.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Apr 2018 11:27:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/How-to-replace-remove-SVG-Elements-by-using-EventListener/m-p/389550#M11576</guid>
      <dc:creator>az2451</dc:creator>
      <dc:date>2018-04-04T11:27:51Z</dc:date>
    </item>
  </channel>
</rss>

