用Highcharts添加特定的Y轴标签

用Highcharts添加特定的Y轴标签

本文介绍了用Highcharts添加特定的Y轴标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个标记为Y轴的图,点为1到100.除了规则间隔的标签(0,10,20等)外,我想为任意点添加一个标签,例如47。这可能与highcharts?

I have a graph with a labelled Y-Axis with points 1 through 100. In addition to the regularly spaced labels (0, 10, 20, etc), I want to add a label for an arbitrary point, say 47. Is this possible with highcharts?

推荐答案

根据您的评论,您可以添加一个自定义的勾号与函数,用这样的代码

Based on your comment, you can add a custom tick with tickPositioner function, with a code like this

$(function () {
    $('#container').highcharts({
        xAxis: {
            categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
        },
        yAxis: {
            tickInterval: 20, //sets the interval ticks
            tickPositioner: function(){
                var ticks = this.tickPositions; // gets the tick positions
                ticks.push(47); // adds the custom tick
                ticks.sort(function(a, b) {
                    return a - b; // sorts numerically the ticks
                });
                return ticks; // returns the new ticks
            }
        },
        series: [{
            data: [29.9, 71.5, 86.4, 29.2, 44.0, 76.0, 93.5, 98.5, 16.4, 94.1, 95.6, 54.4]
        }]
    });
});

这篇关于用Highcharts添加特定的Y轴标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 05:34