如何在 highcharts 的条形图竞赛中为数据标签值添加逗号?
How to add comma to data labels value in bar chart race of 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]
}]
});
});
您可以使用 format
功能来实现它。
API: https://api.highcharts.com/highcharts/series.line.dataLabels.format
我有一个条形图比赛显示,我现在尝试通过在标签中添加逗号来正确呈现标签数据。谁能告诉我如何在超过 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]
}]
});
});
您可以使用 format
功能来实现它。
API: https://api.highcharts.com/highcharts/series.line.dataLabels.format