【发布时间】:2016-06-27 00:38:42
【问题描述】:
我是 D3 和 NVD3 的新手。我正在 ASP.NET 中构建 Web 服务,并且我还尝试使用 NVD3.js 重现以下stackedArea 示例: http://nvd3.org/examples/stackedArea.html
我的目标是在示例运行后使用存储过程发出 ajax 请求。
我已将示例代码复制并粘贴到我的代码中:
<!DOCTYPE html>
<html>
<head>
<link href="css/nv.d3.css" rel="stylesheet" type="text/css">
<script src="scripts/d3.min.js" charset="utf-8"></script>
<script src="scripts/nv.d3.js"></script>
<style>
text {
font: 12px sans-serif;
}
svg {
display: block;
}
html, body, #chart, svg {
margin: 0px;
padding: 0px;
height: 100%;
width: 100%;
}
</style>
</head>
<body>
<div id="chart">
<svg></svg>
</div>
<script>
d3.json('scripts/stackedAreaData.json', function(data) {
nv.addGraph(function () {
var chart = nv.models.stackedAreaChart()
.x(function (d) { return d[0] })
.y(function (d) { return d[1] })
.clipEdge(true)
.useInteractiveGuideline(true)
;
chart.xAxis
.showMaxMin(false)
.tickFormat(function (d) { return d3.time.format('%x')(new Date(d)) });
chart.yAxis
.tickFormat(d3.format(',.2f'));
d3.select('#chart')
.datum(d3.read)
.transition().duration(500).call(chart);
nv.utils.windowResize(chart.update);
return chart;
});
})
</script>
</body>
</html>
我还保存了示例 json 文件:http://nvd3.org/examples/stackedAreaData.json(在示例中给出)。但是,我已经卡了很长时间,它不起作用。如果我犯了明显的错误,我将非常感谢社区的反馈。非常感谢!
【问题讨论】:
-
控制台中是否有任何错误或任何失败的请求?我的意思是在浏览器的开发工具中。
标签: javascript json d3.js nvd3.js