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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:02:09+00:00 2026-06-05T14:02:09+00:00

This is a simple question that I just can’t seem to get figured out

  • 0

This is a simple question that I just can’t seem to get figured out — All I want to do is change the position of an element on a page. I’ve tried the following:

// Text
body = d3.select('body')
sometext = body.append('text').text('testing') // text appears

// Different Ways i've tried to move it
.attr('cx', 40)
.attr('x', 40)
.attr("transform", "translate("40, 100")

However, none of this moves the text — What am I missing (http://jsfiddle.net/Hn5JX/)? I’m having the same issue moving svg elements around a page, i just thought this was easier to see on the jsfiddle. Thanks for help with a basic question,

  • 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-05T14:02:11+00:00Added an answer on June 5, 2026 at 2:02 pm

    Here’s an example of moved text using d3js.
    http://jsfiddle.net/JnNtZ/

    Make sure to include:

    "http://mbostock.github.com/d3/d3.js"
    

    Then include the following javascript

    // Create an svg "canvas" to place text on
    var w = 400, h = 400;    
    var vis = d3.select("body")
      .append("svg")
        .attr("width", w)
        .attr("height", h);
    
    // Add text and set attributes
    var text1 = vis.append('text').text('text1');
    var text2 = vis.append('text').text('text2');
    text1.attr("y", "300").style("fill", "red");
    text2.attr("x", "200").attr("y", "403").style("fill", "blue");  // Notice how this text is on the edge of the canvas
    

    ​
    I think the problem you were running into is that upon selecting text, you’re getting an HTML element instead of an SVGText element (It seems you need an SVG element to allow manipulations by d3js). You also need to make sure that the (x,y) coordinates of the text fall inside the given canvas.

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

Sidebar

Related Questions

This is a super simple question that I just can't seem to find a
I'm sure this is a simple question, just can't seem to get it to
Just a simple question that I can't seem to find the answer to. myarray.length()
Ok this is embarrassingly simple of a question, but I just can't get this
I have a feeling that this question is very simple, but I just can't
Just a quick simple question that I can not seem to find an answer
I've googled and just can't seem to find the answer to this simple question.
Apologies for the rather simple question, I just can't seem to find ANY good
Simple question here that I can't seem to find an answer for: Once a
This seems to me like a very simple question, but I can't seem to

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.