Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/477.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript D3.js表格查找在一个站点上不起作用。。。在本地主机站点上工作_Javascript_D3.js - Fatal编程技术网

Javascript D3.js表格查找在一个站点上不起作用。。。在本地主机站点上工作

Javascript D3.js表格查找在一个站点上不起作用。。。在本地主机站点上工作,javascript,d3.js,Javascript,D3.js,我正在本地主机上开发一个站点,现在正在共享主机上测试它。 该站点在localhost上正常工作,但a颜色查找功能无法正常工作。两个站点都是Drupal,但配置不同。但我不知道从哪里开始找。 在localhost版本中:console.log(“color”+categoryColour[bottom.field_category]);//显示“蓝色”,在web版本中未定义 var imageAttributes = {height:32, width:32, x:-16, y:-16}; con

我正在本地主机上开发一个站点,现在正在共享主机上测试它。 该站点在localhost上正常工作,但a颜色查找功能无法正常工作。两个站点都是Drupal,但配置不同。但我不知道从哪里开始找。 在localhost版本中:console.log(“color”+categoryColour[bottom.field_category]);//显示“蓝色”,在web版本中未定义

var imageAttributes = {height:32, width:32, x:-16, y:-16};
console.log(categoryColour ["volunteer"]); // displays "blue"
var imageAttributes = {height:32, width:32, x:-16, y:-16};
d3.json("../sites/default/d3_files/json/members.json?nocache=" + (new Date()).getTime(),function(error,data){
var bottom=data.organizations.map(function(data) {
  return data.member;
});
 circles.selectAll("circle")
 .data(bottom)
 .enter()
 .append("circle")
 .attr("cx", 0)
 .attr("cy", 0)
 .attr("r", 16)
 .style("fill", function(bottom) { 
      console.log("Category "+[bottom.field_category]); // displays "volunteer"
      console.log("Colour " + categoryColour [bottom.field_category]); // displays "undefined"
      return categoryColour [bottom.field_category]
      })
 .style("stroke", function(bottom) { 
      return categoryColour [bottom.field_category]
      })     
   .style("stroke-width", 0.25)
 .attr("transform",function(bottom){
    return"translate("+projection([bottom.field_lng,bottom.field_lat])+")"; // adjust location
}) // end transform attr

我的错误是,我使用了Drupal模块/视图来生成json字段,但没有注意到类别是大写的。当我把它们小写时,它起作用了。

什么是“类别颜色”。它似乎是一个js数组,但您的代码似乎没有定义它。我怀疑可能还有另一个js文件/脚本没有包含在这个帖子中,因为代码是相同的。。。显然我应该有:var categoryColour={“志愿者”:“蓝色”,“组织”:“绿色”,“空气”:“透明”};如果可能的话,我们非常建议使用JSFIDLE。怀疑“./站点….”返回的数据可能起作用。也许返回的值不能作为关联数组中的键使用。如果我知道如何正确使用JSFIDLE(而不是上传代码),我会的。但你是对的。我认为members.json文件是相同的,但我错了。我没有做任何我认为重要的改变,但显然我必须做。谢谢,这就是问题所在。我使用Drupal模块/视图生成json字段,但没有注意到类别是大写的。谢谢你帮我看这个。