Chart JS - To Set Font Size and Color for the values Displayed on top Bubble Chart

ε祈祈猫儿з 提交于 2021-02-11 15:21:11

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!