【发布时间】:2014-06-25 03:10:14
【问题描述】:
我似乎无法让我的变量引用本地 json 文件而不是当前的远程 json 文件。我希望能够将 Javascript 设置为读取本地 test.json 文件而不是远程 resturl url。我想将当前的resturl 变量更改为它下面的注释resturl。如果您需要更多信息,请告诉我。脚本基于:https://github.com/kenklin/aws-price-comparison-chart
function update() {
// Construct REST URL
var resturl = "http://p1software-eb1.elasticbeanstalk.com/awsec2offering/api"
+ "/" + d3.select("#availabilityZone").node().value // us-east-1a
+ "/" + d3.select("#productDescription").node().value // linux
+ "/" + d3.select("#offeringType").node().value // heavy
+ "/" + d3.select("#instanceType1").node().value // t1.micro
+ "," + d3.select("#instanceType2").node().value; // m1.small
// resturl = "test.json"
// resturl = "http://localhost:8080/awsec2offering/awsec2offering/api/us-east-1a/linux/heavy/t1.micro,m1.small."
d3.json(resturl, function(error, json) {
data = json.ec2offerings;
// Assign colors to each unique name.
var color = d3.scale.category10();
color.domain(data.map(function(p) { return createUniqueName(p); }));
// Coerce the data to numbers.
data.forEach(function(d) {
d.month = +d.month;
});
【问题讨论】:
-
您是否收到任何错误消息?
-
没有。但是,当我更改变量时,我确实得到:中断异常:TypeError:无法读取未定义的属性“ec2offerings”
-
error是否包含任何内容?
标签: javascript jquery json d3.js dart