javascript - Highchart tooltip & events from external function - Stack Overflow

I need to add external function for highchart tooltip formatter and events something like code given be

I need to add external function for highchart tooltip formatter and events something like code given below. How to add it externally.

 $(function(){
      var highchartObj = chart: {renderTo: 'rightBottomContainer'},xAxis: {categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']}, series: [{data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]}]} 
      rchart = new Highcharts.Chart(highchartObj);
        rchart.Point.prototype.tooltipFormatter = function (useHeader) {
        //var point = this, series = point.series;
        return "AAAAAA";
    };

});

I need to add external function for highchart tooltip formatter and events something like code given below. How to add it externally.

 $(function(){
      var highchartObj = chart: {renderTo: 'rightBottomContainer'},xAxis: {categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']}, series: [{data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]}]} 
      rchart = new Highcharts.Chart(highchartObj);
        rchart.Point.prototype.tooltipFormatter = function (useHeader) {
        //var point = this, series = point.series;
        return "AAAAAA";
    };

});
Share Improve this question asked May 28, 2012 at 7:49 Anup SinghAnup Singh 1,5733 gold badges16 silver badges32 bronze badges 4
  • How do you mean externally? Your code seems good enough to put in an external file if that's what you mean. – primavera133 Commented May 28, 2012 at 7:53
  • Externally means I don't want to put tooltip code inside the highchart object. Externally means after rendering the chart How can I assign tooltip function to the chart something like <pre><code> rchart.Point.prototype.tooltipFormatter = function (useHeader) { //var point = this, series = point.series; return "AAAAAA"; }; </code></pre> But that is not working. – Anup Singh Commented May 28, 2012 at 7:55
  • @primavera133 - any solutions for this ?? – Anup Singh Commented May 28, 2012 at 11:28
  • No sorry, but I'm not that familiar with highcharts. – primavera133 Commented May 28, 2012 at 13:44
Add a ment  | 

1 Answer 1

Reset to default 4

You can define your function somewhere like

function tooltipFormatter(){
    //your format here
}

Then pass this function to Highcharts configuration object inside tooltip object as formatter:

var chart = new Highcharts.Chart(..., tooltip: { formatter: tooltipFormatter }, ...);

As a result you can have your code in a separate function that will be passed inside Highcharts object.

Demo: http://jsfiddle/NCnS5/

Docs for formatter parameter: http://www.highcharts./ref/#tooltip--formatter

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745148007a4613735.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信