Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9293985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T21:16:00+00:00 2026-06-18T21:16:00+00:00

I am trying to embed a d3 graph into a handlebar template but when

  • 0

I am trying to embed a d3 graph into a handlebar template but when i am embedding the object registryhelper of handlebar returns [object SVGSVGElement] not as html.

D3 graph with handlebar registry helper

 Handlebars.registerHelper('list', function() {
 svg = d3.select('p').append("svg").attr("width",w).attr("height",h);
 var rect1 =svg.append("rect").attr("x",0).attr("y",3*h/4).
 attr("width",w).attr("height",rect_1_h).style("fill",rect_1_color);
 return svg;
 });

Handlebar Template

{{#each objects}}
 <tr>
 <td><p>{{#list}}{{/list}}</p></td>
 </tr>
 {{/each}}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T21:16:01+00:00Added an answer on June 18, 2026 at 9:16 pm

    Handlebars is displaying the toString value of the svg object.

    Use the html() method to get the HTML representation of svg, see https://github.com/mbostock/d3/wiki/Selections#wiki-html

    Then use Handlebars.SafeString to indicate Handlebars to not escape the HTML, something like this: return new Handlebars.SafeString(svg.html())

    But before doing that, take account that are some issues in your example:

    1. You are using d3.select which means, select an element from DOM. Then you are affecting that element in the DOM directly. Is not working like a “function”, probably what you want to do is to create the p element in memory. Or perhaps you can resolve the problem working with the DOM without creating a Handlebars helper.

    2. A small issue: add var to svg or you’ll be using a global.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Following chunk html code works as expected: <iframe src=http://www.amazon.com/></iframe> But when trying embed inner
I am trying to embed an opensocial gadget into a email. But I don't
I am trying to use embed_html from Graph API but the calls are not
Trying to embed Flash into a HTML page using FBML tag fb:swf and I
I'm trying to embed a TabLayoutPanel inside a DockLayoutPanel but the tabs are not
I'm trying to embed HTML into a MS Word file so that when this
I'm trying to embed Windows-Sidebar-Widgets into my own .Net Application (WPF and C#), but
trying to embed SWF into a FLEX project, importing symbols from it, not whole
I'm trying to embed a google map into a landscape PDF, but somehow, wkhtmltopdf
I am trying to embed bing maps into web page and it works, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.