angular-chart.js icon indicating copy to clipboard operation
angular-chart.js copied to clipboard

Option to show VALUES on chart

Open lvt1325 opened this issue 10 years ago • 2 comments

Is there any option to show values of bar in bar chart. As bar chart at http://jtblin.github.io/angular-chart.js/#bar-chart I want to show value at the top of each bar. Thanks.

lvt1325 avatar Sep 14 '16 03:09 lvt1325

Please check http://www.chartjs.org/docs/ for available options.

jtblin avatar Sep 16 '16 08:09 jtblin

I was trying to search how to show values on a top of bar chart, but unfortunately I didn't found how to do it. is it any option now available for that?

that did help me That did hep

$scope.options = {
    events: false,
    tooltips: {
        enabled: false
    },
    hover: {
        animationDuration: 0
    },
    animation: {
        duration: 1,
        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 = dataset.data[index];                            
                    ctx.fillText(data, bar._model.x, bar._model.y - 5);
                });
            });
        }
    }
};

jack100501 avatar Jul 20 '17 06:07 jack100501