【问题标题】:Highcharts heat map not displaying properlyHighcharts 热图未正确显示
【发布时间】:2016-05-09 13:54:33
【问题描述】:

我正在尝试使用 Highcharts 创建热图,但加载不正确(只是线条而不是热图本身)。

我正在从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;
};

数据已正确记录到控制台,但由于某种原因,热图未加载。

我还创建了一个Plunker,您可以在其中查看其行为。

有什么想法吗?

【问题讨论】:

    标签: javascript angularjs highcharts heatmap


    【解决方案1】:

    我在重新加载图表时犯了一个错误。我只需要将类型添加到事件中:

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

    Plunker

    【讨论】:

      猜你喜欢
      • 2017-02-09
      • 2022-10-14
      • 2013-10-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多