[Chartjs]-How to remove bars for those bars with zero value in Chartjs bar chart?

1👍

By default the barStrokeWidth value is 2.

Just add this :

barStrokeWidth:0,

or :

barShowStroke : false,

In your options.

http://www.chartjs.org/docs/#bar-chart-chart-options

//Boolean – If there is a stroke on each bar

barShowStroke : true,

//Number – Pixel width of the bar stroke

barStrokeWidth : 2,

2👍

update December 2021:

  • barStrokeWidth is deprecated.
  • I used inflateAmount: 0 (default value is auto) and it fixed the issue for me

docs: https://www.chartjs.org/docs/latest/charts/bar.html#dataset-properties

0👍

if barShowStroke : true

not working try to

barRadius: 0

0👍

I found that you can add skipNull property to dataset objects. And bars where value is null or undefined won’t take any space.

https://www.chartjs.org/docs/3.2.0/charts/bar.html

Leave a comment