问题
I would need help in setting the Font Size and Font Color for the Bubble Chart. Currently, i'm adding values on top using the Animation Block's OnComplete property. Please find the below Code for the same:
animation:{
"oncomplete": function(){
var chartInstance = this.chart, ctx = chartInstance.ctx;
ctx.font = Chart.helpers.fontString(Chart.defaults.global.defaultFontSize,
Chart.defaults.global.defaultFontStyle,
Chart.defaults.global.defaultFontFamily);
ctx.textAlign = 'center';
ctx.textBaseline = 'bottom';
this.data.datasets.forEach(function (dataset, i) {
var meta = chartInstance.controller.getDatasetMeta(i);
meta.data.forEach(function (bar, index) {
var data = data[index];
ctx.fillText(data, bar._model.x + 60, bar._model.y);
});
});
}
}
Every Time i load the chart there is a new font color that appears for the data on top of bubble.
I tried changing ctx.font = Chart.helpers.fontString
, still din work.
Any Suggestions to fix the issue is really appreciable. Thanks in advance.
来源:https://stackoverflow.com/questions/63111230/chart-js-to-set-font-size-and-color-for-the-values-displayed-on-top-bubble-cha