HighCharts Bullet Chart标签显示在最顶层可能吗?

问题描述 投票:0回答:1

我想在图表的顶部显示此子弹图的标签而不是左侧。这可能吗?这是代码,

Highcharts.chart('container2', {
    xAxis: {
        categories: ['<span class="hc-cat-title">Profit</span><br/>%']
    },
    yAxis: {
        plotBands: [{
            from: 0,
            to: 20,
            color: '#666'
        }, {
            from: 20,
            to: 25,
            color: '#999'
        }, {
            from: 25,
            to: 100,
            color: '#bbb'
        }],
        labels: {
            format: '{value}%'
        },
        title: null
    },
    series: [{
        data: [{
            y: 22,
            target: 27
        }]
    }],
    tooltip: {
        pointFormat: '<b>{point.y}</b> (with target at {point.target})'
    }
});

这是子弹图。我想将我的Label Profit显示在图表的顶部。

enter image description here你也可以看到jsfiddle:Bullet chart

javascript highcharts bullet-chart
1个回答
1
投票

您可以使用dataLabels属性以及正确的选项:

series: [{
    data: [{
        dataLabels: {
            enabled: true,
            format: '<span class="hc-cat-title">Profit</span>',
            align: 'left',
            y: 40,
            inside: true
        },
        y: 275,
        target: 250
    }]
}]

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

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

© www.soinside.com 2019 - 2024. All rights reserved.