鼠标悬停在直方图高图上的值的舍入

时间:2018-03-20 20:50:15

标签: angular highcharts histogram

我正在尝试使用角度绘制直方图。以下jsfiddle链接仅供参考。请注意,我无法对实际数据进行舍入,因为这不会显示正确的数据表示。

http://jsfiddle.net/x51b6pvs/52/

我需要在鼠标悬停在垃圾箱上时对数据进行舍入。范围应显示十进制值的整数。我如何实现

角度代码

window

新的jsfiddle代码

var Sam = function () {
  var today = new Date();
  var year = today.getFullYear();

  this.age = 27;
  this.birthMonth = "March";
  this.currentYear = year;
  this.birthYear = this.currentYear - this.age;
  
  // Method to say birth year
  this.sayBirthYear = function() {
    console.log("I was born in the year " + this.birthYear );     
  }
}

new Sam().sayBirthYear();

1 个答案:

答案 0 :(得分:0)

尝试使用工具提示格式化程序功能:

var chart = Highcharts.chart('container', {
    tooltip: {
        formatter: function () {
             return `Rounded value is ${Math.round(this.y)}`;
        }
    },
    title : ...,
    xAxis : ...,
}

https://api.highcharts.com/highcharts/tooltip

上的文档