简体   繁体   English

highcharts:获得yaxis头衔?

[英]highcharts: get yaxis title?

I have a graph with 2 yaxis and i am tying to get the yaxis title for each series in the tooltip formatter. 我有一个2 yaxis的图表,我想在工具提示格式化程序中获得每个系列的yaxis标题。

This is my formatter function: 这是我的格式化函数:

formatter: function() {
    var s = '<b>'+  Highcharts.dateFormat('$hc_date_long', this.x) +'</b><table>';
    sum = 0;
    var abweichung = 0;
    var stellen = 0;
    $.each(this.points, function(i, point) {
        var prev = jQuery.inArray(point.x, point.series.processedXData)-1;
        var percent = 0;
        if(prev>=0){
            prev = point.series.points[prev];
            percent = (point.y - prev.y) * 100 / point.y;
        }
        s += '<tr><td style=\"color: '+point.series.color+';padding:2px;\">'+ point.series.name +':</td><td style=\"text-align:right;padding:2px;\"> '+ extround(point.y,100) +' !!GETYAXISTITLE!!</td><td style=\"text-align:right;padding:2px;\">'+percent+'</td></tr>';
        sum += point.y;
    });
    s += '</table>';
     return s;
},

The api only contains the function "setTitle()" there is no getTitle() function? api只包含函数“setTitle()”没有getTitle()函数?

在工具提示格式化程序中获取Y轴标题的正确方法是:

this.point.series.yAxis.axisTitle.textStr

To get title in function 获得职能

chart.options.yAxis[0].title.text

Or set title like this: 或者像这样设置标题:

 yAxis: {
        title: {
            enabled: true,
            text: 'Custom with <b>simple</b> <i>markup</i>',
            style: {
                fontWeight: 'normal'
            }
        }
    },

DEMO DEMO

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM