我在仪表板中使用了calheatmap小部件。
点击下一个(或上一个)按钮后,小部件中的新域包含无数据,直到下一个json数据接收为止。
如何将所有2天的数据导入小部件,不断......
@startDate = new Date(now.getFullYear(), now.getMonth(), now.getDate(), (now.getHours()-4)).getTime()
@firstDate = new Date(now.getFullYear(), now.getMonth(), (now.getDate()-1))
@lastDate = new Date(now.getFullYear(), now.getMonth(), (now.getDate()+1))
@calheatmap.init({
start: @startDate,
itemSelector: "#resque-scheduled-heatmap",
range: 5,
afterLoad: ->
@calheatmap.update(data.items)
afterLoadNextDomain: (date) ->
@calheatmap.update(data.items)
afterLoadPreviousDomain: (date) ->
@calheatmap.update(data.items)
previousSelector: "#previous",
nextSelector: "#next",
cellSize: 7,
minDate: @firstDate,
maxDate: @lastDate,
domainGutter: 5,
legend: d3.range(legendStep, @maxJobPerMinute + legendStep, legendStep),
legendCellSize: 7,
displayLegend: true,
itemName: "enerji uretim",
subDomainDateFormat: "%H:%M",
subDomainTitleFormat: {
empty: "{date} 0",
filled: "{date} {count}"
}
label: {
height: 50
}
})
谢谢
答案 0 :(得分:0)
问题解决了;
将afterLoad行更改为:
afterLoad: - >
$ .getJSON' http://10.10.114.11:3000/data/heatmap.json
按照你的说法删除afterLoadNextDomain和afterLoadPreviousDomain
onData :(数据) - > 如果@calheatmap @ calheatmap.options.data = data.items