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

  • Home
  • SEARCH
  • 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 8878065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:37:22+00:00 2026-06-14T19:37:22+00:00

I am experimenting with this d3 demo and I am having trouble debugging why

  • 0

I am experimenting with this d3 demo and I am having trouble debugging why I am experiencing different behavior in Chrome vs. Safari/FireFox. If I run the full code below, it works in Chrome but not in Safari/Firefox. I seem to have isolated the problem to the following:

If I change this line:

var circles = chart.select("#points").selectAll("circle")

to this:

var circles = chart.selectAll("circle")

it works in Safari/Firefox/Chrome, but I want to understand what is happening and why the code below doesn’t work. Any insight would be greatly appreciated.

Full Code

 <svg>
  <g id="chart">
   <g id="bg">
   </g>
   <g id="countries">
   </g>
   <g id="points">
   </g>
  </g>
 </svg>


  <script type="text/javascript">

  d3.json("costofliving.json", function(col) {

    var cx = 200;
    var cy = 132;

    var cw = 400;
    var ch = 400;

    var svg = d3.select("svg");
    var nticks = 14;

    var price_min = 0;
    var price_max = d3.max(col, function(d) {return d.price});

    var rent_min = 0;
    var rent_max = d3.max(col, function(d) {return d.rent});

    var price_scale = d3.scale.linear()
      .domain([price_min, price_max])
      .range([ch, 0]);
    var rent_scale = d3.scale.linear()
      .domain([rent_min, rent_max])
      .range([0, cw]);

    var price_layout = d3.layout.histogram()
      .value(function(d) { return d.price })
      .range([0, price_max])
      .bins(nticks);

    var rent_layout = d3.layout.histogram()
     .value(function(d) { return d.rent })
     .range([0, rent_max])
     .bins(nticks);

   var chart = svg.append("g")
    .attr("transform", "translate(" + [cx, cy] + ")");

  chart.append("g")
   .attr("id", "countries")
   .style("opacity", 0);

  chart.append("g")
   .attr("id", "points")

  var circles = chart.select("#points").selectAll("circle")
   .data(col);

  circles.enter()
   .append("circle")

  circles.attr({
    r: 6,
    cx: function(d,i) {
    return rent_scale(d.rent);
   },
    cy: function(d,i) {
    return price_scale(d.price);
   }
  })  
 });
 </script>
  • 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-14T19:37:24+00:00Added an answer on June 14, 2026 at 7:37 pm

    You need to set a width and height for any svg element in Firefox. According to the W3C Spec, the svg element will use “100%” as default, but my Firefox 17 (and probably other browsers) may not yet implement it like that.

    When setting some absolute values in your code it works as expected.

    <svg width="600" height="600">
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I run this code for experimenting copy constructor and assignment operator class AClass {
I am experimenting with this code: foreach (var r in _vm.Rules.Take(20)) { Task.Factory.StartNew(() =>
I've been experimenting with tracking area, and having some problems, so I created this
This is a complicated one! Im working with contentEditable in Chrome and I'm experiencing
Currently I'm experimenting with this code (I know it doesn't fit the purpose). I
I'm experimenting with this code: interface Callee { public void foo(Object o); public void
today i was thinking about tell! don't ask! and experimenting with this code. interfaces:
I'm experimenting on this code that I got from the net (I'm trying to
I'm doing some experimenting with this malicious JavaScript line: var undefined = true; Every
I'm experimenting with knockout and the mapping plugin and wondering why this doesn't work.

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.