I am trying to create a barchart with several different datasets but I'm struggling with getting labels below each bar. This is what I currently have.
我想在条形图下面也有标签,而不仅仅是在图例中.下面是我的数据.
{
"labels": [
""
],
"datasets": [
{
"label": "testname1",
"borderColor": "rgba(254, 112, 150, 1)",
"backgroundColor": "rgba(254, 112, 150, 1)",
"borderWidth": 1,
"categoryPercentage": 1,
"data": [
58
]
},
{
"label": "testname2",
"borderColor": "rgba(54, 215, 232, 1)",
"backgroundColor": "rgba(54, 215, 232, 1)",
"borderWidth": 1,
"categoryPercentage": 1,
"data": [
60
]
},
{
"label": "testname3",
"borderColor": "rgba(6, 185, 157, 1)",
"backgroundColor": "rgba(6, 185, 157, 1)",
"borderWidth": 1,
"categoryPercentage": 1,
"data": [
21
]
},
{
"label": "testname4",
"borderColor": "rgba(242, 197, 124, 1)",
"backgroundColor": "rgba(242, 197, 124, 1)",
"borderWidth": 1,
"categoryPercentage": 1,
"data": [
35
]
},
{
"label": "testname5",
"borderColor": "rgba(54,70,82, 1)",
"backgroundColor": "rgba(54,70,82, 1)",
"borderWidth": 1,
"categoryPercentage": 1,
"data": [
32
]
},
{
"label": "testname6",
"borderColor": "rgba(68, 94, 147, 1)",
"backgroundColor": "rgba(68, 94, 147, 1)",
"borderWidth": 1,
"categoryPercentage": 1,
"data": [
75
]
},
{
"label": "testname7",
"borderColor": "rgba(143, 57, 133, 1)",
"backgroundColor": "rgba(143, 57, 133, 1)",
"borderWidth": 1,
"categoryPercentage": 1,
"data": [
5
]
},
{
"label": "testname8",
"borderColor": "rgba(255, 209, 102, 1)",
"backgroundColor": "rgba(255, 209, 102, 1)",
"borderWidth": 1,
"categoryPercentage": 1,
"data": [
0
]
},
{
"label": "testname9",
"borderColor": "rgba(67, 129, 193, 1)",
"backgroundColor": "rgba(67, 129, 193, 1)",
"borderWidth": 1,
"categoryPercentage": 1,
"data": [
42
]
},
{
"label": "testname10",
"borderColor": "rgba(135, 61, 72, 1)",
"backgroundColor": "rgba(135, 61, 72, 1)",
"borderWidth": 1,
"categoryPercentage": 1,
"data": [
76
]
},
{
"label": "testname11",
"borderColor": "rgba(42, 71, 71, 1)",
"backgroundColor": "rgba(42, 71, 71, 1)",
"borderWidth": 1,
"categoryPercentage": 1,
"data": [
75
]
},
{
"label": "testname12",
"borderColor": "rgba(237, 191, 133, 1)",
"backgroundColor": "rgba(237, 191, 133, 1)",
"borderWidth": 1,
"categoryPercentage": 1,
"data": [
34
]
},
{
"label": "testname13",
"borderColor": "rgba(187, 40, 55, 1)",
"backgroundColor": "rgba(187, 40, 55, 1)",
"borderWidth": 1,
"categoryPercentage": 1,
"data": [
59
]
},
{
"label": "testname14",
"borderColor": "rgba(115, 92, 221, 1)",
"backgroundColor": "rgba(115, 92, 221, 1)",
"borderWidth": 1,
"categoryPercentage": 1,
"data": [
98
]
},
{
"label": "testname15",
"borderColor": "rgba(144, 0, 179, 1)",
"backgroundColor": "rgba(144, 0, 179, 1)",
"borderWidth": 1,
"categoryPercentage": 1,
"data": [
64
]
}
]
}
这是我的 Select
{
"scales": {
"y": {
"ticks": {
"display": true
}
},
"x": {
"display": false
}
},
"plugins": {
"legend": {
"display": {
"displayLegend": true
},
"position": "top"
},
"tooltip": {
"callbacks": {}
},
"elements": {
"point": {
"radius": 0
}
}
}
}
我可以设法在列下面添加标签,如果我使它全部1个数据集,但所有列是相同的 colored颜色 ,你不能切换它们. 我也试过这个链接Chart.js manipulate each bar in chart with different labels.但这是用于chartjs的第二个版本,在当前版本中不再工作.在插件之前,路径一直返回cannot set on undefined,当我在chart对象中发现xAxes时,它是undefined.
有人知道如何在我的条形图列下获取标签而不使所有数据集?