javascript - 如何在 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
推荐阅读
- linux - 测量进程的内存百分比(总内存)的最佳方法?
- javascript - setTimeout 函数在 Firefox 上不起作用
- python - 如何在 PyQt 应用程序的绘图内用鼠标移动线条
- python - Python脚本问题:“sh:1:语法错误:反引号替换中的EOF”
- marklogic - 带有 xsi:noNamespaceSchemaLocation 的片段根上的 XDMP-PARENTLINK 错误
- android - 如何在我的布局顶部创建外部阴影?
- python - 会话已设置但未保留
- javascript - redux-saga API 调用返回什么?(举个例子)
- tensorflow - 使用所有可用于 tf.estimator.Estimator().predict() 的 GPU 设备
- c - 为什么我不能将多字节字符串转换为宽字符串?即使 mbstring 似乎有效,mbsrtowcs 也会因 EILSEQ 失败