Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

107
Vistas
Converting Rebinding Exports d3.js v3 to v5 VarName.on not a function

I am trying to convert a data manager API from "Develop a D3.js Edge" - original code https://github.com/backstopmedia/D3Edge/blob/master/code/Chapter07/script.js - from in d3v3 to d3v5.

I have addressed the d3.rebind (I think, I used the advice from d3.rebind in D3 v4).

My issue and question is that I am having issues with other areas of the code - namely how to use Promises (or asyn/await) here. I think this is the source of my error:

Uncaught (in promise) TypeError: loadCsv.on is not a function at Object.exports.loadCsvData (d3Edge_RUPro_Chapter7_v5.3.html:73:21) at d3Edge_RUPro_Chapter7_v5.3.html:136:27

but I am uncertain, any advice would be great.

This js.fiddle is how far I have got: https://jsfiddle.net/Maltbyjim/xqmau08d/4/

I tried this attempt to use promises:

   //Create a method to load the csv file, and apply cleaning function asynchronously.
        exports.loadCsvData = function(_file, _cleaningFunc) {

            //Create the csv request using d3.csv.
            //**how you load csv cahnges in d3v5
            // https://stackoverflow.com/questions/49599691/how-to-load-data-from-a-csv-file-in-d3-v5

            // **previous...
            //const loadCsv = d3.csv(_file);
            loadCsv = d3.csv(_file).then(function(_data){
                return _data
            }); //<---SOURCE OF THE ERROR
            
            
            //On the progress event, dispatch the custom dataLoading event.
            //**previous...
            //loadCsv.on('progress', function() { dispatch.dataLoading(d3.event.loaded);});
            processCsv = loadCsv.then( function (value){
                return Promise.all(
                    value().on('progress', function() { dispatch.dataLoading(d3.event.loaded);}),
                    value.get(function (_err, _response) {
                        //Apply the cleaning function supplied in the _cleaningFunc parameter.
                        _response.forEach(function (d) {
                            _cleaningFunc(d);
                    });
                })
            );
            //Assign the cleaned response to our data variable.
            data = _response;

            //Dispatch our custom dataReady event passing in the cleaned data.
            dispatch.dataReady(_response);
            });
        };
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda