How to use d3Plus in wrapping svg in svg ?











up vote
0
down vote

favorite












   <g id="group" opacity="1" style="pointer-events:inherit">
<rect x="504.5" y="384.3" class="class" width="76.6" height="38.5" id="svg_24" style="pointer-events:inherit" />
<text transform="matrix(0.9 -0.000105047 0.000116718 1 481.583 433.508)" class="test" id="svg_25" y="-11.997081870992588" x="27.779332551456037" style="pointer-events:inherit">Very Long Very Long Very Long Text</text>
</g>


I have this svg,I want to wrap the text inside rect using d3plus.










share|improve this question




























    up vote
    0
    down vote

    favorite












       <g id="group" opacity="1" style="pointer-events:inherit">
    <rect x="504.5" y="384.3" class="class" width="76.6" height="38.5" id="svg_24" style="pointer-events:inherit" />
    <text transform="matrix(0.9 -0.000105047 0.000116718 1 481.583 433.508)" class="test" id="svg_25" y="-11.997081870992588" x="27.779332551456037" style="pointer-events:inherit">Very Long Very Long Very Long Text</text>
    </g>


    I have this svg,I want to wrap the text inside rect using d3plus.










    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











         <g id="group" opacity="1" style="pointer-events:inherit">
      <rect x="504.5" y="384.3" class="class" width="76.6" height="38.5" id="svg_24" style="pointer-events:inherit" />
      <text transform="matrix(0.9 -0.000105047 0.000116718 1 481.583 433.508)" class="test" id="svg_25" y="-11.997081870992588" x="27.779332551456037" style="pointer-events:inherit">Very Long Very Long Very Long Text</text>
      </g>


      I have this svg,I want to wrap the text inside rect using d3plus.










      share|improve this question















         <g id="group" opacity="1" style="pointer-events:inherit">
      <rect x="504.5" y="384.3" class="class" width="76.6" height="38.5" id="svg_24" style="pointer-events:inherit" />
      <text transform="matrix(0.9 -0.000105047 0.000116718 1 481.583 433.508)" class="test" id="svg_25" y="-11.997081870992588" x="27.779332551456037" style="pointer-events:inherit">Very Long Very Long Very Long Text</text>
      </g>


      I have this svg,I want to wrap the text inside rect using d3plus.







      javascript svg d3plus






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 20 at 10:38

























      asked Nov 19 at 14:12









      Shahid

      248




      248
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          You can give the text a background rect using a flood filter. I added spacer elements to give the box a little padding, so to speak. See the following snippet:






          .spacer {
          fill: transparent;
          }

          <svg width="400" height="160" viewBox="0 0 400 160">
          <defs>
          <filter x="0" y="-0.5" width="1" height="2" id="solid">
          <feFlood flood-color="#b2f4f4"/>
          <feComposite in="SourceGraphic"/>
          </filter>
          </defs>
          <text
          filter="url(#solid)"
          y="40"
          x="40"
          style="pointer-events:inherit">
          <tspan class="spacer">.</tspan>
          Very Long Very Long Very Long Text
          <tspan class="spacer">.</tspan>
          </text>
          <text
          filter="url(#solid)"
          y="100"
          x="40"
          style="pointer-events:inherit">
          <tspan class="spacer">.</tspan>
          Short Text
          <tspan class="spacer">.</tspan>
          </text>
          </svg>








          share|improve this answer





















          • I cant add filters in my case,is there any way we can achieve it with js library?
            – Shahid
            Nov 21 at 5:37











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53376478%2fhow-to-use-d3plus-in-wrapping-svg-text-in-svg-rect%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote













          You can give the text a background rect using a flood filter. I added spacer elements to give the box a little padding, so to speak. See the following snippet:






          .spacer {
          fill: transparent;
          }

          <svg width="400" height="160" viewBox="0 0 400 160">
          <defs>
          <filter x="0" y="-0.5" width="1" height="2" id="solid">
          <feFlood flood-color="#b2f4f4"/>
          <feComposite in="SourceGraphic"/>
          </filter>
          </defs>
          <text
          filter="url(#solid)"
          y="40"
          x="40"
          style="pointer-events:inherit">
          <tspan class="spacer">.</tspan>
          Very Long Very Long Very Long Text
          <tspan class="spacer">.</tspan>
          </text>
          <text
          filter="url(#solid)"
          y="100"
          x="40"
          style="pointer-events:inherit">
          <tspan class="spacer">.</tspan>
          Short Text
          <tspan class="spacer">.</tspan>
          </text>
          </svg>








          share|improve this answer





















          • I cant add filters in my case,is there any way we can achieve it with js library?
            – Shahid
            Nov 21 at 5:37















          up vote
          0
          down vote













          You can give the text a background rect using a flood filter. I added spacer elements to give the box a little padding, so to speak. See the following snippet:






          .spacer {
          fill: transparent;
          }

          <svg width="400" height="160" viewBox="0 0 400 160">
          <defs>
          <filter x="0" y="-0.5" width="1" height="2" id="solid">
          <feFlood flood-color="#b2f4f4"/>
          <feComposite in="SourceGraphic"/>
          </filter>
          </defs>
          <text
          filter="url(#solid)"
          y="40"
          x="40"
          style="pointer-events:inherit">
          <tspan class="spacer">.</tspan>
          Very Long Very Long Very Long Text
          <tspan class="spacer">.</tspan>
          </text>
          <text
          filter="url(#solid)"
          y="100"
          x="40"
          style="pointer-events:inherit">
          <tspan class="spacer">.</tspan>
          Short Text
          <tspan class="spacer">.</tspan>
          </text>
          </svg>








          share|improve this answer





















          • I cant add filters in my case,is there any way we can achieve it with js library?
            – Shahid
            Nov 21 at 5:37













          up vote
          0
          down vote










          up vote
          0
          down vote









          You can give the text a background rect using a flood filter. I added spacer elements to give the box a little padding, so to speak. See the following snippet:






          .spacer {
          fill: transparent;
          }

          <svg width="400" height="160" viewBox="0 0 400 160">
          <defs>
          <filter x="0" y="-0.5" width="1" height="2" id="solid">
          <feFlood flood-color="#b2f4f4"/>
          <feComposite in="SourceGraphic"/>
          </filter>
          </defs>
          <text
          filter="url(#solid)"
          y="40"
          x="40"
          style="pointer-events:inherit">
          <tspan class="spacer">.</tspan>
          Very Long Very Long Very Long Text
          <tspan class="spacer">.</tspan>
          </text>
          <text
          filter="url(#solid)"
          y="100"
          x="40"
          style="pointer-events:inherit">
          <tspan class="spacer">.</tspan>
          Short Text
          <tspan class="spacer">.</tspan>
          </text>
          </svg>








          share|improve this answer












          You can give the text a background rect using a flood filter. I added spacer elements to give the box a little padding, so to speak. See the following snippet:






          .spacer {
          fill: transparent;
          }

          <svg width="400" height="160" viewBox="0 0 400 160">
          <defs>
          <filter x="0" y="-0.5" width="1" height="2" id="solid">
          <feFlood flood-color="#b2f4f4"/>
          <feComposite in="SourceGraphic"/>
          </filter>
          </defs>
          <text
          filter="url(#solid)"
          y="40"
          x="40"
          style="pointer-events:inherit">
          <tspan class="spacer">.</tspan>
          Very Long Very Long Very Long Text
          <tspan class="spacer">.</tspan>
          </text>
          <text
          filter="url(#solid)"
          y="100"
          x="40"
          style="pointer-events:inherit">
          <tspan class="spacer">.</tspan>
          Short Text
          <tspan class="spacer">.</tspan>
          </text>
          </svg>








          .spacer {
          fill: transparent;
          }

          <svg width="400" height="160" viewBox="0 0 400 160">
          <defs>
          <filter x="0" y="-0.5" width="1" height="2" id="solid">
          <feFlood flood-color="#b2f4f4"/>
          <feComposite in="SourceGraphic"/>
          </filter>
          </defs>
          <text
          filter="url(#solid)"
          y="40"
          x="40"
          style="pointer-events:inherit">
          <tspan class="spacer">.</tspan>
          Very Long Very Long Very Long Text
          <tspan class="spacer">.</tspan>
          </text>
          <text
          filter="url(#solid)"
          y="100"
          x="40"
          style="pointer-events:inherit">
          <tspan class="spacer">.</tspan>
          Short Text
          <tspan class="spacer">.</tspan>
          </text>
          </svg>





          .spacer {
          fill: transparent;
          }

          <svg width="400" height="160" viewBox="0 0 400 160">
          <defs>
          <filter x="0" y="-0.5" width="1" height="2" id="solid">
          <feFlood flood-color="#b2f4f4"/>
          <feComposite in="SourceGraphic"/>
          </filter>
          </defs>
          <text
          filter="url(#solid)"
          y="40"
          x="40"
          style="pointer-events:inherit">
          <tspan class="spacer">.</tspan>
          Very Long Very Long Very Long Text
          <tspan class="spacer">.</tspan>
          </text>
          <text
          filter="url(#solid)"
          y="100"
          x="40"
          style="pointer-events:inherit">
          <tspan class="spacer">.</tspan>
          Short Text
          <tspan class="spacer">.</tspan>
          </text>
          </svg>






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 20 at 23:30









          Ted

          10.6k11943




          10.6k11943












          • I cant add filters in my case,is there any way we can achieve it with js library?
            – Shahid
            Nov 21 at 5:37


















          • I cant add filters in my case,is there any way we can achieve it with js library?
            – Shahid
            Nov 21 at 5:37
















          I cant add filters in my case,is there any way we can achieve it with js library?
          – Shahid
          Nov 21 at 5:37




          I cant add filters in my case,is there any way we can achieve it with js library?
          – Shahid
          Nov 21 at 5:37


















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53376478%2fhow-to-use-d3plus-in-wrapping-svg-text-in-svg-rect%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          404 Error Contact Form 7 ajax form submitting

          How to know if a Active Directory user can login interactively

          Refactoring coordinates for Minecraft Pi buildings written in Python