Another question is how can I make this dynamic in the number of rows? Assume all bars have the exact…