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 9152111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:57:49+00:00 2026-06-17T11:57:49+00:00

I am attempting to integrate a D3.js visualization into a Meteor app. After the

  • 0

I am attempting to integrate a D3.js visualization into a Meteor app. After the page has loaded, a D3 function injects DOM elements into a <div> in my template, based on available data.

Whenever there is a reactive update anywhere on the page, however, Meteor dumps the contents of the template that were injected by my D3.js function. I can re-insert the elements, but this leads to an undesirable flicker and decrease in performance.

Any idea on how to suppress this dropping of externally injected elements? I gather that since these elements were not part of the template originally, they are discarded as part of Meteor’s ‘cleanup’ process.

  • 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-17T11:57:50+00:00Added an answer on June 17, 2026 at 11:57 am

    With the introduction of the Spark templating engine in version 0.4.0, they’ve introduced the {{#constant}} block helpers to address this issue.

    http://meteor.com/blog/2012/08/31/introducing-spark-a-new-live-page-update-engine

    Your html template should look something like this….

    <template name="samplePageTemplate">
        <div id="samplePage" class="page">
            {{#constant}}
            <div id="sampleGraph"></div>
            {{/constant}}
        </div>
    </template>
    

    And the javascript should look something like this…

    Template.samplePageTemplate.destroyed = function () {
        this.handle && this.handle.stop();
    };
    Template.samplePageTemplate.rendered = function () {
        self.node = self.find("svg");
        if (!self.handle) {
            self.handle = Meteor.autorun(function(){
    
                $('#sampleGraph').html('');
                renderChart();
    
            });
        };
    };
    
    function renderChart(){
    
        // lots of d3 chart specific stuff 
    
        var vis = d3.select("#sampleGraph").append("svg:svg")
            .attr("width", window.innerWidth)
            .attr("height", window.innerHeight)
            .append("svg:g")
            .attr("transform", "translate(" + m[3] + "," + m[0] + ")");
    
        // more d3 chart specific stuff
    
        });
    };
    

    I’ve sometimes had to use self.node instead of self.handle, but otherwise it should be fairly straight forward.

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

Sidebar

Related Questions

I'm attempting to integrate the Flurry SDK into my iOS app for the first
I have an app that I'm attempting to integrate hibernate search into. I'm using
I am attempting integrate jQuery Mobile into an existing mobile page. I want to
I am attempting to integrate an existing payment platform into my webshop. After making
I'm attempting to integrate yaml-cpp into a project, but I'm seeing some unexpected errors
I'm attempting to integrate Masonry into an existing modified Wordpress site. I originally wrote
I am a intermediate web developer, I am attempting to integrate subversion into my
I'm trying to integrate the facebook-ios SDK 3.0 into my app - and I'm
I am attempting to integrate Facebook open graph into my site but I ran
I'm attempting to integrate zeromq into a glib main loop, but I can't figure

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.