/ 设置 10 秒超时 // 每日统计清 0 runtime_set('todaycomments', 0); runtime_set('todayarticles', 0); runtime_set('todayusers', 0); if ($forumlist) { $fidarr = array(); foreach ($forumlist as $fid => $forum) { $fidarr[] = $forum['fid']; } forum_update($fidarr, array('todayposts' => 0, 'todaythreads' => 0)); } // 清理临时附件 attach_gc(); // 当天24点 $today = strtotime(date('Ymd')) + 86400; runtime_set('cron_2_last_date', $today, TRUE); // 往前推8个小时,尽量保证在前一天 升级过来和采集的数据会很卡 // table_day_cron($time - 8 * 3600); cache_delete('cron_lock_2'); } } } ?>javascript - Uncaught TypeError: Cannot read property 'type' of undefined with d3.js - Stack Overflow|Concepts Of Algorithm

javascript - Uncaught TypeError: Cannot read property 'type' of undefined with d3.js - Stack Overflow

admin2025-04-19  3

I've been stuck on this problem for hours at this point and I can't figure out the problem.

I've been following / with my own data set.

The error: Uncaught TypeError: Cannot read property 'type' of undefined - topojson.v0.min.js:1

<!DOCTYPE html>
<head>
<meta charset="utf-8">
<style>

path {
  fill: #ccc;
  stroke: #fff;
  stroke-width: .5px;
}

path:hover {
  fill: red;
}

</style>
</head>
<body>
<script src="../static/js/d3.min.js"></script>
<script src="../static/js/topojson.v0.min.js"></script>
<script>


var width = 900,
    height = 900;

var path = d3.geo.path();

var svg = d3.select("body").append("svg")
    .attr("width", width)
    .attr("height", height);


d3.json("../static/json/newjerseymun.json", function(nj) {
  svg.append("path")
      .datum(topojson.object(nj, nj.objects.subunits))
      .attr("d", d3.geo.path().projection(d3.geo.mercator()));
});

</script>

</body>

Here is a sample of the beginning of my json file:

I've been stuck on this problem for hours at this point and I can't figure out the problem.

I've been following http://bost.ocks/mike/map/ with my own data set.

The error: Uncaught TypeError: Cannot read property 'type' of undefined - topojson.v0.min.js:1

<!DOCTYPE html>
<head>
<meta charset="utf-8">
<style>

path {
  fill: #ccc;
  stroke: #fff;
  stroke-width: .5px;
}

path:hover {
  fill: red;
}

</style>
</head>
<body>
<script src="../static/js/d3.min.js"></script>
<script src="../static/js/topojson.v0.min.js"></script>
<script>


var width = 900,
    height = 900;

var path = d3.geo.path();

var svg = d3.select("body").append("svg")
    .attr("width", width)
    .attr("height", height);


d3.json("../static/json/newjerseymun.json", function(nj) {
  svg.append("path")
      .datum(topojson.object(nj, nj.objects.subunits))
      .attr("d", d3.geo.path().projection(d3.geo.mercator()));
});

</script>

</body>

Here is a sample of the beginning of my json file: http://pastebin./g0Lut36V

Share asked Jan 27, 2013 at 7:03 PFlansPFlans 4202 gold badges6 silver badges17 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 3

The problem seems to be in the file ../static/json/newjerseymun.json.

The segment of the newjerseymin.json you have posted does have the field objects which contains a JSON object but there does not seem to be a subunits field in that object, not at least in the segment you have posted. Hence, ns.objects.subunits would be undefined which causes the error.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1745014069a279982.html

最新回复(0)