logo
down
shadow

topojson/d3.js: Uncaught (in promise) TypeError: Cannot read property 'type' of undefined


topojson/d3.js: Uncaught (in promise) TypeError: Cannot read property 'type' of undefined

Content Index :

topojson/d3.js: Uncaught (in promise) TypeError: Cannot read property 'type' of undefined
Tag : d3.js , By : T11M
Date : November 28 2020, 04:01 AM

this one helps. I am trying to develop freeCodeCamp's fourth project from the Data Visualization Certification, the choropleth map. This is what I have written: , topojson.feature takes two parameters, as seen in the topojson doc's:
topojson.feature(topology, object);
 let counties = topojson.feature(data[0].objects.counties);
let counties = topojson.feature(data[0], data[0].objects.counties);
const promisses = [d3.json('https://raw.githubusercontent.com/no-stack-dub-sack/testable-projects-fcc/master/src/data/choropleth_map/counties.json'), d3.json('https://raw.githubusercontent.com/no-stack-dub-sack/testable-projects-fcc/master/src/data/choropleth_map/for_user_education.json')];

Promise.all(promisses).then((d)=>{return processData(d)});

function processData(data) {
  for (let i = 0; i < data.length; i++) {
    //console.log(JSON.stringify(data[i]));
  }
  
  let w = 800;
  let h = 0.6 * w;
  let padding = 40;
  
  let svg = d3.select('#chart-bg').append('svg');
  
  svg.attr('width', w + 2 * padding)
    .attr('height', h + 2 * padding)
    .attr('id','map')
  
  
  //The next line is where I am having trouble
  let counties = topojson.feature(data[0], data[0].objects.counties);
  console.log(JSON.stringify(counties));
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/topojson/3.0.2/topojson.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/5.7.0/d3.min.js"></script>

Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

topojson Uncaught TypeError: Cannot read property 'feature' of undefined


Tag : javascript , By : bjorngylling
Date : March 29 2020, 07:55 AM
I hope this helps . Came across a GitHub issue where someone reported the same thing, which was fixed in a pull request with the answer, which is to import topojson as a namespace:
import * as topojson from 'topojson';

AOT: Error: Uncaught (in promise): TypeError: Cannot read property '$' of undefined


Tag : javascript , By : Jason Haar
Date : March 29 2020, 07:55 AM
help you fix your problem Create a new definition file (Ex: definitions.d.ts) and add the following code:
interface SignalrWindow extends Window {
    $: any;
}

declare var window: SignalrWindow ;

Uncaught (in promise) TypeError: Cannot read property 'forEach' of undefined


Tag : javascript , By : mitry
Date : March 29 2020, 07:55 AM
seems to work fine If you see the log screenshot you first get and undefined logged. That is most likely because your fetch happens for each key press, and if you search the API for a single character (which is what you sent with the first keyup) you get back no results and thus the forEach fails.
Either check if data has a value before doing the forEach or don't even send a fetch if the search string is a single character.
let data = res.moveData.Search
let output = ''
if (!data) return; //early break if not results where returned.
if (input.trim().length > 1) { // only do the fetch if more than one characters where entered

Rejection (TypeError): Cannot read property 'setState' of undefined, Uncaught (in promise) TypeError: Cannot read proper


Tag : node.js , By : August
Date : March 29 2020, 07:55 AM
Does that help To solve the setState issue, you need to be aware that the async.auto({}) is a promise.
The final error function need to be deleted this code:
function (err, results)
{
    this.setState({active:results.optionsFill})
    console.log('error: ', err)
}
.then((result)=>{
    this.setState({active: result.optionsFill})
})

topojson.js:187: Uncaught TypeError: Cannot read property 'type' of undefined


Tag : d3.js , By : Grik
Date : March 29 2020, 07:55 AM
Related Posts Related QUESTIONS :
shadow
Privacy Policy - Terms - Contact Us © scrbit.com