我们可以在图表中将图表的Y轴值显示为字符串值吗?

时间:2019-06-18 09:21:37

标签: highcharts

在我的方案中,对于Y轴值,显示为字符串值,例如“ NA”。但是我的数据返回正确的数据。但是图表不可见。仍在加载。

http://jsfiddle.net/3ajw61ze/2/

$(function(){

// Create the chart
$('#container').highcharts({
    chart: {
        type: 'column'
    },
    title: {
        text: 'Basic drilldown'
    },
    xAxis: {
        type: 'category'
    },
    plotOptions: {
        series: {
            borderWidth: 1,
            dataLabels: {
                enabled: true,
            }
        }
    },
    series: [{
        id: 'toplevel',
        name: 'Ratio',
        data: [
            {name: 'Income', y: 'NA',color:'Green', drilldown: null},
            {name: 'Expenses',  y: 'NA',color:'Red', drilldown: null},
            {name: 'NetProfit', y: 'NA',color:'Orange', drilldown: null}
        ]
    }],
    drilldown: {
        series: null
    }
})

});

1 个答案:

答案 0 :(得分:0)

高级图表要求xy的值为数字。要解决您的问题,您可以使用category轴类型:

yAxis: {
    categories: ['NA']
},
series: [{
    ...,
    data: [{
            y: 0,
            ...
        },
        ...
    ]
}]

实时演示: http://jsfiddle.net/BlackLabel/spu2gfwn/

API参考: https://api.highcharts.com/highcharts/yAxis.type

相关问题