zoukankan      html  css  js  c++  java
  • HighCharts中几种tooltip的显示格式

    推荐学习地址 => https://www.hcharts.cn/docs/basic-tooltip

              https://api.hcharts.cn/#Highcharts.numberFormat

    这里给出两个常用的例子

    1.折线图横坐标为时间轴时,想显示成

        

    .ts中相关highcharts配置:

     1             $scope.overviewChart = <HighChartsNGConfig>{
     2                 options: {
     3                     title: {
     4                         text: ``
     5                     },
     6                     chart: {
     7                         type: 'line'
     8                     },
     9                     yAxis: {
    10                         min: 0,
    11                         title: { text: null },
    12                         labels: {
    13                             formatter: function () {
    14                                 return this.value + "%";
    15                             }
    16                         }
    17                     },
    18                     xAxis: {
    19                         type: "datetime",
    20                         dateTimeLabelFormats: {
    21                             day: '%b/%e',
    22                             month: '%y年%b月',
    23                             week: '%b/%e',
    24                             year: '%Y年',
    25                             millisecond: '%b/%e',
    26                         }
    27                         // dateTimeLabelFormats: { // don't display the dummy year
    28                         //     month: '%e. %b',
    29                         //     year: '%b'
    30                         // },
    31                     },
    32                     tooltip: {
    33                         formatter: function () {
    34                             var d = new Date(this.x);
    35                             var s = '<b>' + d.getFullYear() + '年' + (d.getMonth() + 1) + '月' + d.getDate() + '日' + '</b>';
    36                             s += '<br/><span style="color:' + this.point.series.color + '">' + this.point.series.name + ': ' +
    37                                 this.point.y.toFixed(2) + '%' + ' </span>';
    38                             return s;
    39                         }
    40                     },
    41                     legend: {
    42                         enabled: true
    43                     },
    44                 },
    45             }

    2. tootip想把数字显示成带有千位符号的,如这样:

                 

            

    饼图的配置代码

     1             //图中数字显示成带千位符号的
     2             Highcharts.setOptions({
     3                 lang: {
     4                     thousandsSep: ','
     5                 }
     6             });
     7             //http code概念饼图
     8             $scope.pieChart = <HighChartsNGConfig>{
     9                 options: {
    10                     title: {
    11                         text: ``
    12                     },
    13                     chart: {
    14                         type: 'pie',
    15                         height: 300,
    16                     },
    17                     tooltip: {
    18                         // headerFormat: '{point.name}<br>',
    19                         // pointFormat: '{series.name}: <b>{point.y}%</b>'
    20                     },
    21                     plotOptions: {
    22                         pie: {
    23                             innerSize: 150,
    24                             allowPointSelect: true,
    25                             cursor: 'pointer',
    26                             dataLabels: {
    27                                 enabled: false,
    28                             },
    29                             showInLegend: true
    30                         }
    31                     },
    32                 },
    33                 loading: false
    34             };
  • 相关阅读:
    猫与老鼠的故事(委托)
    返回类型协变和参数类型逆变
    HTTP 方法:GET 对比 POST
    Ajax
    django(未解决的问题)
    mysql开机启动
    apache的不同路径conf/httpd.conf有什么区别【转载】
    Apache部署Django过程中遇到的一些问题
    执行django-admin.py startproject XXX报错的问题
    yum安装软件的过程中出现的一些问题
  • 原文地址:https://www.cnblogs.com/XHappyness/p/7238116.html
Copyright © 2011-2022 走看看