首页 > 解决方案 > 如何在 highcarts 的条形图竞赛中为数据标签值添加逗号?

问题描述

我有一个条形图比赛显示,我现在尝试通过在标签中添加逗号来正确呈现标签的数据。有人能告诉我如何在超过 1,000 个的数据标签中添加逗号吗?

https://jsfiddle.net/samwhite/Lzh2rwab/

 Highcharts.getJSON('https://api.npoint.io/d70fd8f47a70326609bb', function (data) {
    initialData =[
    {
      "": "",
      "2017": 954,
      "2018": 983,
      "2019": 1107,
          "2020": 1710,
                  "2021": "",
      "Country Code": "CDF",
      "Country Name": "Corporate Disclosures and Financials"
    },
    {
        "": "",
        "2017": 758,
        "2018": 1054,
        "2019": 692,
            "2020": 1078,
                    "2021": "",
        "Country Code": "OF",
        "Country Name": "Offering Fraud"
      },
      {
        "": "",
        "2017": 67,
        "2018": 57,
        "2019": 35,
            "2020": 37,
                    "2021": "",
        "Country Code": "MSAPP",
        "Country Name": "Municipal Securities and Public Pension"
      }
  ];
        
      xAxis: {
        type: 'category',
      },
      yAxis: [{
        tickAmount: 5,
        title: {text:"Number of Tips"}
      }],
      series: [{
      colorByPoint: true,
                colors:['#7cb5ec', '#3e9af3', '#1e9af3',  '#006af3', '#0060f3', '#0020f3', '#0020c1', '#0020a3', '#001060'],
        dataSorting: {
          enabled: true,
          matchByName: true
        },
        type: 'bar',
        dataLabels: [{
          enabled: true,
        }],
        name: startYear,
        data: getData(startYear)[1]
      }]
    });
});

标签: javascriptjqueryhighcharts

解决方案



推荐阅读