Highcharts - 条形图数据限制?

时间:2018-03-09 21:00:49

标签: javascript highcharts highstock

我的一个Highcharts可视化引发了以下错误:

错误:属性x:预期长度," NaN"。 7096错误:属性宽度:预期长度," NaN"。

我已经验证我的所有类别都有不同的名称,数组已正确排序,所有值都是数字。还有其他人遇到过这个问题吗?我觉得它与我的系列中的数组数量有关,但我无法在Highcharts文档中找到任何提及任何内容的内容。

这是一个小提琴:

http://jsfiddle.net/meppielmr/3yywmgrf/8/



Highcharts.chart('container', {
  chart: {
    type: 'bar',
    marginLeft: 150
  },
  credits: {
    enabled: false
  },
  legend: {
    enabled: false,
  },
  labels: {
    enabled: false
  },
  title: {
    text: 'Test Fiddle',
    useHTML: true,
    style: {
      'color': '#363636',
      'font-weight': 'bold',
      'text-align': 'center',
      'font-size': '17px'
      //'background-color': '#efeff5'
    },
    x: -75
  },
  tooltip: {
    followPointer: true,
    shared: false,
    useHTML: true,
    formatter: function() {
      var temp = (1 - this.point.y).toFixed(4);
      if (temp >= 1) temp = 1;
      if (temp <= 0) temp = 0;
      return '<small>' + this.series.name + '</small><table>' +
        '<tr><td style="color: ' + this.color + '">' + this.key + ': </td>' +
        '<td style="text-align: right"><b>' + temp + '</b></td></tr>' +
        '</table>';
    },
  },
  xAxis: {
    type: 'category',
    useHTML: true,
    labels: {
      enabled: true,
      formatter: function() {
        return this.value;
      }
    },
    scrollbar: {
      enabled: true
    }
  },
  yAxis: {
    title: '',
    labels: false,
    gridLineColor: 'transparent',
    stackLabels: {
      enabled: false
    },
    min: 0,
    max: 1
  },
  plotOptions: {
    series: {
      cursor: 'pointer',
      stacking: 'normal',
      events: {
        legendItemClick: function() {
          return false;
        },
        click: function(e) {
          var clickedViz = this.name;
          clickedCategory = e.point.name;
          if (clickedCategory) {
            clickedCategory = clickedCategory.replace(/\ /g, '_');

            $('.modal').modal('hide');

            console.log('Visualization Clicked:  ' + clickedViz);
            console.log('Variable Clicked:  ' + clickedCategory);

            if (clickedViz.toLowerCase().indexOf('plink') > -1) {
              $('#gen-tab').trigger('click');
            } else {
              $('#cat-tab').trigger('click');
            }

            window.scrollTo(0, 0);
          }
        }
      },
      dataLabels: {
        enabled: true,
        formatter: function() {
          var temp = 1 - this.y;
          if (temp === 0 || temp === 1)
            return '';

          return temp.toFixed(4);
        }
      },
      cropThreshold: 10000,
      pointWidth: 25,
      zones: [{
        value: .9001,
        color: '#800000' // Red
      }, {
        value: .95001,
        color: '#e47b3f' // Orange
      }, {
        value: .99001,
        color: '#e4d657' // Yellow
      }, {
        color: '#79a038' // Green
      }],
    }
  },
  exporting: {
    enabled: true,
    buttons: {
      contextButton: {
        menuItems: [{
          textKey: 'printChart',
          onclick: function() {
            this.print();
          },
          separator: false
        }, {
          textKey: 'downloadPNG',
          onclick: function() {
            this.exportChart();
          },
          separator: false
        }]
      }
    }
  }
  // See the series in the fiddle      
});
&#13;
&#13;
&#13;

0 个答案:

没有答案