我正在尝试使用d3.js和cal-heatmap.js来创建可视化效果,但无论我使用什么数据和格式,颜色都不会显示出来。我甚至不能让最基本的默认可视化工作,也看不到任何明确的问题指示器。我看到了日历和单元格模板,只是它们都是空白的,即使有数据。
以下是代码的示例:
<!DOCTYPE html>
<head>
<link rel="stylesheet" type="text/css" href="cal-heatmap.css">
</head>
<body>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="cal-heatmap.min.js"></script>
<div id="cal-heatmap"></div>
<script type="text/javascript">
var cal = new CalHeatMap();
cal.init({
data : "aggregates.json",
id : "cal-heatmap",
domain : "month",
subDomain : "x_day",
cellsize: 15,
cellpadding: 3,
domainGutter: 15
});
</script>
</body>
</html>和一个数据样本。
{
"1258185600": 2.77,
"1258272000": 2.52,
"1258358400": 3.23,
"1258444800": 2.06,
"1258617600": 2.62,
"1258704000": 3.9,
"1258790400": 3.41,
"1258963200": 0,
"1259049600": 0,
"1259049600": 0,
"1259136000": 3.16,
"1259308800": 2.97,
"1259395200": 2.79,
"1259481600": 3.65,
"1259654400": 1.9,
"1259654400": 1.93,
"1259740800": 3.46,
"1259827200": 3.93,
"1260000000": 4.1
}发布于 2014-11-14 03:35:36
样本数据中的第一个时间戳是从2009年11月开始的。您必须为您的特定数据源自定义cal-heatmap,以便日历显示您的数据日期范围的日历,否则它将显示从今天开始的日历。
将start属性设置为new Date(2009, 10, 1)
https://stackoverflow.com/questions/26643077
复制相似问题