如何在条形图中的每个堆栈的顶部和底部写入标签和数据
how to write labels along with data on top and bottom of each stack in bar chart
我正在尝试创建一个像这样的。
现在我正在从图表中的数据中获取值,但我不知道如何在每个堆栈中添加这些标签,例如上方和下方的公司名称。
我在评论中附上js fiddle link。
像这样给两个数据集一个不同的对齐方式:
datasets: [
{
type: 'bar',
data: company,
backgroundColor: '#2FC798',
borderColor: '#2FC798',
borderWidth: 2.2,
lineTension: 0.4,
pointStyle: 'rectRot',
datalabels: {
align: 'start',
}
},
{
type: 'bar',
data: sector,
backgroundColor: '#C72151',
borderColor: '#C72151',
borderWidth: 2.2,
lineTension: 0.4,
pointStyle: 'rectRot',
datalabels: {
align: 'end',
}
},
],
这是一个JSFiddle
我正在尝试创建一个像这样的。
现在我正在从图表中的数据中获取值,但我不知道如何在每个堆栈中添加这些标签,例如上方和下方的公司名称。
像这样给两个数据集一个不同的对齐方式:
datasets: [
{
type: 'bar',
data: company,
backgroundColor: '#2FC798',
borderColor: '#2FC798',
borderWidth: 2.2,
lineTension: 0.4,
pointStyle: 'rectRot',
datalabels: {
align: 'start',
}
},
{
type: 'bar',
data: sector,
backgroundColor: '#C72151',
borderColor: '#C72151',
borderWidth: 2.2,
lineTension: 0.4,
pointStyle: 'rectRot',
datalabels: {
align: 'end',
}
},
],
这是一个JSFiddle