简体   繁体   English

Highcharts热图无法正确显示

[英]Highcharts heat map not displaying properly

I'm trying to create a heat map using Highcharts but it's not loading properly (just lines instead of the heat map itself). 我正在尝试使用Highcharts创建一个热图,但是加载不正确(只是线条而不是热图本身)。

I'm loading the data from a JSON file: 我正在从JSON文件加载数据:

chart: {
  type: 'heatmap',
  marginTop: 40,
  marginBottom: 80,
  plotBorderWidth: 1
},

xAxis: {
  categories: $scope.loadDays()
},

yAxis: {
 categories: $scope.loadHours(),
 title: null,
 reversed: true
},

series: [{
  name: null,
  borderWidth: 1,
  data: [],
  dataLabels: {
    enabled: true,
    color: '#000000'
  }
}]

$scope.getHeatMapData = function(data) {
  var response = [];
  $scope.data = data;

  if(data && $scope.data.timestamps && $scope.data.info) {
    $scope.data.timestamps.forEach(function(element, index) {
      if ($scope.data.info[index]) {
        response.push([
          moment(element).day(),
          moment(element).hour(),
          $scope.data.info[index]
       ]);
      }
    });
  }
  return response;
};

The data is being logged correctly to the console but, for some reason, the heat map isn't loading. 数据已正确记录到控制台,但是由于某些原因,热图未加载。

I've also created a Plunker where you can see its behavior. 我还创建了一个Plunker ,您可以在其中查看其行为。

Any ideas? 有任何想法吗?

I was making a mistake when reloading the chart. 重新加载图表时我犯了一个错误。 I just had to add the type to the event: 我只需要将类型添加到事件中:

chartConfig.chart = { type: 'heatmap', events: { load: callback } };

Plunker 柱塞

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM