为y轴高亮显示文字标签 [英] Highcharts text labels for y-axis

查看:124
本文介绍了为y轴高亮显示文字标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Highcharts,想要显示一个简单的柱状图,但不想使用数值作为y轴,我想使用文本值。

例如, [0,5,10,15,20] 我想用 [Very Low,Low,Medium,High,Very High] code>。

I'm using Highcharts and would like to display a simple column graph, but instead of using numeric values for the y-axis, I would like to use text values.
For example, instead of [0,5,10,15,20] I would like to use [Very Low,Low,Medium,High,Very High].

我注意到有些情况下可以通过绘图带来做到这一点,但仍然显示数字y轴标签,并将文本放在它们旁边。我只想显示文本标签。

I noticed it's somewhat possible to do this with plot bands, but that still shows the numeric y-axis labels and just puts the text beside them. I want to only show the text labels.

推荐答案

您可以通过使用标签格式化程序。假设您的数据形成得当,您可以执行以下操作:

You can change the labels by using a label formatter. Assuming your data is formed appropriately, you can do something like the following:

var yourLabels = ["Very Low", "Low", "Medium", "High", "Very High"];
var yourChart = new Highcharts.Chart({
    //...
    yAxis: {        
        labels: {
            formatter: function() {
                return yourLabels[this.value];
            }
        }
    }
    //...
});

这篇关于为y轴高亮显示文字标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆