Highcharts-显示noData覆盖和x轴标签

Highcharts - Display the noData overlay and the x-axis labels

本文关键字:标签 覆盖 显示 noData Highcharts-      更新时间:2023-09-26

当没有序列数据值时,我可以让noData覆盖层工作,并且我可以通过设置xAxis.max值来让x轴与noData标签一起显示,但我无法让x轴标签显示。

有什么想法吗?

理想情况下,我可以在没有任何虚假系列数据的情况下做到这一点(因为没有数据,我没有任何系列名称可以提供)。这用于定义良好的x值的柱状图(如下面的js fiddle中,使用已知的水果,其中只有每个系列计数是动态的)

我能得到的最接近的是这个jsfiddle:http://jsfiddle.net/eLdn6Lfc/

$(function () {
    var chart = new Highcharts.Chart({
        chart: {
            renderTo: 'container1',
            type: 'column'
        },
        xAxis: {
            categories: ['Mulligatawny', 'Crab bisque', 'Lima bean', 'Wild mushroom'],
            max:3
        },
        series: [{
            data: []
        }],
        lang: {
            noData: "No Soup For You!"
        },
    });
});

如果没有数据,还需要将最小限制设置为x轴。

此处的工作解决方案

var chart = new Highcharts.Chart({
  chart: {
    renderTo: 'container',
    type: 'column'
  },
  xAxis: {
    categories: ['Mulligatawny', 'Crab bisque', 'Lima bean', 'Wild mushroom'],
    min: 0,
    max: 3
  },
  series: [{
    showInLegend: false,
    data: []
  }],
  lang: {
    noData: "No Soup For You!"
  },
});