Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tooltip on custom button in Highcharts

Tags:

highcharts

Came a cross this fiddle in the Highcharts API doc: http://jsfiddle.net/gh/get/jquery/1.7.2/highslide-software/highcharts.com/tree/master/samples/highcharts/exporting/buttons-text/

printButton: {
                text: 'Print',
                onclick: function () {
                    this.print();
                }
            }

As you can see from hovering over "print" or "download", the tooltip is undefined.

So, my question, simply, where do I define it?

Best regards :)

like image 955
Christian Haaland Avatar asked May 31 '13 14:05

Christian Haaland


2 Answers

If you want to add custom tooltip text for a button, you must add a 'lang' object in the chart's options, and define a key with some text.

Then use that key in the custom button's definition.

var chart = new Highcharts.Chart({
    chart: {
        // your chart options
    },
    lang: {
       yourKey: "Custom button tooltip text"
    },
    exporting: {
        buttons: {
            yourCustomButton: {
                text: "Click me",
                _titleKey: "yourKey",
                onclick: function() {
                    // button functionality goes here
                }
            }
        }
    }
});

See http://jsfiddle.net/7wEEj/

like image 190
Ransauce Avatar answered Nov 08 '22 18:11

Ransauce


Add directly _titleKey, see: http://jsfiddle.net/x36qR/1/

like image 32
Paweł Fus Avatar answered Nov 08 '22 16:11

Paweł Fus