Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

717
Views
Uncaught TypeError: Cannot read properties of undefined (reading '#<Object>') with D3.js and Laravel

I'm using D3.js (v. 7) with Laravel (v. 8) and I was able to plot a kind of scatter chart on the page. Everything went well, but when I tried to insert some transitions with the following code:

    .on('mouseover', function (d, i, n) {
        d3.select(n[i])
            .transition()
            .duration(128)
            .style('opacity', 0.75)
    })

I began to receive the following error on the console:

Uncaught TypeError: Cannot read properties of undefined (reading '#<Object>')

I'm not sure if this function (d, i, n) is correct or if anything else should be different as I'm following a tutorial that is using version 5 of D3.

Here the whole js file:

import * as d3 from 'd3';

// SVG common attributes
const width = '100%';
const height = '100%';

// set html element id where chart will be plotted
const earthquake = d3.select('#earthquake');

// create svg background
const svg = earthquake
    .append('svg')
    .attr('width', width)
    .attr('height', height);

// create circles
const circle = svg.selectAll('circle');

// populate circles
// api dataset source
const url = 'https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/significant_month.geojson';
d3.json(url)  // parse json
    .then(data => {circle
        .data(data.features) // data to use
        .enter().append('circle') // automatically create new circle
        .attr('cx', (d, i) => ((i + 1) * 100)) // x axis circle center coordenate
        .attr('cy', (d, i) => d.properties.mag * 10) // y axis circle center coordenate
        .attr('r', (d, i) => d.properties.mag * 10) // circle radius lenght
        .attr('fill', (d, i) => d.properties.alert) // circle fill color
        .on('mouseover', function (d, i, n) {
            d3.select(n[i])
                .transition()
                .duration(128)
                .style('opacity', 0.75)
        })
    })
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!