valor-software / ng2-charts

Beautiful charts for Angular based on Chart.js
http://valor-software.github.io/ng2-charts/
MIT License
2.35k stars 574 forks source link

How to add rounded corners to a doughnut chart? #1082

Closed AnaTorres88 closed 1 year ago

AnaTorres88 commented 5 years ago

I've been trying to add rounded corners to a doughnut/gauge chart. I've tried to use ViewChild to try to manipulate the canvas with no success.

Has someone encountered this problem before? What's the best way to solve it?

https://stackblitz.com/edit/chartjs-angular-pupzff

paviad commented 5 years ago

Stackblitz in link doesn't exist.

mahsaml90 commented 5 years ago

Your link is not available , I used chart options to handle gauge chart, it may help you too.

public chartOptions: any = {
        scaleShowVerticalLines: false,
        responsive: true,
        circumference: Math.PI,
        rotation: Math.PI,
        cutoutPercentage: 80, // precent
        plugins: {
            datalabels: {
                backgroundColor: 'rgba(0, 0, 0, 0.7)',
                borderColor: '#ffffff',
                color: function (context) {
                    return context.dataset.backgroundColor;
                },
                font: function (context) {
                    var w = context.chart.width;
                    return {
                        size: w < 512 ? 18 : 20
                    }
                },
                align: 'start',
                anchor: 'start',
                offset: 10,
                borderRadius: 4,
                borderWidth: 1,
                formatter: function (value, context) {
                    var i = context.dataIndex;
                    var len = context.dataset.data.length - 1;
                    if (i == len) {
                        return null;
                    }
                    return value + ' mph';
                }
            }
        },
        legend: {
            display: false
        },
        tooltips: {
            enabled: `false`
        }
    };
AnaTorres88 commented 5 years ago

Sorry, this is the link.

https://stackblitz.com/edit/chartjs-angular-comp

Ranindu15 commented 3 years ago

I'm also finding solution for this. please can you update the answer

santam85 commented 1 year ago

Not an issue. Refer to the the Chart.js documentation to learn how to configure charts.