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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:16:26+00:00 2026-06-06T19:16:26+00:00

I also posted this question on the Google Group https://groups.google.com/forum/?fromgroups#!topic/d3-js/DYiVeC544ws , but saw that

  • 0

I also posted this question on the Google Group https://groups.google.com/forum/?fromgroups#!topic/d3-js/DYiVeC544ws, but saw that it prefers that help questions are asked here. I’m just having trouble shifting the y-axis to the left of my graph to so that it does not get in the way of the first column. I provided an image on the google group so you can see what I’m talking about.

The code to create the axis is as follows:

   var MARGINS = {top: 20, right: 20, bottom: 20, left: 60}; // margins around the graph
var xRange = d3.scale.linear().range([MARGINS.left, width - MARGINS.right]), // x range function
    yRange = d3.scale.linear().range([height - MARGINS.top, MARGINS.bottom]), // y range function

    xAxis = d3.svg.axis().scale(xRange).tickSize(16).tickSubdivide(true), // x axis function
    yAxis = d3.svg.axis().scale(yRange).tickSize(10).orient("right").tickSubdivide(true); // y axis function


// create the visualization chart
var vis = d3.select("#chart")
   .append("svg")
    .attr("width", width)
    .attr("height", height + margin);


    // add in the x axis
  vis.append("svg:g") // container element
    .attr("class", "x axis") // so we can style it with CSS
    .attr("transform", "translate(0," + height + ")") // move into position
   // .call(xAxis); // add to the visualisation

  // add in the y axis
  vis.append("svg:g") // container element
    .attr("class", "y axis") // so we can style it with CSS
    .call(yAxis); // add to the visualisation
  • 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-06T19:16:28+00:00Added an answer on June 6, 2026 at 7:16 pm

    Use the transform attribute to shift the y-axis, just as you did for the x-axis. For example:

    svg.append("g")
        .attr("class", "y axis")
        .attr("transform", "translate(" + width + ",0)")
        .call(yAxis);
    

    This is only necessary when using right orientation. When the axis is oriented to the left, the default positioning is typically fine.

    Also, I recommend using the following convention for margins:

    • Set the origin of the SVG element to the top-left corner of the inner chart area.
    • Define width and height as the inner width and height.

    For example:

    var margin = {top: 20, right: 10, bottom: 20, left: 10},
        width = 960 - margin.left - margin.right,
        height = 500 - margin.top - margin.bottom;
    
    var x = d3.scale.linear()
        .range([0, width]);
    
    var y = d3.scale.linear()
        .range([height, 0]);
    
    var svg = d3.select("body").append("svg")
        .attr("width", width + margin.left + margin.right)
        .attr("height", height + margin.top + margin.bottom)
      .append("g")
        .attr("transform", "translate(" + margin.left + "," + margin.top + ")");
    

    If you prefer, you could also store the inner and outer dimensions, e.g.,

    var outerWidth = 960,
        outerHeight = 500,
        innerWidth = outerWidth - margin.left - margin.right,
        innerHeight = outerHeight - margin.top - margin.bottom;
    

    Here’s a visual explanation of the convention:

    • http://bl.ocks.org/3019563
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

(Question also posted here: http://www.google.com/support/forum/p/Android+Market/thread?tid=68dc1f694537c7dc&hl=en ) http://developer.android.com/guide/publishing/publishing.html recommends searching for apps by Developer Name
[I have posted this at the Django users | Google Groups also.] Using the
I posted this question: https://stackoverflow.com/questions/418597/java-and-net-for-php-programmer and the answers I was given didn't really help
I posted this question on webmasters.stackexchange.com but no reply, so I thought I'd try
I posted this question on the Qt forum, but got no answers. That's why
I have also posted this question on the netbeans forums - hoping for maximum
I posted this question on the django-users list, but haven't had a reply there
Before I posted this question, I already looked this , but I couldn't get
Note: This question is also posted on the WiX Users mailing list . I
I originally posted this question over at the Zend Forums but figured it would

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.