为Highchart的柱形图添加标签

Add label to column chart of Highchart

我正在尝试使用 Highchart.js 制作此图表。 现在我必须按照下图所示的格式添加标签。 谁能帮帮我。为此,我正在使用 ASP.net MVC 和 jquery。

观点是

  <div id="hourlyChart"></div>

而JS文件是

Highcharts.chart('hourlyChart', {
    chart: {
        type: 'column'
    },
    credits: false,
    title: {
        text: ''
    },
    legend: { enabled: false },
    xAxis: {
        categories: label
    },
    yAxis: [{
        min: 0,
        title: {
            text: ''
        }
    }],
    legend: {
        shadow: false
    },
    tooltip: {
        shared: true
    },
    plotOptions: {
        column: {
            grouping: false,
            shadow: false,
            borderWidth: 0
        }
    },
    series: [{
        name: 'Target',
        color: 'rgba(189, 195, 199, 1)',
        data: target,
        showInLegend: false,
    }, {
        name: 'Achieved',
        color: 'rgb(242, 38, 19)',
        data: achieved,
        pointPadding: 0.2,
        showInLegend: false          
    }
    ]
});

由此我得到了这么多结果

提前致谢。

使用数据标签并按 y 属性 定位它们。示例:

    plotOptions: {
        column: {
            ...,
            dataLabels: {
                verticalAlign: 'bottom',
                allowOverlap: true,
                enabled: true,
                inside: true
            },
        }
    },
    series: [{
        dataLabels: {
            color: 'rgba(189, 195, 199, 1)',
            y: -310
        },
        ...
    }, {
        dataLabels: {
            color: 'rgb(242, 38, 19)',
            y: -330
        },
        ...
    }]

现场演示: http://jsfiddle.net/BlackLabel/hvxbpqj5/

API参考:https://api.highcharts.com/highcharts/series.column.dataLabels