I have a line chart. The data is anywhere between -10 and 10. The labels on the y axis are correct (-10 to 10 incremented by 1).
I need the color of each label to be different, based on an array of colors. The number of labels and the number of colors are both 21 (-10 to 10 including 0). I'd really like a 'strip' of a gradient so that each label is at the vertical position of the color.
I tried this in the code but learned that html is not available within the chart:
options: {
responsive: true,
plugins: {
title: {
display: true,
text: 'Topic Sentiment'
}
},
scales: {
y: {
title: {
display: true,
text: 'Sentiment Scores'
},
min: -10,
max: 10,
ticks: {
stepSize: 1,
callback: function(value, index, ticks) {
return value + " <div style='height:100%; width:8px; background:" + arColors[index] + ";' ></div>"
}
}
}
},
onClick: (e, activeEls) => {
var oChart = e.chart, label = "";
}
}
This is what I mean. The y gradient is added to an image of the actual chart in Photoshop.
Can I do anything like this?