Highcharts:自定义工具提示

时间:2017-07-17 21:23:02

标签: highcharts tooltip

还有一个问题:我有一个带有分类y轴的堆积条形图,我想在每个条上都有自定义工具提示。但到目前为止,我无法弄清楚如何正确处理个别类别。我使用的工具提示格式化程序代码有效,但我无法访问单个类别。有人可以帮忙吗?

这是代码:

Highcharts.chart('container', {
    chart: {
        type: 'bar'
    },
    title: {
        text: ''
    },
    colors: ['#c83f3f', '#66b257'],    
        xAxis: {
            labels: {
            style: {
            fontWeight: 'bold',
            fontSize: '12px',
            fontFamily: 'Merriweather Sans, sans-serif',
          }
        },
        categories: ['<a href="https://www.testlink.com">Testlink Nummer 1</a>', '<a href="https://www.testlink.com">Objektname 2</a>', '<a href="https://www.testlink.com">Die Nummer 3</a>', '<a href="https://www.testlink.com">Test 4</a>', '<a href="https://www.testlink.com">Test 5</a>', '<a href="https://www.testlink.com">Test 6</a>', '<a href="https://www.testlink.com">Test 7</a>', '<a href="https://www.testlink.com">Test</a>']
    },
    tooltip : {
        formatter: function() {
            var tooltip;
            if (this.series == '1') {
                tooltip = '<b>Final result is </b> ' + this.y;
            }
            else {
                tooltip =  '<span style="color:' + this.series.color + '">' + this.series.name + '</span>: <b>' + this.y + '</b><br/>';
            }
            return tooltip;
        }
    },   
    yAxis: {
        min: 0,
        max: 10,
        title: {
            text: ''
        },
        labels: {
            style: {
            fontWeight: 'normal',
            fontFamily: 'Merriweather Sans, sans-serif',
          }
        },
    },
    legend: {
        reversed: true
    },
    plotOptions: {
        series: {
            stacking: 'normal',
            groupPadding: 1,
            pointWidth: 35,
        }
    },
    credits: {
            enabled: false
        },
    series: [{
        name: 'Nicht erfüllte Kriterien',
        data: [5, 3, 4, 7, 2, 6, 4, 5]
    }, {
        name: 'Erfüllte Kriterien',
        data: [5, 7, 6, 3, 8, 4, 6, 5]
    }]
});

非常感谢! - 奥利弗

0 个答案:

没有答案