如何在 xaxis 上添加多个文本

How to add multiple text on xaxis

我正在努力在 x 轴上添加多个文本。大多数像在 x 轴上给出名称字段的东西都不适用于 Sankey 图。

问题:我需要在 Sankey 图上的 x 轴正下方添加 2 个文本。蓝色条正下方和中心的第一个文本。我需要的第二个文本就在灰色条下方,但它应该与第一个文本在同一行

这是我的代码

Highcharts.chart('container', {

    title: {
        text: ''
    },
        xAxis: {
        type: 'football league'
    },

    series: [{
        keys: ['from', 'to', 'weight'],
        data: [
            ['Football', 'Messi', 20 ],
            ['Football', 'ronaldo', 3 ],
            //['Challenged', 'Terminated', 0 ],
            ['Football', 'sachin', 1 ],
            ['Messi', 'sehqag', 12 ],
            //['Instituted', ' Terminated', 0 ],
            ['Messi', 'ashwin', 6 ],
            ['Messi', ' ramesg', 2 ],

        ],
        type: 'sankey',
        name: 'Sankey demo series'
    }]

});

JSFiddle:https://jsfiddle.net/anikettiwari/kLzv8sp0/26/

要向图表添加文本,您可以使用 annotations 模块或 Highcharts.SVGRenderer:

annotations: [{
    labels: [{
        text: 'annotations',
        point: {
            x: 100,
            y: 380
        }
    }, {
        text: 'annotations2',
        point: {
            x: 400,
            y: 380
        }
    }]
}]

现场演示:https://jsfiddle.net/BlackLabel/odc4jsku/

API: https://api.highcharts.com/class-reference/Highcharts.SVGRenderer#text

文档:https://www.highcharts.com/docs/advanced-chart-features/annotations-module

我通过下面的代码实现了这个

 chart: {
      showAxes: true
    },
     xAxis: {
          categories: ['ANIKET','SHivam'],
          labels: {
            style: {
              color: '#000000'
            }
          }
        },
        yAxis: {
          title: '',
          labels: {
            formatter: function() {
              return '';
            },
            style: {
              color: '#4572A7'
            }
          }
        },

对于 y 轴,它给了我默认标签,所以为了删除它,我写了上面的 yaxis 代码