问题
So, I'm trying to display some text inside the actual bars of a bar chart using Chartist.js charts. The end result should look something like this:
Which property do I need to set in order to get the text inside the bars?
回答1:
I would use chartist-bar-labels it should provide what you are looking for, with it you can add the following code:
Chartist.plugins.ctBarLabels({
position: {
x: function (data) {
return data.x1 + 50
}
},
labelOffset: {
y: 7
},
labelInterpolationFnc: function (text) { //<--- this adds text to your bards
return text + '%'
}
})
来源:https://stackoverflow.com/questions/42348622/display-text-inside-bar-in-bar-chart-with-chartist-js