划线仪表板 - calheatmap小部件(resque_heatmap.coffee)在加载下一个/上一个域后删除单元格

时间:2016-05-04 13:16:07

标签: coffeescript heatmap dashboard dashing

我在仪表板中使用了calheatmap小部件。

点击下一个(或上一个)按钮后,小部件中的新域包含无数据,直到下一个json数据接收为止。

如何将所有2天的数据导入小部件,不断......

某些resque_heatmap.coffee行如下

    @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
      }
    })

谢谢

1 个答案:

答案 0 :(得分:0)

问题解决了;

  1. 将afterLoad行更改为: afterLoad: - >
    $ .getJSON' http://10.10.114.11:3000/data/heatmap.json

  2. 按照你的说法删除afterLoadNextDomain和afterLoadPreviousDomain

  3. 在onData:部分添加一个新行,如下所示:
  4. onData :(数据) - >     如果@calheatmap         @ calheatmap.options.data = data.items