Highcharts exports.js更改菜单悬停标题文本

时间:2016-11-14 16:57:24

标签: javascript highcharts

我正在使用highcharts,我已经添加了exports.js,因此我可以导出数据。

这会显示一个菜单,其标题为"图表上下文菜单"。

见附图:

enter image description here

您还可以看到它here

$(function () {
    Highcharts.chart('container', {

        chart: {
            type: 'column'
        },

        title: {
            text: 'Total fruit consumtion, grouped by gender'
        },

        xAxis: {
            categories: ['Apples', 'Oranges', 'Pears', 'Grapes', 'Bananas']
        },

        yAxis: {
            allowDecimals: false,
            min: 0,
            title: {
                text: 'Number of fruits'
            }
        },

        tooltip: {
            formatter: function () {
                return '<b>' + this.x + '</b><br/>' +
                    this.series.name + ': ' + this.y + '<br/>' +
                    'Total: ' + this.point.stackTotal;
            }
        },

        plotOptions: {
            column: {
                stacking: 'normal'
            }
        },

        series: [{
            name: 'John',
            data: [5, 3, 4, 7, 2],
            stack: 'male'
        }, {
            name: 'Joe',
            data: [3, 4, 4, 2, 5],
            stack: 'male'
        }, {
            name: 'Jane',
            data: [2, 5, 6, 2, 1],
            stack: 'female'
        }, {
            name: 'Janet',
            data: [3, 0, 4, 4, 3],
            stack: 'female'
        }]
    });
});

我的问题是..如何更改标题文字,以便说出其他内容?

2 个答案:

答案 0 :(得分:1)

实际上,有一个选项可以通过API更改标题,但您需要在全局选项中设置它 - lang.contextMenuTitle

var shifts = dbContext.PublishedRosterShifts
                .Where(h => h.EmployeeId == EmployeeId);
var inner = shifts
    .Select(x => new
        {
            LatestShiftId = shifts.Max(p => p.PublishedRosterShiftId),
            DayNumber = x.DayNumber
         })
     .GroupBy(s => s.DayNumber)
     .Select(g => g.FirstOrDefault());
 var q = from f in shifts
     select new
     {
         LatestShiftId = shifts.Max(p => p.PublishedRosterShiftId),
         DayNumber = f.DayNumber
     };
 var query = from l in dbContext.PublishedLineBars
     where inner.Select(s => s.LatestShiftId).Contains(l.PublishedRosterShiftId)
     select l;

示例:http://jsfiddle.net/1zmwjskz/

答案 1 :(得分:0)

根据文档,目前没有选项- details of the available options are listed here。但是你总是可以使用jQuery:

$(document).ready(function(){
    $("g.highcharts-contextbutton > title").text("Something else");
});

工作fiddle