Ng2-charts: Its imposible to add rounded corners through ng2-charts for bar chart

Created on 6 Jun 2020  路  6Comments  路  Source: valor-software/ng2-charts

to have a border on the edge of bar,we need to implement that kinda .js method.

Chart.elements.Rectangle.prototype.draw = function()
{}

If a callback did exist,would be awesome.What is wanted to be achieved below

image

Most helpful comment

var options = {
cornerRadius: 20,
};
use this option
I solve this problem with cornerRadius property

All 6 comments

I'm having same issue. Trying for few hours now, not finding any solution. Let me know if anyone found anything

Please, I need that too!

Here is a great stackoverflow answer that covers how to draw rounded bars in detail.

The code there is for simple bar chart, not stacked, but was pretty easy to adapt - see https://codepen.io/danmana/pen/yLOGjPV?editors=1010

image

Thanks, but how do I package the JS code from Angular so that it actually affects the chart in the browser?

I hope this is not too late for you.

First of all, if you switched already to chart.js 3.0 beta, it has rounded corners built in - see sample and docs

For 2.9 I adapted the stackoverflow solution from above to ng2-charts:

https://stackblitz.com/edit/ng2-charts-bar-template-zdhqtt?file=src%2Fapp%2Fapp.component.ts

Important points:

var options = {
cornerRadius: 20,
};
use this option
I solve this problem with cornerRadius property

Was this page helpful?
0 / 5 - 0 ratings

Related issues

grahammutter picture grahammutter  路  4Comments

shyamal890 picture shyamal890  路  4Comments

brandonreid picture brandonreid  路  3Comments

egervari picture egervari  路  4Comments

dj-techs picture dj-techs  路  3Comments